Re: XID formatting and SLRU refactorings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: orlovmg(at)gmail(dot)com, pashkin(dot)elfe(at)gmail(dot)com, japinli(at)hotmail(dot)com, aekorotkov(at)gmail(dot)com, peter(dot)eisentraut(at)enterprisedb(dot)com, aleksander(at)timescale(dot)com, ilan(at)tzirechnoy(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: XID formatting and SLRU refactorings
Date: 2022-03-18 02:29:45
Message-ID: 993503.1647570585@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> writes:
> At Thu, 17 Mar 2022 19:25:00 +0300, Maxim Orlov <orlovmg(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2022-03-18 03:12:44 Re: pgsql: Add option to use ICU as global locale provider
Previous Message Stephen Frost 2022-03-18 02:13:27 Re: Proposal: Support custom authentication methods using hooks