Re: IF (NOT) EXISTS in psql-completion - Mailing list pgsql-hackers

From Kyotaro HORIGUCHI
Subject Re: IF (NOT) EXISTS in psql-completion
Date
Msg-id 20160404.145843.239250938.horiguchi.kyotaro@lab.ntt.co.jp
Whole thread Raw
In response to Re: IF (NOT) EXISTS in psql-completion  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: IF (NOT) EXISTS in psql-completion  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Thank you for testing. That is a silly mistake, sorry.

The attached is the fixed version.

# Can I add a suffix to format-patche's output files?

At Sat, 2 Apr 2016 07:18:32 +0200, Pavel Stehule <pavel.stehule@gmail.com> wrote in
<CAFj8pRADF3rmQ3y33aeR1C7wOi2QsS65C8bBtiRNqU0zWVWayg@mail.gmail.com>
> >> Finally I settled it by replacing comma expression with logical
> >> OR or AND expresssion. gcc 4.9 compains for some unused variables
> >> in flex output but it is the another issue.
> >>
> >> I forgot to address COMPLETE_WITH_ATTTR but it needed an overhaul
> >> of some macros and changing the type of completion_charp. The
> >> third patch does it but it might be unacceptable..
> >>
> >>
> > something is wrong, autocomplete for CREATE TABLE IF NOT EXISTS doesn't
> > work
> >
> 
> CREATE UNLOGGED/TEMP table is working.

Mmm. I mitakenly refactored multi-step matching.

>   else if (HeadMatches3("CREATE", MatchAny, "TABLE") &&
>        MidMatchAndRemove1(1, "TEMP|TEMPORARY|UNLOGGED") &&
>        Matches2("CREATE", "TABLE"))
>     COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
>                    ADDLIST1("IF NOT EXISTS"));

The completion runs only for CREATE AnyKeyword TABLE when
AnyKeyword is removable. It is wrong to do so when any of
prev_words[] that matches the last Matches() can be fileterd out
by the first Headmatches(). The same kind of mistake was found in
the following syntaxes. CREATE SEQENCE had one more mistake.


"CREATE [UNIQUE] INDEX"
"CREATE [TEMP] SEQUENCE"
"CREATE [TEMP..] TABLE"

It is arguable that it is proper to suggest existing object for
CREATE statement, but most of the statement is suggested. It is
semantically wrong but practically useful to know what kind of
word should be there.

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Proposal: RETURNING primary_key()
Next
From: "David G. Johnston"
Date:
Subject: Re: pgbench more operators & functions