From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix parsing of ISO-8601 interval fields with exponential notatio |
Date: | 2023-02-20 21:56:07 |
Message-ID: | E1pUE8l-0029al-3Q@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix parsing of ISO-8601 interval fields with exponential notation.
Historically we've accepted interval input like 'P.1e10D'. This
is probably an accident of having used strtod() to do the parsing,
rather than something anyone intended, but it's been that way for
a long time. Commit e39f99046 broke this by trying to parse the
integer and fractional parts separately, without accounting for
the possibility of an exponent. In principle that coding allowed
for precise conversions of field values wider than 15 decimal
digits, but that does not seem like a goal worth sweating bullets
for. So, rather than trying to manage an exponent on top of the
existing complexity, let's just revert to the previous coding that
used strtod() by itself. We can still improve on the old code to
the extent of allowing the value to range up to 1.0e15 rather than
only INT_MAX. (Allowing more than that risks creating problems
due to precision loss: the converted fractional part might have
absolute value more than 1. Perhaps that could be dealt with in
some way, but it really does not seem worth additional effort.)
Per bug #17795 from Alexander Lakhin. Back-patch to v15 where
the faulty code came in.
Discussion: https://postgr.es/m/17795-748d6db3ed95d313@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f0d0394e84ceeda6f22eb3fdb89bd8adbfc13985
Modified Files
--------------
src/backend/utils/adt/datetime.c | 64 +++++++++++++++-------------------
src/test/regress/expected/interval.out | 10 ++++--
src/test/regress/sql/interval.sql | 1 +
3 files changed, 37 insertions(+), 38 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-02-20 22:26:34 | pgsql: Detect overflow in timestamp[tz] subtraction. |
Previous Message | Tom Lane | 2023-02-20 20:18:44 | pgsql: Prevent join removal from removing the query's result relation. |