Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5e00913

Browse files
committed
Fix varstr_cmp's special case for UTF8 encoding on Windows so that strings
that are reported as "equal" by wcscoll() are checked to see if they really are bitwise equal, and are sorted per strcmp() if not. We made this happen a couple of years ago in the regular code path, but it unaccountably got left out of the Windows/UTF8 case (probably brain fade on my part at the time). As in the prior set of changes, affected users may need to reindex indexes on textual columns. Backpatch as far as 8.2, which is the oldest release we are still supporting on Windows.
1 parent 3e701a0 commit 5e00913

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/backend/utils/adt/varlena.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.162 2008/01/01 19:45:53 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.163 2008/03/13 18:31:56 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1003,6 +1003,19 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
10031003
ereport(ERROR,
10041004
(errmsg("could not compare Unicode strings: %m")));
10051005

1006+
/*
1007+
* In some locales wcscoll() can claim that nonidentical strings
1008+
* are equal. Believing that would be bad news for a number of
1009+
* reasons, so we follow Perl's lead and sort "equal" strings
1010+
* according to strcmp (on the UTF-8 representation).
1011+
*/
1012+
if (result == 0)
1013+
{
1014+
result = strncmp(arg1, arg2, Min(len1, len2));
1015+
if ((result == 0) && (len1 != len2))
1016+
result = (len1 < len2) ? -1 : 1;
1017+
}
1018+
10061019
if (a1p != a1buf)
10071020
pfree(a1p);
10081021
if (a2p != a2buf)

0 commit comments

Comments
 (0)