4
4
* procedural language
5
5
*
6
6
* 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 $
8
8
*
9
9
* This software is copyrighted by Jan Wieck - Hamburg.
10
10
*
@@ -1136,8 +1136,12 @@ stmt_return : K_RETURN lno
1136
1136
new ->retrecno = -1 ;
1137
1137
new ->retrowno = -1 ;
1138
1138
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
+ else if (plpgsql_curr_compile->fn_retistuple)
1141
1145
{
1142
1146
switch (yylex ())
1143
1147
{
@@ -1153,14 +1157,17 @@ stmt_return : K_RETURN lno
1153
1157
break ;
1154
1158
1155
1159
default :
1156
- yyerror (" return type mismatch in function returning tuple" );
1160
+ yyerror (" RETURN must specify a record or row variable in function returning tuple" );
1157
1161
break ;
1158
1162
}
1159
1163
if (yylex () != ' ;' )
1160
- yyerror (" expected \" ; \" " );
1164
+ yyerror (" RETURN must specify a record or row variable in function returning tuple " );
1161
1165
}
1162
1166
else
1167
+ {
1168
+ /* ordinary expression case */
1163
1169
new ->expr = plpgsql_read_expression(' ;' , " ;" );
1170
+ }
1164
1171
1165
1172
new ->cmd_type = PLPGSQL_STMT_RETURN;
1166
1173
new ->lineno = $2 ;
@@ -1173,6 +1180,9 @@ stmt_return_next: K_RETURN_NEXT lno
1173
1180
{
1174
1181
PLpgSQL_stmt_return_next *new ;
1175
1182
1183
+ if (!plpgsql_curr_compile->fn_retset)
1184
+ yyerror (" cannot use RETURN NEXT in a non-SETOF function" );
1185
+
1176
1186
new = malloc(sizeof (PLpgSQL_stmt_return_next));
1177
1187
memset (new , 0 , sizeof (PLpgSQL_stmt_return_next));
1178
1188
@@ -1188,10 +1198,10 @@ stmt_return_next: K_RETURN_NEXT lno
1188
1198
else if (tok == T_ROW)
1189
1199
new ->row = yylval.row;
1190
1200
else
1191
- yyerror (" incorrect argument to RETURN NEXT " );
1201
+ yyerror (" RETURN NEXT must specify a record or row variable in function returning tuple " );
1192
1202
1193
1203
if (yylex () != ' ;' )
1194
- yyerror (" expected \" ; \" " );
1204
+ yyerror (" RETURN NEXT must specify a record or row variable in function returning tuple " );
1195
1205
}
1196
1206
else
1197
1207
new ->expr = plpgsql_read_expression(' ;' , " ;" );
0 commit comments