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: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: IF (NOT) EXISTS in psql-completion
Date: 2016-09-19 04:41:08
Message-ID: CAFj8pRB6yyAQu2BuC=f1R8=FLH8iF77cnrAYOy77WACwXinPwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2016-09-16 10:31 GMT+02:00 Kyotaro HORIGUCHI <
horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>:

> Hello, this is the new version.
>
> At Tue, 13 Sep 2016 10:50:13 +0900 (Tokyo Standard Time), Kyotaro
> HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote in <
> 20160913(dot)105013(dot)65452566(dot)horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
> > > > This patch consists of the following files. Since these files are
> > > > splitted in strange criteria and order for historical reasons,
> > > > I'll reorganize this and post them later.
>
> The focus of this patch has changed. The first motivation was
> completing IF-EXISTS but the underlying issue was flexibility of
> psql_completion. And as Pavel's suggestion, keywords suggested
> along with database objects should follow the character case of
> input.
>
> For the purpose of resolving the issues, I reorganized the
> confused patch set. The attached patches are organized as the
> following.
>
> 1. Refactoring tab-complete to make psql_completion code
>
> Does two things. One is moving out the macros that has grown to
> be too large to stay in tab_completion.c to new file
> tab-complete-macros.h The other is separating out the else-if
> sequence in psql_completion() as a new function
> psql_completion_internal(). This allows us to the following
> things.
>
> - Exit from arbitrary place in the former-else-if sequence just
> by return.
>
> - Do other than "if(matching) { completion }" in anywhere
> convenient in the midst of the former-els...
>
> - Recursively matching for sub syntaxes. EXPLAIN, RULE and
> others are using this feature. (Needs the 4th patch to do
> this, though)
>
>
This first patch looks well - although it is big patch - it doesn't do any
not trivial work. No problems with a patching or compilation. I didn't find
any issue.

Regards

Pavel

> 2. Make keywords' case follow to input
>
> Allow the keywords suggested along with databse objects to
> follow the input letter case. The core part of this patch is a
> new function additional_kw_query(), which dynamically generates
> additional query string with specified keywords in the desired
> letter case. COMPLETE_WITH_* macros are modified to accept the
> function.
>
> 3. Fix suggested keywords to follow input in tab-completion session 2
>
> The 2nd patch above leaves some query string containing static
> keyword strings, which results in failure to follow input
> letter cases. Most of them are naturally removed but role names
> are a bother. This patch puts additional query strings for
> several usage of roles but it might be overdone.
>
> 4. Introduce word shift and removal feature to psql-completion
>
> This is the second core for the flexibility of completion code.
> The word shift feature is the ability to omit first several
> words in *MatchesN macros. For example this allows complete
> create-schema's schema elements in a natural code. (Currently
> those syntaxes that can be a schema elements are using
> TailMatches instead of Matches, as the result HeadMatches are
> not available there). The words removing feature is the ability
> to (desructively) clip multiple suceessive words in the
> previous_words list. This feature allows suceeding completion
> code not to care about the removed words, such like UNIQUE,
> CONCURRENTLY, VERBOSE and so on.
>
> 5. Add suggestion for IF (NOT) EXISTS for some syntaxes
>
> This adds IF (NOT) EXISTS suggestion, as a PoC. This patch no
> loger covers all adoptable syntaces since the places where more
> than boilerplating is required are omitted.
>
> regards,
>
> --
> Kyotaro Horiguchi
> NTT Open Source Software Center
>
>
>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2016-09-19 05:50:13 Re: Hash Indexes
Previous Message Dilip Kumar 2016-09-19 04:20:49 Re: Speed up Clog Access by increasing CLOG buffers