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

Commit 3108b5d

Browse files
committed
Allow the query for a plpgsql cursor to begin with '(' as well as 'SELECT'.
Per example from Kumar, 30-Oct-03.
1 parent f4b4d7c commit 3108b5d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/pl/plpgsql/src/gram.y

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.47 2003/09/25 23:02:12 tgl Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.48 2003/10/30 17:18:55 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -393,7 +393,7 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval
393393
}
394394
| decl_varname K_CURSOR
395395
{ plpgsql_ns_push(NULL); }
396-
decl_cursor_args decl_is_from K_SELECT decl_cursor_query
396+
decl_cursor_args decl_is_from decl_cursor_query
397397
{
398398
PLpgSQL_var *new;
399399
PLpgSQL_expr *curname_def;
@@ -430,7 +430,7 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval
430430

431431
new->datatype = plpgsql_parse_datatype("refcursor");
432432

433-
new->cursor_explicit_expr = $7;
433+
new->cursor_explicit_expr = $6;
434434
if ($4 == NULL)
435435
new->cursor_explicit_argrow = -1;
436436
else
@@ -447,7 +447,7 @@ decl_cursor_query :
447447
PLpgSQL_expr *query;
448448

449449
plpgsql_ns_setlocal(false);
450-
query = read_sql_stmt("SELECT ");
450+
query = read_sql_stmt("");
451451
plpgsql_ns_setlocal(true);
452452

453453
$$ = query;
@@ -1396,7 +1396,9 @@ stmt_open : K_OPEN lno cursor_varptr
13961396
switch (tok)
13971397
{
13981398
case K_SELECT:
1399-
new->query = read_sql_stmt("SELECT ");
1399+
case '(':
1400+
plpgsql_push_back_token(tok);
1401+
new->query = read_sql_stmt("");
14001402
break;
14011403

14021404
case K_EXECUTE:

0 commit comments

Comments
 (0)