diff --git a/doc/src/sgml/ref/lock.sgml b/doc/src/sgml/ref/lock.sgml
index 58e53371c9..20530d75d7 100644
--- a/doc/src/sgml/ref/lock.sgml
+++ b/doc/src/sgml/ref/lock.sgml
@@ -1,5 +1,5 @@
@@ -15,7 +15,7 @@ Postgres documentation
LOCK
- Explicitly lock a table / tables inside a transaction
+ Explicitly lock a table inside a transaction
@@ -23,8 +23,8 @@ Postgres documentation
2001-07-09
-LOCK [ TABLE ] name [,...]
-LOCK [ TABLE ] name [,...] IN lockmode MODE
+LOCK [ TABLE ] name
+LOCK [ TABLE ] name IN lockmode MODE
where lockmode is one of:
@@ -373,7 +373,6 @@ ERROR name: Table does not exist.
An example for this rule was given previously when discussing the
use of SHARE ROW EXCLUSIVE mode rather than SHARE mode.
-
@@ -384,12 +383,6 @@ ERROR name: Table does not exist.
-
- When locking multiple tables, the command LOCK a, b; is equivalent to LOCK
- a; LOCK b;. The tables are locked one-by-one in the order specified in the
- LOCK command.
-
-
1999-06-08
@@ -413,7 +406,6 @@ ERROR name: Table does not exist.
LOCK works only inside transactions.
-
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 827608363c..37814cdcd3 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.137 2001/08/04 19:38:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.138 2001/08/04 22:01:38 momjian Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@@ -1984,7 +1984,8 @@ needs_toast_table(Relation rel)
MAXALIGN(data_length);
return (tuple_length > TOAST_TUPLE_THRESHOLD);
}
-
+
+
/*
*
* LOCK TABLE
@@ -1993,104 +1994,26 @@ needs_toast_table(Relation rel)
void
LockTableCommand(LockStmt *lockstmt)
{
- int relCnt;
+ Relation rel;
+ int aclresult;
- relCnt = length(lockstmt -> rellist);
+ rel = heap_openr(lockstmt->relname, NoLock);
- /* Handle a single relation lock specially to avoid overhead on likely the
- most common case */
+ if (rel->rd_rel->relkind != RELKIND_RELATION)
+ elog(ERROR, "LOCK TABLE: %s is not a table", lockstmt->relname);
- if(relCnt == 1)
- {
+ if (lockstmt->mode == AccessShareLock)
+ aclresult = pg_aclcheck(lockstmt->relname, GetUserId(), ACL_SELECT);
+ else
+ aclresult = pg_aclcheck(lockstmt->relname, GetUserId(),
+ ACL_UPDATE | ACL_DELETE);
- /* Locking a single table */
+ if (aclresult != ACLCHECK_OK)
+ elog(ERROR, "LOCK TABLE: permission denied");
- Relation rel;
- int aclresult;
- char *relname;
+ LockRelation(rel, lockstmt->mode);
- relname = strVal(lfirst(lockstmt->rellist));
-
- freeList(lockstmt->rellist);
-
- 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);
-
- if (aclresult != ACLCHECK_OK)
- elog(ERROR, "LOCK TABLE: permission denied");
-
- LockRelation(rel, lockstmt->mode);
-
- pfree(relname);
-
- heap_close(rel, NoLock); /* close rel, keep lock */
- }
- else
- {
- List *p;
- Relation *RelationArray;
- Relation *pRel;
-
- /* Locking multiple tables */
-
- /* Create an array of relations */
-
- RelationArray = palloc(relCnt * sizeof(Relation));
- pRel = RelationArray;
-
- /* Iterate over the list and populate the relation array */
-
- foreach(p, lockstmt->rellist)
- {
- char* relname = strVal(lfirst(p));
- int aclresult;
-
- *pRel = heap_openr(relname, NoLock);
-
- if ((*pRel)->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);
-
- if (aclresult != ACLCHECK_OK)
- elog(ERROR, "LOCK TABLE: permission denied");
-
- pRel++;
- pfree(relname);
- }
-
- /* Now, lock all the relations, closing each after it is locked
- (Keeping the locks)
- */
-
- for(pRel = RelationArray;
- pRel < RelationArray + relCnt;
- pRel++)
- {
- LockRelation(*pRel, lockstmt->mode);
-
- heap_close(*pRel, NoLock);
- }
-
- /* Free the relation array */
-
- pfree(RelationArray);
- }
+ heap_close(rel, NoLock); /* close rel, keep lock */
}
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 65bd5f27e9..0d9aef03ed 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.149 2001/08/04 19:38:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.150 2001/08/04 22:01:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2425,8 +2425,8 @@ _copyLockStmt(LockStmt *from)
{
LockStmt *newnode = makeNode(LockStmt);
- Node_Copy(from, newnode, rellist);
-
+ if (from->relname)
+ newnode->relname = pstrdup(from->relname);
newnode->mode = from->mode;
return newnode;
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 3a9629cde3..74a88555c5 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.97 2001/08/04 19:38:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.98 2001/08/04 22:01:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1283,7 +1283,7 @@ _equalDropUserStmt(DropUserStmt *a, DropUserStmt *b)
static bool
_equalLockStmt(LockStmt *a, LockStmt *b)
{
- if (!equal(a->rellist, b->rellist))
+ if (!equalstr(a->relname, b->relname))
return false;
if (a->mode != b->mode)
return false;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 130d259aaa..cbefde132f 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.239 2001/08/04 19:38:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.240 2001/08/04 22:01:39 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -3280,11 +3280,11 @@ DeleteStmt: DELETE FROM relation_expr where_clause
}
;
-LockStmt: LOCK_P opt_table relation_name_list opt_lock
+LockStmt: LOCK_P opt_table relation_name opt_lock
{
LockStmt *n = makeNode(LockStmt);
- n->rellist = $3;
+ n->relname = $3;
n->mode = $4;
$$ = (Node *)n;
}
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index ed379ab02e..ad7bcc2e0f 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.137 2001/08/04 19:38:59 momjian Exp $
+ * $Id: parsenodes.h,v 1.138 2001/08/04 22:01:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -760,7 +760,7 @@ typedef struct VariableResetStmt
typedef struct LockStmt
{
NodeTag type;
- List *rellist; /* relations to lock */
+ char *relname; /* relation to lock */
int mode; /* lock mode */
} LockStmt;
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 09180f85c9..88330ad3c1 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -2421,7 +2421,7 @@ DeleteStmt: DELETE FROM relation_expr where_clause
}
;
-LockStmt: LOCK_P opt_table relation_name_list opt_lock
+LockStmt: LOCK_P opt_table relation_name opt_lock
{
$$ = cat_str(4, make_str("lock"), $2, $3, $4);
}