aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-13 18:32:09 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-13 18:32:09 +0000
commit99f720f8228939db8e3f73c84d5d8d01a91f58c2 (patch)
treeb0d995e17d87a8acd05195f5fa54e7080bb00441 /src
parent3917c397f034970a8952b39f64c989b5ab46075e (diff)
downloadpostgresql-99f720f8228939db8e3f73c84d5d8d01a91f58c2.tar.gz
postgresql-99f720f8228939db8e3f73c84d5d8d01a91f58c2.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/varlena.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index d96890f425e..f88c9b21fa0 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.153.2.1 2007/07/19 20:34:27 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.153.2.2 2008/03/13 18:32:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1002,6 +1002,19 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
ereport(ERROR,
(errmsg("could not compare Unicode strings: %m")));
+ /*
+ * In some locales wcscoll() can claim that nonidentical strings
+ * are equal. Believing that would be bad news for a number of
+ * reasons, so we follow Perl's lead and sort "equal" strings
+ * according to strcmp (on the UTF-8 representation).
+ */
+ if (result == 0)
+ {
+ result = strncmp(arg1, arg2, Min(len1, len2));
+ if ((result == 0) && (len1 != len2))
+ result = (len1 < len2) ? -1 : 1;
+ }
+
if (a1p != a1buf)
pfree(a1p);
if (a2p != a2buf)