pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Michael Paquier <michael@paquier.xyz>
Cc: Jim Jones <jim.jones@uni-muenster.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Tab completion for AT TIME ZONE
Date: Thu, 12 Oct 2023 10:27:34 +0100
Message-ID: <87cyxknqbd.fsf@wibble.ilmari.org> (raw)
In-Reply-To: <ZSeXD_iCAXusVD5k@paquier.xyz>
References: <87jzyzsvgv.fsf@wibble.ilmari.org>
	<87zg7dq96c.fsf@wibble.ilmari.org>
	<8f76a2e7-1ea3-76df-3176-887d94ee3aea@uni-muenster.de>
	<87pm86reuq.fsf@wibble.ilmari.org>
	<e88d2f9a-42ba-c19f-cfa1-28731ab4396a@uni-muenster.de>
	<ZSeXD_iCAXusVD5k@paquier.xyz>

Michael Paquier <michael@paquier.xyz> 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.

- ilmari





view thread (12+ messages)  latest in thread

Message-ID: <87cyxknqbd.fsf@wibble.ilmari.org>
Permalink:  ../87cyxknqbd.fsf@wibble.ilmari.org/
Also on:    postgresql.org/message-id/87cyxknqbd.fsf@wibble.ilmari.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ilmari@ilmari.org, michael@paquier.xyz, jim.jones@uni-muenster.de
  Subject: Re: Tab completion for AT TIME ZONE
  In-Reply-To: <87cyxknqbd.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