Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qr6eO-002ZrB-Ui for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2023 01:07:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qr6eL-00CdEE-7o for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2023 01:07:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qr6eK-00CdE6-Ut for pgsql-hackers@lists.postgresql.org; Fri, 13 Oct 2023 01:07:33 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qr6eH-000DEM-Oz for pgsql-hackers@postgresql.org; Fri, 13 Oct 2023 01:07:31 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D34981C0002; Fri, 13 Oct 2023 01:07:25 +0000 (UTC) Message-ID: Date: Fri, 13 Oct 2023 03:07:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Tab completion for AT TIME ZONE Content-Language: en-US To: =?UTF-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= , Michael Paquier Cc: Jim Jones , pgsql-hackers@postgresql.org References: <87jzyzsvgv.fsf@wibble.ilmari.org> <87zg7dq96c.fsf@wibble.ilmari.org> <8f76a2e7-1ea3-76df-3176-887d94ee3aea@uni-muenster.de> <87pm86reuq.fsf@wibble.ilmari.org> <87cyxknqbd.fsf@wibble.ilmari.org> From: Vik Fearing In-Reply-To: <87cyxknqbd.fsf@wibble.ilmari.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: vik@postgresfriends.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/12/23 10:27, Dagfinn Ilmari Mannsåker wrote: > Michael Paquier writes: > >> On Fri, Apr 14, 2023 at 12:05:25PM +0200, Jim Jones wrote: >>> The patch applies cleanly and it does what it is proposing. - and it's IMHO >>> a very nice addition. >>> >>> I've marked the CF entry as "Ready for Committer". >> >> +/* ... AT TIME ZONE ... */ >> + else if (TailMatches("AT")) >> + COMPLETE_WITH("TIME ZONE"); >> + else if (TailMatches("AT", "TIME")) >> + COMPLETE_WITH("ZONE"); >> + else if (TailMatches("AT", "TIME", "ZONE")) >> + COMPLETE_WITH_TIMEZONE_NAME(); >> >> This style will for the completion of timezone values even if "AT" is >> the first word of a query. Shouldn't this be more selective by making >> sure that we are at least in the context of a SELECT query? > > It's valid anywhere an expression is, which is a lot more places than > just SELECT queries. Off the top of my head I can think of WITH, > INSERT, UPDATE, VALUES, CALL, CREATE TABLE, CREATE INDEX. > > As I mentioned upthread, the only place in the grammar where the word AT > occurs is in AT TIME ZONE, so there's no ambiguity. Also, it doesn't > complete time zone names after AT, it completes the literal words TIME > ZONE, and you have to then hit tab again to get a list of time zones. > If we (or the SQL committee) were to invent more operators that start > with the word AT, we can add those to the first if clause above and > complete with the appropriate values after each one separately. Speaking of this... The SQL committee already has another operator starting with AT which is AT LOCAL. I am implementing it in https://commitfest.postgresql.org/45/4343/ where I humbly admit that I did not think of psql tab completion at all. These two patches are co-dependent and whichever goes in first the other will need to be adjusted accordingly. -- Vik Fearing