mirror of
https://github.com/postgres/postgres.git
synced 2026-01-26 09:41:40 +03:00
Add more tests with clause STORAGE on table and TOAST interactions
This commit adds more tests to cover STORAGE MAIN and EXTENDED, checking how these use TOAST tables. EXTENDED is already widely tested as the default behavior, but there were no tests where the clause pattern is directly specified. STORAGE MAIN and its interactions with TOAST was not covered at all. This hole in the tests has been noticed for STORAGE MAIN (inline compressible varlenas), where I have managed to break the backend without the tests able to notice the breakage while playing with the varlena structures. Reviewed-by: Nikhil Kumar Veldanda <veldanda.nikhilkumar17@gmail.com> Discussion: https://postgr.es/m/aXMdX1UTHnzYPkHk@paquier.xyz
This commit is contained in:
@@ -2159,6 +2159,60 @@ SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_com
|
||||
|
|
||||
(1 row)
|
||||
|
||||
TRUNCATE toasttest;
|
||||
-- test with inline compressible varlenas.
|
||||
SET default_toast_compression = 'pglz';
|
||||
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 WHERE chunk_seq = 0;
|
||||
count
|
||||
-------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
RESET default_toast_compression;
|
||||
DROP TABLE toasttest;
|
||||
--
|
||||
-- test length
|
||||
|
||||
@@ -678,6 +678,30 @@ 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.
|
||||
SET default_toast_compression = 'pglz';
|
||||
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 WHERE chunk_seq = 0;
|
||||
RESET default_toast_compression;
|
||||
DROP TABLE toasttest;
|
||||
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user