pgsql: Improve handling of date_trunc() units for infinite input values - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Improve handling of date_trunc() units for infinite input values
Date
Msg-id E1tR2A8-001YJJ-CQ@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Improve handling of date_trunc() units for infinite input values

Previously, if an infinite value was passed to date_trunc(), then the
same infinite value would always be returned regardless of the field
unit given by the caller.  This commit updates the function so that an
error is returned when an invalid unit is passed to date_trunc() with an
infinite value.

This matches the behavior of date_trunc() with a finite value and
date_part() with an infinite value, making the handling of interval,
timestamp and timestamptz more consistent across the board for these two
functions.

Some tests are added to cover all these new failure cases, with an
unsupported unit and infinite values for the three data types.  There
were no test cases in core that checked all these patterns up to now.

Author: Joseph Koshakow
Discussion: https://postgr.es/m/CAAvxfHc4084dGzEJR0_pBZkDuqbPGc5wn7gK_M0XR_kRiCdUJQ@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/timestamp.c         | 121 +++++++++++++++++++++++++-----
src/test/regress/expected/interval.out    |   9 +++
src/test/regress/expected/timestamp.out   |   2 +
src/test/regress/expected/timestamptz.out |   4 +
src/test/regress/sql/interval.sql         |   8 ++
src/test/regress/sql/timestamp.sql        |   2 +
src/test/regress/sql/timestamptz.sql      |   4 +
7 files changed, 131 insertions(+), 19 deletions(-)


pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: pgsql: Remove unused totalrows parameter in compute_expr_stats
Next
From: David Rowley
Date:
Subject: pgsql: Speedup tuple deformation with additional function inlining