Re: Make use of unvolatize() in vac_truncate_clog()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Make use of unvolatize() in vac_truncate_clog()
Date: 2026-02-25 13:33:29
Message-ID: 83e1933b-ee11-4903-91a0-24d5697378f2@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 24.02.26 19:16, Bertrand Drouvot wrote:
> On Tue, Feb 24, 2026 at 11:19:50AM -0600, Nathan Bossart wrote:
>> On Tue, Feb 24, 2026 at 05:08:09PM +0000, Bertrand Drouvot wrote:
>>> This patch makes use of unvolatize() in vac_truncate_clog().
>>>
>>> Note that it does not remove the warning but moves it to c.h (where unvolatize()
>>> is defined) but that's consistent with what 481018f2804 did too.
>>
>> Why is this preferable to marking the function parameter as volatile
>
> I think that that would sound misleading for the other callers that don't really
> need the volatile qualification.
>
>> or removing the volatile qualifier from the variable?
>
> That looks mandatory according to 2d2e40e3bef.

Arguably, putting the volatile qualifier on the whole dbform is broader
than required. So you could imagine writing it something like this instead:

FormData_pg_database *dbform = (Form_pg_database) GETSTRUCT(tuple);
volatile TransactionId *datfrozenxid_p;
volatile TransactionId *datminmxid_p;

*datfrozenxid_p = dbform->datfrozenxid;
*datminmxid_p = dbform->datminmxid;

Alternatively, we should document why applying unvolatize() is
acceptable, like

/* ... unvolatize() is ok because datconnlimit is not concurrently
updated (see above) ...

Or just write it directly like

if (dbform->datconnlimit == DATCONNLIMIT_INVALID_DB)

This violates the abstraction layer, but the variant with the comment
kind of does too.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2026-02-25 13:39:18 Re: Skipping schema changes in publication
Previous Message Aleksander Alekseev 2026-02-25 13:31:45 Re: Passing mac-addresses by value?