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);
|
2021-01-20 17:49:29 +01:00
|
|
|
VACUUM (DISABLE_PAGE_SKIPPING) 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"
|
2021-01-19 10:28:05 +01:00
|
|
|
SELECT octet_length(get_raw_page('test1', 'main', -1));
|
|
|
|
ERROR: invalid block number
|
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)
|
|
|
|
|
2021-01-19 10:28:05 +01:00
|
|
|
SELECT page_checksum(get_raw_page('test1', 0), -1);
|
|
|
|
ERROR: invalid block number
|
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)
|
|
|
|
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
-- If we freeze the only tuple on test1, the infomask should
|
2021-01-20 17:49:29 +01:00
|
|
|
-- always be the same in all test runs.
|
|
|
|
VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test1;
|
2019-09-19 04:01:52 +02:00
|
|
|
SELECT t_infomask, t_infomask2, raw_flags, combined_flags
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
FROM heap_page_items(get_raw_page('test1', 0)),
|
2019-09-19 04:01:52 +02:00
|
|
|
LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);
|
|
|
|
t_infomask | t_infomask2 | raw_flags | combined_flags
|
|
|
|
------------+-------------+-----------------------------------------------------------+--------------------
|
|
|
|
2816 | 2 | {HEAP_XMIN_COMMITTED,HEAP_XMIN_INVALID,HEAP_XMAX_INVALID} | {HEAP_XMIN_FROZEN}
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- tests for decoding of combined flags
|
|
|
|
-- HEAP_XMAX_SHR_LOCK = (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)
|
2019-09-19 04:01:52 +02:00
|
|
|
SELECT * FROM heap_tuple_infomask_flags(x'0050'::int, 0);
|
|
|
|
raw_flags | combined_flags
|
|
|
|
---------------------------------------------+----------------------
|
|
|
|
{HEAP_XMAX_KEYSHR_LOCK,HEAP_XMAX_EXCL_LOCK} | {HEAP_XMAX_SHR_LOCK}
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- HEAP_XMIN_FROZEN = (HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID)
|
2019-09-19 04:01:52 +02:00
|
|
|
SELECT * FROM heap_tuple_infomask_flags(x'0300'::int, 0);
|
|
|
|
raw_flags | combined_flags
|
|
|
|
-----------------------------------------+--------------------
|
|
|
|
{HEAP_XMIN_COMMITTED,HEAP_XMIN_INVALID} | {HEAP_XMIN_FROZEN}
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- HEAP_MOVED = (HEAP_MOVED_IN | HEAP_MOVED_OFF)
|
2019-09-19 04:01:52 +02:00
|
|
|
SELECT * FROM heap_tuple_infomask_flags(x'C000'::int, 0);
|
|
|
|
raw_flags | combined_flags
|
|
|
|
--------------------------------+----------------
|
|
|
|
{HEAP_MOVED_OFF,HEAP_MOVED_IN} | {HEAP_MOVED}
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
(1 row)
|
|
|
|
|
2019-09-19 04:01:52 +02:00
|
|
|
SELECT * FROM heap_tuple_infomask_flags(x'C000'::int, 0);
|
|
|
|
raw_flags | combined_flags
|
|
|
|
--------------------------------+----------------
|
|
|
|
{HEAP_MOVED_OFF,HEAP_MOVED_IN} | {HEAP_MOVED}
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
-- test all flags of t_infomask and t_infomask2
|
2019-09-19 04:01:52 +02:00
|
|
|
SELECT unnest(raw_flags)
|
|
|
|
FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;
|
|
|
|
unnest
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
-----------------------
|
|
|
|
HEAP_COMBOCID
|
|
|
|
HEAP_HASEXTERNAL
|
|
|
|
HEAP_HASNULL
|
|
|
|
HEAP_HASOID_OLD
|
|
|
|
HEAP_HASVARWIDTH
|
|
|
|
HEAP_HOT_UPDATED
|
|
|
|
HEAP_KEYS_UPDATED
|
|
|
|
HEAP_MOVED_IN
|
|
|
|
HEAP_MOVED_OFF
|
|
|
|
HEAP_ONLY_TUPLE
|
|
|
|
HEAP_UPDATED
|
|
|
|
HEAP_XMAX_COMMITTED
|
|
|
|
HEAP_XMAX_EXCL_LOCK
|
|
|
|
HEAP_XMAX_INVALID
|
|
|
|
HEAP_XMAX_IS_MULTI
|
|
|
|
HEAP_XMAX_KEYSHR_LOCK
|
|
|
|
HEAP_XMAX_LOCK_ONLY
|
|
|
|
HEAP_XMIN_COMMITTED
|
|
|
|
HEAP_XMIN_INVALID
|
|
|
|
(19 rows)
|
|
|
|
|
2019-09-19 04:01:52 +02:00
|
|
|
SELECT unnest(combined_flags)
|
|
|
|
FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;
|
|
|
|
unnest
|
|
|
|
--------------------
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
HEAP_MOVED
|
|
|
|
HEAP_XMAX_SHR_LOCK
|
|
|
|
HEAP_XMIN_FROZEN
|
2019-09-19 04:01:52 +02:00
|
|
|
(3 rows)
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
|
2019-09-19 04:01:52 +02:00
|
|
|
-- no flags at all
|
|
|
|
SELECT * FROM heap_tuple_infomask_flags(0, 0);
|
|
|
|
raw_flags | combined_flags
|
|
|
|
-----------+----------------
|
|
|
|
{} | {}
|
|
|
|
(1 row)
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
|
2019-09-19 04:01:52 +02:00
|
|
|
-- no combined flags
|
|
|
|
SELECT * FROM heap_tuple_infomask_flags(x'0010'::int, 0);
|
|
|
|
raw_flags | combined_flags
|
|
|
|
-------------------------+----------------
|
|
|
|
{HEAP_XMAX_KEYSHR_LOCK} | {}
|
|
|
|
(1 row)
|
Add to pageinspect function to make t_infomask/t_infomask2 human-readable
Flags of t_infomask and t_infomask2 for each tuple are already included
in the information returned by heap_page_items as integers, and we
lacked a way to make that information human-readable.
Per discussion, the function includes an option which controls if
combined flags should be decomposed or not. The default is false, to
not decompose combined flags.
The module is bumped to version 1.8.
Author: Craig Ringer, Sawada Masahiko
Reviewed-by: Peter Geoghegan, Robert Haas, Álvaro Herrera, Moon Insung,
Amit Kapila, Michael Paquier, Tomas Vondra
Discussion: https://postgr.es/m/CAMsr+YEY7jeaXOb+oX+RhDyOFuTMdmHjGsBxL=igCm03J0go9Q@mail.gmail.com
2019-09-12 08:06:00 +02:00
|
|
|
|
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
|
Improve error messages about mismatching relkind
Most error messages about a relkind that was not supported or
appropriate for the command was of the pattern
"relation \"%s\" is not a table, foreign table, or materialized view"
This style can become verbose and tedious to maintain. Moreover, it's
not very helpful: If I'm trying to create a comment on a TOAST table,
which is not supported, then the information that I could have created
a comment on a materialized view is pointless.
Instead, write the primary error message shorter and saying more
directly that what was attempted is not possible. Then, in the detail
message, explain that the operation is not supported for the relkind
the object was. To simplify that, add a new function
errdetail_relkind_not_supported() that does this.
In passing, make use of RELKIND_HAS_STORAGE() where appropriate,
instead of listing out the relkinds individually.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/dc35a398-37d0-75ce-07ea-1dd71d98f8ec@2ndquadrant.com
2021-07-08 09:38:52 +02:00
|
|
|
ERROR: cannot get raw page from relation "test_partitioned"
|
|
|
|
DETAIL: This operation is not supported for partitioned tables.
|
2018-05-09 19:03:43 +02:00
|
|
|
select get_raw_page('test_partitioned_index', 0); -- error about partitioned index
|
Improve error messages about mismatching relkind
Most error messages about a relkind that was not supported or
appropriate for the command was of the pattern
"relation \"%s\" is not a table, foreign table, or materialized view"
This style can become verbose and tedious to maintain. Moreover, it's
not very helpful: If I'm trying to create a comment on a TOAST table,
which is not supported, then the information that I could have created
a comment on a materialized view is pointless.
Instead, write the primary error message shorter and saying more
directly that what was attempted is not possible. Then, in the detail
message, explain that the operation is not supported for the relkind
the object was. To simplify that, add a new function
errdetail_relkind_not_supported() that does this.
In passing, make use of RELKIND_HAS_STORAGE() where appropriate,
instead of listing out the relkinds individually.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/dc35a398-37d0-75ce-07ea-1dd71d98f8ec@2ndquadrant.com
2021-07-08 09:38:52 +02:00
|
|
|
ERROR: cannot get raw page from relation "test_partitioned_index"
|
|
|
|
DETAIL: This operation is not supported for partitioned indexes.
|
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;
|
pageinspect: Fix handling of page sizes and AM types
This commit fixes a set of issues related to the use of the SQL
functions in this module when the caller is able to pass down raw page
data as input argument:
- The page size check was fuzzy in a couple of places, sometimes
looking after only a sub-range, but what we are looking for is an exact
match on BLCKSZ. After considering a few options here, I have settled
down to do a generalization of get_page_from_raw(). Most of the SQL
functions already used that, and this is not strictly required if not
accessing an 8-byte-wide value from a raw page, but this feels safer in
the long run for alignment-picky environment, particularly if a code
path begins to access such values. This also reduces the number of
strings that need to be translated.
- The BRIN function brin_page_items() uses a Relation but it did not
check the access method of the opened index, potentially leading to
crashes. All the other functions in need of a Relation already did
that.
- Some code paths could fail on elog(), but we should to use ereport()
for failures that can be triggered by the user.
Tests are added to stress all the cases that are fixed as of this
commit, with some junk raw pages (\set VERBOSITY ensures that this works
across all page sizes) and unexpected index types when functions open
relations.
Author: Michael Paquier, Justin Prysby
Discussion: https://postgr.es/m/20220218030020.GA1137@telsasoft.com
Backpatch-through: 10
2022-03-16 03:19:39 +01:00
|
|
|
-- Failure with incorrect page size
|
|
|
|
-- Suppress the DETAIL message, to allow the tests to work across various
|
|
|
|
-- page sizes.
|
|
|
|
\set VERBOSITY terse
|
|
|
|
SELECT fsm_page_contents('aaa'::bytea);
|
|
|
|
ERROR: invalid page size
|
|
|
|
SELECT page_checksum('bbb'::bytea, 0);
|
|
|
|
ERROR: invalid page size
|
|
|
|
SELECT page_header('ccc'::bytea);
|
|
|
|
ERROR: invalid page size
|
|
|
|
\set VERBOSITY default
|