mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
Improve syntax error messages for invalid-argument cases in RETURN and
RETURN NEXT.
This commit is contained in:
parent
0117ed7d4c
commit
6c72f44c62
@ -4,7 +4,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.52 2004/03/24 23:38:49 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.53 2004/04/15 13:01:45 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -1136,8 +1136,12 @@ stmt_return : K_RETURN lno
|
|||||||
new->retrecno = -1;
|
new->retrecno = -1;
|
||||||
new->retrowno = -1;
|
new->retrowno = -1;
|
||||||
|
|
||||||
if (plpgsql_curr_compile->fn_retistuple &&
|
if (plpgsql_curr_compile->fn_retset)
|
||||||
!plpgsql_curr_compile->fn_retset)
|
{
|
||||||
|
if (yylex() != ';')
|
||||||
|
yyerror("RETURN cannot have a parameter in function returning set; use RETURN NEXT");
|
||||||
|
}
|
||||||
|
else if (plpgsql_curr_compile->fn_retistuple)
|
||||||
{
|
{
|
||||||
switch (yylex())
|
switch (yylex())
|
||||||
{
|
{
|
||||||
@ -1153,14 +1157,17 @@ stmt_return : K_RETURN lno
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
yyerror("return type mismatch in function returning tuple");
|
yyerror("RETURN must specify a record or row variable in function returning tuple");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (yylex() != ';')
|
if (yylex() != ';')
|
||||||
yyerror("expected \";\"");
|
yyerror("RETURN must specify a record or row variable in function returning tuple");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/* ordinary expression case */
|
||||||
new->expr = plpgsql_read_expression(';', ";");
|
new->expr = plpgsql_read_expression(';', ";");
|
||||||
|
}
|
||||||
|
|
||||||
new->cmd_type = PLPGSQL_STMT_RETURN;
|
new->cmd_type = PLPGSQL_STMT_RETURN;
|
||||||
new->lineno = $2;
|
new->lineno = $2;
|
||||||
@ -1173,6 +1180,9 @@ stmt_return_next: K_RETURN_NEXT lno
|
|||||||
{
|
{
|
||||||
PLpgSQL_stmt_return_next *new;
|
PLpgSQL_stmt_return_next *new;
|
||||||
|
|
||||||
|
if (!plpgsql_curr_compile->fn_retset)
|
||||||
|
yyerror("cannot use RETURN NEXT in a non-SETOF function");
|
||||||
|
|
||||||
new = malloc(sizeof(PLpgSQL_stmt_return_next));
|
new = malloc(sizeof(PLpgSQL_stmt_return_next));
|
||||||
memset(new, 0, sizeof(PLpgSQL_stmt_return_next));
|
memset(new, 0, sizeof(PLpgSQL_stmt_return_next));
|
||||||
|
|
||||||
@ -1188,10 +1198,10 @@ stmt_return_next: K_RETURN_NEXT lno
|
|||||||
else if (tok == T_ROW)
|
else if (tok == T_ROW)
|
||||||
new->row = yylval.row;
|
new->row = yylval.row;
|
||||||
else
|
else
|
||||||
yyerror("incorrect argument to RETURN NEXT");
|
yyerror("RETURN NEXT must specify a record or row variable in function returning tuple");
|
||||||
|
|
||||||
if (yylex() != ';')
|
if (yylex() != ';')
|
||||||
yyerror("expected \";\"");
|
yyerror("RETURN NEXT must specify a record or row variable in function returning tuple");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
new->expr = plpgsql_read_expression(';', ";");
|
new->expr = plpgsql_read_expression(';', ";");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user