pageinspect: Fix handling of page sizes and AM types
authorMichael Paquier <michael@paquier.xyz>
Wed, 16 Mar 2022 02:19:39 +0000 (11:19 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 16 Mar 2022 02:19:39 +0000 (11:19 +0900)
This commit fixes a set of issues related to the use of the SQL
functions in this module when the caller is able to pass down raw page
data as input argument:
- The page size check was fuzzy in a couple of places, sometimes
looking after only a sub-range, but what we are looking for is an exact
match on BLCKSZ.  After considering a few options here, I have settled
down to do a generalization of get_page_from_raw().  Most of the SQL
functions already used that, and this is not strictly required if not
accessing an 8-byte-wide value from a raw page, but this feels safer in
the long run for alignment-picky environment, particularly if a code
path begins to access such values.  This also reduces the number of
strings that need to be translated.
- The BRIN function brin_page_items() uses a Relation but it did not
check the access method of the opened index, potentially leading to
crashes.  All the other functions in need of a Relation already did
that.
- Some code paths could fail on elog(), but we should to use ereport()
for failures that can be triggered by the user.

Tests are added to stress all the cases that are fixed as of this
commit, with some junk raw pages (\set VERBOSITY ensures that this works
across all page sizes) and unexpected index types when functions open
relations.

Author: Michael Paquier, Justin Prysby
Discussion: https://postgr.es/m/20220218030020.GA1137@telsasoft.com
Backpatch-through: 10

18 files changed:
contrib/pageinspect/brinfuncs.c
contrib/pageinspect/btreefuncs.c
contrib/pageinspect/expected/brin.out
contrib/pageinspect/expected/btree.out
contrib/pageinspect/expected/gin.out
contrib/pageinspect/expected/gist.out
contrib/pageinspect/expected/hash.out
contrib/pageinspect/expected/page.out
contrib/pageinspect/fsmfuncs.c
contrib/pageinspect/gistfuncs.c
contrib/pageinspect/hashfuncs.c
contrib/pageinspect/rawpage.c
contrib/pageinspect/sql/brin.sql
contrib/pageinspect/sql/btree.sql
contrib/pageinspect/sql/gin.sql
contrib/pageinspect/sql/gist.sql
contrib/pageinspect/sql/hash.sql
contrib/pageinspect/sql/page.sql

index b7c83652180da592f91d9996594a0dbac3362a76..bd0ea8b18c1a268d4f4a9a270d2590b2b30f6f9b 100644 (file)
@@ -16,6 +16,7 @@
 #include "access/brin_tuple.h"
 #include "access/htup_details.h"
 #include "catalog/index.h"
+#include "catalog/pg_am_d.h"
 #include "catalog/pg_type.h"
 #include "funcapi.h"
 #include "lib/stringinfo.h"
@@ -31,6 +32,8 @@ PG_FUNCTION_INFO_V1(brin_page_items);
 PG_FUNCTION_INFO_V1(brin_metapage_info);
 PG_FUNCTION_INFO_V1(brin_revmap_data);
 
+#define IS_BRIN(r) ((r)->rd_rel->relam == BRIN_AM_OID)
+
 typedef struct brin_column_state
 {
        int                     nstored;
@@ -45,8 +48,7 @@ Datum
 brin_page_type(PG_FUNCTION_ARGS)
 {
        bytea      *raw_page = PG_GETARG_BYTEA_P(0);
-       Page            page = VARDATA(raw_page);
-       int                     raw_page_size;
+       Page            page;
        char       *type;
 
        if (!superuser())
@@ -54,14 +56,7 @@ brin_page_type(PG_FUNCTION_ARGS)
                                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                 errmsg("must be superuser to use raw page functions")));
 
-       raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
-
-       if (raw_page_size != BLCKSZ)
-               ereport(ERROR,
-                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                errmsg("input page too small"),
-                                errdetail("Expected size %d, got %d",
-                                                  BLCKSZ, raw_page_size)));
+       page = get_page_from_raw(raw_page);
 
        switch (BrinPageType(page))
        {
@@ -89,19 +84,7 @@ brin_page_type(PG_FUNCTION_ARGS)
 static Page
 verify_brin_page(bytea *raw_page, uint16 type, const char *strtype)
 {
-       Page            page;
-       int                     raw_page_size;
-
-       raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
-
-       if (raw_page_size != BLCKSZ)
-               ereport(ERROR,
-                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                errmsg("input page too small"),
-                                errdetail("Expected size %d, got %d",
-                                                  BLCKSZ, raw_page_size)));
-
-       page = VARDATA(raw_page);
+       Page            page = get_page_from_raw(raw_page);
 
        /* verify the special space says this page is what we want */
        if (BrinPageType(page) != type)
@@ -143,6 +126,13 @@ brin_page_items(PG_FUNCTION_ARGS)
        SetSingleFuncCall(fcinfo, 0);
 
        indexRel = index_open(indexRelid, AccessShareLock);
+
+       if (!IS_BRIN(indexRel))
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                errmsg("\"%s\" is not a %s index",
+                                               RelationGetRelationName(indexRel), "BRIN")));
+
        bdesc = brin_build_desc(indexRel);
 
        /* minimally verify the page we got */
