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

Commita54d3fb

Browse files
committed
Fix plpgsql to not lookup block labels except in contexts where a block label
is sane (eg, EXIT argument or first part of a qualified identifier), and causemore-closely-nested record variables to take precedence over outer blocklabels. This cures the breakage exhibited by Marko Kreen that 8.3 no longerallowed a function's name to be used for a variable within the function, andmakes plpgsql's handling of block labels more like Oracle's. It's importantto fix this now because we are documenting the use of block labels as variablequalifiers for the first time in 8.3.
1 parent42fd80d commita54d3fb

File tree

4 files changed

+190
-179
lines changed

4 files changed

+190
-179
lines changed

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

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.106 2007/11/09 23:58:32 tgl Exp $
12+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.107 2007/11/27 19:58:44 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -43,6 +43,7 @@ static PLpgSQL_row*make_scalar_list1(const char *initial_name,
4343
int lineno);
4444
staticvoidcheck_sql_expr(constchar *stmt);
4545
staticvoidplpgsql_sql_error_callback(void *arg);
46+
staticchar*check_label(constchar *yytxt);
4647
staticvoidcheck_labels(constchar *start_label,
4748
constchar *end_label);
4849

@@ -214,7 +215,6 @@ staticvoid check_labels(const char *start_label,
214215
%tokenT_ROW
215216
%tokenT_RECORD
216217
%tokenT_DTYPE
217-
%tokenT_LABEL
218218
%tokenT_WORD
219219
%tokenT_ERROR
220220

@@ -505,7 +505,8 @@ decl_aliasitem: T_WORD
505505
yyerror("only positional parameters can be aliased");
506506

507507
plpgsql_ns_setlocal(false);
508-
nsi = plpgsql_ns_lookup(name,NULL);
508+
509+
nsi = plpgsql_ns_lookup(name,NULL,NULL,NULL);
509510
if (nsi ==NULL)
510511
{
511512
plpgsql_error_lineno = plpgsql_scanner_lineno();
@@ -1642,20 +1643,28 @@ opt_block_label:
16421643
}
16431644
;
16441645

1646+
/*
1647+
* need all the options because scanner will have tried to resolve as variable
1648+
*/
16451649
opt_label:
16461650
{
16471651
$$ =NULL;
16481652
}
1649-
|T_LABEL
1653+
|T_WORD
1654+
{
1655+
$$ = check_label(yytext);
1656+
}
1657+
|T_SCALAR
16501658
{
1651-
char *label_name;
1652-
plpgsql_convert_ident(yytext, &label_name,1);
1653-
$$ = label_name;
1659+
$$ = check_label(yytext);
16541660
}
1655-
|T_WORD
1661+
|T_RECORD
16561662
{
1657-
/* just to give a better error than "syntax error"*/
1658-
yyerror("no such label");
1663+
$$ = check_label(yytext);
1664+
}
1665+
|T_ROW
1666+
{
1667+
$$ = check_label(yytext);
16591668
}
16601669
;
16611670

@@ -2484,6 +2493,17 @@ plpgsql_sql_error_callback(void *arg)
24842493
errposition(0);
24852494
}
24862495

2496+
staticchar *
2497+
check_label(constchar *yytxt)
2498+
{
2499+
char *label_name;
2500+
2501+
plpgsql_convert_ident(yytxt, &label_name,1);
2502+
if (plpgsql_ns_lookup_label(label_name) ==NULL)
2503+
yyerror("no such label");
2504+
return label_name;
2505+
}
2506+
24872507
staticvoid
24882508
check_labels(constchar *start_label,constchar *end_label)
24892509
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp