From 9aa58d48f30a0cadfc0f40aad22be91ae7f8c4a8 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 5 Oct 2022 11:46:10 +0900 Subject: [PATCH] Add a few new patterns to the tab completion of psql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/bin/psql/tab-complete.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 71cfe8aec1..584d9d5ae6 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*"))