index 03debe336baa9c140b4065e4974fb9d9ac775c93..d9628dd664dc26ce7e83fd9dfaf6d6e823dfb459 100644 (file)
@@ -206,8 +206,10 @@ bt_page_stats_internal(PG_FUNCTION_ARGS, enum pageinspect_version ext_version)
        rel = relation_openrv(relrv, AccessShareLock);
 
        if (!IS_INDEX(rel) || !IS_BTREE(rel))
-               elog(ERROR, "relation \"%s\" is not a btree index",
-                        RelationGetRelationName(rel));
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                errmsg("\"%s\" is not a %s index",
+                                               RelationGetRelationName(rel), "btree")));
 
        /*
         * Reject attempts to read non-local temporary relations; we would be
@@ -476,8 +478,10 @@ bt_page_items_internal(PG_FUNCTION_ARGS, enum pageinspect_version ext_version)
                rel = relation_openrv(relrv, AccessShareLock);
 
                if (!IS_INDEX(rel) || !IS_BTREE(rel))
-                       elog(ERROR, "relation \"%s\" is not a btree index",
-                                RelationGetRelationName(rel));
+                       ereport(ERROR,
+                                       (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                        errmsg("\"%s\" is not a %s index",
+                                                       RelationGetRelationName(rel), "btree")));
 
                /*
                 * Reject attempts to read non-local temporary relations; we would be
@@ -588,7 +592,6 @@ bt_page_items_bytea(PG_FUNCTION_ARGS)
        Datum           result;
        FuncCallContext *fctx;
        struct user_args *uargs;
-       int                     raw_page_size;
 
        if (!superuser())
                ereport(ERROR,
@@ -601,19 +604,12 @@ bt_page_items_bytea(PG_FUNCTION_ARGS)
                MemoryContext mctx;
                TupleDesc       tupleDesc;
 
-               raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
-
-               if (raw_page_size < SizeOfPageHeaderData)
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                        errmsg("input page too small (%d bytes)", raw_page_size)));
-
                fctx = SRF_FIRSTCALL_INIT();
                mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
 
                uargs = palloc(sizeof(struct user_args));
 
-               uargs->page = VARDATA(raw_page);
+               uargs->page = get_page_from_raw(raw_page);
 
                uargs->offset = FirstOffsetNumber;
 
@@ -698,8 +694,10 @@ bt_metap(PG_FUNCTION_ARGS)
        rel = relation_openrv(relrv, AccessShareLock);
 
        if (!IS_INDEX(rel) || !IS_BTREE(rel))
-               elog(ERROR, "relation \"%s\" is not a btree index",
-                        RelationGetRelationName(rel));
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                errmsg("\"%s\" is not a %s index",
+                                               RelationGetRelationName(rel), "btree")));
 
        /*
         * Reject attempts to read non-local temporary relations; we would be
index 71eb190380cfe51a29e57ea37e67057f208122a3..10cd36c1778c1035e2ed6d677f3911757b80d5dc 100644 (file)
@@ -48,4 +48,8 @@ SELECT * FROM brin_page_items(get_raw_page('test1_a_idx', 2), 'test1_a_idx')
           1 |      0 |      1 | f        | f        | f           | {1 .. 1}
 (1 row)
 
+-- Failure for non-BRIN index.
+CREATE INDEX test1_a_btree ON test1 (a);
+SELECT brin_page_items(get_raw_page('test1_a_btree', 0), 'test1_a_btree');
+ERROR:  "test1_a_btree" is not a BRIN index
 DROP TABLE test1;
index c60bc88560ccab8837491dd4d9cba3065dc5a8da..80b3dfe861c5fafde65ae2816b8f7b9b44d56d4e 100644 (file)
@@ -70,4 +70,19 @@ tids       |
 
 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 2));
 ERROR:  block number 2 is out of range for relation "test1_a_idx"
+-- Failure when using a non-btree index.
+CREATE INDEX test1_a_hash ON test1 USING hash(a);
+SELECT bt_metap('test1_a_hash');
+ERROR:  "test1_a_hash" is not a btree index
+SELECT bt_page_stats('test1_a_hash', 0);
+ERROR:  "test1_a_hash" is not a btree index
+SELECT bt_page_items('test1_a_hash', 0);
+ERROR:  "test1_a_hash" is not a btree index
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT bt_page_items('aaa'::bytea);
+ERROR:  invalid page size
+\set VERBOSITY default
 DROP TABLE test1;
index ef7570b9723be6857889ac5511acda82c8441bb5..802f48284bfa90950b132f099e5f793113ec0b95 100644 (file)
@@ -36,3 +36,14 @@ FROM gin_leafpage_items(get_raw_page('test1_y_idx',
 ?column? | t
 
 DROP TABLE test1;
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT gin_leafpage_items('aaa'::bytea);
+ERROR:  invalid page size
+SELECT gin_metapage_info('bbb'::bytea);
+ERROR:  invalid page size
+SELECT gin_page_opaque_info('ccc'::bytea);
+ERROR:  invalid page size
+\set VERBOSITY default
index 93abfcdd5e1d28a9266b77fbcf5360cf2a68663b..3f33e040661bcf19656a716bc3940de99899b04b 100644 (file)
@@ -64,4 +64,19 @@ SELECT itemoffset, ctid, itemlen FROM gist_page_items_bytea(get_raw_page('test_g
           6 | (6,65535) |      40
 (6 rows)
 
+-- Failure with non-GiST index.
+CREATE INDEX test_gist_btree on test_gist(t);
+SELECT gist_page_items(get_raw_page('test_gist_btree', 0), 'test_gist_btree');
+ERROR:  "test_gist_btree" is not a GiST index
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT gist_page_items_bytea('aaa'::bytea);
+ERROR:  invalid page size
+SELECT gist_page_items('aaa'::bytea, 'test_gist_idx'::regclass);
+ERROR:  invalid page size
+SELECT gist_page_opaque_info('aaa'::bytea);
+ERROR:  invalid page size
+\set VERBOSITY default
 DROP TABLE test_gist;
index bd0628d01369a304a7086bdafa4ca48431a93121..6c606630dd71d516cd5ae2961c9041ca59b7b5e9 100644 (file)
@@ -163,4 +163,21 @@ SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 4));
 
 SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 5));
 ERROR:  page is not a hash bucket or overflow page
+-- Failure with non-hash index
+CREATE INDEX test_hash_a_btree ON test_hash USING btree (a);
+SELECT hash_bitmap_info('test_hash_a_btree', 0);
+ERROR:  "test_hash_a_btree" is not a hash index
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT hash_metapage_info('aaa'::bytea);
+ERROR:  invalid page size
+SELECT hash_page_items('bbb'::bytea);
+ERROR:  invalid page size
+SELECT hash_page_stats('ccc'::bytea);
+ERROR:  invalid page size
+SELECT hash_page_type('ddd'::bytea);
+ERROR:  invalid page size
+\set VERBOSITY default
 DROP TABLE test_hash;
index 4e325ae56dd8471b31b80f396a63696cbdd42470..9bbdda7f1803a3b51e1e300388c34be1a38ad683 100644 (file)
@@ -207,3 +207,14 @@ select tuple_data_split('test8'::regclass, t_data, t_infomask, t_infomask2, t_bi
 (1 row)
 
 drop table test8;
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT fsm_page_contents('aaa'::bytea);
+ERROR:  invalid page size
+SELECT page_checksum('bbb'::bytea, 0);
+ERROR:  invalid page size
+SELECT page_header('ccc'::bytea);
+ERROR:  invalid page size
+\set VERBOSITY default
index dadd62aa20a6e7855bfbe320595e002bc3ac9cad..b914da1d4a9d38d676022a8466be2c4282d8aed7 100644 (file)
@@ -36,6 +36,7 @@ fsm_page_contents(PG_FUNCTION_ARGS)
 {
        bytea      *raw_page = PG_GETARG_BYTEA_P(0);
        StringInfoData sinfo;
+       Page            page;
        FSMPage         fsmpage;
        int                     i;
 
@@ -44,7 +45,8 @@ fsm_page_contents(PG_FUNCTION_ARGS)
                                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                 errmsg("must be superuser to use raw page functions")));
 
-       fsmpage = (FSMPage) PageGetContents(VARDATA(raw_page));
+       page = get_page_from_raw(raw_page);
+       fsmpage = (FSMPage) PageGetContents(page);
 
        initStringInfo(&sinfo);
 
index 10d6dd44d4e083ef06b16b1543a8413996124ad0..a31cff47fea5817da0dfee52bf41591a9a56f9c0 100644 (file)
@@ -14,6 +14,7 @@
 #include "access/htup.h"
 #include "access/relation.h"
 #include "catalog/namespace.h"
+#include "catalog/pg_am_d.h"
 #include "funcapi.h"
 #include "miscadmin.h"
 #include "pageinspect.h"
@@ -28,6 +29,8 @@ PG_FUNCTION_INFO_V1(gist_page_opaque_info);
 PG_FUNCTION_INFO_V1(gist_page_items);
 PG_FUNCTION_INFO_V1(gist_page_items_bytea);
 
+#define IS_GIST(r) ((r)->rd_rel->relam == GIST_AM_OID)
+
 #define ItemPointerGetDatum(X)  PointerGetDatum(X)
 
 
@@ -174,6 +177,12 @@ gist_page_items(PG_FUNCTION_ARGS)
        /* Open the relation */
        indexRel = index_open(indexRelid, AccessShareLock);
 
