*** pgsql/src/backend/commands/tablecmds.c 2009/01/01 17:23:39 1.276 --- pgsql/src/backend/commands/tablecmds.c 2009/01/12 08:54:26 1.277 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.275 2008/12/28 18:53:55 tgl Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.276 2009/01/01 17:23:39 momjian Exp $ * *------------------------------------------------------------------------- */ *************** ExecuteTruncate(TruncateStmt *stmt) *** 772,788 **** { RangeVar *rv = lfirst(cell); Relation rel; rel = heap_openrv(rv, AccessExclusiveLock); /* don't throw error for "TRUNCATE foo, foo" */ ! if (list_member_oid(relids, RelationGetRelid(rel))) { heap_close(rel, AccessExclusiveLock); continue; } truncate_check_rel(rel); rels = lappend(rels, rel); ! relids = lappend_oid(relids, RelationGetRelid(rel)); } /* --- 772,812 ---- { RangeVar *rv = lfirst(cell); Relation rel; + bool recurse = interpretInhOption(rv->inhOpt); + Oid myrelid; rel = heap_openrv(rv, AccessExclusiveLock); + myrelid = RelationGetRelid(rel); /* don't throw error for "TRUNCATE foo, foo" */ ! if (list_member_oid(relids, myrelid)) { heap_close(rel, AccessExclusiveLock); continue; } truncate_check_rel(rel); rels = lappend(rels, rel); ! relids = lappend_oid(relids, myrelid); ! ! if (recurse) ! { ! ListCell *child; ! List *children; ! ! children = find_all_inheritors(myrelid); ! ! foreach(child, children) ! { ! Oid childrelid = lfirst_oid(child); ! ! if (list_member_oid(relids, childrelid)) ! continue; ! ! rel = heap_open(childrelid, AccessExclusiveLock); ! truncate_check_rel(rel); ! rels = lappend(rels, rel); ! relids = lappend_oid(relids, childrelid); ! } ! } } /*