Commit 4011f8c9 authored by Bruce Momjian's avatar Bruce Momjian

Issue clearer notice when inherited merged columns are moved

CREATE TABLE INHERIT moves user-specified columns to the location of the
inherited column.

Report by Fatal Majid
parent c1008f00
...@@ -1756,12 +1756,16 @@ MergeAttributes(List *schema, List *supers, char relpersistence, ...@@ -1756,12 +1756,16 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
*/ */
if (inhSchema != NIL) if (inhSchema != NIL)
{ {
int schema_attno = 0;
foreach(entry, schema) foreach(entry, schema)
{ {
ColumnDef *newdef = lfirst(entry); ColumnDef *newdef = lfirst(entry);
char *attributeName = newdef->colname; char *attributeName = newdef->colname;
int exist_attno; int exist_attno;
schema_attno++;
/* /*
* Does it conflict with some previously inherited column? * Does it conflict with some previously inherited column?
*/ */
...@@ -1780,9 +1784,14 @@ MergeAttributes(List *schema, List *supers, char relpersistence, ...@@ -1780,9 +1784,14 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
* Yes, try to merge the two column definitions. They must * Yes, try to merge the two column definitions. They must
* have the same type, typmod, and collation. * have the same type, typmod, and collation.
*/ */
if (exist_attno == schema_attno)
ereport(NOTICE, ereport(NOTICE,
(errmsg("merging column \"%s\" with inherited definition", (errmsg("merging column \"%s\" with inherited definition",
attributeName))); attributeName)));
else
ereport(NOTICE,
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
errdetail("User-specified column moved to the position of the inherited column.")));
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod); typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod); typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment