Re: Simplifying timezone support

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Simplifying timezone support
Date: 2003-05-18 01:20:44
Message-ID: 19776.1053220844@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Awhile back, "Ross J. Reedstrom" <reedstrm(at)rice(dot)edu> wrote:
> Second solution - try tzset() first, and apply the following heuristic
> to see if it took:
> tzname[0]==$TZ and tzname[1]=="" and timezone=0 and daylight=0

I finally went back to look at this issue, and soon realized that the
above test is in fact glibc-specific. Other implementations of tzset()
may act differently. On HPUX, tzset() appears to adopt the system-wide
setting (from /etc/zoneinfo/localtime) if TZ contains a garbage string.
And yet, that's a better fallback behavior than adopting GMT.

I have applied a patch that just checks for tzname[1] not empty or
timezone != 0; either one means that tzset was able to interpret TZ as a
non-GMT zone (or that it gave up and reverted to a non-GMT default zone,
which we can't distinguish anyway). Failing that, it looks to see if
the string is known as a GMT equivalent to DecodeTimezone. If not, it
complains.

I did not include Ross' idea of accepting other zone names known to
DecodeTimezone as if they were a numeric-offset value. We could still
do that if people like it, but it seemed a bigger change in behavior
than just trying to check that tzset() worked.

I also added code that detects and rejects a leap-second-aware timezone
definition, since we've now seen a couple different reports of systems
where such zones seem to be installed by default, leading to breakage
of our date/time arithmetic.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2003-05-18 01:31:54 Re: Feature suggestions (long)
Previous Message Tom Lane 2003-05-18 01:06:26 pgsql-server/src backend/commands/variable.c b ...

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2003-05-18 14:15:26 Re: Win32 patch to allow compilation
Previous Message Alvaro Herrera 2003-05-17 23:14:25 Re: Static snapshot data