Skip to content

Commit 8b469bd

Browse files
committed
Improve ALTER POLICY tab completion.
Complete "ALTER POLICY" with a policy name, as we do for DROP POLICY. And, complete "ALTER POLICY polname ON" with a table name that has such a policy, as we do for DROP POLICY, rather than with any table name at all. Masahiko Sawada
1 parent 348bcd8 commit 8b469bd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/psql/tab-complete.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,10 @@ psql_completion(const char *text, int start, int end)
14591459
COMPLETE_WITH_LIST(list_ALTERMATVIEW);
14601460
}
14611461

1462+
/* ALTER POLICY <name> */
1463+
else if (pg_strcasecmp(prev2_wd, "ALTER") == 0 &&
1464+
pg_strcasecmp(prev_wd, "POLICY") == 0)
1465+
COMPLETE_WITH_QUERY(Query_for_list_of_policies);
14621466
/* ALTER POLICY <name> ON */
14631467
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
14641468
pg_strcasecmp(prev2_wd, "POLICY") == 0)
@@ -1467,7 +1471,10 @@ psql_completion(const char *text, int start, int end)
14671471
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
14681472
pg_strcasecmp(prev3_wd, "POLICY") == 0 &&
14691473
pg_strcasecmp(prev_wd, "ON") == 0)
1470-
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
1474+
{
1475+
completion_info_charp = prev2_wd;
1476+
COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_policy);
1477+
}
14711478
/* ALTER POLICY <name> ON <table> - show options */
14721479
else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
14731480
pg_strcasecmp(prev4_wd, "POLICY") == 0 &&

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy