Re: Hook for extensible parsing.

From: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Jim Mlodgenski <jimmy76(at)gmail(dot)com>, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Hook for extensible parsing.
Date: 2021-09-15 20:35:53
Message-ID: CADUqk8WF15h7yT5c2a0pJDsbasUR5=uOH1i1e13AE-jY_9-pyA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 15, 2021 at 3:55 PM Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-09-15 20:41:50 Re: Hook for extensible parsing.
Previous Message Justin Pryzby 2021-09-15 20:09:28 mem context is not reset between extended stats