Re: Datum as struct - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Datum as struct
Date
Msg-id 2572e720-8e94-40eb-a744-9a765189abbe@eisentraut.org
Whole thread Raw
In response to Re: Datum as struct  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Datum as struct
List pgsql-hackers
On 05.08.25 20:06, Peter Eisentraut wrote:
>  > diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/ 
> adt/timestamp.c
>  > index 25cff56c3d0..e640b48205b 100644
>  > --- a/src/backend/utils/adt/timestamp.c
>  > +++ b/src/backend/utils/adt/timestamp.c
>  > @@ -4954,7 +4954,7 @@ timestamptz_trunc_internal(text *units, 
> TimestampTz timestamp, pg_tz *tzp)
>  >                  case DTK_SECOND:
>  >                  case DTK_MILLISEC:
>  >                  case DTK_MICROSEC:
>  > -                    PG_RETURN_TIMESTAMPTZ(timestamp);
>  > +                    return timestamp;
>  >                     break;
>  >
>  >                 default:
> 
> This one is an actual bug.  With int64-pass-by-reference, 
> PG_RETURN_TIMESTAMPTZ() returns a newly allocated address.  This is 
> easily reproduced by
> 
> SELECT date_trunc( 'week', timestamp with time zone 'infinity' );
> 
> which will return a random value on 32-bit systems.  (It correctly 
> returns 'infinity' otherwise.)
> 
> I'll see about backpatching fixes for this.

This is new in PG18, so I'm continuing the discussion in the original 
thread: 
https://www.postgresql.org/message-id/flat/CAAvxfHc4084dGzEJR0_pBZkDuqbPGc5wn7gK_M0XR_kRiCdUJQ%40mail.gmail.com



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: date_trunc invalid units with infinite value
Next
From: vignesh C
Date:
Subject: Re: Add support for specifying tables in pg_createsubscriber.