On 2019-May-01, Andres Freund wrote:
> Alvaro, could we perhaps clean this up a bit? This is pretty confusing
> looking. I think this probably could just be changed to
>
> bool xmin_frozen = false;
>
> xid = HeapTupleHeaderGetXmin(tuple);
>
> if (xid == FrozenTransactionId)
> xmin_frozen = true;
> else if (TransactionIdIsNormal(xid))
>
> or somesuch. There's no need to check for
> HeapTupleHeaderXminFrozen(tuple) etc, because HeapTupleHeaderGetXmin()
> already does so - and if it didn't, the issue Tom points out would be
> problematic.
Ah, yeah, that's simpler. I would like to introduce a couple of very
minor changes to the proposed style, per the attached.
* don't initialize xmin_frozen at all; rather, only set its value to the
correct one when we have determined what it is. Doing premature
initialization is what led to some of those old bugs, so I prefer not to
do it.
* Handle the BootstrapXid and InvalidXid cases explicitly, by setting
xmin_frozen to true when xmin is not normal. After all, those XID
values do not need any freezing.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services