Re: [PATCH] Refactor: Extract XLogRecord info

From: Steven Niu <niushiji(at)gmail(dot)com>
To: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, Xiaoran Wang <fanfuxiaoran(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Refactor: Extract XLogRecord info
Date: 2025-06-10 09:56:09
Message-ID: CABBtG=cAyq3Py+swRQ+5QDE_+yt+k-w5Bv-F8E2h9vHeGS91Ww@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm confused by the code of XLR_RMGR_INFO_MASK and XLR_INFO_MASK.

According to the definition of masks, the high 4 bits are for rmgr.

/*
* The high 4 bits in xl_info may be used freely by rmgr. The
* XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY bits can be passed by
* XLogInsert caller. The rest are set internally by XLogInsert.
*/
#define XLR_INFO_MASK 0x0F
#define XLR_RMGR_INFO_MASK 0xF0

However, in function XLogInsert(), there is code:

/*
* The caller can set rmgr bits, XLR_SPECIAL_REL_UPDATE and
* XLR_CHECK_CONSISTENCY; the rest are reserved for use by me.
*/
if ((info & ~(XLR_RMGR_INFO_MASK |
XLR_SPECIAL_REL_UPDATE |
XLR_CHECK_CONSISTENCY)) != 0)
elog(PANIC, "invalid xlog info mask %02X", info);

#define XLR_SPECIAL_REL_UPDATE 0x01
#define XLR_CHECK_CONSISTENCY 0x02

As the XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY are of the low 4
bits,
the above code is indicating the low 4 bits are for rmgr too?

Did I misunderstand something?

Thanks,
Steven

wenhui qiu <qiuwenhuifx(at)gmail(dot)com> 于2025年6月10日周二 16:00写道:

> HI
> > FWIW, I'm not sure what's the benefit of the proposal which comes down
> > to the removal of a bitwise NOT, except more code conflicts with back
> > branches.
> Agree
>
> On Tue, Jun 10, 2025 at 3:37 PM Michael Paquier <michael(at)paquier(dot)xyz>
> wrote:
>
>> On Mon, Jun 09, 2025 at 10:54:43PM -0300, Fabrízio de Royes Mello wrote:
>> > The refactoring LGTM but do we really need two patches? IMHO you can
>> just
>> > merge everything into a single patch.
>>
>> FWIW, I'm not sure what's the benefit of the proposal which comes down
>> to the removal of a bitwise NOT, except more code conflicts with back
>> branches.
>> --
>> Michael
>>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dagfinn Ilmari Mannsåker 2025-06-10 10:05:30 Re: Extend COPY FROM with HEADER <integer> to skip multiple lines
Previous Message Zhijie Hou (Fujitsu) 2025-06-10 09:50:29 RE: Replication slot is not able to sync up