Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f66b0ff

Browse files
committed
Allow plpgsql variables' default value expressions to reference
existing variables (such as function parameters). Per gripe from David Fetter.
1 parent 9114cb1 commit f66b0ff

File tree

1 file changed

+4
-47
lines changed

1 file changed

+4
-47
lines changed

src/pl/plpgsql/src/gram.y

+4-47
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.49 2003/11/29 19:52:12 pgsql Exp $
7+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.50 2003/12/23 00:01:57 tgl Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -628,52 +628,9 @@ decl_defval : ';'
628628
{ $$ = NULL; }
629629
| decl_defkey
630630
{
631-
int tok;
632-
int lno;
633-
PLpgSQL_dstring ds;
634-
PLpgSQL_expr *expr;
635-
636-
lno = plpgsql_scanner_lineno();
637-
expr = malloc(sizeof(PLpgSQL_expr));
638-
plpgsql_dstring_init(&ds);
639-
plpgsql_dstring_append(&ds, "SELECT ");
640-
641-
expr->dtype = PLPGSQL_DTYPE_EXPR;
642-
expr->plan = NULL;
643-
expr->nparams = 0;
644-
645-
tok = yylex();
646-
switch (tok)
647-
{
648-
case 0:
649-
yyerror("unexpected end of function");
650-
case K_NULL:
651-
if (yylex() != ';')
652-
yyerror("expected \";\" after \"NULL\"");
653-
654-
free(expr);
655-
plpgsql_dstring_free(&ds);
656-
657-
$$ = NULL;
658-
break;
659-
660-
default:
661-
plpgsql_dstring_append(&ds, yytext);
662-
while ((tok = yylex()) != ';')
663-
{
664-
if (tok == 0)
665-
yyerror("unterminated default value");
666-
667-
if (plpgsql_SpaceScanned)
668-
plpgsql_dstring_append(&ds, " ");
669-
plpgsql_dstring_append(&ds, yytext);
670-
}
671-
expr->query = strdup(plpgsql_dstring_get(&ds));
672-
plpgsql_dstring_free(&ds);
673-
674-
$$ = expr;
675-
break;
676-
}
631+
plpgsql_ns_setlocal(false);
632+
$$ = plpgsql_read_expression(';', ";");
633+
plpgsql_ns_setlocal(true);
677634
}
678635
;
679636

0 commit comments

Comments
 (0)