Re: Avoid overflow with simplehash

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid overflow with simplehash
Date: 2023-07-06 15:46:48
Message-ID: 1215055.1688658408@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-07-06 15:47:33 Re: pgindent vs. pgperltidy command-line arguments
Previous Message Tomas Vondra 2023-07-06 15:38:38 Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs