diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2011-04-10 00:14:20 +0300 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2011-04-10 00:15:41 +0300 |
commit | 11745364d074f3a7ee54c98fad55cfb5c5149326 (patch) | |
tree | e2466c56cc7fc79cf1ec8ca3e9eb16cb4e6e62e9 /src/backend | |
parent | 00f11f419caa873b44d70071d4ade0b8c75e7f36 (diff) | |
download | postgresql-11745364d074f3a7ee54c98fad55cfb5c5149326.tar.gz postgresql-11745364d074f3a7ee54c98fad55cfb5c5149326.zip |
Add collation support on Windows (MSVC build)
There is not yet support in initdb to populate the pg_collation
catalog, but if that is done manually, the rest should work.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/utils/adt/pg_locale.c | 15 | ||||
-rw-r--r-- | src/backend/utils/adt/varlena.c | 5 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index cbf74a07f2d..09ff926cba6 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -971,8 +971,12 @@ pg_newlocale_from_collation(Oid collid) if (strcmp(collcollate, collctype) == 0) { /* Normal case where they're the same */ +#ifndef WIN32 result = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, collcollate, NULL); +#else + result = _create_locale(LC_ALL, collcollate); +#endif if (!result) ereport(ERROR, (errcode_for_file_access(), @@ -981,6 +985,7 @@ pg_newlocale_from_collation(Oid collid) } else { +#ifndef WIN32 /* We need two newlocale() steps */ locale_t loc1; @@ -996,6 +1001,16 @@ pg_newlocale_from_collation(Oid collid) (errcode_for_file_access(), errmsg("could not create locale \"%s\": %m", collctype))); +#else + /* + * XXX The _create_locale() API doesn't appear to support + * this. Could perhaps be worked around by changing + * pg_locale_t to contain two separate fields. + */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("collations with different collate and ctype values are not supported on this platform"))); +#endif } cache_entry->locale = result; diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 3587fe45951..7a545214755 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -1374,6 +1374,11 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid) ((LPWSTR) a2p)[r] = 0; errno = 0; +#ifdef HAVE_LOCALE_T + if (mylocale) + result = wcscoll_l((LPWSTR) a1p, (LPWSTR) a2p, mylocale); + else +#endif result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p); if (result == 2147483647) /* _NLSCMPERROR; missing from mingw * headers */ |