From 9252c0423099a56538c04517db03b1e25118ece2 Mon Sep 17 00:00:00 2001 From: Rui Zhao Date: Tue, 15 Sep 2026 00:51:00 +0800 Subject: [PATCH 7/7] Store the compressed values of the amcheck TOAST test out of line The rows meant to hold compressed out-of-line values in check_heap.sql compress to 1161 bytes and stay in the heap, so the test does not see a compressed TOAST pointer of either type. Make the values large enough, and show that every value is out of line and half of them compressed. --- contrib/amcheck/expected/check_heap.out | 20 +++++++++++++++++--- contrib/amcheck/sql/check_heap.sql | 14 +++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/contrib/amcheck/expected/check_heap.out b/contrib/amcheck/expected/check_heap.out index 8686fba712d..a4c26dd4f87 100644 --- a/contrib/amcheck/expected/check_heap.out +++ b/contrib/amcheck/expected/check_heap.out @@ -209,13 +209,27 @@ INSERT INTO test_toast_oid (a, b) (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(1,5) gs); INSERT INTO test_toast_oid8 (a, b) (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(1,5) gs); --- Compressed out-of-line values. +-- Compressed out-of-line values. These have to be large enough to stay +-- out of line once compressed. ALTER TABLE test_toast_oid ALTER COLUMN b SET STORAGE EXTENDED; ALTER TABLE test_toast_oid8 ALTER COLUMN b SET STORAGE EXTENDED; INSERT INTO test_toast_oid (a, b) - (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(6,10) gs); + (SELECT gs, repeat('xyzzy', 100000) FROM generate_series(6,10) gs); INSERT INTO test_toast_oid8 (a, b) - (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(6,10) gs); + (SELECT gs, repeat('xyzzy', 100000) FROM generate_series(6,10) gs); +-- All values are out of line, half of them compressed. +SELECT 'test_toast_oid' AS relname, count(pg_column_toast_chunk_id(b)) AS out_of_line, + count(pg_column_compression(b)) AS compressed FROM test_toast_oid +UNION ALL +SELECT 'test_toast_oid8', count(pg_column_toast_chunk_id(b)), + count(pg_column_compression(b)) FROM test_toast_oid8 + ORDER BY 1; + relname | out_of_line | compressed +-----------------+-------------+------------ + test_toast_oid | 10 | 5 + test_toast_oid8 | 10 | 5 +(2 rows) + SELECT c.relname, a.atttypid::regtype AS chunk_id_type FROM pg_class AS c, pg_attribute AS a WHERE c.relname IN ('test_toast_oid', 'test_toast_oid8') AND diff --git a/contrib/amcheck/sql/check_heap.sql b/contrib/amcheck/sql/check_heap.sql index eb46fe71035..0d0dd9834b9 100644 --- a/contrib/amcheck/sql/check_heap.sql +++ b/contrib/amcheck/sql/check_heap.sql @@ -122,13 +122,21 @@ INSERT INTO test_toast_oid (a, b) (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(1,5) gs); INSERT INTO test_toast_oid8 (a, b) (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(1,5) gs); --- Compressed out-of-line values. +-- Compressed out-of-line values. These have to be large enough to stay +-- out of line once compressed. ALTER TABLE test_toast_oid ALTER COLUMN b SET STORAGE EXTENDED; ALTER TABLE test_toast_oid8 ALTER COLUMN b SET STORAGE EXTENDED; INSERT INTO test_toast_oid (a, b) - (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(6,10) gs); + (SELECT gs, repeat('xyzzy', 100000) FROM generate_series(6,10) gs); INSERT INTO test_toast_oid8 (a, b) - (SELECT gs, repeat('xyzzy', 20000) FROM generate_series(6,10) gs); + (SELECT gs, repeat('xyzzy', 100000) FROM generate_series(6,10) gs); +-- All values are out of line, half of them compressed. +SELECT 'test_toast_oid' AS relname, count(pg_column_toast_chunk_id(b)) AS out_of_line, + count(pg_column_compression(b)) AS compressed FROM test_toast_oid +UNION ALL +SELECT 'test_toast_oid8', count(pg_column_toast_chunk_id(b)), + count(pg_column_compression(b)) FROM test_toast_oid8 + ORDER BY 1; SELECT c.relname, a.atttypid::regtype AS chunk_id_type FROM pg_class AS c, pg_attribute AS a WHERE c.relname IN ('test_toast_oid', 'test_toast_oid8') AND -- 2.43.7