Re: IF (NOT) EXISTS in psql-completion

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: David Steele <david(at)pgmasters(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: IF (NOT) EXISTS in psql-completion
Date: 2016-04-02 05:16:48
Message-ID: CAFj8pRBjEAjGYyGdvrzi21RtCD-P6Ti0b0n0J+sZW17a=H4B-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

2016-04-01 10:21 GMT+02:00 Kyotaro HORIGUCHI <
horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>:

> 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..
>
>
something is wrong, autocomplete for CREATE TABLE IF NOT EXISTS doesn't work

Regards

Pavel

> regards,
>
> --
> Kyotaro Horiguchi
> NTT Open Source Software Center
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2016-04-02 05:18:32 Re: IF (NOT) EXISTS in psql-completion
Previous Message Tom Lane 2016-04-02 03:07:01 Re: Re: [COMMITTERS] pgsql: Refer to a TOKEN_USER payload as a "token user, " not as a "user