pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix parsing of ISO-8601 interval fields with exponential notatio
Date: Mon, 20 Feb 2023 21:56:07 +0000
Message-ID: <E1pUE8l-0029al-3Q@gemulon.postgresql.org> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <E1pUE8l-0029al-3Q@gemulon.postgresql.org>
Permalink:  ../E1pUE8l-0029al-3Q@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pUE8l-0029al-3Q@gemulon.postgresql.org

 · 

reply

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: Fix parsing of ISO-8601 interval fields with exponential notatio
  In-Reply-To: <E1pUE8l-0029al-3Q@gemulon.postgresql.org>
  References: <E1pUE8l-0029al-3Q@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