Re: Remove useless casting to the same type

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Remove useless casting to the same type
Date: 2025-11-28 14:42:32
Message-ID: aSm02GCrSWG1pnbW@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, Nov 28, 2025 at 02:20:25PM +0100, Peter Eisentraut wrote:
> On 28.11.25 10:06, Bertrand Drouvot wrote:
> > On Fri, Nov 28, 2025 at 09:11:16AM +0100, Peter Eisentraut wrote:
> > > I think this whole thing could be simplified by overlaying a uint32 over
> > > "data" and just accessing the array fields normally. See attached patch.
> >
> > Indeed, that's a nice simplification.
> >
> > - data += sizeof(uint32) * 2;
> >
> > Is it safe? I mean could XLH_SPLIT_META_UPDATE_MASKS and XLH_SPLIT_META_UPDATE_SPLITPOINT
> > be set simultaneously?
>
> Yes, that's what was probably intended. But apparently not exercised in the
> tests.
>
> So maybe more like this patch.

+ uint32 lowmask = uidata[uidatacount++];
+ uint32 highmask = uidata[uidatacount++];

good idea! That way that's easier to add more branches/flags later if we need
to.

Also, I think that's safe thanks to XLogRecGetBlockData() returning a
MAXALIGNed buffer. Not sure if it's worth to add a comment. I think that a
comment was not needed with the original code as it was using memcpy() instead.

Except for the nit comment remark above, LGTM.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2025-11-28 14:48:41 Re: Fix comments in execTuples.c
Previous Message Ashutosh Bapat 2025-11-28 14:30:13 Re: Fix comments in execTuples.c