Skip to content

Commit 4011f8c

Browse files
committed
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
1 parent c1008f0 commit 4011f8c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/backend/commands/tablecmds.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,12 +1756,16 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
17561756
*/
17571757
if (inhSchema != NIL)
17581758
{
1759+
int schema_attno = 0;
1760+
17591761
foreach(entry, schema)
17601762
{
17611763
ColumnDef *newdef = lfirst(entry);
17621764
char *attributeName = newdef->colname;
17631765
int exist_attno;
17641766

1767+
schema_attno++;
1768+
17651769
/*
17661770
* Does it conflict with some previously inherited column?
17671771
*/
@@ -1780,9 +1784,14 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
17801784
* Yes, try to merge the two column definitions. They must
17811785
* have the same type, typmod, and collation.
17821786
*/
1783-
ereport(NOTICE,
1784-
(errmsg("merging column \"%s\" with inherited definition",
1785-
attributeName)));
1787+
if (exist_attno == schema_attno)
1788+
ereport(NOTICE,
1789+
(errmsg("merging column \"%s\" with inherited definition",
1790+
attributeName)));
1791+
else
1792+
ereport(NOTICE,
1793+
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
1794+
errdetail("User-specified column moved to the position of the inherited column.")));
17861795
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
17871796
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
17881797
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy