From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
Cc: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Mark ItemPointer parameters as const in tuple/table lock functions |
Date: | 2025-08-29 05:42:41 |
Message-ID: | 812f1ee6-eb2f-4793-92d2-98a800273245@eisentraut.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 28.08.25 04:27, Chao Li wrote:
>> On Aug 27, 2025, at 17:24, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>>
>> This style of having Foo be a type alias for pointer-to-FooData is an
>> ancient Postgres coding convention that does not map well to modern C
>> that has an emphasis on judicious use of qualifiers and attributes,
>> and so if this abstraction gets in the way, we sometimes crack it
>> open, like in the case of ItemPointerGetBlockNumber() etc.
>
> You are right, we want to protect the stuff that “tid” points to instead
> of “tid” itself:
>
> *tid = something; // should hit compile error
> tid = something; // ok
>
> Also, thanks for telling the history. I have updated the patch to use
> “const ItemPointerData *” in the same way as ItemPointerGetBlockNumber().
>
> Attached is the v2 patch.
This patch still causes a compiler warning:
../src/backend/storage/lmgr/lmgr.c: In function 'XactLockTableWait':
../src/backend/storage/lmgr/lmgr.c:681:27: error: assignment discards
'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
I have fixed that and committed your patch.
From | Date | Subject | |
---|---|---|---|
Next Message | Ajin Cherian | 2025-08-29 06:12:39 | Re: Improve pg_sync_replication_slots() to wait for primary to advance |
Previous Message | Peter Eisentraut | 2025-08-29 05:23:27 | Re: Remove unneeded cast in heap_xlog_lock. |