From 31b15fe8dcd2e026afc0b566f50141ae9a7273b5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 4 Nov 2008 00:57:19 +0000 Subject: Disallow LOCK TABLE outside a transaction block (or function), since this case almost certainly represents user error. Per a gripe from Sebastian Böhm and subsequent discussion. --- src/backend/tcop/utility.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/backend') diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index b1a0fe28ca5..1218e7cb9b8 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.299 2008/10/10 13:48:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.300 2008/11/04 00:57:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -938,6 +938,11 @@ ProcessUtility(Node *parsetree, break; case T_LockStmt: + /* + * Since the lock would just get dropped immediately, LOCK TABLE + * outside a transaction block is presumed to be user error. + */ + RequireTransactionChain(isTopLevel, "LOCK TABLE"); LockTableCommand((LockStmt *) parsetree); break; -- cgit v1.2.3