*** pgsql.virg/src/backend/commands/command.c Mon May 28 07:14:02 2001 --- pgsql/src/backend/commands/command.c Wed May 23 14:00:37 2001 *************** *** 1217,1222 **** --- 1217,1223 ---- Relation rel; Node *expr; char *name; + Oid myrelid; if (constr->name) name = constr->name; *************** *** 1226,1231 **** --- 1227,1233 ---- constlist = makeList1(constr); rel = heap_openr(relationName, AccessExclusiveLock); + myrelid = RelationGetRelid(rel); /* make sure it is not a view */ if (rel->rd_rel->relkind == RELKIND_VIEW) *************** *** 1320,1325 **** --- 1322,1356 ---- */ AddRelationRawConstraints(rel, NIL, constlist); heap_close(rel, NoLock); + + if (inh) { + List *child, + *children; + + /* this routine is actually in the planner */ + children = find_all_inheritors(myrelid); + + /* + * find_all_inheritors does the recursive search of the + * inheritance hierarchy, so all we have to do is process all + * of the relids in the list that it returns. + */ + foreach(child, children) + { + Oid childrelid = lfirsti(child); + char *childrelname; + + if (childrelid == myrelid) + continue; + rel = heap_open(childrelid, AccessExclusiveLock); + childrelname = pstrdup(RelationGetRelationName(rel)); + heap_close(rel, AccessExclusiveLock); + + AlterTableAddConstraint(childrelname, false, newConstraint); + + pfree(childrelname); + } + } pfree(constlist); break;