Re: Wrong Results from SP-GiST with Collations - Mailing list pgsql-bugs

From Peter Geoghegan
Subject Re: Wrong Results from SP-GiST with Collations
Date
Msg-id CAH2-WzkUksjq9M=OFvY4nd4ywA4BGAyBBBpFSEjLyhjWq8YYMw@mail.gmail.com
Whole thread Raw
In response to Re: Wrong Results from SP-GiST with Collations  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Wrong Results from SP-GiST with Collations  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Mon, Apr 16, 2018 at 11:51 AM, Tom Lane <tgl@sss.pgh.pa.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


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Wrong Results from SP-GiST with Collations
Next
From: Tom Lane
Date:
Subject: Re: Wrong Results from SP-GiST with Collations