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_kricd...@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(-)