postgresql/src
Michael Paquier 2242b26ce4 Fix incorrect Datum conversion in timestamptz_trunc_internal()
The code used a PG_RETURN_TIMESTAMPTZ() where the return type is
TimestampTz and not a Datum.

On 64-bit systems, there is no effect since this just ends up casting
64-bit integers back and forth.  On 32-bit systems, timestamptz is
pass-by-reference.  PG_RETURN_TIMESTAMPTZ() allocates new memory and
returns the address, meaning that the caller could interpret this as a
timestamp value.

The effect is using "date_trunc(..., 'infinity'::timestamptz) will
return random values (instead of the correct return value 'infinity').

Bug introduced in commit d85ce012f9.

Author: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/2d320b6f-b4af-4fbc-9eec-5d0fa15d187b@eisentraut.org
Discussion: https://postgr.es/m/4bf60a84-2862-4a53-acd5-8eddf134a60e@eisentraut.org
Backpatch-through: 18
2025-08-07 11:02:04 +09:00
..
backend Fix incorrect Datum conversion in timestamptz_trunc_internal() 2025-08-07 11:02:04 +09:00
bin Expand usage of macros for protocol characters. 2025-08-06 13:37:00 -05:00
common Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:40 -04:00
fe_utils Fix bug in archive streamer with LZ4 decompression 2025-07-02 13:48:36 +09:00
include Expand usage of macros for protocol characters. 2025-08-06 13:37:00 -05:00
interfaces Fix typo in comment. 2025-08-06 22:52:13 +09:00
makefiles meson: Increase minimum version to 0.57.2 2025-07-02 11:14:53 +02:00
pl Reduce leakage during PL/pgSQL function compilation. 2025-08-02 21:59:46 -04:00
port Use strchr instead of strstr for single-char lookups 2025-07-23 12:02:55 +12:00
template thread-safety: gmtime_r(), localtime_r() 2024-08-23 07:43:04 +02:00
test Fix printf format specfiers in test_int128 module. 2025-08-06 10:16:14 +01:00
timezone Update time zone data files to tzdata release 2025b. 2025-04-30 11:13:49 -04:00
tools Convert src/tools/testint128.c into a test module. 2025-08-06 09:41:11 +01:00
tutorial Doc: simplify the tutorial's window-function examples. 2025-01-21 14:43:21 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:40 -04:00
Makefile.shlib Use exported symbols list on macOS for loadable modules as well 2025-06-10 07:04:43 +02:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00