postgresql/src
Tom Lane b15e8f71db Fix broken collation-aware searches in SP-GiST text opclass.
spg_text_leaf_consistent() supposed that it should compare only
Min(querylen, entrylen) bytes of the two strings, and then deal with
any excess bytes in one string or the other by assuming the longer
string is greater if the prefixes are equal.  Quite aside from the
fact that that's just wrong in some locales (e.g., 'ch' is not less
than 'd' in cs_CZ), it also risked passing incomplete multibyte
characters to strcoll(), with ensuing bad results.

Instead, just pass the full strings to varstr_cmp, and let it decide
what to do about unequal-length strings.

Fortunately, this error doesn't imply any index corruption, it's just
that searches might return the wrong set of entries.

Per report from Emre Hasegeli, though this is not his patch.
Thanks to Peter Geoghegan for review and discussion.

This code was born broken, so back-patch to all supported branches.
In HEAD, I failed to resist the temptation to do a bit of cosmetic
cleanup/pgindent'ing on 710d90da1, too.

Discussion: https://postgr.es/m/CAE2gYzzb6K51VnTq5i5p52z+j9p2duEa-K1T3RrC_GQEynAKEg@mail.gmail.com
2018-04-16 16:06:58 -04:00
..
backend Fix broken collation-aware searches in SP-GiST text opclass. 2018-04-16 16:06:58 -04:00
bin Don't attempt to verify checksums on new pages 2018-04-15 14:05:56 +02:00
common Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
fe_utils Switch client-side code to include catalog/pg_foo_d.h not pg_foo.h. 2018-04-08 13:59:52 -04:00
include List src/include/partitioning in src/include/Makefile 2018-04-14 21:33:32 -03:00
interfaces In libpq, free any partial query result before collecting a server error. 2018-04-13 12:53:45 -04:00
makefiles Fix pgxs.mk to not try to build generated headers in external builds. 2018-04-10 12:41:51 -04:00
pl Support named and default arguments in CALL 2018-04-14 09:13:53 -04:00
port Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
template Force "restrict" not to be used when compiling with xlc. 2017-10-13 12:15:06 -07:00
test Update expected output of new test 2018-04-16 16:39:32 -03:00
timezone Update time zone data files to tzdata release 2018c. 2018-01-27 16:42:28 -05:00
tools Revert MERGE patch 2018-04-12 11:22:56 +01:00
tutorial Update copyright for 2018 2018-01-02 23:30:12 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Invoke submake-generated-headers during "make check", too. 2018-04-11 13:18:54 -04:00
Makefile.shlib Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-04-03 16:26:05 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00