mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-27 22:41:57 +02:00
Fix segmentation fault in MergeInheritedAttribute()
While converting a pg_attribute tuple into a ColumnDef, ColumnDef::compression remains NULL if there is no compression method set fot the attribute. Calling strcmp() with NULL ColumnDef::compression, when comparing compression methods of parents, causes segmentation fault in MergeInheritedAttribute(). Skip comparing compression methods if either of them is NULL. Author: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> Reported-by: Alexander Lakhin <exclusion@gmail.com> Discussion: https://www.postgresql.org/message-id/b22a6834-aacb-7b18-0424-a3f5fe889667%40gmail.com
This commit is contained in:
parent
91e7115b17
commit
8f0a97dfff
@ -3432,12 +3432,16 @@ MergeInheritedAttribute(List *inh_columns,
|
|||||||
*/
|
*/
|
||||||
if (prevdef->compression == NULL)
|
if (prevdef->compression == NULL)
|
||||||
prevdef->compression = newdef->compression;
|
prevdef->compression = newdef->compression;
|
||||||
else if (strcmp(prevdef->compression, newdef->compression) != 0)
|
else if (newdef->compression != NULL)
|
||||||
ereport(ERROR,
|
{
|
||||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
if (strcmp(prevdef->compression, newdef->compression) != 0)
|
||||||
errmsg("column \"%s\" has a compression method conflict",
|
ereport(ERROR,
|
||||||
attributeName),
|
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||||
errdetail("%s versus %s", prevdef->compression, newdef->compression)));
|
errmsg("column \"%s\" has a compression method conflict",
|
||||||
|
attributeName),
|
||||||
|
errdetail("%s versus %s",
|
||||||
|
prevdef->compression, newdef->compression)));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for GENERATED conflicts
|
* Check for GENERATED conflicts
|
||||||
|
@ -223,15 +223,18 @@ SELECT pg_column_compression(f1) FROM cmpart2;
|
|||||||
pglz
|
pglz
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- test compression with inheritance, error
|
-- test compression with inheritance
|
||||||
CREATE TABLE cminh() INHERITS(cmdata, cmdata1);
|
CREATE TABLE cminh() INHERITS(cmdata, cmdata1); -- error
|
||||||
NOTICE: merging multiple inherited definitions of column "f1"
|
NOTICE: merging multiple inherited definitions of column "f1"
|
||||||
ERROR: column "f1" has a compression method conflict
|
ERROR: column "f1" has a compression method conflict
|
||||||
DETAIL: pglz versus lz4
|
DETAIL: pglz versus lz4
|
||||||
CREATE TABLE cminh(f1 TEXT COMPRESSION lz4) INHERITS(cmdata);
|
CREATE TABLE cminh(f1 TEXT COMPRESSION lz4) INHERITS(cmdata); -- error
|
||||||
NOTICE: merging column "f1" with inherited definition
|
NOTICE: merging column "f1" with inherited definition
|
||||||
ERROR: column "f1" has a compression method conflict
|
ERROR: column "f1" has a compression method conflict
|
||||||
DETAIL: pglz versus lz4
|
DETAIL: pglz versus lz4
|
||||||
|
CREATE TABLE cmdata3(f1 text);
|
||||||
|
CREATE TABLE cminh() INHERITS (cmdata, cmdata3);
|
||||||
|
NOTICE: merging multiple inherited definitions of column "f1"
|
||||||
-- test default_toast_compression GUC
|
-- test default_toast_compression GUC
|
||||||
SET default_toast_compression = '';
|
SET default_toast_compression = '';
|
||||||
ERROR: invalid value for parameter "default_toast_compression": ""
|
ERROR: invalid value for parameter "default_toast_compression": ""
|
||||||
@ -251,6 +254,7 @@ INSERT INTO cmdata VALUES (repeat('123456789', 4004));
|
|||||||
f1 | text | | | | extended | lz4 | |
|
f1 | text | | | | extended | lz4 | |
|
||||||
Indexes:
|
Indexes:
|
||||||
"idx" btree (f1)
|
"idx" btree (f1)
|
||||||
|
Child tables: cminh
|
||||||
|
|
||||||
SELECT pg_column_compression(f1) FROM cmdata;
|
SELECT pg_column_compression(f1) FROM cmdata;
|
||||||
pg_column_compression
|
pg_column_compression
|
||||||
|
@ -93,9 +93,11 @@ INSERT INTO cmpart VALUES (repeat('123456789', 4004));
|
|||||||
SELECT pg_column_compression(f1) FROM cmpart1;
|
SELECT pg_column_compression(f1) FROM cmpart1;
|
||||||
SELECT pg_column_compression(f1) FROM cmpart2;
|
SELECT pg_column_compression(f1) FROM cmpart2;
|
||||||
|
|
||||||
-- test compression with inheritance, error
|
-- test compression with inheritance
|
||||||
CREATE TABLE cminh() INHERITS(cmdata, cmdata1);
|
CREATE TABLE cminh() INHERITS(cmdata, cmdata1); -- error
|
||||||
CREATE TABLE cminh(f1 TEXT COMPRESSION lz4) INHERITS(cmdata);
|
CREATE TABLE cminh(f1 TEXT COMPRESSION lz4) INHERITS(cmdata); -- error
|
||||||
|
CREATE TABLE cmdata3(f1 text);
|
||||||
|
CREATE TABLE cminh() INHERITS (cmdata, cmdata3);
|
||||||
|
|
||||||
-- test default_toast_compression GUC
|
-- test default_toast_compression GUC
|
||||||
SET default_toast_compression = '';
|
SET default_toast_compression = '';
|
||||||
|
Loading…
Reference in New Issue
Block a user