Re: Add macros for ReorderBufferTXN toptxn

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add macros for ReorderBufferTXN toptxn
Date: 2023-03-14 11:43:18
Message-ID: CAA4eK1LGFhOsqLhZfiHOvgmzzO5MHJ7OgQMnOCbYp6A9Ks92WQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 14, 2023 at 12:37 PM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Thanks for the review!
>
> On Mon, Mar 13, 2023 at 6:19 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> ...
>
> > 4) We check if txn->toptxn is not null twice here both in if condition
> > and in the assignment, we could retain the assignment operation as
> > earlier to remove the 2nd check:
> > - if (txn->toptxn)
> > - txn = txn->toptxn;
> > + if (isa_subtxn(txn))
> > + txn = get_toptxn(txn);
> >
> > We could avoid one check again by:
> > + if (isa_subtxn(txn))
> > + txn = txn->toptxn;
> >
>
> Yeah, that is true, but I chose not to keep the original assignment in
> this case mainly because then it is consistent with the other changed
> code --- e.g. Every other direct member assignment/access of the
> 'toptxn' member now hides behind the macros so I did not want this
> single place to be the odd one out. TBH, I don't think 1 extra check
> is of any significance, but it is not a problem to change like you
> suggested if other people also want it done that way.
>

Can't we directly use rbtxn_get_toptxn() for this case? I think that
way code will look neat. I see that it is not exactly matching the
existing check so you might be worried but I feel the new code will
achieve the same purpose and will be easy to follow.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-03-14 11:46:50 Re: Add macros for ReorderBufferTXN toptxn
Previous Message vignesh C 2023-03-14 11:32:39 Re: Add macros for ReorderBufferTXN toptxn