Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit225ebfe

Browse files
committed
Add regression test for short varlenas saved in TOAST relations
toast_save_datum() has for a very long time some code able to handleshort varlenas (values up to 126 bytes reduced to a 1-byte header),converting such varlenas to an external on-disk TOAST pointer with thevalue saved uncompressed in the secondary TOAST relation.There was zero coverage for this code path. This commit adds a testable to exercise it, relying on two external attributes, one with a lowtoast_tuple_target, so as it is possible to trigger the threshold forthe insertion of short varlenas into the TOAST relation.Author: Nikhil Kumar Veldanda <veldanda.nikhilkumar17@gmail.com>Co-authored-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/aJAl7-NvIk0kZByz@paquier.xyz
1 parent0b6aea0 commit225ebfe

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

‎src/test/regress/expected/strings.out‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,40 @@ SELECT c FROM toasttest;
20902090
x
20912091
(1 row)
20922092

2093+
DROP TABLE toasttest;
2094+
-- test with short varlenas (up to 126 data bytes reduced to a 1-byte header)
2095+
-- being toasted.
2096+
CREATE TABLE toasttest (f1 text, f2 text);
2097+
ALTER TABLE toasttest SET (toast_tuple_target = 128);
2098+
ALTER TABLE toasttest ALTER COLUMN f1 SET STORAGE EXTERNAL;
2099+
ALTER TABLE toasttest ALTER COLUMN f2 SET STORAGE EXTERNAL;
2100+
-- Here, the first value is a varlena large enough to make it toasted and
2101+
-- stored uncompressed. The second value is a short varlena, toasted
2102+
-- and stored uncompressed.
2103+
INSERT INTO toasttest values(repeat('1234', 1000), repeat('5678', 30));
2104+
SELECT reltoastrelid::regclass AS reltoastname FROM pg_class
2105+
WHERE oid = 'toasttest'::regclass \gset
2106+
-- There should be two values inserted in the toast relation.
2107+
SELECT count(*) FROM :reltoastname WHERE chunk_seq = 0;
2108+
count
2109+
-------
2110+
2
2111+
(1 row)
2112+
2113+
SELECT substr(f1, 5, 10) AS f1_data, substr(f2, 5, 10) AS f2_data
2114+
FROM toasttest;
2115+
f1_data | f2_data
2116+
------------+------------
2117+
1234123412 | 5678567856
2118+
(1 row)
2119+
2120+
SELECT pg_column_compression(f1) AS f1_comp, pg_column_compression(f2) AS f2_comp
2121+
FROM toasttest;
2122+
f1_comp | f2_comp
2123+
---------+---------
2124+
|
2125+
(1 row)
2126+
20932127
DROP TABLE toasttest;
20942128
--
20952129
-- test length

‎src/test/regress/sql/strings.sql‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,26 @@ SELECT length(c), c::text FROM toasttest;
650650
SELECT cFROM toasttest;
651651
DROPTABLE toasttest;
652652

653+
-- test with short varlenas (up to 126 data bytes reduced to a 1-byte header)
654+
-- being toasted.
655+
CREATETABLEtoasttest (f1text, f2text);
656+
ALTERTABLE toasttestSET (toast_tuple_target=128);
657+
ALTERTABLE toasttest ALTER COLUMN f1SET STORAGE EXTERNAL;
658+
ALTERTABLE toasttest ALTER COLUMN f2SET STORAGE EXTERNAL;
659+
-- Here, the first value is a varlena large enough to make it toasted and
660+
-- stored uncompressed. The second value is a short varlena, toasted
661+
-- and stored uncompressed.
662+
INSERT INTO toasttestvalues(repeat('1234',1000), repeat('5678',30));
663+
SELECT reltoastrelid::regclassAS reltoastnameFROM pg_class
664+
WHEREoid='toasttest'::regclass \gset
665+
-- There should be two values inserted in the toast relation.
666+
SELECTcount(*)FROM :reltoastnameWHERE chunk_seq=0;
667+
SELECT substr(f1,5,10)AS f1_data, substr(f2,5,10)AS f2_data
668+
FROM toasttest;
669+
SELECT pg_column_compression(f1)AS f1_comp, pg_column_compression(f2)AS f2_comp
670+
FROM toasttest;
671+
DROPTABLE toasttest;
672+
653673
--
654674
-- test length
655675
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp