Re: [dynahash] do not refill the hashkey after hash_search

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Junwang Zhao <zhjwpku(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [dynahash] do not refill the hashkey after hash_search
Date: 2023-10-25 14:50:00
Message-ID: 20231025145000.GA981848@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 25, 2023 at 12:48:52PM +0700, John Naylor wrote:
> On Wed, Oct 25, 2023 at 12:21 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>
>> John Naylor <johncnaylorls(at)gmail(dot)com> writes:
>> > I'd prefer just adding "Assert(hentry->event == oldn);" and declaring
>> > hentry PG_USED_FOR_ASSERTS_ONLY.
>>
>> I'm not aware of any other places where we have Asserts checking
>> that hash_search() honored its contract. Why do we need one here?
>
> [removing old CC]
> The author pointed out here that we're not consistent in this regard:
>
> https://www.postgresql.org/message-id/CAEG8a3KEO_Kdt2Y5hFNWMEX3DpCXi9jtZOJY-GFUEE9QLgF%2Bbw%40mail.gmail.com
>
> ...but I didn't try seeing where the balance lay. We can certainly
> just remove redundant assignments.

While it probably doesn't hurt anything, IMHO it's unnecessary to verify
that hash_search() works every time it is called. This behavior seems
unlikely to change anytime soon, too.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniele Varrazzo 2023-10-25 15:03:18 libpq async connection and multiple hosts
Previous Message Peter Eisentraut 2023-10-25 14:36:41 Re: [patch] pg_basebackup: mention that spread checkpoints are the default in --help