pgsql: Fix parsing of ISO-8601 interval fields with exponential notatio

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix parsing of ISO-8601 interval fields with exponential notatio
Дата
Msg-id E1pUE8l-0029an-4P@gemulon.postgresql.org
обсуждение исходный текст
Список 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
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ded5ede2779fec65ed0a4022296efa71e9c64aac

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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Prevent join removal from removing the query's result relation.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Detect overflow in timestamp[tz] subtraction.