Re: 002_types.pl fails on some timezones on windows
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers@postgresql.org,
Peter Eisentraut <peter_e@gmx.net>,
Petr Jelinek <petr@2ndquadrant.com>
Date: 2021-09-30T20:03:15Z
Lists: pgsql-hackers
I wrote:
> ... sure enough, 002_types.pl
> falls over with TZ=Africa/Casablanca on my Linux machine, too.
Independently of whether Africa/Casablanca is a sane translation of
that Windows zone name, it'd be nice if 002_types.pl weren't so
sensitive to the prevailing zone. I looked into exactly why it's
falling over, and the answer seems to be this bit:
(2, tstzrange('Mon Aug 04 00:00:00 2014 CEST'::timestamptz - interval '2 days', 'Mon Aug 04 00:00:00 2014 CEST'::timestamptz), '{"[2,3]", "[20,30]"}'),
(3, tstzrange('Mon Aug 04 00:00:00 2014 CEST'::timestamptz - interval '3 days', 'Mon Aug 04 00:00:00 2014 CEST'::timestamptz), '{"[3,4]"}'),
(4, tstzrange('Mon Aug 04 00:00:00 2014 CEST'::timestamptz - interval '4 days', 'Mon Aug 04 00:00:00 2014 CEST'::timestamptz), '{"[4,5]", NULL, "[40,50]"}'),
The problem with this is the blithe assumption that "minus N days"
is an immutable computation. It ain't. As bad luck would have it,
these intervals all manage to cross a Moroccan DST boundary
(Ramadan, I assume):
Rule Morocco 2014 only - Jun 28 3:00 0 -
Rule Morocco 2014 only - Aug 2 2:00 1:00 -
Thus, in GMT or most other zones, we get 24-hour-spaced times of day for
these calculations:
regression=# set timezone to 'GMT';
SET
regression=# select n, 'Mon Aug 04 00:00:00 2014 CEST'::timestamptz - n * interval '1 day' from generate_series(0,4) n;
n | ?column?
---+------------------------
0 | 2014-08-03 22:00:00+00
1 | 2014-08-02 22:00:00+00
2 | 2014-08-01 22:00:00+00
3 | 2014-07-31 22:00:00+00
4 | 2014-07-30 22:00:00+00
(5 rows)
but not so much in Morocco:
regression=# set timezone to 'Africa/Casablanca';
SET
regression=# select n, 'Mon Aug 04 00:00:00 2014 CEST'::timestamptz - n * interval '1 day' from generate_series(0,4) n;
n | ?column?
---+------------------------
0 | 2014-08-03 23:00:00+01
1 | 2014-08-02 23:00:00+01
2 | 2014-08-01 23:00:00+00
3 | 2014-07-31 23:00:00+00
4 | 2014-07-30 23:00:00+00
(5 rows)
What I'm inclined to do about that is get rid of the totally-irrelevant-
to-this-test interval subtractions, and just write the desired timestamps
as constants.
regards, tom lane
Commits
-
Doc: improve timezone/README's recipe for tracking Windows zones.
- db692b0c8490 15.0 landed
-
Update our mapping of Windows time zone names some more.
- c1aa3b3c0d21 15.0 landed
- d0b0b70dc2a6 11.14 landed
- cd2479142588 10.19 landed
- c53ff69e1fd2 13.5 landed
- b5f34ae08ad2 9.6.24 landed
- 919c08d909f7 14.1 landed
- 07873a5dc925 12.9 landed
-
Update our mapping of Windows time zone names using CLDR info.
- dbec5a2fea4d 9.6.24 landed
- e323630cdd3c 10.19 landed
- 9cc919b51855 11.14 landed
- e5b25f19b37b 12.9 landed
- 9c76689de442 13.5 landed
- fa8db48791c5 14.1 landed
- 9b8d68cc6589 15.0 landed
-
Re-alphabetize the win32_tzmap[] array.
- 37cbe0f79129 9.6.24 landed
- cb0799db0d8e 10.19 landed
- bb6d426699a6 11.14 landed
- 4721e8aa6223 12.9 landed
- 7ba8eb81f6b7 13.5 landed
- 81464999bc92 14.1 landed
- ad740067aea5 15.0 landed
-
Remove gratuitous environment dependency in 002_types.pl test.
- d30d8257ec74 10.19 landed
- b46710dadf0c 11.14 landed
- f2cf745a038c 12.9 landed
- 649e561f65c5 13.5 landed
- afc6081f6ea8 14.1 landed
- 20f8671ef69b 15.0 landed