From a5536a66684b0540e223ce9a64da27e0ce43e744 Mon Sep 17 00:00:00 2001
From: Robins Tharakan <tharakan@gmail.com>
Date: Fri, 29 Nov 2024 19:05:38 +1030
Subject: [PATCH v1] Add tab completion for ALTER USER RESET

---
 src/bin/psql/tab-complete.in.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index bbd08770c3..8d60408e26 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1068,6 +1068,11 @@ Keywords_for_list_of_owner_roles, "PUBLIC"
 "   FROM pg_catalog.pg_user_mappings "\
 "  WHERE usename LIKE '%s'"
 
+#define Query_for_list_of_user_vars \
+" SELECT pg_catalog.split_part(pg_catalog.unnest(rolconfig),'=',1) "\
+"   FROM pg_catalog.pg_roles "\
+"  WHERE rolname LIKE '%s'"
+
 #define Query_for_list_of_access_methods \
 " SELECT amname "\
 "   FROM pg_catalog.pg_am "\
@@ -2467,6 +2472,10 @@ match_previous_words(int pattern_id,
 					  "RENAME TO", "REPLICATION", "RESET", "SET", "SUPERUSER",
 					  "VALID UNTIL", "WITH");
 
+	/* ALTER USER,ROLE <name> RESET */
+	else if (Matches("ALTER", "USER|ROLE", MatchAny, "RESET"))
+		COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_user_vars, "ALL");
+
 	/* ALTER USER,ROLE <name> WITH */
 	else if (Matches("ALTER", "USER|ROLE", MatchAny, "WITH"))
 		/* Similar to the above, but don't complete "WITH" again. */
-- 
2.39.5

