Fix incorrect lack of Datum conversion in _int_matchsel()
authorPeter Eisentraut <[email protected]>
Fri, 8 Aug 2025 10:06:06 +0000 (12:06 +0200)
committerPeter Eisentraut <[email protected]>
Fri, 8 Aug 2025 10:11:06 +0000 (12:11 +0200)
commit387883f68c851e716476975229c539c938d1f206
treed065cea422115a511ce26416eb6272b564e5d734
parentafdb4cde14948cdeb83701f457ecbfc4522c1a06
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

    return (Selectivity) 0.0;

where

    PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org
contrib/intarray/_int_selfuncs.c