Re: IF (NOT) EXISTS in psql-completion

Поиск
Список
Период
Сортировка
От Kyotaro HORIGUCHI
Тема Re: IF (NOT) EXISTS in psql-completion
Дата
Msg-id 20160330.124336.151071905.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
Hello,

At Tue, 29 Mar 2016 13:12:06 +0200, Pavel Stehule <pavel.stehule@gmail.com> wrote in
<CAFj8pRCnrpdSqSozg4Y8__2LFyiNqUCE=KPzFw1+AF_LutmRiQ@mail.gmail.com>
> 2016-03-29 12:08 GMT+02:00 Kyotaro HORIGUCHI <
> > > > As mentioned before, upper-lower problem is an existing
> > > > issue. The case of the words in a query result list cannot be
> > > > edited since it may contain words that should not be changed,
> > > > such as relation names. So we can address it only before issueing
> > > > a query but I haven't found simple way to do it.
> > > >
> > >
> > > This is unpleasant. I am sorry. I had very uncomfortable feeling from
> > this
> > > behave. I am thinking so it should be solvable - you have to convert only
> > > keyword IF EXISTS or IF NOT EXISTS. Maybe there are not trivial solution,
> > > but this should be fixed.
> >
> > I understand that and feel the same. But I don't want to put
> > puzzling code. Defining a macro enable this by writing as the
> > following.
> >
> 
> puzzle is wrong, but nonconsistent behave is not acceptable

Mmm. Ok, The attched patch, which applies on top of the
IF(NOT)EXIST patch, does this in rather saner appearance, but
needs to run additional C function at runtime and additional some
macros. The function is called up to once per completion, so it
won't be a performance problem.

>    else if (Matches2("ALTER", "TABLE"))
>        COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
>            ADDLIST2("", "IF EXISTS", "ALL IN TABLESPACE"));

or

>    else if (Matches5("ALTER", "TABLE", MatchAny, "DROP", "CONSTRAINT"))
>    {
>        completion_info_charp = prev3_wd;
>        COMPLETE_WITH_QUERY(
>            ADDLIST1(Query_for_constraint_of_table, "IF EXISTS"));
>    }

I think this syntax is acceptable. Only keywords follows the
setting of COMP_KEYWORD_CASE, as Artur suggested.

=# alter table <tab>
ALL IN TABLESPACE    pg_catalog.          public.
alpha.               pg_temp_1.           x
IF EXISTS            pg_toast.            
information_schema.  pg_toast_temp_1.     
=# alter table i<tab>
if exists
information_schema.sql_features
...
=# 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?

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

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

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Combining Aggregates
Следующее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: PATCH: index-only scans with partial indexes