| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz>, Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Cc: | li carol <carol(dot)li2025(at)outlook(dot)com>, Roman Khapov <rkhapov(at)yandex-team(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, zengman <zengman(at)halodbtech(dot)com> |
| Subject: | Re: Use correct macro for accessing offset numbers. |
| Date: | 2026-04-24 08:23:23 |
| Message-ID: | 97f9375a-be61-4272-a44d-408337fe8fa6@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 14.01.26 09:08, Michael Paquier wrote:
> On Mon, Jan 12, 2026 at 01:51:10PM +0500, Kirill Reshke wrote:
>> PFA v3 with fixes for signed usage across the tree, with my new
>> findings and suggestions from thread
>
> Note that the change in get_opfamily_member() is not right based on
> the type of "strategy". The rest was OK, so done.
The thread [0] is proposing a patch to change these things in the
opposite direction, effectively reverting commit 6dcfac9696c.
I think the premise of the patch in this thread is incorrect. You have
changed
Int16GetDatum(offset)
to
UInt16GetDatum(offset)
because the variable offset is of type OffsetNumber, which is uint16.
But that is not the meaning of the "UInt16" in UInt16GetDatum(), at
least that's the argument being made in the other thread.
These values end up being converted to an output parameter of type
smallint, and the output function int2out uses DatumGetInt16() to
convert its argument. So the *GetDatum() function should match that, so
we should use Int16GetDatum().
The real problem here is that offset values that are uint32 are being
output via the SQL type smallint, which can't handle the whole set of
values, but this is probably not a problem in practice.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Etsuro Fujita | 2026-04-24 08:59:22 | Re: Use-after-free issue in postgres_fdw |
| Previous Message | Fabrice Chapuis | 2026-04-24 08:13:11 | question on visibility map |