Undocumented AT TIME ZONE INTERVAL syntax - Mailing list pgsql-hackers

From Corey Huinker
Subject Undocumented AT TIME ZONE INTERVAL syntax
Date
Msg-id CADkLM=cP+gVDwbQ9K-r9=6Nd2ThiareqhZYo71ZEK6CK1n6mrg@mail.gmail.com
Whole thread Raw
Responses Re: Undocumented AT TIME ZONE INTERVAL syntax
List pgsql-hackers

In reviewing Paul's application period patch, I noticed some very curious syntax in the test cases. I learned that Paul is equally confused by it, and has asked about it in his PgCon 2020 presentation

> SELECT '2018-03-04' AT TIME ZONE INTERVAL '2' HOUR TO MINUTE;
      timezone      
---------------------
 2018-03-04 05:02:00
(1 row)

Searching around, I found several instances of this syntax being used [1][2][3], but with one important clarifying difference: the expected syntax was

> SELECT '2018-03-04' AT TIME ZONE INTERVAL '2:00' HOUR TO MINUTE;
      timezone      
---------------------
 2018-03-04 07:00:00
(1 row)

Now I understand that the user probably meant to do this:

# SELECT '2018-03-04' AT TIME ZONE INTERVAL '2' HOUR;
      timezone      
---------------------
 2018-03-04 07:00:00
(1 row)


But none of this is in our own documentation.

Before I write a patch to add this to the documentation, I'm curious what level of sloppiness we should tolerate in the interval calculation. Should we enforce the time string to actually conform to the format laid out in the X TO Y spec? If we don't require that, is it correct to say that the values will be filled from order of least significance to greatest?

pgsql-hackers by date:

Previous
From: Corey Huinker
Date:
Subject: Re: SQL:2011 application time
Next
From: DEVOPS_WwIT
Date:
Subject: Re: So, about that cast-to-typmod-minus-one business