Debian Codegraph @

contrib/pageinspect/sql/gin.sql

raw
1 CREATE TABLE test1 (x int, y int[]);
2 INSERT INTO test1 VALUES (1, ARRAY[11, 111]);
3 CREATE INDEX test1_y_idx ON test1 USING gin (y) WITH (fastupdate = off);
4
5 \x
6
7 SELECT * FROM gin_metapage_info(get_raw_page('test1_y_idx', 0));
8 SELECT * FROM gin_metapage_info(get_raw_page('test1_y_idx', 1));
9
10 SELECT * FROM gin_page_opaque_info(get_raw_page('test1_y_idx', 1));
11
12 SELECT * FROM gin_leafpage_items(get_raw_page('test1_y_idx', 1));
13
14 INSERT INTO test1 SELECT x, ARRAY[1,10] FROM generate_series(2,10000) x;
15
16 SELECT COUNT(*) > 0
17 FROM gin_leafpage_items(get_raw_page('test1_y_idx',
18 (pg_relation_size('test1_y_idx') /
19 current_setting('block_size')::bigint)::int - 1));
20
21 -- Failure with various modes.
22 -- Suppress the DETAIL message, to allow the tests to work across various
23 -- page sizes and architectures.
24 \set VERBOSITY terse
25 -- invalid page size
26 SELECT gin_leafpage_items('aaa'::bytea);
27 SELECT gin_metapage_info('bbb'::bytea);
28 SELECT gin_page_opaque_info('ccc'::bytea);
29 -- invalid special area size
30 SELECT * FROM gin_metapage_info(get_raw_page('test1', 0));
31 SELECT * FROM gin_page_opaque_info(get_raw_page('test1', 0));
32 SELECT * FROM gin_leafpage_items(get_raw_page('test1', 0));
33 \set VERBOSITY default
34
35 -- Tests with all-zero pages.
36 SHOW block_size \gset
37 SELECT gin_leafpage_items(decode(repeat('00', :block_size), 'hex'));
38 SELECT gin_metapage_info(decode(repeat('00', :block_size), 'hex'));
39 SELECT gin_page_opaque_info(decode(repeat('00', :block_size), 'hex'));
40
41 DROP TABLE test1;