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-03-31 09:22:20
Message-ID: CAFj8pRD7vADuNOiApB8Exwc+C5cCis-rj2dPhvZCwZKgXjb_Xg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2016-03-30 10:34 GMT+02:00 Kyotaro HORIGUCHI <
horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>:

> Hi,
>
> At Wed, 30 Mar 2016 09:23:49 +0200, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote in <
> CAFj8pRBVKa6NG4JwZ2QmrO7inudFJws5w0+demVgZZNuF-HUkQ(at)mail(dot)gmail(dot)com>
> > Hi
> >
> > ...
> > >> =# alter table if<tab>
> > >> =# alter table if exists
> > >> ======
> > >> =# alter table I<tab>
> > >> =# alter table IF EXISTS // "information_schema" doesn't match.
> > >>
> > >> Since this is another problem from IF (NOT) EXISTS, this is
> > >> in separate form.
> > >>
> > >> What do you think about this?
> > >>
> > >
> > > +1
> > >
> >
> > The new behave is much better.
>
> I'm glad to hear that.
>
> > 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 */
>
> > #define SHIFT_TO_LAST1(p1) \
> > (HEADSHIFT(find_last_index_of(p1, previous_words,
> previous_words_count)), \
> > true)
>
> > #define HEADSHIFT(n) \
> > (head_shift += n, true)
>
> expanding the macros the lines at the error will be
>
> else if (HeadMatches2("CREATE", "SCHEMA") &&
> (head_shift +=
> find_last_index_of("CREATE", previous_words,
> previous_words_count),
> true) &&
> 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..
>
> Any thougts?
>
> > There is small minor issue - I don't know if it is solvable. Autocomplete
> > is working only for "if" keyword. When I am writing "if " or "if " or "if
> > exi" - then autocomplete doesn't work. But this issue is exactly same for
> > other "multi words" completation like "alter foreign data wrapper". So
> if
> > it is fixable, then it can be out of scope this patch.
>
> Yes. It can be saved only by adding completion for every word,
> as some of the similar completion is doing.
>
> > anything else looks well.
>
> Thanks.
>

please, final patch

Regards

Pavel

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bernd Helmle 2016-03-31 09:27:27 standalone backend PANICs during recovery
Previous Message Kyotaro HORIGUCHI 2016-03-31 09:17:55 Re: PATCH: index-only scans with partial indexes