Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38f5fdb

Browse files
committed
Repair OPEN cursor(args), which I broke on 11/29/01 with a change to
be smarter about parentheses in read_sql_construct(). Sigh.
1 parent44fbe20 commit38f5fdb

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

‎src/pl/plpgsql/src/gram.y

Lines changed: 34 additions & 7 deletions
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.32 2002/05/01 12:40:22 wieck Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.33 2002/05/21 18:50:16 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -1346,17 +1346,44 @@ stmt_open: K_OPEN lno cursor_varptr
13461346
if (tok !='(')
13471347
{
13481348
plpgsql_error_lineno = yylineno;
1349-
elog(ERROR,"cursor %s has arguments", $3->refname);
1349+
elog(ERROR,"cursor %s has arguments",
1350+
$3->refname);
13501351
}
13511352

1353+
/*
1354+
* Push back the '(', else read_sql_stmt
1355+
* will complain about unbalanced parens.
1356+
*/
1357+
plpgsql_push_back_token(tok);
1358+
13521359
new->argquery = read_sql_stmt("SELECT");
1353-
/* Remove the trailing right paren,
1354-
* because we want "select 1, 2", not
1355-
* "select (1, 2)".
1360+
1361+
/*
1362+
* Now remove the leading and trailing parens,
1363+
* because we want "select 1, 2", not
1364+
* "select (1, 2)".
13561365
*/
13571366
cp =new->argquery->query;
1358-
cp += strlen(cp);
1359-
--cp;
1367+
1368+
if (strncmp(cp,"SELECT",6) !=0)
1369+
{
1370+
plpgsql_error_lineno = yylineno;
1371+
elog(ERROR,"expected 'SELECT (', got '%s' (internal error)",
1372+
new->argquery->query);
1373+
}
1374+
cp +=6;
1375+
while (*cp =='')/* could be more than 1 space here*/
1376+
cp++;
1377+
if (*cp !='(')
1378+
{
1379+
plpgsql_error_lineno = yylineno;
1380+
elog(ERROR,"expected 'SELECT (', got '%s' (internal error)",
1381+
new->argquery->query);
1382+
}
1383+
*cp ='';
1384+
1385+
cp += strlen(cp) -1;
1386+
13601387
if (*cp !=')')
13611388
{
13621389
plpgsql_error_lineno = yylineno;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp