aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-10-05 11:46:10 +0900
committerMichael Paquier <michael@paquier.xyz>2022-10-05 11:46:10 +0900
commit9aa58d48f30a0cadfc0f40aad22be91ae7f8c4a8 (patch)
treeae3778722dade21b4f9464c156b70d767130e1f8 /src
parentbdf9b60085bca2dbb0af920d50f1a0917dda0cbb (diff)
downloadpostgresql-9aa58d48f30a0cadfc0f40aad22be91ae7f8c4a8.tar.gz
postgresql-9aa58d48f30a0cadfc0f40aad22be91ae7f8c4a8.zip
Add a few new patterns to the tab completion of psql
This improves the tab completion of psql on a few points: - Provide a list of subscriptions on \dRs. - Provide a list of publications on \dRp. - Add CURRENT_ROLE, CURRENT_USER, SESSION_USER when OWNER TO is provided at the end of a query (as defined by RoleSpec in gram.y). Author: Vignesh C Reviewed-by: Dagfinn Ilmari Mannsåker Discussion: https://postgr.es/m/CALDaNm3toRBt6c6saY3174f7CsGztXRvVvfWbikkJEXY7x5WAA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/tab-complete.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 71cfe8aec15..584d9d5ae64 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -4160,7 +4160,10 @@ psql_completion(const char *text, int start, int end)
/* OWNER TO - complete with available roles */
else if (TailMatches("OWNER", "TO"))
- COMPLETE_WITH_QUERY(Query_for_list_of_roles);
+ COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_roles,
+ "CURRENT_ROLE",
+ "CURRENT_USER",
+ "SESSION_USER");
/* ORDER BY */
else if (TailMatches("FROM", MatchAny, "ORDER"))
@@ -4614,6 +4617,10 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_tables);
else if (TailMatchesCS("\\dP*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations);
+ else if (TailMatchesCS("\\dRp*"))
+ COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications);
+ else if (TailMatchesCS("\\dRs*"))
+ COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions);
else if (TailMatchesCS("\\ds*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences);
else if (TailMatchesCS("\\dt*"))