Make time calculations always long long.
authorTatsuo Ishii <[email protected]>
Fri, 3 Oct 2025 12:10:50 +0000 (21:10 +0900)
committerTatsuo Ishii <[email protected]>
Thu, 9 Oct 2025 10:40:08 +0000 (19:40 +0900)
commit97ab3f1257c6fe0635281f31e8beaf8850bde882
tree6ad429f7951697632e74228fc3c0a7ed1d0662af
parentf4d04d77c20e3b0e53bc4833ab9dda563115f7ab
Make time calculations always long long.

Previously pgpool assumed that time_t to be a simple long. This causes
a lot of compile time warnings on certain systems, for example
OpenBSD because on the system time_t is __int64, which results in long
long. This commit upcasts such calculations to long long to avoid the
issue.

This way times can't get truncated and for the places where time_t is
actually used as a time and not a time diff this would allow pgpool to
keep working correctly post Y2038 on 64 bit clean time_t systems
(e.g. i386 OpenBSD).

Moreover, json_get_long_value_for_key is changed to
json_get_llong_value_for_key and changed the parameter to long long.
This makes it more in line _json_value's integer, which is defined as
int64. This should also give 32 bit platforms proper retrieval of the
max value of an integer and may or may not solve some weird integer
overflow issues.

Backpatch for 4.6 was rebased by Gyorgy Sarvari.

Author: Martijn van Duren <[email protected]>
Reviewed-by: Tatsuo Ishii <[email protected]>
Reviewed-by: Gyorgy Sarvari <[email protected]>
Backpatch-through: v4.6
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2025-May/004584.html
Discussion: https://www.postgresql.org/message-id/20251003.211957.2067537305399895611.ishii%40postgresql.org
Discussion: https://github.com/pgpool/pgpool2/pull/128
14 files changed:
src/include/utils/json.h
src/include/watchdog/wd_commands.h
src/include/watchdog/wd_json_data.h
src/main/pgpool_logger.c
src/pcp_con/pcp_worker.c
src/protocol/pool_connection_pool.c
src/query_cache/pool_memqcache.c
src/utils/json.c
src/utils/pool_process_reporting.c
src/utils/pool_relcache.c
src/watchdog/watchdog.c
src/watchdog/wd_commands.c
src/watchdog/wd_heartbeat.c
src/watchdog/wd_json_data.c