2017-09-07 8:08 GMT+02:00 Anthony Bykov <a.by...@postgrespro.ru>: > The following review has been posted through the commitfest application: > make installcheck-world: not tested > Implements feature: not tested > Spec compliant: not tested > Documentation: not tested > > I'm afraid this patch conflicts with current master branch. > > The new status of this patch is: Waiting on Author >
rebased > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers >
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index a637551..49327b2 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -409,6 +409,7 @@ do_compile(FunctionCallInfo fcinfo, for (i = 0; i < numargs; i++) { char buf[32]; + char *argname = NULL; Oid argtypeid = argtypes[i]; char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; PLpgSQL_type *argdtype; @@ -433,9 +434,12 @@ do_compile(FunctionCallInfo fcinfo, errmsg("PL/pgSQL functions cannot accept type %s", format_type_be(argtypeid)))); + argname = (argnames && argnames[i][0] != 0) ? argnames[i] : NULL; + /* Build variable and add to datum list */ - argvariable = plpgsql_build_variable(buf, 0, - argdtype, false); + argvariable = plpgsql_build_variable(argname != NULL ? + argname : buf, + 0, argdtype, false); if (argvariable->dtype == PLPGSQL_DTYPE_VAR) { @@ -461,9 +465,9 @@ do_compile(FunctionCallInfo fcinfo, add_parameter_name(argitemtype, argvariable->dno, buf); /* If there's a name for the argument, make an alias */ - if (argnames && argnames[i][0] != '\0') + if (argname != '\0') add_parameter_name(argitemtype, argvariable->dno, - argnames[i]); + argname); } /* diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index 7ebbde6..a9fe736 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -5979,3 +5979,15 @@ LINE 1: SELECT (SELECT string_agg(id || '=' || name, ',') FROM d) ^ QUERY: SELECT (SELECT string_agg(id || '=' || name, ',') FROM d) CONTEXT: PL/pgSQL function alter_table_under_transition_tables_upd_func() line 3 at RAISE +-- should fail -- message should to contain argument name +CREATE TYPE ct AS (a int, b int); +CREATE OR REPLACE FUNCTION fx(x ct) +RETURNS void AS $$ +BEGIN + GET DIAGNOSTICS x = ROW_COUNT; +end; +$$ language plpgsql; +ERROR: "x" is not a scalar variable +LINE 4: GET DIAGNOSTICS x = ROW_COUNT; + ^ +DROP TYPE ct; diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index 60d1d38..4716ac0 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -4766,3 +4766,15 @@ ALTER TABLE alter_table_under_transition_tables DROP column name; UPDATE alter_table_under_transition_tables SET id = id; + +-- should fail -- message should to contain argument name +CREATE TYPE ct AS (a int, b int); + +CREATE OR REPLACE FUNCTION fx(x ct) +RETURNS void AS $$ +BEGIN + GET DIAGNOSTICS x = ROW_COUNT; +end; +$$ language plpgsql; + +DROP TYPE ct;
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers