Undocumented AT TIME ZONE INTERVAL syntax
От | Corey Huinker |
---|---|
Тема | Undocumented AT TIME ZONE INTERVAL syntax |
Дата | |
Msg-id | CADkLM=cP+gVDwbQ9K-r9=6Nd2ThiareqhZYo71ZEK6CK1n6mrg@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Undocumented AT TIME ZONE INTERVAL syntax
|
Список | 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)
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)
> 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)
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 по дате отправления: