Re: BUG #19000: gist index returns inconsistent result with gist_inet_ops

Tender Wang <tndrwang@gmail.com>

From: Tender Wang <tndrwang@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Guo <guofenglinux@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2025-08-01T04:38:00Z
Lists: pgsql-bugs
Tom Lane <tgl@sss.pgh.pa.us> 于2025年8月1日周五 11:33写道:

> Richard Guo <guofenglinux@gmail.com> writes:
> > On Fri, Aug 1, 2025 at 3:17 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> We've known about this for, um, decades: btree_gist's support for
> >> inet/cidr is fundamentally broken [1][2].  It's still there
> >> only because nobody's been able to think of a way of removing it
> >> without causing pain for anyone who has indexes like that.
> >> But maybe we should just accept that it's going to cause pain
> >> and remove it.
>
> > I think correctness should take priority over avoiding pain.
>
> Yeah.  I spent a little time investigating this today, and hope
> to have a patch to propose tomorrow.
>

What I debugged yesterday was, in  gbt_inet_consistent(),

query = convert_network_to_scalar(dquery, INETOID, &failure);
(gdb) p query
$2 = 11822170368
then in gbt_num_consistent(), called tinfo->f_lt(query, key->upper,
flinfo), which is gbt_inetlt()
and
(gdb) p *(double *) b
$5 = 11822170368

a is equal to b, gbt_inet_consistent() returned false, no index tuple found.


-- 
Thanks,
Tender Wang