File tree 3 files changed +28
-3
lines changed
3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -433,9 +433,14 @@ do_compile(FunctionCallInfo fcinfo,
433
433
errmsg ("PL/pgSQL functions cannot accept type %s" ,
434
434
format_type_be (argtypeid ))));
435
435
436
- /* Build variable and add to datum list */
437
- argvariable = plpgsql_build_variable (buf , 0 ,
438
- argdtype , false);
436
+ /*
437
+ * Build variable and add to datum list. If there's a name
438
+ * for the argument, use that as refname, else use $n name.
439
+ */
440
+ argvariable = plpgsql_build_variable ((argnames &&
441
+ argnames [i ][0 ] != '\0' ) ?
442
+ argnames [i ] : buf ,
443
+ 0 , argdtype , false);
439
444
440
445
if (argvariable -> dtype == PLPGSQL_DTYPE_VAR )
441
446
{
Original file line number Diff line number Diff line change @@ -6029,3 +6029,14 @@ SELECT * FROM list_partitioned_table() AS t;
6029
6029
2
6030
6030
(2 rows)
6031
6031
6032
+ --
6033
+ -- Check argument name is used instead of $n in error message
6034
+ --
6035
+ CREATE FUNCTION fx(x WSlot) RETURNS void AS $$
6036
+ BEGIN
6037
+ GET DIAGNOSTICS x = ROW_COUNT;
6038
+ RETURN;
6039
+ END; $$ LANGUAGE plpgsql;
6040
+ ERROR: "x" is not a scalar variable
6041
+ LINE 3: GET DIAGNOSTICS x = ROW_COUNT;
6042
+ ^
Original file line number Diff line number Diff line change @@ -4811,3 +4811,12 @@ BEGIN
4811
4811
END; $$ LANGUAGE plpgsql;
4812
4812
4813
4813
SELECT * FROM list_partitioned_table() AS t;
4814
+
4815
+ --
4816
+ -- Check argument name is used instead of $n in error message
4817
+ --
4818
+ CREATE FUNCTION fx (x WSlot) RETURNS void AS $$
4819
+ BEGIN
4820
+ GET DIAGNOSTICS x = ROW_COUNT;
4821
+ RETURN;
4822
+ END; $$ LANGUAGE plpgsql;
You can’t perform that action at this time.
0 commit comments