Re: Making tab-complete.c easier to maintain - Mailing list pgsql-hackers

From Kyotaro HORIGUCHI
Subject Re: Making tab-complete.c easier to maintain
Date
Msg-id 20151117.160925.45883793.horiguchi.kyotaro@lab.ntt.co.jp
Whole thread Raw
In response to Re: Making tab-complete.c easier to maintain  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: Making tab-complete.c easier to maintain  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
List pgsql-hackers
Hello,

At Mon, 16 Nov 2015 12:19:23 -0300, Alvaro Herrera <alvherre@2ndquadrant.com> wrote in
<20151116151923.GX614468@alvherre.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




pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Speed up Clog Access by increasing CLOG buffers
Next
From: Jim Nasby
Date:
Subject: Re: Proposal: "Causal reads" mode for load balancing reads without stale data