TAB completion for ALTER TABLE ... ALTER CONSTRAINT ... ENFORCED

Поиск
Список
Период
Сортировка
Искать

TAB completion for ALTER TABLE ... ALTER CONSTRAINT ... ENFORCED

От:
Kirill Reshke <reshkekirill@gmail.com>
Дата:
Вложения:
Hi hackers!

While looking at [0] I noticed that  current psql tab-complete lacks support for

ALTER TABLE ... ALTER CONSTRAINT ... [NOT] ENFORCED and

ALTER TABLE ... ALTER CONSTRAINT ... [NO] INHERIT

patterns.

I do understand that the psql tab complete feature is not designed for
full PostgreSQL's grammar support, yet this particular case is
relatively simple to support. So, should we add this feature?

Please let me know your thoughts.


[0] https://www.postgresql.org/message-id/CACJufxFY%3DGkptsiH8X%3DVdyYAnNE_%3Du5j6WyDufTste6CuzRvnw%40mail.gmail.com


-- 
Best regards,
Kirill Reshke

Re: TAB completion for ALTER TABLE ... ALTER CONSTRAINT ... ENFORCED

От:
Roman Khapov <rkhapov@yandex-team.ru>
Дата:
Вложения:


> On 11 Aug 2025, at 18:20, Kirill Reshke  wrote:
> 
> Hi hackers!
> 
> While looking at [0] I noticed that  current psql tab-complete lacks support for
> 
> ALTER TABLE ... ALTER CONSTRAINT ... [NOT] ENFORCED and
> 
> ALTER TABLE ... ALTER CONSTRAINT ... [NO] INHERIT
> 
> patterns.

Hi!

> COMPLETE_WITH("ENFORCED", "NOT ENFORCED", "NO INHERIT", "INHERIT");

According to gram.y there might be DEFERRABLE and NOT DEFERRABLE, INITIALLY IMMEDIATE and INITIALLY DEFERRED (NOT VALID is acceptable by rules but not by the action)

Maybe we can add them too? If so, i attached v2 patch with this options added.

--
Best regards,
Roman Khapov



Re: TAB completion for ALTER TABLE ... ALTER CONSTRAINT ... ENFORCED

От:
Kirill Reshke <reshkekirill@gmail.com>
Дата:
Вложения:
On Mon, 29 Dec 2025 at 20:13, Roman Khapov  wrote:
>
>
>
> > On 11 Aug 2025, at 18:20, Kirill Reshke  wrote:
> >
> > Hi hackers!
> >
> > While looking at [0] I noticed that  current psql tab-complete lacks support for
> >
> > ALTER TABLE ... ALTER CONSTRAINT ... [NOT] ENFORCED and
> >
> > ALTER TABLE ... ALTER CONSTRAINT ... [NO] INHERIT
> >
> > patterns.
>
> Hi!
>
> > COMPLETE_WITH("ENFORCED", "NOT ENFORCED", "NO INHERIT", "INHERIT");
>
> According to gram.y there might be DEFERRABLE and NOT DEFERRABLE, INITIALLY IMMEDIATE and INITIALLY DEFERRED (NOT VALID is acceptable by rules but not by the action)
>
> Maybe we can add them too? If so, i attached v2 patch with this options added.
>
> --
> Best regards,
> Roman Khapov
>
>
>


Thanks. PFA v3 with commit msg polishing, and added support for NOT -
statement patterns.

        }
+       /* if we have ALTER TABLE  ALTER|DROP|RENAME CONSTRAINT
 NOT, provide DEFERRABLE or ENFORCED */
+       else if (Matches("ALTER", "TABLE", MatchAny,
"ALTER|DROP|RENAME", "CONSTRAINT", MatchAny, "NOT"))
+       {
+               COMPLETE_WITH("DEFERRABLE", "ENFORCED");
+       }
        /* ALTER TABLE  VALIDATE CONSTRAINT  */
        else if (Matches("ALTER", "TABLE", MatchAny, "VALIDATE", "CONSTRAINT"))
        {


-- 
Best regards,
Kirill Reshke
FAQ