mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Back out Alvaro's patch until regression tests pass.
This commit is contained in:
parent
c0f7dcdac1
commit
757b98fda8
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.47 2002/10/19 02:25:51 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.48 2002/10/19 03:01:09 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1643,53 +1643,22 @@ AlterTableAddColumn(Oid myrelid,
|
|||||||
colDefChild->inhcount = 1;
|
colDefChild->inhcount = 1;
|
||||||
colDefChild->is_local = false;
|
colDefChild->is_local = false;
|
||||||
|
|
||||||
/* we only need direct inheritors */
|
/* this routine is actually in the planner */
|
||||||
children = find_inheritance_children(myrelid);
|
children = find_all_inheritors(myrelid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the child has a column with same name and type,
|
* find_all_inheritors does the recursive search of the
|
||||||
* increment its attinhcount and continue. If it has
|
* inheritance hierarchy, so all we have to do is process all of
|
||||||
* different type, abort. If it doesn't have a column
|
* the relids in the list that it returns.
|
||||||
* with the same name, add it.
|
|
||||||
*/
|
*/
|
||||||
foreach(child, children)
|
foreach(child, children)
|
||||||
{
|
{
|
||||||
Oid childrelid = lfirsti(child);
|
Oid childrelid = lfirsti(child);
|
||||||
HeapTuple tuple;
|
|
||||||
Form_pg_attribute childatt;
|
|
||||||
|
|
||||||
if (childrelid == myrelid)
|
if (childrelid == myrelid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
attrdesc = heap_openr(AttributeRelationName, RowExclusiveLock);
|
|
||||||
tuple = SearchSysCacheCopyAttName(childrelid, colDef->colname);
|
|
||||||
if (!HeapTupleIsValid(tuple))
|
|
||||||
{
|
|
||||||
heap_close(attrdesc, RowExclusiveLock);
|
|
||||||
AlterTableAddColumn(childrelid, false, true, colDefChild);
|
AlterTableAddColumn(childrelid, false, true, colDefChild);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
childatt = (Form_pg_attribute) GETSTRUCT(tuple);
|
|
||||||
|
|
||||||
typeTuple = typenameType(colDef->typename);
|
|
||||||
tform = (Form_pg_type) GETSTRUCT(typeTuple);
|
|
||||||
|
|
||||||
if (HeapTupleGetOid(typeTuple) != childatt->atttypid ||
|
|
||||||
colDef->typename->typmod != childatt->atttypmod)
|
|
||||||
elog(ERROR, "ALTER TABLE: child table %u has different "
|
|
||||||
"type for column \"%s\"",
|
|
||||||
childrelid, colDef->colname);
|
|
||||||
|
|
||||||
childatt->attinhcount++;
|
|
||||||
simple_heap_update(attrdesc, &tuple->t_self, tuple);
|
|
||||||
CatalogUpdateIndexes(attrdesc, tuple);
|
|
||||||
|
|
||||||
elog(NOTICE, "ALTER TABLE: merging definition of column "
|
|
||||||
"\"%s\" for child %u", colDef->colname, childrelid);
|
|
||||||
|
|
||||||
heap_close(attrdesc, RowExclusiveLock);
|
|
||||||
heap_freetuple(tuple);
|
|
||||||
ReleaseSysCache(typeTuple);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user