Add hint for people who place EXECUTE USING arguments in parentheses (in plpgsql)

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Add hint for people who place EXECUTE USING arguments in parentheses (in plpgsql)
Date: 2016-08-05 20:22:27
Message-ID: CAKFQuwaggRt64JJuXvcXCUvWPN7ZUvX9S+ohnjgsTvmiuD4OQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Basically,

diff --git a/src/backend/parser/parse_param.c
b/src/backend/parser/parse_param.c
index b402843..97064fc 100644
--- a/src/backend/parser/parse_param.c
+++ b/src/backend/parser/parse_param.c
@@ -108,6 +108,9 @@ fixed_paramref_hook(ParseState *pstate, ParamRef *pref)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PARAMETER),
errmsg("there is no parameter $%d", paramno),
+ parstate->numParams == 1 && < It is of pseudo-type record >
+ ? errhint("%s", _("did you incorrectly enclose USING arguments in
parentheses?"))
+ : 0
parser_errposition(pstate, pref->location)));

param = makeNode(Param);

I didn't spend too much time trying to figure out how to test that a
parameter is composite/record typed...

I think a false positive on SQL EXECUTE is going to be very small...but I
choose here mostly out of ease - a fix in pl/pgsql would be more correct.

David J.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-08-05 20:35:02 Re: truncate trigger for foreign data wrappers
Previous Message Jeff Janes 2016-08-05 19:58:53 Re: Notice lock waits