2016-09-29 18:00:00 +02:00
|
|
|
CREATE EXTENSION pageinspect;
|
2019-05-07 06:00:24 +02:00
|
|
|
CREATE TABLE test1 (a int, b int);
|
|
|
|
INSERT INTO test1 VALUES (16777217, 131584);
|
|
|
|
VACUUM test1; -- set up FSM
|
2016-09-29 18:00:00 +02:00
|
|
|
-- The page contents can vary, so just test that it can be read
|
|
|
|
-- successfully, but don't keep the output.
|
2019-05-07 06:00:24 +02:00
|
|
|
SELECT octet_length(get_raw_page('test1', 'main', 0)) AS main_0;
|
2016-09-29 18:00:00 +02:00
|
|
|
main_0
|
|
|
|
--------
|
|
|
|
8192
|
|
|
|
(1 row)
|
|
|
|
|
2019-05-07 06:00:24 +02:00
|
|
|
SELECT octet_length(get_raw_page('test1', 'main', 1)) AS main_1;
|
|
|
|
ERROR: block number 1 is out of range for relation "test1"
|
|
|
|
SELECT octet_length(get_raw_page('test1', 'fsm', 0)) AS fsm_0;
|
2016-09-29 18:00:00 +02:00
|
|
|
fsm_0
|
|
|
|
-------
|
|
|
|
8192
|
|
|
|
(1 row)
|
|
|
|
|
2019-05-07 06:00:24 +02:00
|
|
|
SELECT octet_length(get_raw_page('test1', 'fsm', 1)) AS fsm_1;
|
|
|
|
fsm_1
|
|
|
|
-------
|
|
|
|
8192
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT octet_length(get_raw_page('test1', 'vm', 0)) AS vm_0;
|
2016-09-29 18:00:00 +02:00
|
|
|
vm_0
|
|
|
|
------
|
|
|
|
8192
|
|
|
|
(1 row)
|
|
|
|
|
2019-05-07 06:00:24 +02:00
|
|
|
SELECT octet_length(get_raw_page('test1', 'vm', 1)) AS vm_1;
|
|
|
|
ERROR: block number 1 is out of range for relation "test1"
|
2016-09-29 18:00:00 +02:00
|
|
|
SELECT octet_length(get_raw_page('xxx', 'main', 0));
|
|
|
|
ERROR: relation "xxx" does not exist
|
2019-05-07 06:00:24 +02:00
|
|
|
SELECT octet_length(get_raw_page('test1', 'xxx', 0));
|
2016-09-29 18:00:00 +02:00
|
|
|
ERROR: invalid fork name
|
|
|
|
HINT: Valid fork names are "main", "fsm", "vm", and "init".
|
2019-05-07 06:00:24 +02:00
|
|
|
SELECT get_raw_page('test1', 0) = get_raw_page('test1', 'main', 0);
|
2016-09-29 18:00:00 +02:00
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
2017-03-17 14:23:39 +01:00
|
|
|
SELECT pagesize, version FROM page_header(get_raw_page('test1', 0));
|
|
|
|
pagesize | version
|
|
|
|
----------+---------
|
|
|
|
8192 | 4
|
|
|
|
(1 row)
|
|
|
|
|
2017-03-17 14:49:10 +01:00
|
|
|
SELECT page_checksum(get_raw_page('test1', 0), 0) IS NOT NULL AS silly_checksum_test;
|
|
|
|
silly_checksum_test
|
|
|
|
---------------------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
2016-09-29 18:00:00 +02:00
|
|
|
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
|
|
|
|
-------------------------------
|
2016-11-01 17:00:00 +01:00
|
|
|
{"\\x01000001","\\x00020200"}
|
2016-09-29 18:00:00 +02:00
|
|
|
(1 row)
|
|
|
|
|
2019-05-07 06:00:24 +02:00
|
|
|
SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
|
|
|
|
fsm_page_contents
|
|
|
|
-------------------
|
|
|
|
0: 254 +
|
|
|
|
1: 254 +
|
|
|
|
3: 254 +
|
|
|
|
7: 254 +
|
|
|
|
15: 254 +
|
|
|
|
31: 254 +
|
|
|
|
63: 254 +
|
|
|
|
127: 254 +
|
|
|
|
255: 254 +
|
|
|
|
511: 254 +
|
|
|
|
1023: 254 +
|
|
|
|
2047: 254 +
|
|
|
|
4095: 254 +
|
|
|
|
fp_next_slot: 0 +
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
2016-09-29 18:00:00 +02:00
|
|
|
DROP TABLE test1;
|
2018-05-09 19:03:43 +02:00
|
|
|
-- check that using any of these functions with a partitioned table or index
|
|
|
|
-- would fail
|
2017-03-09 22:34:25 +01:00
|
|
|
create table test_partitioned (a int) partition by range (a);
|
2018-05-09 19:03:43 +02:00
|
|
|
create index test_partitioned_index on test_partitioned (a);
|
2017-03-09 22:34:25 +01:00
|
|
|
select get_raw_page('test_partitioned', 0); -- error about partitioned table
|
|
|
|
ERROR: cannot get raw page from partitioned table "test_partitioned"
|
2018-05-09 19:03:43 +02:00
|
|
|
select get_raw_page('test_partitioned_index', 0); -- error about partitioned index
|
|
|
|
ERROR: cannot get raw page from partitioned index "test_partitioned_index"
|
2017-03-09 22:34:25 +01:00
|
|
|
-- 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;
|
2018-01-04 20:59:00 +01:00
|
|
|
-- 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);
|
2018-01-04 21:59:29 +01:00
|
|
|
insert into test8(f1, f8) values (x'7f00007f'::int, 0);
|
2018-01-04 20:59:00 +01:00
|
|
|
select t_bits, t_data from heap_page_items(get_raw_page('test8', 0));
|
|
|
|
t_bits | t_data
|
|
|
|
----------+--------------------
|
2018-01-04 21:59:29 +01:00
|
|
|
10000001 | \x7f00007f00000000
|
2018-01-04 20:59:00 +01:00
|
|
|
(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
|
|
|
|
-------------------------------------------------------------
|
2018-01-04 21:59:29 +01:00
|
|
|
{"\\x7f00007f",NULL,NULL,NULL,NULL,NULL,NULL,"\\x00000000"}
|
2018-01-04 20:59:00 +01:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
drop table test8;
|