diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y index e3a992c..2737a3a 100644 --- a/src/pl/plpgsql/src/pl_gram.y +++ b/src/pl/plpgsql/src/pl_gram.y @@ -167,6 +167,7 @@ static List *read_raise_options(void); %type decl_sect %type decl_varname +%type decl_varnames %type decl_const decl_notnull exit_type %type decl_defval decl_cursor_query %type decl_datatype @@ -471,9 +472,10 @@ decl_stmt : decl_statement } ; -decl_statement : decl_varname decl_const decl_datatype decl_collate decl_notnull decl_defval +decl_statement : decl_varnames decl_const decl_datatype decl_collate decl_notnull decl_defval { PLpgSQL_variable *var; + ListCell *lc; /* * If a collation is supplied, insert it into the @@ -492,38 +494,44 @@ decl_statement : decl_varname decl_const decl_datatype decl_collate decl_notnull $3->collation = $4; } - var = plpgsql_build_variable($1.name, $1.lineno, - $3, true); - if ($2) - { - if (var->dtype == PLPGSQL_DTYPE_VAR) - ((PLpgSQL_var *) var)->isconst = $2; - else - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("row or record variable cannot be CONSTANT"), - parser_errposition(@2))); - } - if ($5) - { - if (var->dtype == PLPGSQL_DTYPE_VAR) - ((PLpgSQL_var *) var)->notnull = $5; - else - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("row or record variable cannot be NOT NULL"), - parser_errposition(@4))); - } - if ($6 != NULL) + foreach(lc, $1) { - if (var->dtype == PLPGSQL_DTYPE_VAR) - ((PLpgSQL_var *) var)->default_val = $6; - else - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("default value for row or record variable is not supported"), - parser_errposition(@5))); + YYSTYPE *v = (YYSTYPE *) lfirst(lc); + + var = plpgsql_build_variable(v->varname.name, v->varname.lineno, + $3, true); + if ($2) + { + if (var->dtype == PLPGSQL_DTYPE_VAR) + ((PLpgSQL_var *) var)->isconst = $2; + else + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("row or record variable cannot be CONSTANT"), + parser_errposition(@2))); + } + if ($5) + { + if (var->dtype == PLPGSQL_DTYPE_VAR) + ((PLpgSQL_var *) var)->notnull = $5; + else + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("row or record variable cannot be NOT NULL"), + parser_errposition(@4))); + + } + if ($6 != NULL) + { + if (var->dtype == PLPGSQL_DTYPE_VAR) + ((PLpgSQL_var *) var)->default_val = $6; + else + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("default value for row or record variable is not supported"), + parser_errposition(@5))); + } } } | decl_varname K_ALIAS K_FOR decl_aliasitem ';' @@ -773,6 +781,22 @@ decl_varname : T_WORD } ; +decl_varnames : decl_varname + { + YYSTYPE *v = palloc(sizeof(YYSTYPE)); + v->varname.name = pstrdup($1.name); + v->varname.lineno = $1.lineno; + $$ = list_make1(v); + } + | decl_varnames ',' decl_varname + { + YYSTYPE *v = palloc(sizeof(YYSTYPE)); + v->varname.name = pstrdup($3.name); + v->varname.lineno = $3.lineno; + $$ = lappend($1, v); + } + ; + decl_const : { $$ = false; } | K_CONSTANT