pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()
Date: 2025-08-08 10:17:03
Message-ID: E1ukK9n-001N3S-0E@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a3906b44c5b920cd7beb569a097660f487adf883

Modified Files
--------------
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2025-08-08 13:46:44 pgsql: Remove obsolete comment.
Previous Message Etsuro Fujita 2025-08-08 08:39:10 pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.