Re: Datum as struct

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Datum as struct
Date: 2025-08-05 18:06:26
Message-ID: 2d320b6f-b4af-4fbc-9eec-5d0fa15d187b@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-08-05 18:09:47 headerscheck warnings with late-model gcc
Previous Message Masahiko Sawada 2025-08-05 18:05:29 Re: Add backup_type to pg_stat_progress_basebackup