mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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.
This commit is contained in:
@ -971,8 +971,12 @@ pg_newlocale_from_collation(Oid collid)
|
|||||||
if (strcmp(collcollate, collctype) == 0)
|
if (strcmp(collcollate, collctype) == 0)
|
||||||
{
|
{
|
||||||
/* Normal case where they're the same */
|
/* Normal case where they're the same */
|
||||||
|
#ifndef WIN32
|
||||||
result = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, collcollate,
|
result = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, collcollate,
|
||||||
NULL);
|
NULL);
|
||||||
|
#else
|
||||||
|
result = _create_locale(LC_ALL, collcollate);
|
||||||
|
#endif
|
||||||
if (!result)
|
if (!result)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
@ -981,6 +985,7 @@ pg_newlocale_from_collation(Oid collid)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifndef WIN32
|
||||||
/* We need two newlocale() steps */
|
/* We need two newlocale() steps */
|
||||||
locale_t loc1;
|
locale_t loc1;
|
||||||
|
|
||||||
@ -996,6 +1001,16 @@ pg_newlocale_from_collation(Oid collid)
|
|||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg("could not create locale \"%s\": %m",
|
errmsg("could not create locale \"%s\": %m",
|
||||||
collctype)));
|
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;
|
cache_entry->locale = result;
|
||||||
|
@ -1374,6 +1374,11 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid)
|
|||||||
((LPWSTR) a2p)[r] = 0;
|
((LPWSTR) a2p)[r] = 0;
|
||||||
|
|
||||||
errno = 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);
|
result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p);
|
||||||
if (result == 2147483647) /* _NLSCMPERROR; missing from mingw
|
if (result == 2147483647) /* _NLSCMPERROR; missing from mingw
|
||||||
* headers */
|
* headers */
|
||||||
|
@ -1571,7 +1571,7 @@ setup_collation(void)
|
|||||||
fputs(_("creating collations ... "), stdout);
|
fputs(_("creating collations ... "), stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
#ifdef HAVE_LOCALE_T
|
#if defined(HAVE_LOCALE_T) && !defined(WIN32)
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"\"%s\" %s template1 >%s",
|
"\"%s\" %s template1 >%s",
|
||||||
backend_exec, backend_options,
|
backend_exec, backend_options,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* changes to be valid for Visual C++ (and compatible):
|
* changes to be valid for Visual C++ (and compatible):
|
||||||
*
|
*
|
||||||
* HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_GETOPT, HAVE_GETOPT_H,
|
* HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_GETOPT, HAVE_GETOPT_H,
|
||||||
* HAVE_GETOPT_LONG, HAVE_RINT, HAVE_STRINGS_H, HAVE_STRTOLL,
|
* HAVE_GETOPT_LONG, HAVE_LOCALE_T, HAVE_RINT, HAVE_STRINGS_H, HAVE_STRTOLL,
|
||||||
* HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY,
|
* HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY,
|
||||||
* USE_INLINE, inline
|
* USE_INLINE, inline
|
||||||
*/
|
*/
|
||||||
@ -244,6 +244,9 @@
|
|||||||
#define HAVE_LL_CONSTANTS 1
|
#define HAVE_LL_CONSTANTS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `locale_t'. */
|
||||||
|
#define HAVE_LOCALE_T 1
|
||||||
|
|
||||||
/* Define to 1 if `long int' works and is 64 bits. */
|
/* Define to 1 if `long int' works and is 64 bits. */
|
||||||
/* #undef HAVE_LONG_INT_64 */
|
/* #undef HAVE_LONG_INT_64 */
|
||||||
|
|
||||||
@ -547,6 +550,9 @@
|
|||||||
/* Define to build with Kerberos 5 support. (--with-krb5) */
|
/* Define to build with Kerberos 5 support. (--with-krb5) */
|
||||||
/* #undef KRB5 */
|
/* #undef KRB5 */
|
||||||
|
|
||||||
|
/* Define to 1 if `locale_t' requires <xlocale.h>. */
|
||||||
|
/* #undef LOCALE_T_IN_XLOCALE */
|
||||||
|
|
||||||
/* Define to the location of locale files. */
|
/* Define to the location of locale files. */
|
||||||
/* #undef LOCALEDIR */
|
/* #undef LOCALEDIR */
|
||||||
|
|
||||||
|
@ -275,6 +275,20 @@ typedef int pid_t;
|
|||||||
#define EBADFD WSAENOTSOCK
|
#define EBADFD WSAENOTSOCK
|
||||||
#define EOPNOTSUPP WSAEOPNOTSUPP
|
#define EOPNOTSUPP WSAEOPNOTSUPP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extended locale functions with gratuitous underscore prefixes.
|
||||||
|
* (These APIs are nevertheless fully documented by Microsoft.)
|
||||||
|
*/
|
||||||
|
#define locale_t _locale_t
|
||||||
|
#define tolower_l _tolower_l
|
||||||
|
#define toupper_l _toupper_l
|
||||||
|
#define towlower_l _towlower_l
|
||||||
|
#define towupper_l _towupper_l
|
||||||
|
#define isalnum_l _isalnum_l
|
||||||
|
#define iswalnum_l _iswalnum_l
|
||||||
|
#define strcoll_l _strcoll_l
|
||||||
|
#define wcscoll_l _wcscoll_l
|
||||||
|
|
||||||
|
|
||||||
/* In backend/port/win32/signal.c */
|
/* In backend/port/win32/signal.c */
|
||||||
extern PGDLLIMPORT volatile int pg_signal_queue;
|
extern PGDLLIMPORT volatile int pg_signal_queue;
|
||||||
|
Reference in New Issue
Block a user