Re: Add missing tab completion for ALTER TABLE ADD COLUMN IF NOT EXISTS

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Karina Litskevich <litskevichkarina(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add missing tab completion for ALTER TABLE ADD COLUMN IF NOT EXISTS
Date: 2024-11-07 11:42:30
Message-ID: CALdSSPiatEWDXCGz26A5dmy5mEGdUQ-zKcVKWTqFZ53fVCWnZg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, thank you for your feedback.

On Wed, 6 Nov 2024 at 20:09, Karina Litskevich
<litskevichkarina(at)gmail(dot)com> wrote:
>
> Hi Kirill,
>
> I looked through your patches. First of all, please note that TAB
> completion doesn't have to complete all valid grammatical
> constructions. See the comment on the top of tab-complete.in.c:
>
> * This file implements a somewhat more sophisticated readline "TAB
> * completion" in psql. It is not intended to be AI, to replace
> * learning SQL, or to relieve you from thinking about what you're
> * doing. Also it does not always give you all the syntactically legal
> * completions, only those that are the most common or the ones that
> * the programmer felt most like implementing.
>
> Considering this, I don't think 0001 should be accepted as is. Neither
> "IF NOT EXIST" nor "IF EXISTS" appears anywhere in tab-complete.in.c.
> Adding it for the only "ALTER TABLE ... ADD COLUMN" case doesn't seem
> right. Adding it everywhere looks like lots of work of questionable
> utility.

Ok. I dropped this patch from v4.

> 0003 looks good to me. Considering that we already have a completion of
> "CREATE TEMP TABLE ... USING" with table access methods, completion of
> "CREATE TABLE ..." with USING seems reasonable. It’s strange we didn’t
> have this before. Good catch!

Cool.

> I can't judge if 0002 adds useful completion cases, but I noticed that
> you add completion of "DROP/ADD ATTRIBUTE ..." with CASCADE/RESRTICT
> while ignoring "ALTER/RENAME ATTRIBUTE ..." that also can be followed
> by CASCADE/RESRTICT according to the documentation. Is it intentional?

v3-0002 patch actually mixes two types of completion. First one, which
adds a data type completion for ADD ATTRIBUTE, is pretty useful.
similar to existing tab completion for `ALTER TABLE xxx ADD [IF NOT
EXISTS] [COLUMN] yyy `.
The second one (CASCADE/RESTRICT) is dubious, and I'm also not sure if
we really need it, so perhaps we should wait for some other views..
For this reason, I split v3-0002 into two separate patches.

I also want to propose an Access method completion for create M.V.
<foo> using. This is a patch I forgot to attach in my last email.
Please, see v4-0004

--
Best regards,
Kirill Reshke

Attachment Content-Type Size
v4-0003-Add-missing-tab-completion-for-CREATE-TEMP-TABLE-.patch application/octet-stream 1.1 KB
v4-0001-Enhance-tab-completion-to-ALTER-TYPE-ADD-ATTRIBUT.patch application/octet-stream 1.1 KB
v4-0002-Add-CASCADE-RESRTICT-to-ALTER-TYPE-patterns.patch application/octet-stream 1.9 KB
v4-0004-Suggest-table-access-method-for-create-maateriali.patch application/octet-stream 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-11-07 12:09:53 Re: altering a column's collation leaves an invalid foreign key
Previous Message Amit Kapila 2024-11-07 11:10:51 Re: Linkify mentions of the primary/subscriber's max_replication_slots