1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Don't require dynamic timezone abbreviations to match underlying time zone.

Previously, we threw an error if a dynamic timezone abbreviation did not
match any abbreviation recorded in the referenced IANA time zone entry.
That seemed like a good consistency check at the time, but it turns out
that a number of the abbreviations in the IANA database are things that
Olson and crew made up out of whole cloth.  Their current policy is to
remove such names in favor of using simple numeric offsets.  Perhaps
unsurprisingly, a lot of these made-up abbreviations have varied in meaning
over time, which meant that our commit b2cbced9e and later changes made
them into dynamic abbreviations.  So with newer IANA database versions
that don't mention these abbreviations at all, we fail, as reported in bug
#14307 from Neil Anderson.  It's worse than just a few unused-in-the-wild
abbreviations not working, because the pg_timezone_abbrevs view stops
working altogether (since its underlying function tries to compute the
whole view result in one call).

We considered deleting these abbreviations from our abbreviations list, but
the problem with that is that we can't stay ahead of possible future IANA
changes.  Instead, let's leave the abbreviations list alone, and treat any
"orphaned" dynamic abbreviation as just meaning the referenced time zone.
It will behave a bit differently than it used to, in that you can't any
longer override the zone's standard vs. daylight rule by using the "wrong"
abbreviation of a pair, but that's better than failing entirely.  (Also,
this solution can be interpreted as adding a small new feature, which is
that any abbreviation a user wants can be defined as referencing a time
zone name.)

Back-patch to all supported branches, since this problem affects all
of them when using tzdata 2016f or newer.

Report: <20160902031551.15674.67337@wrigleys.postgresql.org>
Discussion: <6189.1472820913@sss.pgh.pa.us>
This commit is contained in:
Tom Lane
2016-09-02 17:29:32 -04:00
parent 949878126e
commit ee78d48853
5 changed files with 132 additions and 32 deletions

View File

@ -8977,6 +8977,13 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
</tgroup>
</table>
<para>
While most timezone abbreviations represent fixed offsets from UTC,
there are some that have historically varied in value
(see <xref linkend="datetime-config-files"> for more information).
In such cases this view presents their current meaning.
</para>
</sect1>
<sect1 id="view-pg-timezone-names">

View File

@ -384,19 +384,38 @@
<para>
A <replaceable>zone_abbreviation</replaceable> is just the abbreviation
being defined. The <replaceable>offset</replaceable> is the equivalent
offset in seconds from UTC, positive being east from Greenwich and
negative being west. For example, -18000 would be five hours west
of Greenwich, or North American east coast standard time. <literal>D</>
indicates that the zone name represents local daylight-savings time rather
than standard time. Alternatively, a <replaceable>time_zone_name</> can
be given, in which case that time zone definition is consulted, and the
abbreviation's meaning in that zone is used. This alternative is
recommended only for abbreviations whose meaning has historically varied,
as looking up the meaning is noticeably more expensive than just using
a fixed integer value.
being defined. An <replaceable>offset</replaceable> is an integer giving
the equivalent offset in seconds from UTC, positive being east from
Greenwich and negative being west. For example, -18000 would be five
hours west of Greenwich, or North American east coast standard time.
<literal>D</> indicates that the zone name represents local
daylight-savings time rather than standard time.
</para>
<para>
Alternatively, a <replaceable>time_zone_name</> can be given, referencing
a zone name defined in the IANA timezone database. The zone's definition
is consulted to see whether the abbreviation is or has been in use in
that zone, and if so, the appropriate meaning is used &mdash; that is,
the meaning that was currently in use at the timestamp whose value is
being determined, or the meaning in use immediately before that if it
wasn't current at that time, or the oldest meaning if it was used only
after that time. This behavior is essential for dealing with
abbreviations whose meaning has historically varied. It is also allowed
to define an abbreviation in terms of a zone name in which that
abbreviation does not appear; then using the abbreviation is just
equivalent to writing out the zone name.
</para>
<tip>
<para>
Using a simple integer <replaceable>offset</replaceable> is preferred
when defining an abbreviation whose offset from UTC has never changed,
as such abbreviations are much cheaper to process than those that
require consulting a time zone definition.
</para>
</tip>
<para>
The <literal>@INCLUDE</> syntax allows inclusion of another file in the
<filename>.../share/timezonesets/</> directory. Inclusion can be nested,