mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -17863,9 +17863,13 @@ GetAttributeCompression(Form_pg_attribute att, char *compression)
|
|||||||
|
|
||||||
/* fallback to default compression if it's not specified */
|
/* fallback to default compression if it's not specified */
|
||||||
if (compression == NULL)
|
if (compression == NULL)
|
||||||
cmethod = GetDefaultToastCompression();
|
return GetDefaultToastCompression();
|
||||||
else
|
|
||||||
cmethod = CompressionNameToMethod(compression);
|
cmethod = CompressionNameToMethod(compression);
|
||||||
|
if (!CompressionMethodIsValid(cmethod))
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
errmsg("invalid compression method \"%s\"", compression)));
|
||||||
|
|
||||||
return cmethod;
|
return cmethod;
|
||||||
}
|
}
|
||||||
|
@ -347,4 +347,10 @@ SELECT length(f1) FROM cmmove3;
|
|||||||
10040
|
10040
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression); -- fails
|
||||||
|
ERROR: invalid compression method "i_do_not_exist_compression"
|
||||||
|
CREATE TABLE badcompresstbl (a text);
|
||||||
|
ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression; -- fails
|
||||||
|
ERROR: invalid compression method "i_do_not_exist_compression"
|
||||||
|
DROP TABLE badcompresstbl;
|
||||||
\set HIDE_TOAST_COMPRESSION true
|
\set HIDE_TOAST_COMPRESSION true
|
||||||
|
@ -340,4 +340,10 @@ SELECT length(f1) FROM cmmove3;
|
|||||||
10000
|
10000
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression); -- fails
|
||||||
|
ERROR: invalid compression method "i_do_not_exist_compression"
|
||||||
|
CREATE TABLE badcompresstbl (a text);
|
||||||
|
ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression; -- fails
|
||||||
|
ERROR: invalid compression method "i_do_not_exist_compression"
|
||||||
|
DROP TABLE badcompresstbl;
|
||||||
\set HIDE_TOAST_COMPRESSION true
|
\set HIDE_TOAST_COMPRESSION true
|
||||||
|
@ -137,4 +137,9 @@ SELECT length(f1) FROM cmmove1;
|
|||||||
SELECT length(f1) FROM cmmove2;
|
SELECT length(f1) FROM cmmove2;
|
||||||
SELECT length(f1) FROM cmmove3;
|
SELECT length(f1) FROM cmmove3;
|
||||||
|
|
||||||
|
CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression); -- fails
|
||||||
|
CREATE TABLE badcompresstbl (a text);
|
||||||
|
ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression; -- fails
|
||||||
|
DROP TABLE badcompresstbl;
|
||||||
|
|
||||||
\set HIDE_TOAST_COMPRESSION true
|
\set HIDE_TOAST_COMPRESSION true
|
||||||
|
Reference in New Issue
Block a user