Re: generate_series for timestamptz and time zone problem
| От | Przemysław Sztoch |
|---|---|
| Тема | Re: generate_series for timestamptz and time zone problem |
| Дата | |
| Msg-id | c7ca451a-0145-503a-ce43-fe9f4737f17e@sztoch.pl обсуждение исходный текст |
| Ответ на | Re: generate_series for timestamptz and time zone problem (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: generate_series for timestamptz and time zone problem
|
| Список | pgsql-hackers |
Tom Lane wrote on 31.05.2022 22:54:
1. Of course it is intentional. And usually everything works as it should.Przemysław Sztoch <przemyslaw@sztoch.pl> writes:|generate_series| ( /|start|/ |timestamp with time zone|, /|stop|/ |timestamp with time zone|, /|step|/ |interval| ) produces results depending on the timezone value set:That's intentional. If you don't want it, maybe you should be using generate_series on timestamp without time zone? regards, tom lane
But with multi-zone applications, using timestamptz generates a lot of trouble.
It would be appropriate to supplement a few functions with the possibility of specifying a zone (of course, for timestamptz variants):
- generate_series
- date_bin (additionally with support for months and years)
- timestamptz_plus_interval (the key issue is adding months and years, "+" operator only does this in the local zone)
Not everything can be solved by converting the time between timestamptz and timestamp (e.g. using the timezone function).
Daylight saving time reveals additional problems that are not visible at first glance.
Just if DST did not exist, a simple conversion (AT TIME ZONE '...') would have been enough.
Unfortunately, DST is popular and, additionally, countries modify their time zones from time to time.
2. Because I lack the necessary experience, I want to introduce changes in parts.
There is patch for first function timestamptz_plus_interval.
I don't know how to properly correct pg_proc.dat and add a variant of this function with 3 arguments now.
Please comment on the patch and provide tips for pg_proc.
If it works for me, I will improve generate_series.
--
Przemysław Sztoch | Mobile +48 509 99 00 66
Przemysław Sztoch | Mobile +48 509 99 00 66
Вложения
В списке pgsql-hackers по дате отправления: