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 CAFj8pRCvWyOD42djcEY4NEFC9ai+51juVJuYiKU-r5tvAOU5_A@mail.gmail.com
Whole thread Raw
In response to Re: IF (NOT) EXISTS in psql-completion  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Responses Re: IF (NOT) EXISTS in psql-completion  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers


2016-03-30 5:43 GMT+02:00 Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>:
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?

+1

Regards

Pavel

 

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

pgsql-hackers by date:

Previous
From: Fabrízio de Royes Mello
Date:
Subject: Re: Sequence Access Method WIP
Next
From: Amit Kapila
Date:
Subject: Re: OOM in libpq and infinite loop with getCopyStart()