1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Arrange to install a "posixrules" entry in our timezone database, so that

POSIX-style timezone specs that don't exactly match any database entry will
be treated as having correct USA DST rules.  Also, document that this can
be changed if you want to use some other DST rules with a POSIX zone spec.

We could consider changing localtime.c's TZDEFRULESTRING, but since that
facility can only deal with one DST transition rule, it seems fairly useless
now; might as well just plan to override it using a "posixrules" entry.

Backpatch as far as 8.0.  There isn't much we can do in 7.x ... either your
libc gets it right, or it doesn't.
This commit is contained in:
Tom Lane
2007-03-14 17:38:22 +00:00
parent 3cda014bf4
commit 45ca0be21b
2 changed files with 29 additions and 16 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/datetime.sgml,v 2.47 2005/09/09 02:31:48 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/datetime.sgml,v 2.47.2.1 2007/03/14 17:38:21 tgl Exp $
--> -->
<appendix id="datetime-appendix"> <appendix id="datetime-appendix">
@ -2230,24 +2230,33 @@ $PostgreSQL: pgsql/doc/src/sgml/datetime.sgml,v 2.47 2005/09/09 02:31:48 tgl Exp
<para> <para>
In addition to the names listed in the table, In addition to the names listed in the table,
<productname>PostgreSQL</productname> will accept time zone names of the <productname>PostgreSQL</productname> will accept POSIX-style time zone
form <replaceable>STD</><replaceable>offset</> or specifications of the form <replaceable>STD</><replaceable>offset</> or
<replaceable>STD</><replaceable>offset</><replaceable>DST</>, where <replaceable>STD</><replaceable>offset</><replaceable>DST</>, where
<replaceable>STD</> is a zone abbreviation, <replaceable>offset</> is a <replaceable>STD</> is a zone abbreviation, <replaceable>offset</> is a
numeric offset in hours west from UTC, and <replaceable>DST</> is an numeric offset in hours west from UTC, and <replaceable>DST</> is an
optional daylight-savings zone abbreviation, assumed to stand for one hour optional daylight-savings zone abbreviation, assumed to stand for one
ahead of the given offset. For example, if <literal>EST5EDT</> were not hour ahead of the given offset. For example, if <literal>EST5EDT</>
already a recognized zone name, it would be accepted and would be were not already a recognized zone name, it would be accepted and would
functionally equivalent to USA East Coast time. When a daylight-savings be functionally equivalent to USA East Coast time. When a
zone name is present, it is assumed to be used according to USA time zone daylight-savings zone name is present, it is assumed to be used
rules, so this feature is of limited use outside North America. according to the same daylight-savings transition rules used in the
One should also be wary that this provision can lead to <literal>zic</> time zone database's <filename>posixrules</> entry.
silently accepting bogus input, since there is no check on the In a standard <productname>PostgreSQL</productname> installation,
reasonableness of the zone abbreviations. For example, <filename>posixrules</> is the same as <literal>US/Eastern</>, so
<literal>SET TIMEZONE TO FOOBAR0</> will work, leaving the system that POSIX-style time zone specifications follow USA daylight-savings
effectively using a rather peculiar abbreviation for GMT. rules. If needed, you can adjust this behavior by replacing the
<filename>posixrules</> file.
</para> </para>
<para>
One should be wary that the POSIX-style time zone feature can
lead to silently accepting bogus input, since there is no check on the
reasonableness of the zone abbreviations. For example, <literal>SET
TIMEZONE TO FOOBAR0</> will work, leaving the system effectively using
a rather peculiar abbreviation for UTC.
</para>
</sect1> </sect1>
<sect1 id="datetime-units-history"> <sect1 id="datetime-units-history">

View File

@ -4,7 +4,7 @@
# Makefile for the timezone library # Makefile for the timezone library
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/timezone/Makefile,v 1.22 2005/07/06 21:40:09 momjian Exp $ # $PostgreSQL: pgsql/src/timezone/Makefile,v 1.22.2.1 2007/03/14 17:38:22 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -25,6 +25,10 @@ TZDATA := africa antarctica asia australasia europe northamerica southamerica \
pacificnew etcetera factory backward systemv solar87 solar88 solar89 pacificnew etcetera factory backward systemv solar87 solar88 solar89
TZDATAFILES := $(TZDATA:%=$(srcdir)/data/%) TZDATAFILES := $(TZDATA:%=$(srcdir)/data/%)
# which zone should determine the DST rules (not the specific UTC offset!)
# for POSIX-style timezone specs
POSIXRULES = US/Eastern
all: SUBSYS.o submake-libpgport zic all: SUBSYS.o submake-libpgport zic
SUBSYS.o: $(OBJS) SUBSYS.o: $(OBJS)
@ -34,7 +38,7 @@ zic: $(ZICOBJS)
$(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs
./zic -d $(DESTDIR)$(datadir)/timezone $(TZDATAFILES) ./zic -d $(DESTDIR)$(datadir)/timezone -p $(POSIXRULES) $(TZDATAFILES)
installdirs: installdirs:
$(mkinstalldirs) $(DESTDIR)$(datadir) $(mkinstalldirs) $(DESTDIR)$(datadir)