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

Commit6c72f44

Browse files
committed
Improve syntax error messages for invalid-argument cases in RETURN and
RETURN NEXT.
1 parent0117ed7 commit6c72f44

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.52 2004/03/24 23:38:49 tgl Exp $
7+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.53 2004/04/15 13:01:45 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -1136,8 +1136,12 @@ stmt_return: K_RETURN lno
11361136
new->retrecno= -1;
11371137
new->retrowno= -1;
11381138

1139-
if (plpgsql_curr_compile->fn_retistuple &&
1140-
!plpgsql_curr_compile->fn_retset)
1139+
if (plpgsql_curr_compile->fn_retset)
1140+
{
1141+
if (yylex() !=';')
1142+
yyerror("RETURN cannot have a parameter in function returning set; use RETURN NEXT");
1143+
}
1144+
elseif (plpgsql_curr_compile->fn_retistuple)
11411145
{
11421146
switch (yylex())
11431147
{
@@ -1153,14 +1157,17 @@ stmt_return: K_RETURN lno
11531157
break;
11541158

11551159
default:
1156-
yyerror("return type mismatch in function returning tuple");
1160+
yyerror("RETURN must specify a record or row variable in function returning tuple");
11571161
break;
11581162
}
11591163
if (yylex() !=';')
1160-
yyerror("expected\";\"");
1164+
yyerror("RETURN must specify a record or row variable in function returning tuple");
11611165
}
11621166
else
1167+
{
1168+
/* ordinary expression case*/
11631169
new->expr = plpgsql_read_expression(';',";");
1170+
}
11641171

11651172
new->cmd_type = PLPGSQL_STMT_RETURN;
11661173
new->lineno =$2;
@@ -1173,6 +1180,9 @@ stmt_return_next: K_RETURN_NEXT lno
11731180
{
11741181
PLpgSQL_stmt_return_next *new;
11751182

1183+
if (!plpgsql_curr_compile->fn_retset)
1184+
yyerror("cannot use RETURN NEXT in a non-SETOF function");
1185+
11761186
new = malloc(sizeof(PLpgSQL_stmt_return_next));
11771187
memset(new,0,sizeof(PLpgSQL_stmt_return_next));
11781188

@@ -1188,10 +1198,10 @@ stmt_return_next: K_RETURN_NEXT lno
11881198
elseif (tok == T_ROW)
11891199
new->row = yylval.row;
11901200
else
1191-
yyerror("incorrect argument to RETURN NEXT");
1201+
yyerror("RETURN NEXT must specify a record or row variable in function returning tuple");
11921202

11931203
if (yylex() !=';')
1194-
yyerror("expected\";\"");
1204+
yyerror("RETURN NEXT must specify a record or row variable in function returning tuple");
11951205
}
11961206
else
11971207
new->expr = plpgsql_read_expression(';',";");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp