* procedural language
*
* 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.
*
new->retrecno = -1;
new->retrowno = -1;
- if (plpgsql_curr_compile->fn_retistuple &&
- !plpgsql_curr_compile->fn_retset)
+ if (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())
{
break;
default:
- yyerror("return type mismatch in function returning tuple");
+ yyerror("RETURN must specify a record or row variable in function returning tuple");
break;
}
if (yylex() != ';')
- yyerror("expected \";\"");
+ yyerror("RETURN must specify a record or row variable in function returning tuple");
}
else
+ {
+ /* ordinary expression case */
new->expr = plpgsql_read_expression(';', ";");
+ }
new->cmd_type = PLPGSQL_STMT_RETURN;
new->lineno = $2;
{
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));
memset(new, 0, sizeof(PLpgSQL_stmt_return_next));
else if (tok == T_ROW)
new->row = yylval.row;
else
- yyerror("incorrect argument to RETURN NEXT");
+ yyerror("RETURN NEXT must specify a record or row variable in function returning tuple");
if (yylex() != ';')
- yyerror("expected \";\"");
+ yyerror("RETURN NEXT must specify a record or row variable in function returning tuple");
}
else
new->expr = plpgsql_read_expression(';', ";");