From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: pgsql-hackers@lists.postgresql.org
Subject: Re: Tab completion for SET TimeZone
Date: Wed, 16 Mar 2022 13:26:57 +0000
Message-ID: <87h77yrpsu.fsf@wibble.ilmari.org> (raw)
In-Reply-To: <87k0curq0w.fsf@wibble.ilmari.org>
References: <87k0curq0w.fsf@wibble.ilmari.org>
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> writes:
> Hi hackers,
>
> I noticed there was no tab completion for time zones in psql, so here's
> a patch that implements that.
I just noticed I left out the = in the match check, here's an updated
patch that fixes that.
- ilmari
Attachments:v2-0001-Add-tab-completion-for-SET-TimeZone-TO.patch (text/x-diff, 1.5K) download
From bcfa40ff3a6702e1bd7112eeaecfde87efaa43c2 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 v2] =?UTF-8?q?Add=20tab=20completion=20for=20SET=20TimeZon?=
=?UTF-8?q?e=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..d68d001085 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: <87h77yrpsu.fsf@wibble.ilmari.org>
References: <87k0curq0w.fsf@wibble.ilmari.org> <87h77yrpsu.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