Re: Wrong Results from SP-GiST with Collations

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Emre Hasegeli <emre(at)hasegeli(dot)com>
Cc: 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 16:38:34
Message-ID: CAH2-Wzn-WOUtAQbnFrhbHWO69vq0QOkwkcwNykQ=qjJfkOM5Jg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Apr 16, 2018 at 8:16 AM, Emre Hasegeli <emre(at)hasegeli(dot)com> wrote:
> I think the only fix is to remove support for those operators from the
> operator class. The logic on match_special_index_operator() doesn't
> seem to need any change. Patch attached. As far as I understand, we
> cannot back-patch catalog changes. In this case, we can leave it
> broken and apply the documentation part.

Has the operator class really been completely broken since SP-GiST was
first introduced? I tend to doubt that. spg_text_inner_consistent()
has the following code, which appears to acknowledge the problem with
non-C collations:

for (j = 0; j < in->nkeys; j++)
{
StrategyNumber strategy = in->scankeys[j].sk_strategy;
text *inText;
int inSize;
int r;

/*
* If it's a collation-aware operator, but the collation is C, we
* can treat it as non-collation-aware. With non-C collation we
* need to traverse whole tree :-( so there's no point in making
* any check here. (Note also that our reconstructed value may
* well end with a partial multibyte character, so that applying
* any encoding-sensitive test to it would be risky anyhow.)
*/
if (SPG_IS_COLLATION_AWARE_STRATEGY(strategy))
{
if (collate_is_c)
strategy -= SPG_STRATEGY_ADDITION;
else
continue;
}

Maybe this is a simple, relatively benign bug. Maybe this problem is
due to commit 710d90da, which is only a couple of weeks old. Have you
reproduced the problem on v10 of Postgres?

--
Peter Geoghegan

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Liudmila Mantrova 2018-04-16 16:48:47 Re: Fwd: [BUGS] pg_trgm word_similarity inconsistencies or bug
Previous Message Peter Geoghegan 2018-04-16 16:04:56 Re: BUG #15144: *** glibc detected *** postgres: postgres smsconsole [local] SELECT: double free or corruption (!pre