Re: Remove traces of long in dynahash.c
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, Tom Lane <tgl@sss.pgh.pa.us>, Chao Li <li.evan.chao@gmail.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-09-09T03:58:32Z
Lists: pgsql-hackers
Attachments
- v3-0001-Replace-callers-of-dynahash.h-s-my_log-by-equival.patch (text/x-diff) patch v3-0001
- v3-0002-Remove-dynahash.h.patch (text/x-diff) patch v3-0002
On Fri, Sep 05, 2025 at 10:40:46AM +0100, Dean Rasheed wrote: > Alternatively, why not just impose the upper bound at the call sites > if needed, so there may be no need for these functions at all. For > example, looking at nodeHash.c, it would seem much more logical to > have ExecChooseHashTableSize() put an upper bound on nbuckets, rather > than capping log2_nbuckets after nbuckets has been chosen, risking > them getting out-of-sync. Yep, that may be the best course of action. As far as I can see, this is capped by palloc() and HashJoinTuple, so we should be OK with putting a hard limit at (INT_MAX / 2) and call it a day, I guess? The two other call sites of my_log2() are worker.c, for the number of subxacts, which relies on int32. The other call site is nodeAgg.c, capped at HASHAGG_MAX_PARTITIONS (1024). As of the attached, dynahash.h can be removed, which is the minimal goal I had in mind. I am not sure about the need to tweak more dynahash.c, as we've relied on long in this file for many years. We could bite the bullet and do it, of course, but I am not sure.. So I would be happy with only the attached changes. What do you think? -- Michael
Commits
-
Remove dynahash.h
- e6da68a6e1d6 19 (unreleased) landed
-
Replace callers of dynahash.h's my_log() by equivalent in pg_bitutils.h
- b1187266e077 19 (unreleased) landed
-
Change dynahash.c and hsearch.h to use int64 instead of long
- 13b935cd5217 19 (unreleased) landed