From 504c2205abc7de67386f9c95630f38ee15626f07 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 28 Apr 2017 13:52:17 -0400 Subject: Fix crash when partitioned column specified twice. Amit Langote, reviewed by Beena Emerson Discussion: http://postgr.es/m/6ed23d3d-c09d-4cbc-3628-0a8a32f750f4@lab.ntt.co.jp --- src/backend/commands/tablecmds.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/backend/commands/tablecmds.c') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index a35713096d9..4df17c0efcb 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1919,6 +1919,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence, def->is_local = false; def->is_not_null = attribute->attnotnull; def->is_from_type = false; + def->is_from_parent = true; def->storage = attribute->attstorage; def->raw_default = NULL; def->cooked_default = NULL; @@ -2206,11 +2207,20 @@ MergeAttributes(List *schema, List *supers, char relpersistence, * merge the column options into the column from the * parent */ - coldef->is_not_null = restdef->is_not_null; - coldef->raw_default = restdef->raw_default; - coldef->cooked_default = restdef->cooked_default; - coldef->constraints = restdef->constraints; - list_delete_cell(schema, rest, prev); + if (coldef->is_from_parent) + { + coldef->is_not_null = restdef->is_not_null; + coldef->raw_default = restdef->raw_default; + coldef->cooked_default = restdef->cooked_default; + coldef->constraints = restdef->constraints; + coldef->is_from_parent = false; + list_delete_cell(schema, rest, prev); + } + else + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_COLUMN), + errmsg("column \"%s\" specified more than once", + coldef->colname))); } prev = rest; rest = next; -- cgit v1.2.3