Re: Making tab-complete.c easier to maintain

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
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-12-14 05:13:02
Message-ID: CAB7nPqSggjPA8U1WV7ivW44xzboC8pci_Etmffr+ZEzxSX_ahA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 14, 2015 at 8:10 AM, Thomas Munro
<thomas(dot)munro(at)enterprisedb(dot)com> wrote:
> I've also add (very) primitive negative pattern support and used it in
> 5 places. Improvement? Examples:
>
> /* ALTER TABLE xxx RENAME yyy */
> - else if (TailMatches5("ALTER", "TABLE", MatchAny, "RENAME", MatchAny) &&
> - !TailMatches1("CONSTRAINT|TO"))
> + else if (TailMatches5("ALTER", "TABLE", MatchAny, "RENAME",
> "!CONSTRAINT|TO"))
> COMPLETE_WITH_CONST("TO");
>
> /* If we have CLUSTER <sth>, then add "USING" */
> - else if (TailMatches2("CLUSTER", MatchAny) &&
> !TailMatches1("VERBOSE|ON"))
> + else if (TailMatches2("CLUSTER", "!VERBOSE|ON"))
> COMPLETE_WITH_CONST("USING");

+ /* Handle negated patterns. */
+ if (*pattern == '!')
+ return !word_matches(pattern + 1, word);

Yeah, I guess that's an improvement for those cases, and there is no
immediate need for a per-keyword NOT operator in our cases to allow
things of the type (foo1 OR NOT foo2). Still, in the case of this
patch !foo1|foo2 actually means (NOT foo1 AND NOT foo2). It does not
seem that much intuitive. Reading straight this expression it seems
that !foo1|foo2 means actually (NOT foo1 OR foo2) because the lack of
parenthesis. Thoughts?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-12-14 05:56:30 Function and view to retrieve WAL receiver status
Previous Message Tom Lane 2015-12-14 04:03:22 Re: Disabling an index temporarily