postgresql/src/timezone
Tom Lane 631dc390f4 Fix some odd behaviors when using a SQL-style simple GMT offset timezone.
Formerly, when using a SQL-spec timezone setting with a fixed GMT offset
(called a "brute force" timezone in the code), the session_timezone
variable was not updated to match the nominal timezone; rather, all code
was expected to ignore session_timezone if HasCTZSet was true.  This is
of course obviously fragile, though a search of the code finds only
timeofday() failing to honor the rule.  A bigger problem was that
DetermineTimeZoneOffset() supposed that if its pg_tz parameter was
pointer-equal to session_timezone, then HasCTZSet should override the
parameter.  This would cause datetime input containing an explicit zone
name to be treated as referencing the brute-force zone instead, if the
zone name happened to match the session timezone that had prevailed
before installing the brute-force zone setting (as reported in bug #8572).
The same malady could affect AT TIME ZONE operators.

To fix, set up session_timezone so that it matches the brute-force zone
specification, which we can do using the POSIX timezone definition syntax
"<abbrev>offset", and get rid of the bogus lookaside check in
DetermineTimeZoneOffset().  Aside from fixing the erroneous behavior in
datetime parsing and AT TIME ZONE, this will cause the timeofday() function
to print its result in the user-requested time zone rather than some
previously-set zone.  It might also affect results in third-party
extensions, if there are any that make use of session_timezone without
considering HasCTZSet, but in all cases the new behavior should be saner
than before.

Back-patch to all supported branches.
2013-11-01 12:13:18 -04:00
..
data Update time zone data files to tzdata release 2013d. 2013-09-02 15:06:21 -04:00
tznames Update time zone abbreviation lists for changes missed since 2006. 2013-03-23 19:17:46 -04:00
.gitignore Semi-automatically detect changes in timezone abbreviations. 2013-03-23 19:17:44 -04:00
ialloc.c
known_abbrevs.txt Update time zone abbreviation lists for changes missed since 2006. 2013-03-23 19:17:46 -04:00
localtime.c Fix edge-case behavior of pg_next_dst_boundary(). 2012-04-25 17:26:10 -04:00
Makefile Semi-automatically detect changes in timezone abbreviations. 2013-03-23 19:17:44 -04:00
pgtz.c Fix some odd behaviors when using a SQL-style simple GMT offset timezone. 2013-11-01 12:13:18 -04:00
pgtz.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
private.h
README Semi-automatically detect changes in timezone abbreviations. 2013-03-23 19:17:44 -04:00
scheck.c
strftime.c
tzfile.h
zic.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00

src/timezone/README

Timezone
========

This is a PostgreSQL adapted version of the timezone library from
http://www.iana.org/time-zones

The source code can be found at:

	ftp://ftp.iana.org/tz/releases/tzcode*.tar.gz

The code is currently synced with release 2010c.  There are many cosmetic
(and not so cosmetic) differences from the original tzcode library, but
diffs in the upstream version should usually be propagated to our version.

The data files under data/ are an exact copy of the latest data set from:

	ftp://ftp.iana.org/tz/releases/tzdata*.tar.gz

Since time zone rules change frequently in some parts of the world,
we should endeavor to update the data files before each PostgreSQL
release.

While the files under data/ can just be duplicated when updating, manual
effort is needed to update the time zone abbreviation lists under tznames/.
These need to be changed whenever new abbreviations are invented or the
UTC offset associated with an existing abbreviation changes.  To detect
if this has happened, after installing new files under data/ do
	gmake abbrevs.txt
which will produce a file showing all abbreviations that are in current
use according to the data/ files.  Compare this to known_abbrevs.txt,
which is the list that existed last time the tznames/ files were updated.
Update tznames/ as seems appropriate, then replace known_abbrevs.txt
in the same commit.

When there has been a new release of Windows (probably including Service
Packs), the list of matching timezones need to be updated. Run the
script in src/tools/win32tzlist.pl on a Windows machine running this new
release and apply any new timezones that it detects. Never remove any
mappings in case they are removed in Windows, since we still need to
match properly on the old version.