Add LOCK command as DELETE FROM ... WHERE false.
authorBruce Momjian
Thu, 22 Jan 1998 23:05:18 +0000 (23:05 +0000)
committerBruce Momjian
Thu, 22 Jan 1998 23:05:18 +0000 (23:05 +0000)
src/backend/parser/gram.y
src/backend/parser/keywords.c
src/bin/psql/psqlHelp.h
src/man/declare.l

index e259fbeca82bdf348e0fa4b7bf797e2a6201e558..fae67cb8baf0f15e1740ef9429d5fa9acad1ac5d 100644 (file)
@@ -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;
+               }
+       ;
+
 
 /*****************************************************************************
  *
index 904d71a43f98a770e5cb07056049ac8c6a83e137..71ca0817dd244013c1ef31fbc82d9b9789ca3804 100644 (file)
@@ -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},
index 3feb800bfad41ca75a02bf419341e0991ef94932..d273929c4aba2b5c9fe751d688d8ad6ca41473a0 100644 (file)
@@ -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 ];"},
index c906f772178fc9e469b341a87b0d6dfd5a57cffa..37a3e11a253dddf64661cb368c43d5a56bf999a3 100644 (file)
@@ -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