pgsql: Detect Julian-date overflow in timestamp[tz]_pl_interval.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Detect Julian-date overflow in timestamp[tz]_pl_interval.
Дата
Msg-id E1rTR7T-003Et5-E9@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Detect Julian-date overflow in timestamp[tz]_pl_interval.

We perform addition of the days field of an interval via
arithmetic on the Julian-date representation of the timestamp's date.
This step is subject to int32 overflow, and we also should not let
the Julian date become very negative, for fear of weird results from
j2date.  (In the timestamptz case, allow a Julian date of -1 to pass,
since it might convert back to zero after timezone rotation.)

The additions of the months and microseconds fields could also
overflow, of course.  However, I believe we need no additional
checks there; the existing range checks should catch such cases.
The difficulty here is that j2date's magic modular arithmetic could
produce something that looks like it's in-range.

Per bug #18313 from Christian Maurer.  This has been wrong for
a long time, so back-patch to all supported branches.

Discussion: https://postgr.es/m/18313-64d2c8952d81e84b@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/425127bed2e72c0596fd35b976fde569f64f814d

Modified Files
--------------
src/backend/utils/adt/timestamp.c      | 27 +++++++++++++++++++++++----
src/test/regress/expected/horology.out |  4 ++++
src/test/regress/sql/horology.sql      |  2 ++
3 files changed, 29 insertions(+), 4 deletions(-)


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: pgsql: Temporary patch to help debug pg_walsummary test failures.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Compare varnullingrels too in assign_param_for_var().