Hi all, I have written a small patch to improve psql autocompletion for SET LOCAL / SET SESSION, which did not show any autocompletion options before. The patch implements the autocompletion changes to show the standard list of set vars, plus the special options TIME ZONE, SCHEMA, and NAMES.
Thanks, Álvaro Rodríguez
From 20f863211297ed432392ebfad80f2edf0ae01240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Rodr=C3=ADguez?= <[email protected]> Date: Thu, 26 Mar 2026 14:53:07 +0100 Subject: Add SET LOCAL and SET SESSION to tab completion in PSQL This commit adds autocompletion options for SET LOCAL and SET SESSION. The options provided are all the SET variables for the given session, plus "TIME ZONE", "SCHEMA" and "NAMES" for the special syntax for those options. --- src/bin/psql/tab-complete.in.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 523d3f39fc5..7842fe9a284 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5266,6 +5266,13 @@ match_previous_words(int pattern_id, "ROLE", "TABLESPACE", "ALL"); + /* Complete "SET LOCAL" or "SET SESSION" */ + else if (Matches("SET", "LOCAL") || + Matches("SET", "SESSION")) + COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_set_vars, + "TIME ZONE", + "SCHEMA", + "NAMES"); else if (Matches("SHOW")) COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_show_vars, "SESSION AUTHORIZATION", -- 2.52.0
