Re: [PATCH] psql: Add tab-complete for optional view parameters

From: David Zhang <david(dot)zhang(at)highgo(dot)ca>
To: Christoph Heiss <christoph(at)c8h4(dot)io>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Mikhail Gribkov <youzhick(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] psql: Add tab-complete for optional view parameters
Date: 2023-08-11 19:48:17
Message-ID: 0e527af2-6b4e-25f3-59d0-f1b581ee48be@highgo.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Applied v3 patch to master and verified it with below commands,

#Alter view

postgres=# alter view v <tab>
ALTER COLUMN  OWNER TO      RENAME        RESET (       SET

postgres=# alter view v set <tab>
(       SCHEMA

postgres=# alter view v set ( <tab>
CHECK_OPTION      SECURITY_BARRIER  SECURITY_INVOKER

postgres=# alter view v reset ( <tab>
CHECK_OPTION      SECURITY_BARRIER  SECURITY_INVOKER

postgres=# alter view v set ( check_option = <tab>
CASCADED  LOCAL

postgres=# alter view v set ( security_barrier = <tab>
FALSE  TRUE

postgres=# alter view v set ( security_invoker = <tab>
FALSE  TRUE

#Create view

postgres=# create view v
AS      WITH (
postgres=# create or replace view v
AS      WITH (

postgres=# create view v with (
CHECK_OPTION      SECURITY_BARRIER  SECURITY_INVOKER

postgres=# create or replace view v with (
CHECK_OPTION      SECURITY_BARRIER  SECURITY_INVOKER

postgres=# create view v with (*)<tab>AS
postgres=# create or replace view v with (*)<tab>AS

postgres=# create view v as <tab>SELECT
postgres=# create or replace view v as <tab>SELECT

For below changes,

     else if (TailMatches("CREATE", "VIEW", MatchAny, "AS") ||
-             TailMatches("CREATE", "OR", "REPLACE", "VIEW", MatchAny,
"AS"))
+             TailMatches("CREATE", "VIEW", MatchAny, "WITH", "(*)",
"AS") ||
+             TailMatches("CREATE", "OR", "REPLACE", "VIEW", MatchAny,
"AS") ||
+             TailMatches("CREATE", "OR", "REPLACE", "VIEW", MatchAny,
"WITH", "(*)", "AS"))

it would be great to switch the order of the 3rd and the 4th line to
make a better match for "CREATE" and "CREATE OR REPLACE" .

Since it supports <tab> in the middle for below case,
postgres=# alter view v set ( security_<tab>
security_barrier  security_invoker

and during view reset it can also provide all the options list,
postgres=# alter view v reset (
CHECK_OPTION      SECURITY_BARRIER  SECURITY_INVOKER

but not sure if it is a good idea or possible to autocomplete the reset
options after seeing one of the options showing up with "," for example,
postgres=# alter view v reset ( CHECK_OPTION, <tab>
SECURITY_BARRIER  SECURITY_INVOKER

Thank you,

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2023-08-11 19:51:09 Re: walsender "wakeup storm" on PG16, likely because of bc971f4025c (Optimize walsender wake up logic using condition variables)
Previous Message Andres Freund 2023-08-11 19:26:17 Re: AssertLog instead of Assert in some places