Re: date_trunc invalid units with infinite value - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: date_trunc invalid units with infinite value
Date
Msg-id aJQUuQw0mDfGRig-@paquier.xyz
Whole thread Raw
In response to Re: date_trunc invalid units with infinite value  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On Thu, Aug 07, 2025 at 09:06:25AM +0900, Michael Paquier wrote:
> Yes, confirmed the broken case on 32-bit builds with the incorrect
> result returned by timestamptz_trunc_internal():
> SELECT date_trunc( 'week', timestamp with time zone 'infinity' );
>
> 0001 four new tests for timestamptz:
> 1) Three tests for timestamptz_trunc():
> - TIMESTAMP_NOT_FINITE + a valid unit, new path.
> - TIMESTAMP_NOT_FINITE + "not supported" unit, new path.
> - !TIMESTAMP_NOT_FINITE +

Blurp here.  I meant !TIMESTAMP_NOT_FINITE with unsupported unit, old
code path.

> 2) One test for timestamptz_trunc_zone():
> - !TIMESTAMP_NOT_FINITE + "not supported" unit

There can be an extra test here, for the case of an infinite value
with a valid unit and a time zone specified, which would also have
failed with the bug as timestamptz_trunc_internal() is also used by
timestamptz_trunc_zone(), like:
SELECT date_trunc( 'week', timestamp with time zone 'infinity', 'GMT')
  AS inf_zone_trunc;

I have added one more test, reversed the order to avoid spurious
failures should one have the idea to do a bisect with a 32b build, and
applied both things.

Thanks for the report!
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: [PATCH] OAuth: fix performance bug with stuck multiplexer events
Next
From: shveta malik
Date:
Subject: Re: Logical Replication of sequences