Content-Length: 356515 | pFad | http://github.com/postgrespro/postgres/commit/a4d5284a10b5096585f1bbf1bf723954e9d6c2e0

BB Error on invalid TOAST compression in CREATE or ALTER TABLE. · postgrespro/postgres@a4d5284 · GitHub
Skip to content

Commit a4d5284

Browse files
committed
Error on invalid TOAST compression in CREATE or ALTER TABLE.
The previous coding treated an invalid compression method name as equivalent to the default, which is certainly not right. Justin Pryzby Discussion: http://postgr.es/m/20210321235544.GD4203@telsasoft.com
1 parent 24f0e39 commit a4d5284

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/backend/commands/tablecmds.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17863,9 +17863,13 @@ GetAttributeCompression(Form_pg_attribute att, char *compression)
1786317863

1786417864
/* fallback to default compression if it's not specified */
1786517865
if (compression == NULL)
17866-
cmethod = GetDefaultToastCompression();
17867-
else
17868-
cmethod = CompressionNameToMethod(compression);
17866+
return GetDefaultToastCompression();
17867+
17868+
cmethod = CompressionNameToMethod(compression);
17869+
if (!CompressionMethodIsValid(cmethod))
17870+
ereport(ERROR,
17871+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
17872+
errmsg("invalid compression method \"%s\"", compression)));
1786917873

1787017874
return cmethod;
1787117875
}

src/test/regress/expected/compression.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,10 @@ SELECT length(f1) FROM cmmove3;
347347
10040
348348
(2 rows)
349349

350+
CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression); -- fails
351+
ERROR: invalid compression method "i_do_not_exist_compression"
352+
CREATE TABLE badcompresstbl (a text);
353+
ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression; -- fails
354+
ERROR: invalid compression method "i_do_not_exist_compression"
355+
DROP TABLE badcompresstbl;
350356
\set HIDE_TOAST_COMPRESSION true

src/test/regress/expected/compression_1.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,10 @@ SELECT length(f1) FROM cmmove3;
340340
10000
341341
(1 row)
342342

343+
CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression); -- fails
344+
ERROR: invalid compression method "i_do_not_exist_compression"
345+
CREATE TABLE badcompresstbl (a text);
346+
ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression; -- fails
347+
ERROR: invalid compression method "i_do_not_exist_compression"
348+
DROP TABLE badcompresstbl;
343349
\set HIDE_TOAST_COMPRESSION true

src/test/regress/sql/compression.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,9 @@ SELECT length(f1) FROM cmmove1;
137137
SELECT length(f1) FROM cmmove2;
138138
SELECT length(f1) FROM cmmove3;
139139

140+
CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression); -- fails
141+
CREATE TABLE badcompresstbl (a text);
142+
ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression; -- fails
143+
DROP TABLE badcompresstbl;
144+
140145
\set HIDE_TOAST_COMPRESSION true

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/a4d5284a10b5096585f1bbf1bf723954e9d6c2e0

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy