aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2014-09-03 11:54:31 -0400
committerBruce Momjian <bruce@momjian.us>2014-09-03 11:54:31 -0400
commit4011f8c98bd8bb67715449d2db5fc97dffa6a41f (patch)
tree91d5c1261de8eee3f9cf68538c458b401e8175a7
parentc1008f0037ec9c738127c2fa6d7f6c88d885f45f (diff)
downloadpostgresql-4011f8c98bd8bb67715449d2db5fc97dffa6a41f.tar.gz
postgresql-4011f8c98bd8bb67715449d2db5fc97dffa6a41f.zip
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
-rw-r--r--src/backend/commands/tablecmds.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 3720a0fe563..0a679be24e7 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1756,12 +1756,16 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
*/
if (inhSchema != NIL)
{
+ int schema_attno = 0;
+
foreach(entry, schema)
{
ColumnDef *newdef = lfirst(entry);
char *attributeName = newdef->colname;
int exist_attno;
+ schema_attno++;
+
/*
* Does it conflict with some previously inherited column?
*/
@@ -1780,9 +1784,14 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
* Yes, try to merge the two column definitions. They must
* have the same type, typmod, and collation.
*/
- ereport(NOTICE,
- (errmsg("merging column \"%s\" with inherited definition",
- attributeName)));
+ if (exist_attno == schema_attno)
+ ereport(NOTICE,
+ (errmsg("merging column \"%s\" with inherited definition",
+ 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);
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);