Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1174536

Browse files
committed
Add collation support on Windows (MSVC build)
There is not yet support in initdb to populate the pg_collationcatalog, but if that is done manually, the rest should work.
1 parent00f11f4 commit1174536

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,12 @@ pg_newlocale_from_collation(Oid collid)
971971
if (strcmp(collcollate,collctype)==0)
972972
{
973973
/* Normal case where they're the same */
974+
#ifndefWIN32
974975
result=newlocale(LC_COLLATE_MASK |LC_CTYPE_MASK,collcollate,
975976
NULL);
977+
#else
978+
result=_create_locale(LC_ALL,collcollate);
979+
#endif
976980
if (!result)
977981
ereport(ERROR,
978982
(errcode_for_file_access(),
@@ -981,6 +985,7 @@ pg_newlocale_from_collation(Oid collid)
981985
}
982986
else
983987
{
988+
#ifndefWIN32
984989
/* We need two newlocale() steps */
985990
locale_tloc1;
986991

@@ -996,6 +1001,16 @@ pg_newlocale_from_collation(Oid collid)
9961001
(errcode_for_file_access(),
9971002
errmsg("could not create locale \"%s\": %m",
9981003
collctype)));
1004+
#else
1005+
/*
1006+
* XXX The _create_locale() API doesn't appear to support
1007+
* this. Could perhaps be worked around by changing
1008+
* pg_locale_t to contain two separate fields.
1009+
*/
1010+
ereport(ERROR,
1011+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1012+
errmsg("collations with different collate and ctype values are not supported on this platform")));
1013+
#endif
9991014
}
10001015

10011016
cache_entry->locale=result;

‎src/backend/utils/adt/varlena.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,11 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid)
13741374
((LPWSTR)a2p)[r]=0;
13751375

13761376
errno=0;
1377+
#ifdefHAVE_LOCALE_T
1378+
if (mylocale)
1379+
result=wcscoll_l((LPWSTR)a1p, (LPWSTR)a2p,mylocale);
1380+
else
1381+
#endif
13771382
result=wcscoll((LPWSTR)a1p, (LPWSTR)a2p);
13781383
if (result==2147483647)/* _NLSCMPERROR; missing from mingw
13791384
* headers */

‎src/bin/initdb/initdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ setup_collation(void)
15711571
fputs(_("creating collations ... "),stdout);
15721572
fflush(stdout);
15731573

1574-
#ifdefHAVE_LOCALE_T
1574+
#if defined(HAVE_LOCALE_T)&& !defined(WIN32)
15751575
snprintf(cmd,sizeof(cmd),
15761576
"\"%s\" %s template1 >%s",
15771577
backend_exec,backend_options,

‎src/include/pg_config.h.win32

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* changes to be valid for Visual C++ (and compatible):
66
*
77
* HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_GETOPT, HAVE_GETOPT_H,
8-
* HAVE_GETOPT_LONG, HAVE_RINT, HAVE_STRINGS_H, HAVE_STRTOLL,
8+
* HAVE_GETOPT_LONG,HAVE_LOCALE_T,HAVE_RINT, HAVE_STRINGS_H, HAVE_STRTOLL,
99
* HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY,
1010
* USE_INLINE, inline
1111
*/
@@ -244,6 +244,9 @@
244244
#define HAVE_LL_CONSTANTS 1
245245
#endif
246246

247+
/* Define to 1 if the system has the type `locale_t'. */
248+
#define HAVE_LOCALE_T 1
249+
247250
/* Define to 1 if `long int' works and is 64 bits. */
248251
/* #undef HAVE_LONG_INT_64 */
249252

@@ -547,6 +550,9 @@
547550
/* Define to build with Kerberos 5 support. (--with-krb5) */
548551
/* #undef KRB5 */
549552

553+
/* Define to 1 if `locale_t' requires <xlocale.h>. */
554+
/* #undef LOCALE_T_IN_XLOCALE */
555+
550556
/* Define to the location of locale files. */
551557
/* #undef LOCALEDIR */
552558

‎src/include/port/win32.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ typedef int pid_t;
275275
#defineEBADFD WSAENOTSOCK
276276
#defineEOPNOTSUPP WSAEOPNOTSUPP
277277

278+
/*
279+
* Extended locale functions with gratuitous underscore prefixes.
280+
* (These APIs are nevertheless fully documented by Microsoft.)
281+
*/
282+
#definelocale_t _locale_t
283+
#definetolower_l _tolower_l
284+
#definetoupper_l _toupper_l
285+
#definetowlower_l _towlower_l
286+
#definetowupper_l _towupper_l
287+
#defineisalnum_l _isalnum_l
288+
#defineiswalnum_l _iswalnum_l
289+
#definestrcoll_l _strcoll_l
290+
#definewcscoll_l _wcscoll_l
291+
278292

279293
/* In backend/port/win32/signal.c */
280294
externPGDLLIMPORTvolatileintpg_signal_queue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp