aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-09-24 00:56:31 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-09-24 07:55:24 -0400
commit6dda0998afc7d449145b9ba216844bdba7a817d6 (patch)
tree619337522ed6a6a87597546e3ab9591287ec5f97 /src
parent9b31c72a9492880e657b68b1ed971dec3c361c95 (diff)
downloadpostgresql-6dda0998afc7d449145b9ba216844bdba7a817d6.tar.gz
postgresql-6dda0998afc7d449145b9ba216844bdba7a817d6.zip
Allow ICU to use SortSupport on Windows with UTF-8
There is no reason to ever prevent the use of SortSupport on Windows when ICU locales are used. We previously avoided SortSupport on Windows with UTF-8 server encoding and a non C-locale due to restrictions in Windows' libc functionality. This is now considered to be a restriction in one platform's libc collation provider, and not a more general platform restriction. Reported-by: Peter Geoghegan <pg@bowt.ie>
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/varlena.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 260efd519aa..4b5483dbb97 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -1823,12 +1823,6 @@ varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar)
* requirements of BpChar callers. However, if LC_COLLATE = C, we can
* make things quite a bit faster with varstrfastcmp_c or bpcharfastcmp_c,
* both of which use memcmp() rather than strcoll().
- *
- * There is a further exception on Windows. When the database encoding is
- * UTF-8 and we are not using the C collation, complex hacks are required.
- * We don't currently have a comparator that handles that case, so we fall
- * back on the slow method of having the sort code invoke bttextcmp() (in
- * the case of text) via the fmgr trampoline.
*/
if (lc_collate_is_c(collid))
{
@@ -1839,14 +1833,8 @@ varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar)
collate_c = true;
}
-#ifdef WIN32
- else if (GetDatabaseEncoding() == PG_UTF8)
- return;
-#endif
else
{
- ssup->comparator = varstrfastcmp_locale;
-
/*
* We need a collation-sensitive comparison. To make things faster,
* we'll figure out the collation based on the locale id and cache the
@@ -1867,6 +1855,22 @@ varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar)
}
locale = pg_newlocale_from_collation(collid);
}
+
+ /*
+ * There is a further exception on Windows. When the database
+ * encoding is UTF-8 and we are not using the C collation, complex
+ * hacks are required. We don't currently have a comparator that
+ * handles that case, so we fall back on the slow method of having the
+ * sort code invoke bttextcmp() (in the case of text) via the fmgr
+ * trampoline. ICU locales work just the same on Windows, however.
+ */
+#ifdef WIN32
+ if (GetDatabaseEncoding() == PG_UTF8 &&
+ !(locale && locale->provider == COLLPROVIDER_ICU))
+ return;
+#endif
+
+ ssup->comparator = varstrfastcmp_locale;
}
/*