summaryrefslogtreecommitdiff
path: root/contrib/pageinspect/sql/page.sql
diff options
context:
space:
mode:
authorMichael Paquier2019-09-19 02:01:52 +0000
committerMichael Paquier2019-09-19 02:01:52 +0000
commit58b4cb30a5bf52d71a4d0e5f9f7e1da3e64f67cc (patch)
tree94866dcd6aa67583a626306fa96169b44de1e934 /contrib/pageinspect/sql/page.sql
parent59354ccef5d7671bb11982628d6ddd6fffbad2c4 (diff)
Redesign pageinspect function printing infomask bits
After more discussion, the new function added by ddbd5d8 could have been designed in a better way. Based on an idea from Álvaro, instead of returning one column which includes both the raw and combined flags, use two columns, with one for the raw flags and one for the combined flags. This also takes care of some issues with HEAP_LOCKED_UPGRADED and HEAP_XMAX_IS_LOCKED_ONLY which are not really combined flags as they depend on conditions defined by other raw bits, as mentioned by Amit. While on it, fix an extra issue with combined flags. A combined flag was returned if at least one of its bits was set, but all its bits need to be set to include it in the result. Author: Michael Paquier Reviewed-by: Álvaro Herrera, Amit Kapila Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'contrib/pageinspect/sql/page.sql')
-rw-r--r--contrib/pageinspect/sql/page.sql42
1 files changed, 17 insertions, 25 deletions
diff --git a/contrib/pageinspect/sql/page.sql b/contrib/pageinspect/sql/page.sql
index 0319b5fa114..bd049aeb247 100644
--- a/contrib/pageinspect/sql/page.sql
+++ b/contrib/pageinspect/sql/page.sql
@@ -36,42 +36,34 @@ SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
-- default: HEAP_XMIN_COMMITTED and HEAP_XMIN_INVALID.
VACUUM FREEZE test1;
-SELECT t_infomask, t_infomask2, flags
+SELECT t_infomask, t_infomask2, raw_flags, combined_flags
FROM heap_page_items(get_raw_page('test1', 0)),
- LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2) m(flags);
+ LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);
-- output the decoded flag HEAP_XMIN_FROZEN instead
-SELECT t_infomask, t_infomask2, flags
+SELECT t_infomask, t_infomask2, raw_flags, combined_flags
FROM heap_page_items(get_raw_page('test1', 0)),
- LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2, true) m(flags);
+ LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2);
-- tests for decoding of combined flags
-- HEAP_XMAX_SHR_LOCK = (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)
-SELECT heap_tuple_infomask_flags(x'0050'::int, 0, true);
-SELECT heap_tuple_infomask_flags(x'0050'::int, 0, false);
+SELECT * FROM heap_tuple_infomask_flags(x'0050'::int, 0);
-- HEAP_XMIN_FROZEN = (HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID)
-SELECT heap_tuple_infomask_flags(x'0300'::int, 0, true);
-SELECT heap_tuple_infomask_flags(x'0300'::int, 0, false);
+SELECT * FROM heap_tuple_infomask_flags(x'0300'::int, 0);
-- HEAP_MOVED = (HEAP_MOVED_IN | HEAP_MOVED_OFF)
-SELECT heap_tuple_infomask_flags(x'C000'::int, 0, true);
-SELECT heap_tuple_infomask_flags(x'C000'::int, 0, false);
--- HEAP_LOCKED_UPGRADED = (HEAP_XMAX_IS_MULTI | HEAP_XMAX_LOCK_ONLY)
-SELECT heap_tuple_infomask_flags(x'1080'::int, 0, true);
-SELECT heap_tuple_infomask_flags(x'1080'::int, 0, false);
+SELECT * FROM heap_tuple_infomask_flags(x'C000'::int, 0);
+SELECT * FROM heap_tuple_infomask_flags(x'C000'::int, 0);
-- test all flags of t_infomask and t_infomask2
-SELECT unnest(heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int, false))
- AS flags ORDER BY 1;
-SELECT unnest(heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int, true))
- AS flags ORDER BY 1;
-SELECT unnest(heap_tuple_infomask_flags(-1, -1, false))
- AS flags ORDER BY 1;
-SELECT unnest(heap_tuple_infomask_flags(-1, -1, true))
- AS flags ORDER BY 1;
-
--- no flags
-SELECT unnest(heap_tuple_infomask_flags(0, 0, false));
-SELECT unnest(heap_tuple_infomask_flags(0, 0, true));
+SELECT unnest(raw_flags)
+ FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;
+SELECT unnest(combined_flags)
+ FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;
+
+-- no flags at all
+SELECT * FROM heap_tuple_infomask_flags(0, 0);
+-- no combined flags
+SELECT * FROM heap_tuple_infomask_flags(x'0010'::int, 0);
DROP TABLE test1;