Re: Avoid overflow with simplehash

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Ranier Vilela <ranier.vf@gmail.com>, Daniel Gustafsson <daniel@yesql.se>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2023-07-06T15:46:48Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On 2023-07-06 11:16:26 -0400, Tom Lane wrote:
>> It does seem like we could do
>> 	uint64		startelem = SH_MAX_SIZE;
>> 	...
>> 	Assert(startelem < SH_MAX_SIZE);
>> which'd make it a little clearer that the expectation is for
>> startelem to have changed value.

> I guess? I find it easier to understand all-bits-set in a coredump as
> too-large than SH_MAX_SIZE, but ...

What'd help even more is a comment:

	/* We should have found an empty element */
	Assert(startelem < SH_MAX_SIZE);

			regards, tom lane



Commits

  1. Fix type of iterator variable in SH_START_ITERATE