Skip to content

Commit dcf5d7f

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 b994acf commit dcf5d7f

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
@@ -1426,6 +1426,10 @@ psql_completion(const char *text, int start, int end)
14261426
COMPLETE_WITH_LIST(list_ALTERMATVIEW);
14271427
}
14281428

1429+
/* ALTER POLICY <name> */
1430+
else if (pg_strcasecmp(prev2_wd, "ALTER") == 0 &&
1431+
pg_strcasecmp(prev_wd, "POLICY") == 0)
1432+
COMPLETE_WITH_QUERY(Query_for_list_of_policies);
14291433
/* ALTER POLICY <name> ON */
14301434
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
14311435
pg_strcasecmp(prev2_wd, "POLICY") == 0)
@@ -1434,7 +1438,10 @@ psql_completion(const char *text, int start, int end)
14341438
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
14351439
pg_strcasecmp(prev3_wd, "POLICY") == 0 &&
14361440
pg_strcasecmp(prev_wd, "ON") == 0)
1437-
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
1441+
{
1442+
completion_info_charp = prev2_wd;
1443+
COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_policy);
1444+
}
14381445
/* ALTER POLICY <name> ON <table> - show options */
14391446
else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
14401447
pg_strcasecmp(prev4_wd, "POLICY") == 0 &&

0 commit comments

Comments
 (0)