Re: XID formatting and SLRU refactorings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: XID formatting and SLRU refactorings
Date
Msg-id 993503.1647570585@sss.pgh.pa.us
Whole thread Raw
In response to Re: XID formatting and SLRU refactorings  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> At Thu, 17 Mar 2022 19:25:00 +0300, Maxim Orlov <orlovmg@gmail.com> wrote in
>> +/* printf/elog format compatible with 32 and 64 bit xid. */
>> +typedef unsigned long long        XID_TYPE;
>> ...
>> +     errmsg_internal("found multixact %llu from before relminmxid %llu",
>> +             (XID_TYPE) multi, (XID_TYPE) relminmxid)));

> "(XID_TYPE) x" is actually equivalent to "(long long) x" here, but the
> point here is "%llu in format string accepts (long long)" so we should
> use literally (or bare) (long long) and the maybe-all precedents does
> that.

Yes.  Please do NOT do it like that.  Write (long long), not something
else, to cast a value to match an "ll" format specifier.  Otherwise
you're just making readers wonder whether your code is correct.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Proposal: Support custom authentication methods using hooks
Next
From: Mark Dilger
Date:
Subject: New Object Access Type hooks