Re: Making tab-complete.c easier to maintain

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Making tab-complete.c easier to maintain
Date: 2015-11-16 05:59:06
Message-ID: CAEepm=26AR3drcAUW+paLvJmXS6WV36kk6e72GWS4rAykOueOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 12, 2015 at 5:16 PM, Kyotaro HORIGUCHI <
horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:

> Hello. How about regular expressions?
>
> I've been thinking of better mechanism for tab-compltion for
> these days since I found some bugs in it.
>
> At Fri, 23 Oct 2015 14:50:58 -0300, Alvaro Herrera <
> alvherre(at)2ndquadrant(dot)com> wrote in <20151023175058(dot)GA3391(at)alvherre(dot)pgsql>
> > Jeff Janes wrote:
> >
> > > For the bigger picture, I don't think we should not apply this patch
> simply
> > > because there is something even better we might theoretically do at
> some
> > > point in the future.
> >
> > Agreed.
>
> Auto-generating from grammer should be the ultimate solution but
> I don't think it will be available. But still I found that the
> word-splitting-then-match-word-by-word-for-each-matching is
> terriblly unmaintainable and poorly capable. So, how about
> regular expressions?
>
> I tried to use pg_regex in frontend and found that it is easily
> doable. As a proof of the concept, the two patches attached to
> this message does that changes.
>
> 1. 0001-Allow-regex-module-to-be-used-outside-server.patch
>
> This small change makes pg_regex possible to be used in
> frontend.
>
> 2. 0002-Replace-previous-matching-rule-with-regexps.patch
>
> Simply replaces existing matching rules almost one-by-one with
> regular expression matches.
>
> I made these patches not to change the behavior except inevitable
> ones.
>
> We would have far powerful matching capability using regular
> expressions and it makes tab-complete.c look simpler. On the
> other hand, regular expressions - which are stashed away into new
> file by this patch - is a chunk of complexity and (also) error
> prone. For all that I think this is better than the current
> situation in terms of maintainability and capability.
>
> This should look stupid because it really be replaced stupidly
> and of course this can be more sane/effective/maintainable by
> refactoring. But before that issue, I'm not confident at all that
> this is really a alternative with *gigantic* improvement.
>
> Any opinions?
>

It's an interesting idea to use regular expressions, but it's a shame to
move the patterns so far away from the actions they trigger.

--
Thomas Munro
http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-11-16 07:24:59 Re: COPY (INSERT/UPDATE/DELETE .. RETURNING ..)
Previous Message Kouhei Kaigai 2015-11-16 05:13:48 Re: Foreign join pushdown vs EvalPlanQual