Re: Wrong Results from SP-GiST with Collations

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Emre Hasegeli <emre(at)hasegeli(dot)com>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Wrong Results from SP-GiST with Collations
Date: 2018-04-16 19:19:36
Message-ID: CAH2-WzkUksjq9M=OFvY4nd4ywA4BGAyBBBpFSEjLyhjWq8YYMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Apr 16, 2018 at 11:51 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> You're on to something, but I think the bug is in
> spg_text_leaf_consistent, which thinks it can do collation-aware
> comparisons like this:
>
> r = varstr_cmp(fullValue, Min(queryLen, fullLen),
> VARDATA_ANY(query), Min(queryLen, fullLen),
> PG_GET_COLLATION());

Ah. Those arguments make that code completely broken.

> and then the bit below about
>
> if (r == 0)
> {
> if (queryLen > fullLen)
> r = -1;
> else if (queryLen < fullLen)
> r = 1;
> }
>
> needs to move into the "non-collation-aware" branch.

Right. Alternatively, you could actually call varstr_cmp() within the
"non-collation-aware" branch.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-04-16 19:28:54 Re: Wrong Results from SP-GiST with Collations
Previous Message Tom Lane 2018-04-16 18:51:06 Re: Wrong Results from SP-GiST with Collations