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 1nUTgD-0007aJ-MR for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Mar 2022 13:27:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nUTgC-0006Cg-Ge for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Mar 2022 13:27:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUTgC-0006CX-7r for pgsql-hackers@lists.postgresql.org; Wed, 16 Mar 2022 13:27:08 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUTg5-0001B9-Sd for pgsql-hackers@lists.postgresql.org; Wed, 16 Mar 2022 13:27:07 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E2AE05C0125 for ; Wed, 16 Mar 2022 09:26:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 16 Mar 2022 09:26:59 -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:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; bh=FSZU5VJDF75OfWUVfvq9WStGL9+P5/1xC9I5X/ YznSc=; b=Why0UNE3WDraDsDX9jNZASx+Obd5g2s3I5zc78DUllKYDWe3nLia75 xfSgqn5emkl2HlFSOMTBFNlQs+jNVTTQSN8bbDtSnQs8cOorTG6wQLoip7grmFmr dG+WsE1YOY7WN/4VZ4PAAqLvCqELj4xDlNdDHyYoMrcTYiBRZPDbS4LVPmRw14d2 RtRZcGVZPLpT5kQPAx47lPqiy6ca4v1vg6ryBH798do2AJVE3ugnB24AKE/W3WbN GseJJXvdUXqPAns/XeCREcB4tOZ4FdMQp05alZRS/2+UaA6c79iJFQXfH6sJd/5O uWyZnq9cWKT4U8qiN9S/yrhmMfDecQig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :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=FSZU5VJDF75OfWUVf vq9WStGL9+P5/1xC9I5X/YznSc=; b=k+77NnIOgOjRFKDuyoX83kmXpZJPfIH50 GAqRCi65eKhF6G89cbxVqh0oy+Ic3gOJ2cS8rITrSxiurW7I6lllryvb3SqOfRO2 jNIUgyNJJURcYLokt7Z0c15J2TOKj87xLlhMRc8fUd5IljI6T+Tl+kIgNy4N+cGl V3BGAtSdXnW3gwlqFdnxNHYySrXc5uaProz7G+2KfVQlVYUfhrbEzKiLkRLdO9Ub /jgQjzxPHRi+38zan3Uf1PQetf2yeE6xuM98XCvV6VCeHE6cWntco+Q71waAovNk ulF2WpaLpcQBoudq9GSIu+HE8ir1Ov1JK0pdDT1botkaPkZrUK2Dw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudefvddghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufhffjgfkfgggtgesmhdtre ertderjeenucfhrhhomhepffgrghhfihhnnhgpkfhlmhgrrhhipgforghnnhhsnohkvghr uceoihhlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnhepteevie ehteetleeglefghfefkeejheelledttedtgfdvkeffheffvdekheeuudffnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhisehilh hmrghrihdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 16 Mar 2022 09:26:59 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: pgsql-hackers@lists.postgresql.org Subject: Re: Tab completion for SET TimeZone References: <87k0curq0w.fsf@wibble.ilmari.org> Date: Wed, 16 Mar 2022 13:26:57 +0000 In-Reply-To: <87k0curq0w.fsf@wibble.ilmari.org> ("Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker=22's?= message of "Wed, 16 Mar 2022 13:22:07 +0000") Message-ID: <87h77yrpsu.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; charset=utf-8 Content-Transfer-Encoding: 8bit Dagfinn Ilmari Mannsåker 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v2-0001-Add-tab-completion-for-SET-TimeZone-TO.patch From bcfa40ff3a6702e1bd7112eeaecfde87efaa43c2 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 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.c index 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 --=-=-=--