Re: IF (NOT) EXISTS in psql-completion - Mailing list pgsql-hackers
From | Pavel Stehule |
---|---|
Subject | Re: IF (NOT) EXISTS in psql-completion |
Date | |
Msg-id | CAFj8pRADF3rmQ3y33aeR1C7wOi2QsS65C8bBtiRNqU0zWVWayg@mail.gmail.com Whole thread Raw |
In response to | Re: IF (NOT) EXISTS in psql-completion (Pavel Stehule <pavel.stehule@gmail.com>) |
Responses |
Re: IF (NOT) EXISTS in psql-completion
|
List | pgsql-hackers |
2016-04-02 7:16 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
Hi2016-04-01 10:21 GMT+02:00 Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.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.kyotaro@lab.ntt.co.jp> wrote in <20160401.115203.98896697.horiguchi.kyotaro@lab.ntt.co.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
CREATE UNLOGGED/TEMP table is working.
Pavel
RegardsPavelregards,
--
Kyotaro Horiguchi
NTT Open Source Software Center
pgsql-hackers by date: