CREATE TABLE ... LIKE ... should mark the columns it creates with
authorTom Lane <[email protected]>
Wed, 11 Oct 2006 20:03:11 +0000 (20:03 +0000)
committerTom Lane <[email protected]>
Wed, 11 Oct 2006 20:03:11 +0000 (20:03 +0000)
attislocal = true, since they are not really inherited but merely copied
from the original table.  I'm not sure if there are any cases where it makes
a real difference given the existing uses of the flag, but wrong is wrong.
This was fixed in passing in HEAD by the LIKE INCLUDING CONSTRAINTS patch,
but never back-patched.

src/backend/parser/analyze.c

index fcb9354b54b5fd1a858ce31b71dd09543b0b6f4a..8db539817231384d238a64131580c251d3b5c4f8 100644 (file)
@@ -1088,7 +1088,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
        constr = tupleDesc->constr;
 
        /*
-        * Insert the inherited attributes into the cxt for the new table
+        * Insert the copied attributes into the cxt for the new table
         * definition.
         */
        for (parent_attno = 1; parent_attno <= tupleDesc->natts;
@@ -1106,7 +1106,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
                        continue;
 
                /*
-                * Create a new inherited column.
+                * Create a new column, which is marked as NOT inherited.
                 *
                 * For constraints, ONLY the NOT NULL constraint is inherited by the
                 * new column definition per SQL99.
@@ -1118,7 +1118,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
                typename->typmod = attribute->atttypmod;
                def->typename = typename;
                def->inhcount = 0;
-               def->is_local = false;
+               def->is_local = true;
                def->is_not_null = attribute->attnotnull;
                def->raw_default = NULL;
                def->cooked_default = NULL;