pgsql: Prefer timezone name "UTC" over alternative spellings. - Mailing list pgsql-committers

From Andrew Gierth
Subject pgsql: Prefer timezone name "UTC" over alternative spellings.
Date
Msg-id E1hcClF-0003UX-O7@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5f5b6667ebf3ab24327ecb275167709d8d70cece

Modified Files
--------------
src/bin/initdb/findtimezone.c | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Add pg_dumpall --rows-per-insert
Next
From: Tomas Vondra
Date:
Subject: pgsql: Fix incorrect CREATE STATISTICS example in docs