Re: Remove unneeded cast in heap_xlog_lock.

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Remove unneeded cast in heap_xlog_lock.
Date: 2025-08-22 05:36:30
Message-ID: CALdSSPjVW0K5vbaUGNWu=yab3AXz=n-Wzx0LjfF_wRz2YN1aew@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 22 Aug 2025 at 06:41, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>
> If you run 'git grep', you'll find a lot more instances where the
> result of BufferGetPage() is explicitly cast to Page.
>
> git grep -rn "(Page) BufferGetPage" | wc -l
> 69
>
> Although these casts are unnecessary for sure, I'm not sure if it's
> worth making the code changes to fix them.

I can see your point. But I can see that there is a great amount of
commits in HEAD (every now and then), which are just pure refactoring
and standardizing things.
I am uncertain about the delineation between when we make changes and
when we refrain from doing so.

I do not insist on this modification. I just spotted two completely
same codes in [0] & [1], which only differ in BufferGetPage cast. And
I merely tried to do something with it.

v2 attached with all 69 casts removed, but I see there is a little
chance of this committed.

[0] https://github.com/postgres/postgres/blob/13b935c/src/backend/access/heap/heapam_xlog.c#L1007-L1050
[1] https://github.com/postgres/postgres/blob/13b935c/src/backend/access/heap/heapam_xlog.c#L1083-L1121

--
Best regards,
Kirill Reshke

Attachment Content-Type Size
v2-0001-Remove-unneeded-cast-in-BufferGetPage.patch application/octet-stream 27.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2025-08-22 05:44:45 Re: Improve pg_sync_replication_slots() to wait for primary to advance
Previous Message Michael Paquier 2025-08-22 05:32:22 Re: Remove redundant assignment of a variable in function AlterPublicationTables