Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUTbU-0007QE-QN for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Mar 2022 13:22:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nUTbT-0003DB-2l for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Mar 2022 13:22:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUTbR-0003D2-Hw for pgsql-hackers@lists.postgresql.org; Wed, 16 Mar 2022 13:22:14 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUTbO-00073P-JF for pgsql-hackers@lists.postgresql.org; Wed, 16 Mar 2022 13:22:12 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 662535C011B for ; Wed, 16 Mar 2022 09:22:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 16 Mar 2022 09:22:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm2; bh=Z gLS2DTuI8H9kVMapSc/IoKzjx+o2iz4u8WhFBqXzz0=; b=DmJYpLvyema68IG95 i8deKJqbtLWpGrctKA99TWD0VO6BZ3OqQSX4Lp/v4Dmf/eML7Ek75oGZOCqFpoOZ TO5Ng+qRnVejuiaJBDvJJy2gq5UA3SKXOdeGVzorlPnyHhfIjIhlseTF+MxpO6u/ /iuBEshhfDk/Dre8+ZLJDEahJMVx849YKlLUQc7C/5NY221+MbJhAKcBOu9Zr362 Bh4HbrDXdgqE9tG+x2yfKfAKm5Aa9UOe6+ktxcGFz8RiD5TuzzBdsrE9EDFRFF8o 3BkKVVu084IX+XirD6H4xDYZKoLSWJQA/Y3lRUxwkPIVCjiYnXYos4OgiqZtvmFa m4wZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=ZgLS2DTuI8H9kVMapSc/IoKzjx+o2iz4u8WhFBqXz z0=; b=nGW62nNInCap26ZPDAE+DFblY4jRoNiY3gisu9rV+N4EFEq3JMhoqMxa9 cGU+VsOu/CHwLgYJfJeOEVDYI1jaJ7EDuxgq5CiLvm/vHIASg1PG5lcrcspiaYd6 SAmW+yBrBKetQq3ln+SeIQ5e84dKb5X/JikAxajvYhZEkF30VJI9bjPf4r7FjeEs f6f53MzOlFxSVuAYtN7B9iIahQh5QOoBER2Hfz4Om3QsMVlUpTE9MjgAYcxZX+OM CJcbdhkdR892oROD3jREk8g73dRP8SEkzOIsxV+xWOfoEpVE7ZikIHUYpLhKGS0R Jf+6arvWDrAxZ27M8TjZX8HXOMVmg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudefvddggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkfgggtgesmhdtreertd erjeenucfhrhhomhepffgrghhfihhnnhgpkfhlmhgrrhhipgforghnnhhsnohkvghruceo ihhlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnhepvddvvdevve fhvefgfeffvdfhheehkeeftdffffeftdejffduleevveegteetteeinecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrg hrihdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 16 Mar 2022 09:22:08 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= 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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-tab-completion-for-SET-TimeZone-TO.patch From 96ce5843641d990b278c0038f5b97941df6e73a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= 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.c index 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 --=-=-=--