1 CREATE TABLE test1 (a int8, b int4range);
2 INSERT INTO test1 VALUES (72057594037927937, '[0,1)');
3 CREATE INDEX test1_a_idx ON test1 USING btree (a);
5 SELECT * FROM bt_metap('test1_a_idx');
6 -[ RECORD 1 ]-------------+-------
13 last_cleanup_num_delpages | 0
14 last_cleanup_num_tuples | -1
17 SELECT * FROM bt_page_stats('test1_a_idx', -1);
18 ERROR: invalid block number
19 SELECT * FROM bt_page_stats('test1_a_idx', 0);
20 ERROR: block 0 is a meta page
21 SELECT * FROM bt_page_stats('test1_a_idx', 1);
35 SELECT * FROM bt_page_stats('test1_a_idx', 2);
36 ERROR: block number out of range
37 SELECT * FROM bt_page_items('test1_a_idx', -1);
38 ERROR: invalid block number
39 SELECT * FROM bt_page_items('test1_a_idx', 0);
40 ERROR: block 0 is a meta page
41 SELECT * FROM bt_page_items('test1_a_idx', 1);
42 -[ RECORD 1 ]-----------------------
48 data | 01 00 00 00 00 00 00 01
53 SELECT * FROM bt_page_items('test1_a_idx', 2);
54 ERROR: block number out of range
55 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', -1));
56 ERROR: invalid block number
57 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 0));
58 ERROR: block is a meta page
59 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 1));
60 -[ RECORD 1 ]-----------------------
66 data | 01 00 00 00 00 00 00 01
71 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 2));
72 ERROR: block number 2 is out of range for relation "test1_a_idx"
73 -- Failure when using a non-btree index.
74 CREATE INDEX test1_a_hash ON test1 USING hash(a);
75 SELECT bt_metap('test1_a_hash');
76 ERROR: "test1_a_hash" is not a btree index
77 SELECT bt_page_stats('test1_a_hash', 0);
78 ERROR: "test1_a_hash" is not a btree index
79 SELECT bt_page_items('test1_a_hash', 0);
80 ERROR: "test1_a_hash" is not a btree index
81 SELECT bt_page_items(get_raw_page('test1_a_hash', 0));
82 ERROR: block is a meta page
83 CREATE INDEX test1_b_gist ON test1 USING gist(b);
84 -- Special area of GiST is the same as btree, this complains about inconsistent
85 -- leaf data on the page.
86 SELECT bt_page_items(get_raw_page('test1_b_gist', 0));
87 ERROR: block is not a valid btree leaf page
88 -- Several failure modes.
89 -- Suppress the DETAIL message, to allow the tests to work across various
90 -- page sizes and architectures.
93 SELECT bt_page_items('aaa'::bytea);
94 ERROR: invalid page size
95 -- invalid special area size
96 CREATE INDEX test1_a_brin ON test1 USING brin(a);
97 SELECT bt_page_items(get_raw_page('test1', 0));
98 ERROR: input page is not a valid btree page
99 SELECT bt_page_items(get_raw_page('test1_a_brin', 0));
100 ERROR: input page is not a valid btree page
101 \set VERBOSITY default
102 -- Tests with all-zero pages.
103 SHOW block_size \gset
104 SELECT bt_page_items(decode(repeat('00', :block_size), 'hex'));