+       if (!IS_GIST(indexRel))
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                errmsg("\"%s\" is not a %s index",
+                                               RelationGetRelationName(indexRel), "GiST")));
+
        page = get_page_from_raw(raw_page);
 
        /* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */
index 090eba4a93de080eaebe027a6964f81518af7e4f..ff73c363fc8261ab5391abe564dc14df0491dcd7 100644 (file)
@@ -417,8 +417,10 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
        indexRel = index_open(indexRelid, AccessShareLock);
 
        if (!IS_HASH(indexRel))
-               elog(ERROR, "relation \"%s\" is not a hash index",
-                        RelationGetRelationName(indexRel));
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                errmsg("\"%s\" is not a %s index",
+                                               RelationGetRelationName(indexRel), "hash")));
 
        if (RELATION_IS_OTHER_TEMP(indexRel))
                ereport(ERROR,
index 7e41af045f34e2b723085d7d7b7b71f0e04ce388..92ffb2d930e47f161c72c4c80a1d0c66ec4d7e86 100644 (file)
@@ -246,7 +246,6 @@ Datum
 page_header(PG_FUNCTION_ARGS)
 {
        bytea      *raw_page = PG_GETARG_BYTEA_P(0);
-       int                     raw_page_size;
 
        TupleDesc       tupdesc;
 
@@ -263,18 +262,7 @@ page_header(PG_FUNCTION_ARGS)
                                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                 errmsg("must be superuser to use raw page functions")));
 
