Commit dfa23f5e authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

SELECT FOR UPDATE syntax

parent b5626a20
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.41 1998/12/30 19:56:28 wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.42 1999/01/05 15:46:25 vadim Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -174,7 +174,7 @@ Oid param_type(int t); /* used in parse_expr.c */
%type <boolean> TriggerForOpt, TriggerForType
%type <list> union_clause, select_list
%type <list> union_clause, select_list, for_update_clause
%type <list> join_list
%type <joinusing>
join_using
......@@ -2215,6 +2215,8 @@ ViewStmt: CREATE VIEW name AS SelectStmt
elog(ERROR,"Order by and Distinct on views is not implemented.");
if (((SelectStmt *)n->query)->unionClause != NULL)
elog(ERROR,"Views on unions not implemented.");
if (((SelectStmt *)n->query)->forUpdate != NULL)
elog(ERROR, "SELECT FOR UPDATE is not allowed in CREATE VIEW");
$$ = (Node *)n;
}
;
......@@ -2677,7 +2679,7 @@ opt_of: OF columnList
SelectStmt: SELECT opt_unique res_target_list2
result from_clause where_clause
group_clause having_clause
union_clause sort_clause
union_clause sort_clause for_update_clause
{
SelectStmt *n = makeNode(SelectStmt);
n->unique = $2;
......@@ -2689,6 +2691,19 @@ SelectStmt: SELECT opt_unique res_target_list2
n->havingClause = $8;
n->unionClause = $9;
n->sortClause = $10;
n->forUpdate = $11;
if (n->forUpdate != NULL)
{
if (n->unionClause != NULL)
elog(ERROR, "SELECT FOR UPDATE is not allowed with UNION clause");
if (n->unique != NULL)
elog(ERROR, "SELECT FOR UPDATE is not allowed with DISTINCT clause");
if (n->groupClause != NULL)
elog(ERROR, "SELECT FOR UPDATE is not allowed with GROUP BY clause");
if (n->havingClause != NULL)
elog(ERROR, "SELECT FOR UPDATE is not allowed with HAVING clause");
}
else
$$ = (Node *)n;
}
;
......@@ -2818,6 +2833,20 @@ having_clause: HAVING a_expr
| /*EMPTY*/ { $$ = NULL; }
;
for_update_clause:
FOR UPDATE
{
$$ = lcons(NULL, NULL);
}
| FOR UPDATE OF va_list
{
$$ = $4;
}
| /* EMPTY */
{
$$ = NULL;
}
;
/*****************************************************************************
*
......
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.64 1998/12/21 12:50:29 wieck Exp $
* $Id: parsenodes.h,v 1.65 1999/01/05 15:45:49 vadim Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -653,6 +653,7 @@ typedef struct SelectStmt
bool unionall; /* union without unique sort */
Node *limitOffset; /* # of result tuples to skip */
Node *limitCount; /* # of result tuples to return */
List *forUpdate; /* FOR UPDATE clause */
} SelectStmt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment