pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Change dynahash.c and hsearch.h to use int64 instead of long
Date: Fri, 22 Aug 2025 02:59:36 +0000
Message-ID: <E1upI08-0014RL-0i@gemulon.postgresql.org> (raw)

Change dynahash.c and hsearch.h to use int64 instead of long

This code was relying on "long", which is signed 8 bytes everywhere
except on Windows where it is 4 bytes, that could potentially expose it
to overflows, even if the current uses in the code are fine as far as I
know.  This code is now able to rely on the same sizeof() variable
everywhere, with int64.  long was used for sizes, partition counts and
entry counts.

Some callers of the dynahash.c routines used long declarations, that can
be cleaned up to use int64 instead.  There was one shortcut based on
SIZEOF_LONG, that can be removed.  long is entirely removed from
dynahash.c and hsearch.h.

Similar work was done in b1e5c9fa9ac4.

Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aKQYp-bKTRtRauZ6@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/13b935cd5217457f62e9936fce668d15515a3072

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c |  4 +-
src/backend/catalog/storage.c                   |  2 +-
src/backend/storage/ipc/shmem.c                 |  4 +-
src/backend/storage/lmgr/lock.c                 |  2 +-
src/backend/storage/lmgr/predicate.c            |  2 +-
src/backend/utils/hash/dynahash.c               | 92 ++++++++++++-------------
src/include/storage/shmem.h                     |  2 +-
src/include/utils/dynahash.h                    |  2 +-
src/include/utils/hsearch.h                     | 16 ++---
9 files changed, 61 insertions(+), 65 deletions(-)



Message-ID: <E1upI08-0014RL-0i@gemulon.postgresql.org>
Permalink:  ../E1upI08-0014RL-0i@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1upI08-0014RL-0i@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Change dynahash.c and hsearch.h to use int64 instead of long
  In-Reply-To: <E1upI08-0014RL-0i@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox