Re: IF (NOT) EXISTS in psql-completion

Поиск
Список
Период
Сортировка
От Kyotaro HORIGUCHI
Тема Re: IF (NOT) EXISTS in psql-completion
Дата
Msg-id 20160330.173408.176121912.horiguchi.kyotaro@lab.ntt.co.jp
обсуждение исходный текст
Ответ на Re: IF (NOT) EXISTS in psql-completion  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: IF (NOT) EXISTS in psql-completion  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
Hi,

At Wed, 30 Mar 2016 09:23:49 +0200, Pavel Stehule <pavel.stehule@gmail.com> wrote in
<CAFj8pRBVKa6NG4JwZ2QmrO7inudFJws5w0+demVgZZNuF-HUkQ@mail.gmail.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.

regards,


-- 
Kyotaro Horiguchi
NTT Open Source Software Center





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Langote
Дата:
Сообщение: Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: Missing mention of GSSAPI in MSVC's config_default.pl