-       raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
-
-       /*
-        * Check that enough data was supplied, so that we don't try to access
-        * fields outside the supplied buffer.
-        */
-       if (raw_page_size < SizeOfPageHeaderData)
-               ereport(ERROR,
-                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                errmsg("input page too small (%d bytes)", raw_page_size)));
-
-       page = (PageHeader) VARDATA(raw_page);
+       page = (PageHeader) get_page_from_raw(raw_page);
 
        /* Build a tuple descriptor for our result type */
        if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
@@ -350,8 +338,7 @@ page_checksum_internal(PG_FUNCTION_ARGS, enum pageinspect_version ext_version)
 {
        bytea      *raw_page = PG_GETARG_BYTEA_P(0);
        int64           blkno = (ext_version == PAGEINSPECT_V1_8 ? PG_GETARG_UINT32(1) : PG_GETARG_INT64(1));
-       int                     raw_page_size;
-       PageHeader      page;
+       Page            page;
 
        if (!superuser())
                ereport(ERROR,
@@ -363,17 +350,7 @@ page_checksum_internal(PG_FUNCTION_ARGS, enum pageinspect_version ext_version)
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 errmsg("invalid block number")));
 
-       raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
-
-       /*
-        * Check that the supplied page is of the right size.
-        */
-       if (raw_page_size != BLCKSZ)
-               ereport(ERROR,
-                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                errmsg("incorrect size of input page (%d bytes)", raw_page_size)));
-
-       page = (PageHeader) VARDATA(raw_page);
+       page = get_page_from_raw(raw_page);
 
        PG_RETURN_INT16(pg_checksum_page((char *) page, blkno));
 }
