Обсуждение: Add hint for people who place EXECUTE USING arguments in parentheses (in plpgsql)

Поиск
Список
Период
Сортировка

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

От
"David G. Johnston"
Дата:
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.