public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: Postgres hackers <[email protected]>
Subject: Some tests for TOAST, STORAGE MAIN/EXTENDED
Date: Fri, 23 Jan 2026 16:03:59 +0900
Message-ID: <[email protected]> (raw)

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


Attachments:

  [text/x-diff] 0001-More-tests-for-TOAST-and-STORAGE.patch (3.6K, ../[email protected]/2-0001-More-tests-for-TOAST-and-STORAGE.patch)
  download | inline diff:
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



  [application/pgp-signature] signature.asc (833B, ../[email protected]/3-signature.asc)
  download

view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Some tests for TOAST, STORAGE MAIN/EXTENDED
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox