Re: IF (NOT) EXISTS in psql-completion

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: pavel(dot)stehule(at)gmail(dot)com
Cc: david(at)pgmasters(dot)net, peter_e(at)gmx(dot)net, pgsql-hackers(at)postgresql(dot)org
Subject: Re: IF (NOT) EXISTS in psql-completion
Date: 2016-04-01 08:21:46
Message-ID: 20160401.172146.224029447.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

Hello, sorry for being a bit late.
The attatched are the new version of the patch.. set.

1. 0001-Suggest-IF-NOT-EXISTS-for-tab-completion-of-psql.patch

Adds IF (NOT) EXISTS completion. It doesn't fix the issue that
the case of additional keywords don't follow the input.

2. 0002-Make-added-keywords-for-completion-queries-follow-to.patch

Fixes the case-don't-follow issue by introducing a new macro set
ADDLISTn(). This leaves the issue for keywords along with
attributes.

3. 0003-Make-COMPLETE_WITH_ATTR-to-accept-additional-keyword.patch

Fixes the issue left after 0002 patch.
This patch does the following
things.

1. Change completion_charp from const char * to PQExpBuffer.

2. Chnage COMPLETE_WITH_QUERY and COMPLETE_WITH_ATTR to accept
an expression instead of string literal.

3. Replace all additional keyword lists in psql_copmletion with
ADDLISTn() expression.

At Fri, 01 Apr 2016 11:52:03 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote in <20160401(dot)115203(dot)98896697(dot)horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
> > > > I found new warning
> > > >
> > > > tab-complete.c:1438:87: warning: right-hand operand of comma expression
> > > > has no effect [-Wunused-value]
> > >
> > > Mmm. Google said me that gcc 4.9 does so. I'm using 4.8.5 so I
> > > haven't see the warning.
> > >
> > > https://gcc.gnu.org/gcc-4.9/porting_to.html
> > >
> > > 1436: else if (HeadMatches2("CREATE", "SCHEMA") &&
> > > 1437: SHIFT_TO_LAST1("CREATE") &&
> > > 1438: false) {} /* FALL THROUGH */
...
> > > But the right hand value (true) is actually "used" in the
> > > expression (even though not effective). Perhaps (true && false)
> > > was potimized as false and the true is regarded to be unused?
> > > That's stupid.. Using functions instead of macros seems to solve
> > > this but they needed to be wraped by macros as
> > > additional_kw_query(). That's a pain..
...
> This needs to use gcc 4.9 to address, but CentOS7 doesn't have
> devtools-2 repo so now I'm building CentOS6 environment for this
> purpose. Please wait for a while.

Finally I settled it by replacing comma expression with logical
OR or AND expresssion. gcc 4.9 compains for some unused variables
in flex output but it is the another issue.

I forgot to address COMPLETE_WITH_ATTTR but it needed an overhaul
of some macros and changing the type of completion_charp. The
third patch does it but it might be unacceptable..

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
0001-Suggest-IF-NOT-EXISTS-for-tab-completion-of-psql.patch text/x-patch 45.3 KB
0002-Make-added-keywords-for-completion-queries-follow-to.patch text/x-patch 23.2 KB
0003-Make-COMPLETE_WITH_ATTR-to-accept-additional-keyword.patch text/x-patch 64.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-04-01 08:35:18 Re: Move PinBuffer and UnpinBuffer to atomics
Previous Message Dilip Kumar 2016-04-01 08:20:10 Re: Move PinBuffer and UnpinBuffer to atomics