Hi all, While playing with the TOAST code this week, I have managed to break the handling of inline compressible entries, and noticed that the main regression test suite did not complain following that.
Breaking that stuff is my issue, but I would like to add some regression tests to cover all that, giving the attached. This also includes tests with EXTENDED in the same area, while on it, with checks for the TOAST table itself. Thoughts or comments? -- Michael
From b00fa7379eece6e3da2d46c0fd19aa80531cd7a9 Mon Sep 17 00:00:00 2001 From: Michael Paquier <[email protected]> Date: Fri, 23 Jan 2026 15:32:50 +0900 Subject: [PATCH] More tests for TOAST and STORAGE --- src/test/regress/expected/strings.out | 52 +++++++++++++++++++++++++++ src/test/regress/sql/strings.sql | 22 ++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index 5f2b5c391739..db03fd00d071 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -2159,6 +2159,58 @@ SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_com | (1 row) +TRUNCATE toasttest; +-- test with inline compressible varlenas. +ALTER TABLE toasttest ALTER COLUMN f1 SET STORAGE MAIN; +ALTER TABLE toasttest ALTER COLUMN f2 SET STORAGE MAIN; +INSERT INTO toasttest values(repeat('1234', 1024), repeat('5678', 1024)); +-- There should be no values in the toast relation. +SELECT substr(f1, 5, 10) AS f1_data, substr(f2, 5, 10) AS f2_data + FROM toasttest; + f1_data | f2_data +------------+------------ + 1234123412 | 5678567856 +(1 row) + +SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_comp + FROM toasttest; + f1_comp | f2_comp +---------+--------- + pglz | pglz +(1 row) + +SELECT count(*) FROM :reltoastname; + count +------- + 0 +(1 row) + +TRUNCATE toasttest; +-- test with external compressed data (default) +ALTER TABLE toasttest ALTER COLUMN f1 SET STORAGE EXTENDED; +ALTER TABLE toasttest ALTER COLUMN f2 SET STORAGE EXTENDED; +INSERT INTO toasttest values(repeat('1234', 10240), NULL); +-- There should be one value in the toast relation. +SELECT substr(f1, 5, 10) AS f1_data, substr(f2, 5, 10) AS f2_data + FROM toasttest; + f1_data | f2_data +------------+--------- + 1234123412 | +(1 row) + +SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_comp + FROM toasttest; + f1_comp | f2_comp +---------+--------- + pglz | +(1 row) + +SELECT count(*) FROM :reltoastname; + count +------- + 1 +(1 row) + DROP TABLE toasttest; -- -- test length diff --git a/src/test/regress/sql/strings.sql b/src/test/regress/sql/strings.sql index 37c0893ae838..592599722b8b 100644 --- a/src/test/regress/sql/strings.sql +++ b/src/test/regress/sql/strings.sql @@ -678,6 +678,28 @@ SELECT substr(f1, 5, 10) AS f1_data, substr(f2, 5, 10) AS f2_data FROM toasttest; SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_comp FROM toasttest; +TRUNCATE toasttest; +-- test with inline compressible varlenas. +ALTER TABLE toasttest ALTER COLUMN f1 SET STORAGE MAIN; +ALTER TABLE toasttest ALTER COLUMN f2 SET STORAGE MAIN; +INSERT INTO toasttest values(repeat('1234', 1024), repeat('5678', 1024)); +-- There should be no values in the toast relation. +SELECT substr(f1, 5, 10) AS f1_data, substr(f2, 5, 10) AS f2_data + FROM toasttest; +SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_comp + FROM toasttest; +SELECT count(*) FROM :reltoastname; +TRUNCATE toasttest; +-- test with external compressed data (default) +ALTER TABLE toasttest ALTER COLUMN f1 SET STORAGE EXTENDED; +ALTER TABLE toasttest ALTER COLUMN f2 SET STORAGE EXTENDED; +INSERT INTO toasttest values(repeat('1234', 10240), NULL); +-- There should be one value in the toast relation. +SELECT substr(f1, 5, 10) AS f1_data, substr(f2, 5, 10) AS f2_data + FROM toasttest; +SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_comp + FROM toasttest; +SELECT count(*) FROM :reltoastname; DROP TABLE toasttest; -- -- 2.51.0
signature.asc
Description: PGP signature
