Allow plpgsql variables' default value expressions to reference
existing variables (such as function parameters). Per gripe from David Fetter.
This commit is contained in:
parent
9114cb1c5f
commit
f66b0ff066
@ -4,7 +4,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.49 2003/11/29 19:52:12 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.50 2003/12/23 00:01:57 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@ -628,52 +628,9 @@ decl_defval : ';'
|
||||
{ $$ = NULL; }
|
||||
| decl_defkey
|
||||
{
|
||||
int tok;
|
||||
int lno;
|
||||
PLpgSQL_dstring ds;
|
||||
PLpgSQL_expr *expr;
|
||||
|
||||
lno = plpgsql_scanner_lineno();
|
||||
expr = malloc(sizeof(PLpgSQL_expr));
|
||||
plpgsql_dstring_init(&ds);
|
||||
plpgsql_dstring_append(&ds, "SELECT ");
|
||||
|
||||
expr->dtype = PLPGSQL_DTYPE_EXPR;
|
||||
expr->plan = NULL;
|
||||
expr->nparams = 0;
|
||||
|
||||
tok = yylex();
|
||||
switch (tok)
|
||||
{
|
||||
case 0:
|
||||
yyerror("unexpected end of function");
|
||||
case K_NULL:
|
||||
if (yylex() != ';')
|
||||
yyerror("expected \";\" after \"NULL\"");
|
||||
|
||||
free(expr);
|
||||
plpgsql_dstring_free(&ds);
|
||||
|
||||
$$ = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
plpgsql_dstring_append(&ds, yytext);
|
||||
while ((tok = yylex()) != ';')
|
||||
{
|
||||
if (tok == 0)
|
||||
yyerror("unterminated default value");
|
||||
|
||||
if (plpgsql_SpaceScanned)
|
||||
plpgsql_dstring_append(&ds, " ");
|
||||
plpgsql_dstring_append(&ds, yytext);
|
||||
}
|
||||
expr->query = strdup(plpgsql_dstring_get(&ds));
|
||||
plpgsql_dstring_free(&ds);
|
||||
|
||||
$$ = expr;
|
||||
break;
|
||||
}
|
||||
plpgsql_ns_setlocal(false);
|
||||
$$ = plpgsql_read_expression(';', ";");
|
||||
plpgsql_ns_setlocal(true);
|
||||
}
|
||||
;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user