diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-08-10 14:30:15 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-08-10 14:30:15 +0000 |
commit | 77a69a2ed165c31a981ac553f56c7b43e12d9ab5 (patch) | |
tree | 3bb56d3c86d6184feb748cedd62a0bff4ebc2671 /src/backend/commands/command.c | |
parent | 49eb4f47c7e9300638aee5f9b4a12c3a5c69e707 (diff) | |
download | postgresql-77a69a2ed165c31a981ac553f56c7b43e12d9ab5.tar.gz postgresql-77a69a2ed165c31a981ac553f56c7b43e12d9ab5.zip |
Patch to LOCK multiple tables in one LOCK command.
Neil Padgett
Diffstat (limited to 'src/backend/commands/command.c')
-rw-r--r-- | src/backend/commands/command.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 37814cdcd38..3d02fdb5fd2 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.138 2001/08/04 22:01:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.139 2001/08/10 14:30:14 momjian Exp $ * * NOTES * The PerformAddAttribute() code, like most of the relation @@ -1984,8 +1984,7 @@ needs_toast_table(Relation rel) MAXALIGN(data_length); return (tuple_length > TOAST_TUPLE_THRESHOLD); } - - + /* * * LOCK TABLE @@ -1994,26 +1993,38 @@ needs_toast_table(Relation rel) void LockTableCommand(LockStmt *lockstmt) { - Relation rel; - int aclresult; - - rel = heap_openr(lockstmt->relname, NoLock); - - if (rel->rd_rel->relkind != RELKIND_RELATION) - elog(ERROR, "LOCK TABLE: %s is not a table", lockstmt->relname); - - if (lockstmt->mode == AccessShareLock) - aclresult = pg_aclcheck(lockstmt->relname, GetUserId(), ACL_SELECT); - else - aclresult = pg_aclcheck(lockstmt->relname, GetUserId(), - ACL_UPDATE | ACL_DELETE); + List *p; + Relation rel; + + /* Iterate over the list and open, lock, and close the relations + one at a time + */ - if (aclresult != ACLCHECK_OK) - elog(ERROR, "LOCK TABLE: permission denied"); + foreach(p, lockstmt->rellist) + { + char* relname = strVal(lfirst(p)); + int aclresult; + + rel = heap_openr(relname, NoLock); + + if (rel->rd_rel->relkind != RELKIND_RELATION) + elog(ERROR, "LOCK TABLE: %s is not a table", + relname); + + if (lockstmt->mode == AccessShareLock) + aclresult = pg_aclcheck(relname, GetUserId(), + ACL_SELECT); + else + aclresult = pg_aclcheck(relname, GetUserId(), + ACL_UPDATE | ACL_DELETE); - LockRelation(rel, lockstmt->mode); + if (aclresult != ACLCHECK_OK) + elog(ERROR, "LOCK TABLE: permission denied"); - heap_close(rel, NoLock); /* close rel, keep lock */ + LockRelation(rel, lockstmt->mode); + + heap_close(rel, NoLock); /* close rel, keep lock */ + } } |