From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas@vondra.me>
Cc: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Bug in brin_minmax_multi_distance_numeric()
Date: Thu, 31 Jul 2025 13:33:35 -0400
Message-ID: <2093712.1753983215@sss.pgh.pa.us> (raw)
Per the discussion in [1], I think we need something like
- PG_RETURN_FLOAT8(DirectFunctionCall1(numeric_float8, d));
+ PG_RETURN_DATUM(DirectFunctionCall1(numeric_float8, d));
in brin_minmax_multi_distance_numeric(). Peter was proposing
that as cosmetic cleanup, but I think it's actually a functional
bug that needs to be back-patched. It is certainly broken on
32-bit machines where the Datum result of numeric_float8 will
be a pointer, so that we will convert the numeric pointer value
to a float and return that, yielding a totally-garbage distance
value. But I think it's broken on 64-bit machines too, because
we'll be interpreting the output of numeric_float8 as a uintptr_t
and applying some unwanted conversion to make that a float.
It's not clear to me exactly what this function is used for,
but I guess the consequences would be broken BRIN indexes
on numeric columns?
regards, tom lane
[1] https://www.postgresql.org/message-id/2091622.1753982274%40sss.pgh.pa.us
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, tomas@vondra.me, peter@eisentraut.org, pgsql-hackers@lists.postgresql.org
Subject: Re: Bug in brin_minmax_multi_distance_numeric()
In-Reply-To: <2093712.1753983215@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox