From: Tom Lane <tgl@sss.pgh.pa.us>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: Simon Riggs <simon.riggs@enterprisedb.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Jim Mlodgenski <jimmy76@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Hook for extensible parsing.
Date: Thu, 23 Sep 2021 10:21:20 -0400
Message-ID: <2289707.1632406880@sss.pgh.pa.us> (raw)
In-Reply-To: <20210923133158.trw2aibki5c3mivu@nol>
References: <CANbhV-EFq08gH_1ZAfenRucq4iR=-2G29Z4f6OPpciy_FqxjiA@mail.gmail.com>
<CAB_5SRfOGwEhsz6kR4BxYHjjDeUcmCHZRrCtvWQKi+6GL7M7aQ@mail.gmail.com>
<984300.1631719616@sss.pgh.pa.us>
<CAOBaU_bpnN7v+yCrK0gt1pxLESNGABV90V2Zd5euFW0TR8hnpQ@mail.gmail.com>
<1023941.1631725020@sss.pgh.pa.us>
<20210915195506.bse4pzi2x5atxzzw@alap3.anarazel.de>
<1091268.1631739097@sss.pgh.pa.us>
<20210915214019.xtphp3vd2345dir4@alap3.anarazel.de>
<CAOBaU_b0JuzzLAyWxREqod1M43wzmO5Bo9PQeS87rgJ9mfk2Kw@mail.gmail.com>
<CANbhV-EJ+JdJuejAj7DD+Aj5tTSUuhF9rFmvdqRJC4OdURknhw@mail.gmail.com>
<20210923133158.trw2aibki5c3mivu@nol>
Julien Rouhaud <rjuju123@gmail.com> writes:
> My POC's grammar is only like:
> CREATE HYPOTHETICAL INDEX opt_index_name ON relation_expr '(' index_params ')'
> {
> IndexStmt *n = makeNode(IndexStmt);
> n->idxname = $4;
> n->relation = $6;
> n->accessMethod = DEFAULT_INDEX_TYPE;
> n->indexParams = $8;
> n->options = list_make1(makeDefElem("hypothetical", NULL, -1));
> $$ = (Node *) n;
> }
I'm not too impressed by this example, because there seems little
reason why you couldn't just define "hypothetical" as an index_param
option, and not need to touch the grammar at all.
> as I'm not willing to import the whole CREATE INDEX grammar for now for a patch
> that may be rejected.
The fact that that's so daunting seems to me to be a perfect illustration
of the problems with this concept. Doing anything interesting with a
hook like this will create a maintenance nightmare, because you'll have
to duplicate (and track every change in) large swaths of gram.y. To the
extent that you fail to, say, match every detail of the core's expression
grammar, you'll be creating a crappy user experience.
> that once my parser returns this parse tree, all I need to do is intercept
> IndexStmt containing this option in a utility_hook and run my code rather than
> a plain DefineIndex(), which works as intended as I showed above.
And I'm even less impressed by the idea of half a dozen extensions
each adding its own overhead to the parser and also to ProcessUtility
so that they can process statements in this klugy, highly-restricted
way.
I do have sympathy for the idea that extensions would like to define
their own statement types. I just don't see a practical way to do it
in our existing parser infrastructure. This patch certainly doesn't
offer that.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, rjuju123@gmail.com, simon.riggs@enterprisedb.com, andres@anarazel.de, jimmy76@gmail.com
Subject: Re: Hook for extensible parsing.
In-Reply-To: <2289707.1632406880@sss.pgh.pa.us>
References: <CANbhV-EFq08gH_1ZAfenRucq4iR=-2G29Z4f6OPpciy_FqxjiA@mail.gmail.com> <CAB_5SRfOGwEhsz6kR4BxYHjjDeUcmCHZRrCtvWQKi+6GL7M7aQ@mail.gmail.com> <984300.1631719616@sss.pgh.pa.us> <CAOBaU_bpnN7v+yCrK0gt1pxLESNGABV90V2Zd5euFW0TR8hnpQ@mail.gmail.com> <1023941.1631725020@sss.pgh.pa.us> <20210915195506.bse4pzi2x5atxzzw@alap3.anarazel.de> <1091268.1631739097@sss.pgh.pa.us> <20210915214019.xtphp3vd2345dir4@alap3.anarazel.de> <CAOBaU_b0JuzzLAyWxREqod1M43wzmO5Bo9PQeS87rgJ9mfk2Kw@mail.gmail.com> <CANbhV-EJ+JdJuejAj7DD+Aj5tTSUuhF9rFmvdqRJC4OdURknhw@mail.gmail.com> <20210923133158.trw2aibki5c3mivu@nol> <2289707.1632406880@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox