Re: Hook for extensible parsing.

Поиск
Список
Период
Сортировка
От Jonah H. Harris
Тема Re: Hook for extensible parsing.
Дата
Msg-id CADUqk8WF15h7yT5c2a0pJDsbasUR5=uOH1i1e13AE-jY_9-pyA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Hook for extensible parsing.  (Andres Freund <andres@anarazel.de>)
Ответы Re: Hook for extensible parsing.  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On Wed, Sep 15, 2021 at 3:55 PM Andres Freund <andres@anarazel.de> wrote:
On 2021-09-15 12:57:00 -0400, Tom Lane wrote:
> That's not what the patch actually does, though.  It only replaces
> the grammar, not semantic analysis.  So you couldn't associate the
> (+)-decorated WHERE clause with the appropriate join.  (And no,
> I will not accept that it's okay to perform catalog lookups in
> the grammar to get around that.  See comment at the head of gram.y.)

> In general, I'm having a hard time believing that anything very
> interesting can be done at only the grammar level without changing
> the parse analysis phase.  That's not unrelated to the restriction
> that the grammar can't do catalog accesses.  Maybe with some fundamental
> restructuring, we could get around that issue ... but this patch isn't
> doing any fundamental restructuring, it's just putting a hook where it's
> easy to do so.  We've often found that such hooks aren't as useful as
> they initially seem.

Agreed - it doesn't make sense to me to have a hook that only replaces raw
parsing, without also hooking into parse-analysis. ISTM that the least a
patchset going for a parser hook would have to do is to do sufficient
restructuring so that one could hook together into both raw parsing and
analysis. It could still be two callbacks, but perhaps we'd ensure that
they're both set.

This is a bad example as it doesn't require semantic analysis from Postgres. While most of the tools out there tend to do simple replacement, this can be done within a custom parser by simply walking its own AST, evaluating join conditions against the expression, and rewriting the join accordingly. Or, do you have an example that couldn't be done this way within a custom parser?

--
Jonah H. Harris

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

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: mem context is not reset between extended stats
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Hook for extensible parsing.