Re: Function Error Response Is Not Clear

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Function Error Response Is Not Clear
Дата
Msg-id 15085.1749312307@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Function Error Response Is Not Clear  (Luke Muther <lmutes8@gmail.com>)
Список pgsql-bugs
Luke Muther <lmutes8@gmail.com> writes:
> Some functions if they are missing the correct arguments give vague error
> messages while others give specific ones.

Yeah, it's difficult to move the goalposts here at reasonable cost.
The functions that you are complaining about do not go through the
normal parsing process for functions; instead they have hard-wired
grammar productions:

/*
 * Special expressions that are considered to be functions.
 */
func_expr_common_subexpr:
...
            | NULLIF '(' a_expr ',' a_expr ')'
...
            | COALESCE '(' expr_list ')'

and Bison just doesn't do any better than "syntax error" if it
cannot find a match in the grammar.  In these particular cases
we could make the grammar production more agnostic and complain
about wrong-number-of-arguments in parse analysis.  However
that idea doesn't go very far, because most of the variants of
func_expr_common_subexpr have weird SQL-spec-mandated special
syntax, eg

            | TRIM '(' trim_list ')'

...

trim_list:    a_expr FROM expr_list
            | FROM expr_list
            | expr_list
        ;

So I don't see an easy way to make more than a very small
dent in the problem.  If you're feeling motivated to
research this and look for a better answer, please do.

            regards, tom lane



В списке pgsql-bugs по дате отправления: