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

Commit77e0d7b

Browse files
committed
Instead of trying (and failing) to allow <<label>> at the end of a DECLARE
section, throw an error message saying explicitly that the label must gobefore DECLARE. Per investigation of a recent pgsql-novice question,this code did not work as intended in any modern PG version, maybe not ever.Allowing such a thing would only create ambiguity anyway, so it seems betterto remove it than fix it.
1 parent7c55be7 commit77e0d7b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

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

Lines changed: 17 additions & 13 deletions
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.141 2010/03/02 16:14:39 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.142 2010/03/03 01:53:17 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -170,7 +170,6 @@ staticList*read_raise_options(void);
170170
%type<datum>decl_cursor_args
171171
%type<list>decl_cursor_arglist
172172
%type<nsitem>decl_aliasitem
173-
%type<str>decl_stmtsdecl_stmt
174173

175174
%type<expr>expr_until_semiexpr_until_rightbracket
176175
%type<expr>expr_until_thenexpr_until_loopopt_expr_until_when
@@ -386,10 +385,7 @@ decl_sect: opt_block_label
386385
|opt_block_labeldecl_startdecl_stmts
387386
{
388387
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
389-
if ($3 !=NULL)
390-
$$.label =$3;
391-
else
392-
$$.label =$1;
388+
$$.label =$1;
393389
/* Remember variables declared in decl_stmts*/
394390
$$.n_initvars = plpgsql_add_initdatums(&($$.initvarnos));
395391
}
@@ -408,17 +404,25 @@ decl_start: K_DECLARE
408404
;
409405

410406
decl_stmts:decl_stmtsdecl_stmt
411-
{$$ =$2;}
412407
|decl_stmt
413-
{$$ =$1;}
414408
;
415409

416-
decl_stmt:LESS_LESSany_identifierGREATER_GREATER
417-
{$$ =$2;}
410+
decl_stmt:decl_statement
418411
|K_DECLARE
419-
{$$ =NULL;}
420-
|decl_statement
421-
{$$ =NULL;}
412+
{
413+
/* We allow useless extra DECLAREs*/
414+
}
415+
|LESS_LESSany_identifierGREATER_GREATER
416+
{
417+
/*
418+
* Throw a helpful error if user tries to put block
419+
* label just before BEGIN, instead of before DECLARE.
420+
*/
421+
ereport(ERROR,
422+
(errcode(ERRCODE_SYNTAX_ERROR),
423+
errmsg("block label must be placed before DECLARE, not after"),
424+
parser_errposition(@1)));
425+
}
422426
;
423427

424428
decl_statement:decl_varnamedecl_constdecl_datatypedecl_notnulldecl_defval

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp