Re: IF (NOT) EXISTS in psql-completion

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: pavel(dot)stehule(at)gmail(dot)com
Cc: david(at)pgmasters(dot)net, peter_e(at)gmx(dot)net, pgsql-hackers(at)postgresql(dot)org
Subject: Re: IF (NOT) EXISTS in psql-completion
Date: 2016-04-04 05:58:43
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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(dot)stehule(at)gmail(dot)com> wrote in <CAFj8pRADF3rmQ3y33aeR1C7wOi2QsS65C8bBtiRNqU0zWVWayg(at)mail(dot)gmail(dot)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,

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.


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.


Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
0001-Suggest-IF-NOT-EXISTS-for-tab-completion-of-psql.patch text/x-patch 45.4 KB
0002-Make-added-keywords-for-completion-queries-follow-to.patch text/x-patch 24.3 KB
0003-Make-COMPLETE_WITH_ATTR-to-accept-additional-keyword.patch text/x-patch 64.4 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2016-04-04 06:05:40 Re: pgbench more operators & functions
Previous Message David G. Johnston 2016-04-04 05:52:12 Re: Proposal: RETURNING primary_key()