pgpool: Make time calculations always long long.

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgpool-committers(at)lists(dot)postgresql(dot)org
Subject: pgpool: Make time calculations always long long.
Date: 2025-10-09 11:34:55
Message-ID: E1v6ov8-00GH8S-2H@gothos.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-committers

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 <pgpool(at)list(dot)imperialat(dot)at>
Reviewed-by: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Reviewed-by: Gyorgy Sarvari <skandigraun(at)gmail(dot)com>
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

Branch
------
master

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=97ab3f1257c6fe0635281f31e8beaf8850bde882

Modified Files
--------------
src/include/utils/json.h | 2 +-
src/include/watchdog/wd_commands.h | 2 +-
src/include/watchdog/wd_json_data.h | 4 ++--
src/main/pgpool_logger.c | 2 +-
src/pcp_con/pcp_worker.c | 4 ++--
src/protocol/pool_connection_pool.c | 12 ++++++------
src/query_cache/pool_memqcache.c | 8 ++++----
src/utils/json.c | 2 +-
src/utils/pool_process_reporting.c | 2 +-
src/utils/pool_relcache.c | 2 +-
src/watchdog/watchdog.c | 4 ++--
src/watchdog/wd_commands.c | 4 ++--
src/watchdog/wd_heartbeat.c | 4 ++--
src/watchdog/wd_json_data.c | 20 +++++++++++---------
14 files changed, 37 insertions(+), 35 deletions(-)

Browse pgpool-committers by date

  From Date Subject
Next Message Tatsuo Ishii 2025-10-09 11:35:27 pgpool: Make time calculations always long long.
Previous Message Bo Peng 2025-10-06 01:26:02 pgpool: Update mailing list address to use pgpool-hackers@lists.postgre