mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Add ONLY support to LOCK and TRUNCATE. By default, these commands are now
recursive. => Note this incompatibility in the release notes.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.276 2009/01/01 17:23:39 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.277 2009/01/12 08:54:26 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -772,17 +772,41 @@ ExecuteTruncate(TruncateStmt *stmt)
|
||||
{
|
||||
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, RelationGetRelid(rel)))
|
||||
if (list_member_oid(relids, myrelid))
|
||||
{
|
||||
heap_close(rel, AccessExclusiveLock);
|
||||
continue;
|
||||
}
|
||||
truncate_check_rel(rel);
|
||||
rels = lappend(rels, rel);
|
||||
relids = lappend_oid(relids, RelationGetRelid(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user