Re: Making tab-complete.c easier to maintain

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: alvherre(at)2ndquadrant(dot)com
Cc: thomas(dot)munro(at)enterprisedb(dot)com, jeff(dot)janes(at)gmail(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Making tab-complete.c easier to maintain
Date: 2015-11-17 07:09:25
Message-ID: 20151117.160925.45883793.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

At Mon, 16 Nov 2015 12:19:23 -0300, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote in <20151116151923(dot)GX614468(at)alvherre(dot)pgsql>
> Thomas Munro wrote:
> > New version attached, merging recent changes.
>
> I wonder about the TailMatches and Matches macros --- wouldn't it be
> better to have a single one, renaming TailMatches to Matches and
> replacing the current Matches() with an initial token that corresponds
> to anchoring to start of command? Just wondering, not terribly attached
> to the idea.

Does it looks like this?

> if (Match(BOL, "ALTER", "TABLE", EOL)) ...

It would be doable giving special meaning to
word_matches(BOL/EOL, *_wd). And I give +1 to that than having so
many similar macros.

The following is my delusion..

It could develop to some mini-laguages like the following, which
is a kind of subset of regular expressions, that is powerful than
current mechanism but not meesier than regular expressions by
narrowing its functionarity. Addition to that the custom minilang
could have specilized functionarity for matching SQL statements.

> if (Match("^ALTER TABLE \id$"))...

It would be nice to have tokens to match to optional words.

> if (Match("^ALTER TABLE(IF EXISTS) \id$"))...
> if (Match("CREATE(OR REPLACE)FUNCTION \id (\CSL)$")

Mmm. this might be another kind of complexity? This is also
accomplished by multiple matching descriptions.

> if (Match("^,ALTER,TABLE,\id,$") ||
> Match("^,ALTER,TABLE,IF,EXISTS,\id,$"))...

Interpreting this kind of mini-language into regular expressions
could be doable..

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2015-11-17 07:13:53 Re: Proposal: "Causal reads" mode for load balancing reads without stale data
Previous Message Amit Kapila 2015-11-17 06:50:36 Re: Speed up Clog Access by increasing CLOG buffers