postgresql/contrib/pageinspect/expected/page.out
Amit Kapila 08ecdfe7e5 Make FSM test portable.
In b0eaa4c51b, we allow FSM to be created only after 4 pages.  One of the
tests check the FSM contents and to do that it populates many tuples in
the relation.  The FSM contents depend on the availability of freespace in
the page and it could vary because of the alignment of tuples.

This commit removes the dependency on FSM contents.

Author: Amit Kapila
Discussion: https://postgr.es/m/CAA4eK1KADF6K1bagr0--mGv3dMcZ%3DH_Z-Qtvdfbp5PjaC6PJJA%40mail.gmail.com
2019-02-04 10:08:29 +05:30

104 lines
4.0 KiB
Plaintext

CREATE EXTENSION pageinspect;
CREATE TABLE test_rel_forks (a int);
-- Make sure there are enough blocks in the heap for the FSM to be created.
INSERT INTO test_rel_forks SELECT i from generate_series(1,2000) i;
-- set up FSM and VM
VACUUM test_rel_forks;
-- The page contents can vary, so just test that it can be read
-- successfully, but don't keep the output.
SELECT octet_length(get_raw_page('test_rel_forks', 'main', 0)) AS main_0;
main_0
--------
8192
(1 row)
SELECT octet_length(get_raw_page('test_rel_forks', 'main', 100)) AS main_100;
ERROR: block number 100 is out of range for relation "test_rel_forks"
SELECT octet_length(get_raw_page('test_rel_forks', 'fsm', 0)) AS fsm_0;
fsm_0
-------
8192
(1 row)
SELECT octet_length(get_raw_page('test_rel_forks', 'fsm', 20)) AS fsm_20;
ERROR: block number 20 is out of range for relation "test_rel_forks"
SELECT octet_length(get_raw_page('test_rel_forks', 'vm', 0)) AS vm_0;
vm_0
------
8192
(1 row)
SELECT octet_length(get_raw_page('test_rel_forks', 'vm', 1)) AS vm_1;
ERROR: block number 1 is out of range for relation "test_rel_forks"
SELECT octet_length(get_raw_page('xxx', 'main', 0));
ERROR: relation "xxx" does not exist
SELECT octet_length(get_raw_page('test_rel_forks', 'xxx', 0));
ERROR: invalid fork name
HINT: Valid fork names are "main", "fsm", "vm", and "init".
EXPLAIN (costs off, analyze on, timing off, summary off) SELECT * FROM
fsm_page_contents(get_raw_page('test_rel_forks', 'fsm', 0));
QUERY PLAN
------------------------------------------------------------
Function Scan on fsm_page_contents (actual rows=1 loops=1)
(1 row)
SELECT get_raw_page('test_rel_forks', 0) = get_raw_page('test_rel_forks', 'main', 0);
?column?
----------
t
(1 row)
DROP TABLE test_rel_forks;
CREATE TABLE test1 (a int, b int);
INSERT INTO test1 VALUES (16777217, 131584);
SELECT pagesize, version FROM page_header(get_raw_page('test1', 0));
pagesize | version
----------+---------
8192 | 4
(1 row)
SELECT page_checksum(get_raw_page('test1', 0), 0) IS NOT NULL AS silly_checksum_test;
silly_checksum_test
---------------------
t
(1 row)
SELECT tuple_data_split('test1'::regclass, t_data, t_infomask, t_infomask2, t_bits)
FROM heap_page_items(get_raw_page('test1', 0));
tuple_data_split
-------------------------------
{"\\x01000001","\\x00020200"}
(1 row)
DROP TABLE test1;
-- check that using any of these functions with a partitioned table or index
-- would fail
create table test_partitioned (a int) partition by range (a);
create index test_partitioned_index on test_partitioned (a);
select get_raw_page('test_partitioned', 0); -- error about partitioned table
ERROR: cannot get raw page from partitioned table "test_partitioned"
select get_raw_page('test_partitioned_index', 0); -- error about partitioned index
ERROR: cannot get raw page from partitioned index "test_partitioned_index"
-- a regular table which is a member of a partition set should work though
create table test_part1 partition of test_partitioned for values from ( 1 ) to (100);
select get_raw_page('test_part1', 0); -- get farther and error about empty table
ERROR: block number 0 is out of range for relation "test_part1"
drop table test_partitioned;
-- check null bitmap alignment for table whose number of attributes is multiple of 8
create table test8 (f1 int, f2 int, f3 int, f4 int, f5 int, f6 int, f7 int, f8 int);
insert into test8(f1, f8) values (x'7f00007f'::int, 0);
select t_bits, t_data from heap_page_items(get_raw_page('test8', 0));
t_bits | t_data
----------+--------------------
10000001 | \x7f00007f00000000
(1 row)
select tuple_data_split('test8'::regclass, t_data, t_infomask, t_infomask2, t_bits)
from heap_page_items(get_raw_page('test8', 0));
tuple_data_split
-------------------------------------------------------------
{"\\x7f00007f",NULL,NULL,NULL,NULL,NULL,NULL,"\\x00000000"}
(1 row)
drop table test8;