Re: Datum as struct
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-06T11:07:34Z
Lists: 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
Commits
-
Use consistent type for pgaio_io_get_id() result
- b942360f82a0 18.0 landed
- 47932f3cdc4c 19 (unreleased) landed
-
Mop-up for Datum conversion cleanups.
- 665c3dbba497 19 (unreleased) landed
-
Add missing Datum conversions
- ff89e182d420 19 (unreleased) landed
-
Remove useless/superfluous Datum conversions
- dcfc0f891273 19 (unreleased) landed
-
Fix incorrect lack of Datum conversion in _int_matchsel()
- 387883f68c85 13.22 landed
- 64dec8060c84 14.19 landed
- f0d55b68ef92 15.14 landed
- a3906b44c5b9 16.10 landed
- 276cdd4cc378 17.6 landed
- 992a18f5161c 18.0 landed
- fd2ab03fea23 19 (unreleased) landed
-
Improve tests of date_trunc() with infinity and unsupported units
- 67ffe1987d0a 18.0 landed
- 572c0f1b0e2a 19 (unreleased) landed
-
Fix incorrect Datum conversion in timestamptz_trunc_internal()
- 074db8604ad1 18.0 landed
- 2242b26ce472 19 (unreleased) landed
-
Fix various hash function uses
- 2ad6e80de9a6 19 (unreleased) landed
-
Fix mixups of FooGetDatum() vs. DatumGetFoo()
- 1469e312977c 19 (unreleased) landed