Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7015dfe

Browse files
committed
Add LOCK command as DELETE FROM ... WHERE false.
1 parent 0fd8d60 commit 7015dfe

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

src/backend/parser/gram.y

+25-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.95 1998/01/20 05:04:07 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.96 1998/01/22 23:04:52 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHOR DATE MAJOR EVENT
@@ -116,7 +116,7 @@ Oid param_type(int t); /* used in parse_expr.c */
116116
CopyStmt, CreateStmt, CreateAsStmt, CreateSeqStmt, DefineStmt, DestroyStmt,
117117
ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt,
118118
CreatePLangStmt, DropPLangStmt,
119-
IndexStmt, ListenStmt, OptimizableStmt,
119+
IndexStmt, ListenStmt, LockStmt, OptimizableStmt,
120120
ProcedureStmt, RecipeStmt, RemoveAggrStmt, RemoveOperStmt,
121121
RemoveFuncStmt, RemoveStmt,
122122
RenameStmt, RevokeStmt, RuleStmt, TransactionStmt, ViewStmt, LoadStmt,
@@ -276,7 +276,7 @@ Oid param_type(int t); /* used in parse_expr.c */
276276
DATABASE, DELIMITERS, DO, EXPLAIN, EXTEND,
277277
FORWARD, FUNCTION, HANDLER,
278278
INDEX, INHERITS, INSTEAD, ISNULL,
279-
LANCOMPILER, LISTEN, LOAD, LOCATION, MERGE, MOVE,
279+
LANCOMPILER, LISTEN, LOAD, LOCK_P, LOCATION, MERGE, MOVE,
280280
NEW, NONE, NOTHING, NOTNULL, OIDS, OPERATOR, PROCEDURAL,
281281
RECIPE, RENAME, REPLACE, RESET, RETURNS, RULE,
282282
SEQUENCE, SETOF, SHOW, STDIN, STDOUT, TRUSTED,
@@ -364,6 +364,7 @@ stmt : AddAttrStmt
364364
| GrantStmt
365365
| IndexStmt
366366
| ListenStmt
367+
| LockStmt
367368
| ProcedureStmt
368369
| RecipeStmt
369370
| RemoveAggrStmt
@@ -2210,6 +2211,27 @@ DeleteStmt: DELETE FROM relation_name
22102211
}
22112212
;
22122213

2214+
/*
2215+
* Total hack to just lock a table inside a transaction.
2216+
* Is it worth making this a separate command, with
2217+
* its own node type and file. I don't think so. bjm 1998/1/22
2218+
*/
2219+
LockStmt: LOCK_P relation_name
2220+
{
2221+
DeleteStmt *n = makeNode(DeleteStmt);
2222+
A_Const *c = makeNode(A_Const);
2223+
2224+
c->val.type = T_String;
2225+
c->val.val.str = "f";
2226+
c->typename = makeNode(TypeName);
2227+
c->typename->name = xlateSqlType("bool");
2228+
2229+
n->relname = $2;
2230+
n->whereClause = c;
2231+
$$ = (Node *)n;
2232+
}
2233+
;
2234+
22132235

22142236
/*****************************************************************************
22152237
*

src/backend/parser/keywords.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.31 1998/01/20 05:04:09 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.32 1998/01/22 23:04:54 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -127,6 +127,7 @@ static ScanKeyword ScanKeywords[] = {
127127
{"load", LOAD},
128128
{"local", LOCAL},
129129
{"location", LOCATION},
130+
{"lock", LOCK_P},
130131
{"match", MATCH},
131132
{"merge", MERGE},
132133
{"minute", MINUTE_P},

src/bin/psql/psqlHelp.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: psqlHelp.h,v 1.38 1998/01/11 20:02:15 momjian Exp $
8+
* $Id: psqlHelp.h,v 1.39 1998/01/22 23:05:09 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -250,6 +250,9 @@ static struct _helpStruct QL_HELP[] = {
250250
{"load",
251251
"dynamically load a module",
252252
"load <filename>;"},
253+
{"lock",
254+
"exclusive lock a table inside a transaction",
255+
"lock <class_name>;"},
253256
{"move",
254257
"move an cursor position",
255258
"move [forward|backward] [<number>|all] [in <cursorname>];"},

src/man/declare.l

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.\" This is -*-nroff-*-
22
.\" XXX standard disclaimer belongs here....
3-
.\" $Header: /cvsroot/pgsql/src/man/Attic/declare.l,v 1.2 1998/01/11 22:17:24 momjian Exp $
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/declare.l,v 1.3 1998/01/22 23:05:18 momjian Exp $
44
.TH FETCH SQL 01/23/93 PostgreSQL PostgreSQL
55
.SH NAME
6-
declere - declare a cursor
6+
declare - declare a cursor
77
.SH SYNOPSIS
88
.nf
99
\fBdeclare\fR [ \fBbinary\fR ] \fBcursor for\fR select statement

0 commit comments

Comments
 (0)