pgsql: Attempt to identify system timezone by reading /etc/localtime sy

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Attempt to identify system timezone by reading /etc/localtime sy
Date: 2018-09-13 16:36:33
Message-ID: E1g0UbZ-0001qI-0h@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Attempt to identify system timezone by reading /etc/localtime symlink.

On many modern platforms, /etc/localtime is a symlink to a file within the
IANA database. Reading the symlink lets us find out the name of the system
timezone directly, without going through the brute-force search embodied in
scan_available_timezones(). This shortens the runtime of initdb by some
tens of ms, which is helpful for the buildfarm, and it also allows us to
reliably select the same zone name the system was actually configured for,
rather than possibly choosing one of IANA's many zone aliases. (For
example, in a system configured for "Asia/Tokyo", the brute-force search
would not choose that name but its alias "Japan", on the grounds of the
latter string being shorter. More surprisingly, "Navajo" is preferred
to either "America/Denver" or "US/Mountain", as seen in an old complaint
from Josh Berkus.)

If /etc/localtime doesn't exist, or isn't a symlink, or we can't make
sense of its contents, or the contents match a zone we know but that
zone doesn't match the observed behavior of localtime(), fall back to
the brute-force search.

Also, tweak initdb so that it prints the zone name it selected.

In passing, replace the last few references to the "Olson" database in
code comments with "IANA", as that's been our preferred term since
commit b2cbced9e.

Patch by me, per a suggestion from Robert Haas; review by Michael Paquier

Discussion: https://postgr.es/m/7408.1525812528@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/23bd3cec6eb1ffb80ed2601c13f89d89e658fcc1

Modified Files
--------------
src/bin/initdb/findtimezone.c | 136 ++++++++++++++++++++++++++---
src/bin/initdb/initdb.c | 8 +-
src/interfaces/ecpg/pgtypeslib/dt_common.c | 2 +-
3 files changed, 133 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2018-09-13 17:43:03 pgsql: Detect LLVM 7 without specifying binaries explicitly.
Previous Message Amit Kapila 2018-09-13 10:58:12 pgsql: Attach FPI to the first record after full_page_writes is turned