index 735bc3b6733db4ce99d4e1f501939d2b00e73a65..8717229c5d2f85fdd6930578e287c8247ca3f1c6 100644 (file)
@@ -15,4 +15,8 @@ SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 1)) LIMIT 5;
 SELECT * FROM brin_page_items(get_raw_page('test1_a_idx', 2), 'test1_a_idx')
     ORDER BY blknum, attnum LIMIT 5;
 
+-- Failure for non-BRIN index.
+CREATE INDEX test1_a_btree ON test1 (a);
+SELECT brin_page_items(get_raw_page('test1_a_btree', 0), 'test1_a_btree');
+
 DROP TABLE test1;
index 963591795973edc888ab962ae8f35d2160d876ca..fdda777b9ef6ff13e0470e188162fe5bda672b20 100644 (file)
@@ -21,4 +21,17 @@ SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 0));
 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 1));
 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 2));
 
+-- Failure when using a non-btree index.
+CREATE INDEX test1_a_hash ON test1 USING hash(a);
+SELECT bt_metap('test1_a_hash');
+SELECT bt_page_stats('test1_a_hash', 0);
+SELECT bt_page_items('test1_a_hash', 0);
+
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT bt_page_items('aaa'::bytea);
+\set VERBOSITY default
+
 DROP TABLE test1;
index 423f5c574999b02e3efbe6c07b05808691230aa8..aadb07856d43686abb61c5a014b69bb5962379e1 100644 (file)
@@ -19,3 +19,12 @@ FROM gin_leafpage_items(get_raw_page('test1_y_idx',
                          current_setting('block_size')::bigint)::int - 1));
 
 DROP TABLE test1;
+
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT gin_leafpage_items('aaa'::bytea);
+SELECT gin_metapage_info('bbb'::bytea);
+SELECT gin_page_opaque_info('ccc'::bytea);
+\set VERBOSITY default
index 3e83239a9d0a967fc57bd1dce24edf21f204ba88..8abeb1914029fccfbe698e39747914b34dcee055 100644 (file)
@@ -26,4 +26,17 @@ SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 1), 'test_gist_idx')
 -- platform-dependent (endianness), so omit the actual key data from the output.
 SELECT itemoffset, ctid, itemlen FROM gist_page_items_bytea(get_raw_page('test_gist_idx', 0));
 
+-- Failure with non-GiST index.
+CREATE INDEX test_gist_btree on test_gist(t);
+SELECT gist_page_items(get_raw_page('test_gist_btree', 0), 'test_gist_btree');
+
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT gist_page_items_bytea('aaa'::bytea);
+SELECT gist_page_items('aaa'::bytea, 'test_gist_idx'::regclass);
+SELECT gist_page_opaque_info('aaa'::bytea);
+\set VERBOSITY default
+
 DROP TABLE test_gist;
index 64f33f1d52fd152e82cd0e769f633628d5b8fd6a..fcddd706ae429c41a19cd0b992a93c995cd3194a 100644 (file)
@@ -78,5 +78,18 @@ SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 3));
 SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 4));
 SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 5));
 
+-- Failure with non-hash index
+CREATE INDEX test_hash_a_btree ON test_hash USING btree (a);
+SELECT hash_bitmap_info('test_hash_a_btree', 0);
+
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT hash_metapage_info('aaa'::bytea);
+SELECT hash_page_items('bbb'::bytea);
+SELECT hash_page_stats('ccc'::bytea);
+SELECT hash_page_type('ddd'::bytea);
+\set VERBOSITY default
 
 DROP TABLE test_hash;
index d333b763d709ac4ddce69e988027a886985aa58a..38b16815412d0884950b89b8f481d954400930a8 100644 (file)
@@ -82,3 +82,12 @@ select t_bits, t_data from heap_page_items(get_raw_page('test8', 0));
 select tuple_data_split('test8'::regclass, t_data, t_infomask, t_infomask2, t_bits)
     from heap_page_items(get_raw_page('test8', 0));
 drop table test8;
+
+-- Failure with incorrect page size
+-- Suppress the DETAIL message, to allow the tests to work across various
+-- page sizes.
+\set VERBOSITY terse
+SELECT fsm_page_contents('aaa'::bytea);
+SELECT page_checksum('bbb'::bytea, 0);
+SELECT page_header('ccc'::bytea);
+\set VERBOSITY default