]> granicus.if.org Git - postgresql/commit
Prefer timezone name "UTC" over alternative spellings.
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Sat, 15 Jun 2019 17:15:23 +0000 (18:15 +0100)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Sat, 15 Jun 2019 17:21:41 +0000 (18:21 +0100)
commit6335f8a999d846e5d60c9f463601b6fe80dfef34
tree976d86ed183bef85e24c4a8ec7cd56b0b9b25be5
parent77dc741a1727f16ce76dcdc6fd5c23bb8267091f
Prefer timezone name "UTC" over alternative spellings.

tzdb 2019a made "UCT" a link to the "UTC" zone rather than a separate
zone with its own abbreviation. Unfortunately, our code for choosing a
timezone in initdb has an arbitrary preference for names earlier in
the alphabet, and so it would choose the spelling "UCT" over "UTC"
when the system is running on a UTC zone.

Commit 23bd3cec6 was backpatched in order to address this issue, but
that code helps only when /etc/localtime exists as a symlink, and does
nothing to help on systems where /etc/localtime is a copy of a zone
file (as is the standard setup on FreeBSD and probably some other
platforms too) or when /etc/localtime is simply absent (giving UTC as
the default).

Accordingly, add a preference for the spelling "UTC", such that if
multiple zone names have equally good content matches, we prefer that
name before applying the existing arbitrary rules. Also add a slightly
lower preference for "Etc/UTC"; lower because that preserves the
previous behaviour of choosing the shorter name, but letting us still
choose "Etc/UTC" over "Etc/UCT" when both exist but "UTC" does
not (not common, but I've seen it happen).

Backpatch all the way, because the tzdb change that sparked this issue
is in those branches too.
src/bin/initdb/findtimezone.c