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 -1
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 2 is out of range
37 -- bt_multi_page_stats() function returns a set of records of page statistics.
38 CREATE TABLE test2 AS (SELECT generate_series(1, 1000)::int8 AS col1);
39 CREATE INDEX test2_col1_idx ON test2(col1);
40 SELECT * FROM bt_multi_page_stats('test2_col1_idx', 0, 1);
41 ERROR: block 0 is a meta page
42 SELECT * FROM bt_multi_page_stats('test2_col1_idx', 1, -1);
92 SELECT * FROM bt_multi_page_stats('test2_col1_idx', 1, 0);
95 SELECT * FROM bt_multi_page_stats('test2_col1_idx', 1, 2);
121 SELECT * FROM bt_multi_page_stats('test2_col1_idx', 3, 2);
147 SELECT * FROM bt_multi_page_stats('test2_col1_idx', 7, 2);
148 ERROR: block number 7 is out of range
150 SELECT * FROM bt_page_items('test1_a_idx', -1);
151 ERROR: invalid block number -1
152 SELECT * FROM bt_page_items('test1_a_idx', 0);
153 ERROR: block 0 is a meta page
154 SELECT * FROM bt_page_items('test1_a_idx', 1);
155 -[ RECORD 1 ]-----------------------
161 data | 01 00 00 00 00 00 00 01
166 SELECT * FROM bt_page_items('test1_a_idx', 2);
167 ERROR: block number 2 is out of range
168 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', -1));
169 ERROR: invalid block number
170 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 0));
171 ERROR: block is a meta page
172 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 1));
173 -[ RECORD 1 ]-----------------------
179 data | 01 00 00 00 00 00 00 01
184 SELECT * FROM bt_page_items(get_raw_page('test1_a_idx', 2));
185 ERROR: block number 2 is out of range for relation "test1_a_idx"
186 -- Failure when using a non-btree index.
187 CREATE INDEX test1_a_hash ON test1 USING hash(a);
188 SELECT bt_metap('test1_a_hash');
189 ERROR: "test1_a_hash" is not a btree index
190 SELECT bt_page_stats('test1_a_hash', 0);
191 ERROR: "test1_a_hash" is not a btree index
192 SELECT bt_page_items('test1_a_hash', 0);
193 ERROR: "test1_a_hash" is not a btree index
194 SELECT bt_page_items(get_raw_page('test1_a_hash', 0));
195 ERROR: block is a meta page
196 CREATE INDEX test1_b_gist ON test1 USING gist(b);
197 -- Special area of GiST is the same as btree, this complains about inconsistent
198 -- leaf data on the page.
199 SELECT bt_page_items(get_raw_page('test1_b_gist', 0));
200 ERROR: block is not a valid btree leaf page
201 -- Several failure modes.
202 -- Suppress the DETAIL message, to allow the tests to work across various
203 -- page sizes and architectures.
206 SELECT bt_page_items('aaa'::bytea);
207 ERROR: invalid page size
208 -- invalid special area size
209 CREATE INDEX test1_a_brin ON test1 USING brin(a);
210 SELECT bt_page_items(get_raw_page('test1', 0));
211 ERROR: input page is not a valid btree page
212 SELECT bt_page_items(get_raw_page('test1_a_brin', 0));
213 ERROR: input page is not a valid btree page
214 \set VERBOSITY default
215 -- Tests with all-zero pages.
216 SHOW block_size \gset
217 SELECT bt_page_items(decode(repeat('00', :block_size), 'hex'));