Simplifying timezone support

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Cc: "Robert Haas" <Robert(dot)Haas(at)tekconnect(dot)com>
Subject: Simplifying timezone support
Date: 2003-02-20 03:35:58
Message-ID: 16783.1045712158@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

While looking at this recent bug report (which still fails in CVS tip)
http://archives.postgresql.org/pgsql-bugs/2003-02/msg00094.php
I realized that the code paths that putatively exist for machines
with neither HAVE_TM_ZONE nor HAVE_INT_TIMEZONE have gone unused
since at least 6.5. Proof is that abstime2tm() doesn't even compile
in that code path (it has a reference to an undefined variable "now").

Since we evidently have no supported platforms that have neither method
of learning the timezone, I propose that we stop contorting the code
with the illusion that we can handle this case reasonably. We can
easily set it up so that we just default to GMT when neither config
symbol is defined.

The reason I want to do this is to remove the dependency on
system-supplied values of CTimeZone and CTZName. CTZName can go
away altogether (ditto CDayLight), and CTimeZone will only be used
when the user explicitly sets a timezone as a numeric offset from
GMT (ie, the HasCTZSet paths). This will save cycles during every
transaction start, where we currently expend time setting these values
(see GetCurrentAbsoluteTimeUsec). And it will fix the above-mentioned
bug, which exists because CTimeZone is set at transaction start and not
updated by a later SET TIMEZONE command.

The bug could be fixed, sort of, by calling GetCurrentAbsoluteTimeUsec
again after executing SET TIMEZONE. But there is a variant scenario
where the same bug exists: if there has been a daylight-savings
transition since the current transaction started, we'll still get the
wrong answers. So trying to make CTimeZone track the current timezone
correctly seems doomed to failure anyhow.

Any objections?

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jordan Henderson 2003-02-20 03:41:33 Re: request for sql3 compliance for the update command
Previous Message Gavin Sherry 2003-02-20 03:32:49 Re: request for sql3 compliance for the update command

Browse pgsql-patches by date

  From Date Subject
Next Message Ross J. Reedstrom 2003-02-20 19:34:53 Re: Simplifying timezone support
Previous Message Steven Singer 2003-02-20 03:05:02 contrib/dbmirror