Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd90b290

Browse files
committed
Fix broken collation-aware searches in SP-GiST text opclass.
spg_text_leaf_consistent() supposed that it should compare onlyMin(querylen, entrylen) bytes of the two strings, and then deal withany excess bytes in one string or the other by assuming the longerstring is greater if the prefixes are equal. Quite aside from thefact that that's just wrong in some locales (e.g., 'ch' is not lessthan 'd' in cs_CZ), it also risked passing incomplete multibytecharacters to strcoll(), with ensuing bad results.Instead, just pass the full strings to varstr_cmp, and let it decidewhat to do about unequal-length strings.Fortunately, this error doesn't imply any index corruption, it's justthat 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 cosmeticcleanup/pgindent'ing on710d90d, too.Discussion:https://postgr.es/m/CAE2gYzzb6K51VnTq5i5p52z+j9p2duEa-K1T3RrC_GQEynAKEg@mail.gmail.com
1 parent65f2e86 commitd90b290

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎src/backend/access/spgist/spgtextproc.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,22 +603,22 @@ spg_text_leaf_consistent(PG_FUNCTION_ARGS)
603603
/* If asserts enabled, verify encoding of reconstructed string */
604604
Assert(pg_verifymbstr(fullValue,fullLen, false));
605605

606-
r=varstr_cmp(fullValue,Min(queryLen,fullLen),
607-
VARDATA_ANY(query),Min(queryLen,fullLen),
606+
r=varstr_cmp(fullValue,fullLen,
607+
VARDATA_ANY(query),queryLen,
608608
PG_GET_COLLATION());
609609
}
610610
else
611611
{
612612
/* Non-collation-aware comparison */
613613
r=memcmp(fullValue,VARDATA_ANY(query),Min(queryLen,fullLen));
614-
}
615614

616-
if (r==0)
617-
{
618-
if (queryLen>fullLen)
619-
r=-1;
620-
elseif (queryLen<fullLen)
621-
r=1;
615+
if (r==0)
616+
{
617+
if (queryLen>fullLen)
618+
r=-1;
619+
elseif (queryLen<fullLen)
620+
r=1;
621+
}
622622
}
623623

624624
switch (strategy)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp