pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Emre Hasegeli <emre@hasegeli.com>
Cc: Teodor Sigaev <teodor@sigaev.ru>
Cc: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: Re: Wrong Results from SP-GiST with Collations
Date: Mon, 16 Apr 2018 14:51:06 -0400
Message-ID: <19693.1523904666@sss.pgh.pa.us> (raw)
In-Reply-To: <CAH2-Wzn-WOUtAQbnFrhbHWO69vq0QOkwkcwNykQ=qjJfkOM5Jg@mail.gmail.com>
References: <CAE2gYzzb6K51VnTq5i5p52z+j9p2duEa-K1T3RrC_GQEynAKEg@mail.gmail.com>
	<CAH2-Wz=fBmXr5M=b8oQgD_k+V8jXAXOq1Zho_jz9kmUkPF86dw@mail.gmail.com>
	<CAE2gYzx_kC06hQkvF6VsFgt_47+vPfevsWee5gqy95LJE59PvQ@mail.gmail.com>
	<CAH2-Wzn-WOUtAQbnFrhbHWO69vq0QOkwkcwNykQ=qjJfkOM5Jg@mail.gmail.com>

Peter Geoghegan <pg@bowt.ie> writes:
> 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:

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());

That's got nothing to do with reality for non-C collations, and it seems
rather pointless anyway,  Why isn't this just

            r = varstr_cmp(fullValue, fullLen,
                           VARDATA_ANY(query), queryLen,
                           PG_GET_COLLATION());

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.

			regards, tom lane




view thread (11+ messages)  latest in thread

Message-ID: <19693.1523904666@sss.pgh.pa.us>
Permalink:  ../19693.1523904666@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19693.1523904666@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pg@bowt.ie, emre@hasegeli.com, teodor@sigaev.ru
  Subject: Re: Wrong Results from SP-GiST with Collations
  In-Reply-To: <19693.1523904666@sss.pgh.pa.us>
  References: <CAE2gYzzb6K51VnTq5i5p52z+j9p2duEa-K1T3RrC_GQEynAKEg@mail.gmail.com> <CAH2-Wz=fBmXr5M=b8oQgD_k+V8jXAXOq1Zho_jz9kmUkPF86dw@mail.gmail.com> <CAE2gYzx_kC06hQkvF6VsFgt_47+vPfevsWee5gqy95LJE59PvQ@mail.gmail.com> <CAH2-Wzn-WOUtAQbnFrhbHWO69vq0QOkwkcwNykQ=qjJfkOM5Jg@mail.gmail.com> <19693.1523904666@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