|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.47 2002/10/1902:25:51 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.48 2002/10/1903:01:09 momjian Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -1643,53 +1643,22 @@ AlterTableAddColumn(Oid myrelid, |
1643 | 1643 | colDefChild->inhcount=1; |
1644 | 1644 | colDefChild->is_local= false; |
1645 | 1645 |
|
1646 | | -/*we only need direct inheritors */ |
1647 | | -children=find_inheritance_children(myrelid); |
| 1646 | +/*this routine is actually in the planner */ |
| 1647 | +children=find_all_inheritors(myrelid); |
1648 | 1648 |
|
1649 | 1649 | /* |
1650 | | - * If the child has a column with same name and type, |
1651 | | - * increment its attinhcount and continue. If it has |
1652 | | - * different type, abort. If it doesn't have a column |
1653 | | - * with the same name, add it. |
| 1650 | + * find_all_inheritors does the recursive search of the |
| 1651 | + * inheritance hierarchy, so all we have to do is process all of |
| 1652 | + * the relids in the list that it returns. |
1654 | 1653 | */ |
1655 | 1654 | foreach(child,children) |
1656 | 1655 | { |
1657 | 1656 | Oidchildrelid=lfirsti(child); |
1658 | | -HeapTupletuple; |
1659 | | -Form_pg_attributechildatt; |
1660 | 1657 |
|
1661 | 1658 | if (childrelid==myrelid) |
1662 | 1659 | continue; |
1663 | 1660 |
|
1664 | | -attrdesc=heap_openr(AttributeRelationName,RowExclusiveLock); |
1665 | | -tuple=SearchSysCacheCopyAttName(childrelid,colDef->colname); |
1666 | | -if (!HeapTupleIsValid(tuple)) |
1667 | | -{ |
1668 | | -heap_close(attrdesc,RowExclusiveLock); |
1669 | | -AlterTableAddColumn(childrelid, false, true,colDefChild); |
1670 | | -continue; |
1671 | | -} |
1672 | | -childatt= (Form_pg_attribute)GETSTRUCT(tuple); |
1673 | | - |
1674 | | -typeTuple=typenameType(colDef->typename); |
1675 | | -tform= (Form_pg_type)GETSTRUCT(typeTuple); |
1676 | | - |
1677 | | -if (HeapTupleGetOid(typeTuple)!=childatt->atttypid|| |
1678 | | -colDef->typename->typmod!=childatt->atttypmod) |
1679 | | -elog(ERROR,"ALTER TABLE: child table %u has different " |
1680 | | -"type for column \"%s\"", |
1681 | | -childrelid,colDef->colname); |
1682 | | - |
1683 | | -childatt->attinhcount++; |
1684 | | -simple_heap_update(attrdesc,&tuple->t_self,tuple); |
1685 | | -CatalogUpdateIndexes(attrdesc,tuple); |
1686 | | - |
1687 | | -elog(NOTICE,"ALTER TABLE: merging definition of column " |
1688 | | -"\"%s\" for child %u",colDef->colname,childrelid); |
1689 | | - |
1690 | | -heap_close(attrdesc,RowExclusiveLock); |
1691 | | -heap_freetuple(tuple); |
1692 | | -ReleaseSysCache(typeTuple); |
| 1661 | +AlterTableAddColumn(childrelid, false, true,colDefChild); |
1693 | 1662 | } |
1694 | 1663 | } |
1695 | 1664 | else |
|