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: michael(dot)paquier(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: IF (NOT) EXISTS in psql-completion
Date: 2017-02-14 10:51:52
Message-ID: 20170214.195152.59283261.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

Thank you for the comment.

At Mon, 6 Feb 2017 17:10:43 +0100, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote in <CAFj8pRD85cnxEEgLtOoqL-Bda2XpzvHB3a6Mr+bvf+OKpiq3Eg(at)mail(dot)gmail(dot)com>
> > 0001-Refactoring-tab-complete-to-make-psql_completion-cod.patch
> > - Just a refactoring of psql_completion
> >
> > 0002-Make-keywords-case-follow-to-input.patch
> > - The letter case of additional suggestions for
> > COMPLETION_WITH_XX follows input.
> >
> > 0003-Introduce-word-shift-and-removal-feature-to-psql-com.patch
> > - A feature to ignore preceding words. And a feature to remove
> > intermediate words.
> >
> > 0004-Add-README-for-tab-completion.patch
> > - README
> >
> > 0005-Make-SET-RESET-SHOW-varialble-follow-input-letter-ca.patch
> > 0006-Allow-complete-schema-elements-in-more-natural-way.patch
> > 0007-Allow-CREATE-RULE-to-use-command-completion-recursiv.patch
> > 0008-Allow-completing-the-body-of-EXPLAIN.patch
> > 0009-Simpilfy-ALTER-TABLE-ALTER-COLUMN-completion.patch
> > 0010-Simplify-completion-for-CLUSTER-VERBOSE.patch
> > 0011-Simplify-completion-for-COPY.patch
> > 0012-Simplify-completion-for-CREATE-INDEX.patch
> > 0013-Simplify-completion-for-CREATE-SEQUENCE.patch
> > 0014-Simplify-completion-for-DROP-INDEX.patch
> > 0015-Add-CURRENT_USER-to-some-completions-of-role.patch
> > 0016-Refactor-completion-for-ALTER-DEFAULT-PRIVILEGES.patch
> > 0017-Add-suggestions-of-IF-NOT-EXISTS.patch
> > - A kind of sample refctoring (or augmenting) suggestion code
> > based on the new infrastructure.
> >
> > 0018-Debug-output-of-psql-completion.patch
> > - Debug logging for psql_completion (described above)
> >
> > 0019-Add-suggestion-of-OR-REPLACE.patch
> > - Suggestion of CREATE OR REPLACE.
> >
> >
> > # I hear the footsteps of another conflict..
> >
> The patch 0018 was not be applied.

The fear came true. fd6cd69 conflicts with it but on a
comment. The attached patch set applies on top of the current
master head (ae0e550).

> Few other notes from testing - probably these notes should not be related
> to your patch set
>
> 1. When we have set of keywords, then the upper or lower chars should to
> follow previous keyword. Is it possible? It should to have impact only on
> keywords.

It sounds reasonable, more flexible than "upper"/"lower" of
COMP_KEYWORD_CASE. The additional 20th(!) patch does that. It
adds a new value 'follow-first' to COMP_KEYWORD_CASE. All
keywords in a command line will be in the case of the first
letter of the first word. ("CREATE" in the following case. I
think it is enogh for the purpose.)

postgres=# \set COMP_KEYWORD_CASE follow-first
postgres=# CREATE in<tab>
=># CREATE INDEX hoge <tab>
=># CREATE INDEX hoge ON emp<tab>
=># CREATE INDEX hoge ON employee ..
postgres=# create IN<tab>
=># create index

Typing tab at the first in a command line shows all available
keywords in upper case.

> 2. the list of possible functions after EXECUTE PROCEDURE in CREATE TRIGGER
> statement should be reduced to trigger returns function only.

Actually Query_for_list_of_trigger_functions returns too many
candidates. The suggested restriction reduces them to a
reasonable number. The 21th patch does that.

> CREATE OR REPLACE FUNCTIONS works great, thank you!

Thanks. It was easier than expected.

As the result, 21 paches are attached to this message. 1 - 19th
are described above and others are described below.

0020-New-COMP_KEYWORD_CASE-mode-follow-first.patch

- Add new COMP_KEYWORD_CASE mode "follow-first". The completion
works with the case of the first word. (This doesn't rely on
this patchset but works in more cases with 0002)

0021-Suggest-only-trigger-functions-for-CREAET-TRIGGER.EX.patch
- Restrict suggestion for the syntax to ones acutually usable
there. (This relies on none of this patchset, though..)

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
if_not_exists_20170214.tar.gz application/octet-stream 51.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2017-02-14 11:48:41 Re: Measuring replay lag
Previous Message Dave Page 2017-02-14 10:44:04 PostgreSQL Code of Conduct Draft