From 7015dfef4babdc2cce655baf24c1b2b741864a60 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 22 Jan 1998 23:05:18 +0000 Subject: [PATCH] Add LOCK command as DELETE FROM ... WHERE false. --- src/backend/parser/gram.y | 28 +++++++++++++++++++++++++--- src/backend/parser/keywords.c | 3 ++- src/bin/psql/psqlHelp.h | 5 ++++- src/man/declare.l | 4 ++-- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index e259fbeca8..fae67cb8ba 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.95 1998/01/20 05:04:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.96 1998/01/22 23:04:52 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -116,7 +116,7 @@ Oid param_type(int t); /* used in parse_expr.c */ CopyStmt, CreateStmt, CreateAsStmt, CreateSeqStmt, DefineStmt, DestroyStmt, ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt, CreatePLangStmt, DropPLangStmt, - IndexStmt, ListenStmt, OptimizableStmt, + IndexStmt, ListenStmt, LockStmt, OptimizableStmt, ProcedureStmt, RecipeStmt, RemoveAggrStmt, RemoveOperStmt, RemoveFuncStmt, RemoveStmt, RenameStmt, RevokeStmt, RuleStmt, TransactionStmt, ViewStmt, LoadStmt, @@ -276,7 +276,7 @@ Oid param_type(int t); /* used in parse_expr.c */ DATABASE, DELIMITERS, DO, EXPLAIN, EXTEND, FORWARD, FUNCTION, HANDLER, INDEX, INHERITS, INSTEAD, ISNULL, - LANCOMPILER, LISTEN, LOAD, LOCATION, MERGE, MOVE, + LANCOMPILER, LISTEN, LOAD, LOCK_P, LOCATION, MERGE, MOVE, NEW, NONE, NOTHING, NOTNULL, OIDS, OPERATOR, PROCEDURAL, RECIPE, RENAME, REPLACE, RESET, RETURNS, RULE, SEQUENCE, SETOF, SHOW, STDIN, STDOUT, TRUSTED, @@ -364,6 +364,7 @@ stmt : AddAttrStmt | GrantStmt | IndexStmt | ListenStmt + | LockStmt | ProcedureStmt | RecipeStmt | RemoveAggrStmt @@ -2210,6 +2211,27 @@ DeleteStmt: DELETE FROM relation_name } ; +/* + * Total hack to just lock a table inside a transaction. + * Is it worth making this a separate command, with + * its own node type and file. I don't think so. bjm 1998/1/22 + */ +LockStmt: LOCK_P relation_name + { + DeleteStmt *n = makeNode(DeleteStmt); + A_Const *c = makeNode(A_Const); + + c->val.type = T_String; + c->val.val.str = "f"; + c->typename = makeNode(TypeName); + c->typename->name = xlateSqlType("bool"); + + n->relname = $2; + n->whereClause = c; + $$ = (Node *)n; + } + ; + /***************************************************************************** * diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c index 904d71a43f..71ca0817dd 100644 --- a/src/backend/parser/keywords.c +++ b/src/backend/parser/keywords.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.31 1998/01/20 05:04:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.32 1998/01/22 23:04:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -127,6 +127,7 @@ static ScanKeyword ScanKeywords[] = { {"load", LOAD}, {"local", LOCAL}, {"location", LOCATION}, + {"lock", LOCK_P}, {"match", MATCH}, {"merge", MERGE}, {"minute", MINUTE_P}, diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h index 3feb800bfa..d273929c4a 100644 --- a/src/bin/psql/psqlHelp.h +++ b/src/bin/psql/psqlHelp.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: psqlHelp.h,v 1.38 1998/01/11 20:02:15 momjian Exp $ + * $Id: psqlHelp.h,v 1.39 1998/01/22 23:05:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -250,6 +250,9 @@ static struct _helpStruct QL_HELP[] = { {"load", "dynamically load a module", "load ;"}, + {"lock", + "exclusive lock a table inside a transaction", + "lock ;"}, {"move", "move an cursor position", "move [forward|backward] [|all] [in ];"}, diff --git a/src/man/declare.l b/src/man/declare.l index c906f77217..37a3e11a25 100644 --- a/src/man/declare.l +++ b/src/man/declare.l @@ -1,9 +1,9 @@ .\" This is -*-nroff-*- .\" XXX standard disclaimer belongs here.... -.\" $Header: /cvsroot/pgsql/src/man/Attic/declare.l,v 1.2 1998/01/11 22:17:24 momjian Exp $ +.\" $Header: /cvsroot/pgsql/src/man/Attic/declare.l,v 1.3 1998/01/22 23:05:18 momjian Exp $ .TH FETCH SQL 01/23/93 PostgreSQL PostgreSQL .SH NAME -declere - declare a cursor +declare - declare a cursor .SH SYNOPSIS .nf \fBdeclare\fR [ \fBbinary\fR ] \fBcursor for\fR select statement