summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorTom Lane2017-09-11 20:24:34 +0000
committerTom Lane2017-09-11 20:24:43 +0000
commitb8060e41b5994a3cffb3ececaab10ed39b8d5dfd (patch)
treeded5584672b1560be319add3165d12df8c6ea92d /src/pl
parent3612019a7925012445af29b9ea7af84bd68a5932 (diff)
Prefer argument name over "$n" for the refname of a plpgsql argument.
If a function argument has a name, use that as the "refname" of the PLpgSQL_datum representing the argument, instead of $n as before. This allows better error messages in some cases. Pavel Stehule, reviewed by Jeevan Chalke Discussion: https://postgr.es/m/CAFj8pRB9GyU2U1Sb2ssgP26DZ_yq-FYDfpvUvGQ=k4R=yOPVjg@mail.gmail.com
Diffstat (limited to 'src/pl')
-rw-r--r--src/pl/plpgsql/src/pl_comp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index e9d7ef55e97..9931ee038fe 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -433,9 +433,14 @@ do_compile(FunctionCallInfo fcinfo,
errmsg("PL/pgSQL functions cannot accept type %s",
format_type_be(argtypeid))));
- /* Build variable and add to datum list */
- argvariable = plpgsql_build_variable(buf, 0,
- argdtype, false);
+ /*
+ * Build variable and add to datum list. If there's a name
+ * for the argument, use that as refname, else use $n name.
+ */
+ argvariable = plpgsql_build_variable((argnames &&
+ argnames[i][0] != '\0') ?
+ argnames[i] : buf,
+ 0, argdtype, false);
if (argvariable->dtype == PLPGSQL_DTYPE_VAR)
{