From: | wenhui qiu <qiuwenhuifx(at)gmail(dot)com> |
---|---|
To: | Steven Niu <niushiji(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: [PATCH] Refactor: Extract XLogRecord info |
Date: | 2025-06-09 07:17:19 |
Message-ID: | CAGjGUAKMSBjR8i_VjgP7NzHNhyXf2A1T98UrrXHRYMsDQ2GgdQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
HI
> And I suggest to create a macro to do this job.
> #define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)
>
> Then the code can become:
> XLogRecGetInfo(record) & ~XLR_INFO_MASK;
> -->
> getRmgrInfo(XLogRecGetInfo(record))
+1 Agreed, this makes the code more readable.
Thanks
On Mon, Jun 9, 2025 at 2:46 PM Steven Niu <niushiji(at)gmail(dot)com> wrote:
> Hi,
>
> I like the idea of your change as it saves me out of converting-in-my-mind.
>
> And I suggest to create a macro to do this job.
> #define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)
>
> Then the code can become:
> XLogRecGetInfo(record) & ~XLR_INFO_MASK;
> -->
> getRmgrInfo(XLogRecGetInfo(record));
>
> Thanks,
> Steven
>
>
> 在 2025/6/9 14:23, Xiaoran Wang 写道:
> > Hi,
> > I refactored the code of extracting XLogRecord info.
> > In XLogRecord, the high 4 bits in xl_info is used by rmgr.
> >
> > typedef struct XLogRecord
> > {
> > uint32 xl_tot_len; /* total len of entire record */
> > TransactionId xl_xid; /* xact id */
> > XLogRecPtr xl_prev; /* ptr to previous record in log */
> > uint8 xl_info; /* flag bits, see below */
> > RmgrId xl_rmid; /* resource manager for this record */
> > /* 2 bytes of padding here, initialize to zero */
> > pg_crc32c xl_crc; /* CRC for this record */
> >
> > /* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no
> > padding */
> >
> > } XLogRecord;
> >
> > I found lots of the code to get the info as below
> >
> > XLogRecGetInfo(record) & ~XLR_INFO_MASK
> >
> > Actually, we can directly use XLR_RMGR_INFO_MASK(0xF0)
> > instead of XLR_INFO_MASK(0x0F), which is easier to understand.
> > Remove XLR_INFO_MASK as it is not used any more.
> >
> >
> > --
> > Best regards !
> > Xiaoran Wang
>
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-06-09 08:21:19 | Cleanup gcc trick with varattrib_1b_e in VARATT_EXTERNAL_GET_POINTER() |
Previous Message | Hayato Kuroda (Fujitsu) | 2025-06-09 07:17:12 | RE: [PATCH] Proposal: Improvements to PDF stylesheet and table column widths |