|
4 | 4 | * procedural language
|
5 | 5 | *
|
6 | 6 | * 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 $ |
8 | 8 | *
|
9 | 9 | * This software is copyrighted by Jan Wieck - Hamburg.
|
10 | 10 | *
|
@@ -1346,17 +1346,44 @@ stmt_open: K_OPEN lno cursor_varptr
|
1346 | 1346 | if (tok !='(')
|
1347 | 1347 | {
|
1348 | 1348 | plpgsql_error_lineno = yylineno;
|
1349 |
| -elog(ERROR,"cursor %s has arguments", $3->refname); |
| 1349 | +elog(ERROR,"cursor %s has arguments", |
| 1350 | + $3->refname); |
1350 | 1351 | }
|
1351 | 1352 |
|
| 1353 | +/* |
| 1354 | + * Push back the '(', else read_sql_stmt |
| 1355 | + * will complain about unbalanced parens. |
| 1356 | +*/ |
| 1357 | +plpgsql_push_back_token(tok); |
| 1358 | + |
1352 | 1359 | 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)". |
1356 | 1365 | */
|
1357 | 1366 | 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 | + |
1360 | 1387 | if (*cp !=')')
|
1361 | 1388 | {
|
1362 | 1389 | plpgsql_error_lineno = yylineno;
|
|