Add hint for people who place EXECUTE USING arguments in parentheses (in plpgsql) - Mailing list pgsql-hackers

From David G. Johnston
Subject Add hint for people who place EXECUTE USING arguments in parentheses (in plpgsql)
Date
Msg-id CAKFQuwaggRt64JJuXvcXCUvWPN7ZUvX9S+ohnjgsTvmiuD4OQg@mail.gmail.com
Whole thread Raw
List 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.

pgsql-hackers by date:

Previous
From: Jeff Janes
Date:
Subject: Re: Notice lock waits
Next
From: Tom Lane
Date:
Subject: Re: truncate trigger for foreign data wrappers