summaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorPeter Eisentraut2024-05-03 09:10:40 +0000
committerPeter Eisentraut2024-05-03 09:10:40 +0000
commit8f0a97dfffc5b5f48f609fb894befcdf761dd576 (patch)
tree25161b8b081bd79a69db9b8b5dde904bbb2ac08a /src/backend/commands/tablecmds.c
parent91e7115b177b0523f9757574b8a329ebe10c0af7 (diff)
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 <[email protected]> Reported-by: Alexander Lakhin <[email protected]> Discussion: https://www.postgresql.org/message-id/b22a6834-aacb-7b18-0424-a3f5fe889667%40gmail.com
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 3309332f1ae..a79ac884f7c 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -3432,12 +3432,16 @@ MergeInheritedAttribute(List *inh_columns,
*/
if (prevdef->compression == NULL)
prevdef->compression = newdef->compression;
- else if (strcmp(prevdef->compression, newdef->compression) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("column \"%s\" has a compression method conflict",
- attributeName),
- errdetail("%s versus %s", prevdef->compression, newdef->compression)));
+ else if (newdef->compression != NULL)
+ {
+ if (strcmp(prevdef->compression, newdef->compression) != 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("column \"%s\" has a compression method conflict",
+ attributeName),
+ errdetail("%s versus %s",
+ prevdef->compression, newdef->compression)));
+ }
/*
* Check for GENERATED conflicts