From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: pgsql-hackers@lists.postgresql.org
Subject: Tab completion for SET TimeZone
Date: Wed, 16 Mar 2022 13:22:07 +0000
Message-ID: <87k0curq0w.fsf@wibble.ilmari.org> (raw)
Hi hackers,
I noticed there was no tab completion for time zones in psql, so here's
a patch that implements that. I chose lower-casing the names since they
are case insensitive, and verbatim since ones without slashes can be
entered without quotes, and (at least my version of) readline completes
them correctly if the entered value starts with a single quote.
- ilmari
Attachments:0001-Add-tab-completion-for-SET-TimeZone-TO.patch (text/x-diff, 1.5K) download
From 96ce5843641d990b278c0038f5b97941df6e73a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Wed, 16 Mar 2022 12:52:21 +0000
Subject: [PATCH] =?UTF-8?q?Add=20tab=20completion=20for=20SET=20TimeZone?=
=?UTF-8?q?=20TO=20=E2=80=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Using verbatim and lower-case for maximum convenience.
---
src/bin/psql/tab-complete.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.cindex 17172827a9..58e62a5e6e 100644--- a/src/bin/psql/tab-complete.c+++ b/src/bin/psql/tab-complete.c@@ -1105,6 +1105,13 @@ static const SchemaQuery Query_for_trigger_of_table = {
" FROM pg_catalog.pg_cursors "\
" WHERE name LIKE '%s'"
+#define Query_for_list_of_timezones \+" SELECT name FROM ("\+" SELECT pg_catalog.lower(name) AS name "\+" FROM pg_catalog.pg_timezone_names() "\+" ) ss "\+" WHERE name LIKE '%s'"+
/*
* These object types were introduced later than our support cutoff of
* server version 9.2. We use the VersionedQuery infrastructure so that
@@ -4171,6 +4178,8 @@ psql_completion(const char *text, int start, int end)
" AND nspname NOT LIKE E'pg\\\\_temp%%'",
"DEFAULT");
}
+ else if (TailMatches("TimeZone", "TO|"))+ COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_timezones, "DEFAULT");
else
{
/* generic, type based, GUC support */
--
2.30.2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: ilmari@ilmari.org
Subject: Re: Tab completion for SET TimeZone
In-Reply-To: <87k0curq0w.fsf@wibble.ilmari.org>
References: <87k0curq0w.fsf@wibble.ilmari.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox