From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow DateTimeParseError to handle bad-timezone error messages.
Date: Fri, 09 Dec 2022 18:30:57 +0000
Message-ID: <E1p3i9A-002hlb-6i@gemulon.postgresql.org> (raw)
Allow DateTimeParseError to handle bad-timezone error messages.
Pay down some ancient technical debt (dating to commit 022fd9966):
fix a couple of places in datetime parsing that were throwing
ereport's immediately instead of returning a DTERR code that could be
interpreted by DateTimeParseError. The reason for that was that there
was no mechanism for passing any auxiliary data (such as a zone name)
to DateTimeParseError, and these errors seemed to really need it.
Up to now it didn't matter that much just where the error got thrown,
but now we'd like to have a hard policy that datetime parse errors
get thrown from just the one place.
Hence, invent a "DateTimeErrorExtra" struct that can be used to
carry any extra values needed for specific DTERR codes. Perhaps
in the future somebody will be motivated to use this to improve
the specificity of other DateTimeParseError messages, but for now
just deal with the timezone-error cases.
This is on the way to making the datetime input functions report
parse errors softly; but it's really an independent change, so
commit separately.
Discussion: https://postgr.es/m/3bbbb0df-7382-bf87-9737-340ba096e034@postgrespro.ru
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2661469d862239ea8b9e3a1cf5352d833f6f0fec
Modified Files
--------------
contrib/adminpack/adminpack.c | 4 +-
src/backend/access/transam/xlogrecovery.c | 4 +-
src/backend/utils/adt/date.c | 28 ++++---
src/backend/utils/adt/datetime.c | 124 +++++++++++++++++++-----------
src/backend/utils/adt/formatting.c | 20 +++--
src/backend/utils/adt/timestamp.c | 54 +++++++++----
src/include/utils/datetime.h | 32 +++++---
7 files changed, 176 insertions(+), 90 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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Allow DateTimeParseError to handle bad-timezone error messages.
In-Reply-To: <E1p3i9A-002hlb-6i@gemulon.postgresql.org>
References: <E1p3i9A-002hlb-6i@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