mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
SELECT FOR UPDATE syntax
This commit is contained in:
parent
b5626a2089
commit
dfa23f5e41
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -174,7 +174,7 @@ Oid param_type(int t); /* used in parse_expr.c */
|
|||||||
|
|
||||||
%type <boolean> TriggerForOpt, TriggerForType
|
%type <boolean> TriggerForOpt, TriggerForType
|
||||||
|
|
||||||
%type <list> union_clause, select_list
|
%type <list> union_clause, select_list, for_update_clause
|
||||||
%type <list> join_list
|
%type <list> join_list
|
||||||
%type <joinusing>
|
%type <joinusing>
|
||||||
join_using
|
join_using
|
||||||
@ -2215,6 +2215,8 @@ ViewStmt: CREATE VIEW name AS SelectStmt
|
|||||||
elog(ERROR,"Order by and Distinct on views is not implemented.");
|
elog(ERROR,"Order by and Distinct on views is not implemented.");
|
||||||
if (((SelectStmt *)n->query)->unionClause != NULL)
|
if (((SelectStmt *)n->query)->unionClause != NULL)
|
||||||
elog(ERROR,"Views on unions not implemented.");
|
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;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -2677,7 +2679,7 @@ opt_of: OF columnList
|
|||||||
SelectStmt: SELECT opt_unique res_target_list2
|
SelectStmt: SELECT opt_unique res_target_list2
|
||||||
result from_clause where_clause
|
result from_clause where_clause
|
||||||
group_clause having_clause
|
group_clause having_clause
|
||||||
union_clause sort_clause
|
union_clause sort_clause for_update_clause
|
||||||
{
|
{
|
||||||
SelectStmt *n = makeNode(SelectStmt);
|
SelectStmt *n = makeNode(SelectStmt);
|
||||||
n->unique = $2;
|
n->unique = $2;
|
||||||
@ -2689,7 +2691,20 @@ SelectStmt: SELECT opt_unique res_target_list2
|
|||||||
n->havingClause = $8;
|
n->havingClause = $8;
|
||||||
n->unionClause = $9;
|
n->unionClause = $9;
|
||||||
n->sortClause = $10;
|
n->sortClause = $10;
|
||||||
$$ = (Node *)n;
|
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; }
|
| /*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
|
* 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 */
|
bool unionall; /* union without unique sort */
|
||||||
Node *limitOffset; /* # of result tuples to skip */
|
Node *limitOffset; /* # of result tuples to skip */
|
||||||
Node *limitCount; /* # of result tuples to return */
|
Node *limitCount; /* # of result tuples to return */
|
||||||
|
List *forUpdate; /* FOR UPDATE clause */
|
||||||
} SelectStmt;
|
} SelectStmt;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user