Re: Confusing variable naming in LWLockRelease

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Confusing variable naming in LWLockRelease
Date: 2025-02-05 22:26:44
Message-ID: 256baafad960f39f56149d4c52be29820d1cf76d.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2025-01-29 at 23:16 -0800, Jacob Brazeal wrote:
> Here the variable name "oldstate" leads one to believe that the value
> is fetched before the sub operation, similar to some other usages in
> lwlock.c.

I believe it refers to the state of the lock prior to lock acquisition;
not prior to subtraction.

I agree that it's a bit confusing, because I don't think it necessarily
changes it back to the state prior to acquisition if it's a shared
lock. But the name "newstate" wouldn't be great, either.

I don't have a great name in mind, so perhaps a comment instead?

Regards,
Jeff Davis

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2025-02-05 22:26:49 Re: Confine vacuum skip logic to lazy_scan_skip
Previous Message Melanie Plageman 2025-02-05 22:08:09 Re: Trigger more frequent autovacuums of heavy insert tables