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-29 11:12:06
Message-ID: CAFj8pRCnrpdSqSozg4Y8__2LFyiNqUCE=KPzFw1+AF_LutmRiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2016-03-29 12:08 GMT+02:00 Kyotaro HORIGUCHI <
horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>:

> Hi, Pavel.
>
> At Tue, 29 Mar 2016 09:59:01 +0200, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote in <
> CAFj8pRDEPgGyMz2aXgTL33PuD7X+xieaO++wa+V9nQPQiYDMGQ(at)mail(dot)gmail(dot)com>
> > > > On 3/18/16 3:22 AM, Pavel Stehule wrote:
> > > >
> > > > > I am looking this patch. It looks well, but this feature
> doesn't
> > > > > respect upper or lower chars. It enforce upper chars. This is
> not
> > > > > consistent with any other autocomplete.
> > >
> > > 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

Regards

Pavel

>
> > else if (Matches2("ALTER", "TABLE"))
> > COMPLETE_WITH_SCHEMA_QUERY(
> > Query_for_list_of_tables,
> > ADDLIST("",
> > "('IF EXISTS'), ('ALL IN TABLESPACE')",
> > "('if exists'), ('all in tablespace')"));
> ...
> > else if (Matches2("ALTER", "POLICY"))
> > COMPLETE_WITH_QUERY(
> > ADDLIST(Query_for_list_of_policies,
> > "('IF EXISTS')", "('if exists')"));
>
> This will work as you expects but it looks quite redundant, but
> avoiding dynamic string (and/or malloc) operation would lead to
> the similar results. Integrating the ADDLIST into
> COMPLETE... might make the situation better.
>
> The attached patch does it only for "ALTER TABLE" and "ALTER
> POLICY".
>
> > > > > I checked it against sql help and these statements doesn't work
> > >
> > > Thank you very much.
> > >
> > > > > alter foreign table hhhh drop column
> > > > > drop cast
> > > > > drop operator
> > > > > drop transform -- missing autocomplete completely
> > >
> > > These are not done. Each of them has issues to be addressed
> > > before adding completion of IF EXISTS.
> > >
> > > > > alter text search configuration jjj drop mapping
> > > > > alter type hhh drop attribute
> > > > > drop extension
> > >
> > > Done.
> > >
> > > > > drop text search
> > >
> > > I don't see the syntax "drop text search [if exists]". drop text
> > > search (configuration|dictionary|parser|template) are already
> > > addressed.
> > >
> >
> > ok, probably my mistake. I am sorry.
> >
> >
> > >
> > > > > drop user mapping
> > >
> > > "drop user" was not completed with "mapping". I added it then
> > > addressed this. (This might be another issue.)
> > >
> > > > > alter table jjj add column
> > >
> > > Done if it is mentioning DROP COLUMN. But new two macros
> > > HeadMatches6 and 7 are introduced together.
> > >
> > > > > create temp sequence
> > > > > create sequence
> > >
> > > DROP SEQUENCE is already completed with IF EXISTS. CREATE [TEMP]
> > > SEQUENCE with IF NOT EXISTS is added.
> > >
> > > > Do you have an idea of when you will have a new patch ready?
> > >
> > > Sorry to to have been late. The attached is the revised version.
> > >
> >
> > I'll check it today.
>
> Thanks.
>
> regards,
>
> --
> Kyotaro Horiguchi
> NTT Open Source Software Center
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sridhar N Bamandlapally 2016-03-29 11:37:38 Re: pg_largeobject
Previous Message Kyotaro HORIGUCHI 2016-03-29 11:12:03 Re: IF (NOT) EXISTS in psql-completion