|From:||Przemysław Sztoch <przemyslaw(at)sztoch(dot)pl>|
|To:||Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>|
|Cc:||Pg Hackers <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: generate_series for timestamptz and time zone problem|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
Tom Lane wrote on 31.05.2022 22:54:
> =?UTF-8?Q?Przemys=c5=82aw_Sztoch?= <przemyslaw(at)sztoch(dot)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
1. Of course it is intentional. And usually everything works as it should.
But with multi-zone applications, using timestamptz generates a lot of
It would be appropriate to supplement a few functions with the
possibility of specifying a zone (of course, for timestamptz variants):
- 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
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
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
|Next Message||Tom Lane||2022-06-01 14:55:28||Re: pg_upgrade test writes to source directory|
|Previous Message||Tom Lane||2022-06-01 14:41:38||Re: funcs.sgml - wrong example|