1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

CREATE TABLE ... LIKE ... should mark the columns it creates with

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.
This commit is contained in:
Tom Lane
2006-10-11 20:03:26 +00:00
parent 7b165e3ba5
commit 1c2d02c499

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.290.2.3 2005/02/19 19:33:42 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.290.2.4 2006/10/11 20:03:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1240,7 +1240,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
constr = tupleDesc->constr; 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. * definition.
*/ */
for (parent_attno = 1; parent_attno <= tupleDesc->natts; for (parent_attno = 1; parent_attno <= tupleDesc->natts;
@ -1258,7 +1258,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
continue; 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 * For constraints, ONLY the NOT NULL constraint is inherited by the
* new column definition per SQL99. * new column definition per SQL99.
@ -1270,7 +1270,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
typename->typmod = attribute->atttypmod; typename->typmod = attribute->atttypmod;
def->typename = typename; def->typename = typename;
def->inhcount = 0; def->inhcount = 0;
def->is_local = false; def->is_local = true;
def->is_not_null = attribute->attnotnull; def->is_not_null = attribute->attnotnull;
def->raw_default = NULL; def->raw_default = NULL;
def->cooked_default = NULL; def->cooked_default = NULL;