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

Commite664969

Browse files
committed
Cause plpgsql to throw an error if "INTO rowtype_var" is followed by a comma.
Per bug #5352, this helps to provide a useful error message if the usertries to do something presently unsupported, namely use a rowtype variableas a member of a multiple-item INTO list.
1 parent5600aac commite664969

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.140 2010/01/19 01:35:30 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.141 2010/03/02 16:14:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2881,18 +2881,39 @@ read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row, bool *strict)
28812881
tok = yylex();
28822882
}
28832883

2884+
/*
2885+
* Currently, a row or record variable can be the single INTO target,
2886+
* but not a member of a multi-target list. So we throw error if there
2887+
* is a comma after it, because that probably means the user tried to
2888+
* write a multi-target list. If this ever gets generalized, we should
2889+
* probably refactor read_into_scalar_list so it handles all cases.
2890+
*/
28842891
switch (tok)
28852892
{
28862893
case T_DATUM:
28872894
if (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_ROW)
28882895
{
28892896
check_assignable(yylval.wdatum.datum, yylloc);
28902897
*row = (PLpgSQL_row *) yylval.wdatum.datum;
2898+
2899+
if ((tok = yylex()) == ',')
2900+
ereport(ERROR,
2901+
(errcode(ERRCODE_SYNTAX_ERROR),
2902+
errmsg("record or row variable cannot be part of multiple-item INTO list"),
2903+
parser_errposition(yylloc)));
2904+
plpgsql_push_back_token(tok);
28912905
}
28922906
else if (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_REC)
28932907
{
28942908
check_assignable(yylval.wdatum.datum, yylloc);
28952909
*rec = (PLpgSQL_rec *) yylval.wdatum.datum;
2910+
2911+
if ((tok = yylex()) == ',')
2912+
ereport(ERROR,
2913+
(errcode(ERRCODE_SYNTAX_ERROR),
2914+
errmsg("record or row variable cannot be part of multiple-item INTO list"),
2915+
parser_errposition(yylloc)));
2916+
plpgsql_push_back_token(tok);
28962917
}
28972918
else
28982919
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp