From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Seek zone abbreviations in the IANA data before timezone_abbrevi
Date: Thu, 16 Jan 2025 19:11:49 +0000
Message-ID: <E1tYVHR-001xWD-Dw@gemulon.postgresql.org> (raw)
Seek zone abbreviations in the IANA data before timezone_abbreviations.
If a time zone abbreviation used in datetime input is defined in
the currently active timezone, use that definition in preference
to looking in the timezone_abbreviations list. That allows us to
correctly handle abbreviations that have different meanings in
different timezones. Also, it eliminates an inconsistency between
datetime input and datetime output: the non-ISO datestyles for
timestamptz have always printed abbreviations taken from the IANA
data, not from timezone_abbreviations. Before this fix, it was
possible to demonstrate cases where casting a timestamp to text
and back fails or changes the value significantly because of that
inconsistency.
While this change removes the ability to override the IANA data about
an abbreviation known in the current zone, it's not clear that there's
any real use-case for doing so. But it is clear that this makes life
a lot easier for dealing with abbreviations that have conflicts across
different time zones.
Also update the pg_timezone_abbrevs view to report abbreviations
that are recognized via the IANA data, and *not* report any
timezone_abbreviations entries that are thereby overridden.
Under the hood, there are now two SRFs, one that pulls the IANA
data and one that pulls timezone_abbreviations entries. They're
combined by logic in the view. This approach was useful for
debugging (since the functions can be called on their own).
While I don't intend to document the functions explicitly,
they might be useful to call directly.
Also improve DecodeTimezoneAbbrev's caching logic so that it can
cache zone abbreviations found in the IANA data. Without that,
this patch would have caused a noticeable degradation of the
runtime of timestamptz_in.
Per report from Aleksander Alekseev and additional investigation.
Discussion: https://postgr.es/m/CAJ7c6TOATjJqvhnYsui0=CO5XFMF4dvTGH+skzB--jNhqSQu5g@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d7674c9fab09d5bab427ba3b9b7a20b169aba715
Modified Files
--------------
doc/src/sgml/config.sgml | 6 +-
doc/src/sgml/datatype.sgml | 4 +
doc/src/sgml/datetime.sgml | 42 +++++-
doc/src/sgml/system-views.sgml | 4 +-
src/backend/catalog/system_views.sql | 7 +-
src/backend/commands/variable.c | 2 +
src/backend/utils/adt/datetime.c | 242 +++++++++++++++++++++++++++---
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 12 +-
src/include/pgtime.h | 7 +
src/include/utils/datetime.h | 2 +
src/test/regress/expected/horology.out | 6 +
src/test/regress/expected/rules.out | 17 ++-
src/test/regress/expected/sysviews.out | 8 +
src/test/regress/expected/timestamptz.out | 59 ++++++++
src/test/regress/sql/horology.sql | 1 +
src/test/regress/sql/sysviews.sql | 3 +
src/test/regress/sql/timestamptz.sql | 17 +++
src/timezone/localtime.c | 114 ++++++++++++++
src/tools/pgindent/typedefs.list | 1 +
20 files changed, 521 insertions(+), 35 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Seek zone abbreviations in the IANA data before timezone_abbrevi
In-Reply-To: <E1tYVHR-001xWD-Dw@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox