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

Commit352f6f2

Browse files
committed
Add collation versions for Windows.
On Vista and later, use GetNLSVersionEx() to request collation versioninformation.Reviewed-by: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>Discussion:https://postgr.es/m/CA%2BhUKGJvqup3s%2BJowVTcacZADO6dOhfdBmvOPHLS3KXUJu41Jw%40mail.gmail.com
1 parent382a821 commit352f6f2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,33 @@ get_collation_actual_version(char collprovider, const char *collcollate)
15551555

15561556
/* Use the glibc version because we don't have anything better. */
15571557
collversion=pstrdup(gnu_get_libc_version());
1558+
#elif defined(WIN32)&&_WIN32_WINNT >=0x0600
1559+
/*
1560+
* If we are targeting Windows Vista and above, we can ask for a name
1561+
* given a collation name (earlier versions required a location code
1562+
* that we don't have).
1563+
*/
1564+
NLSVERSIONINFOEXversion= {sizeof(NLSVERSIONINFOEX)};
1565+
WCHARwide_collcollate[LOCALE_NAME_MAX_LENGTH];
1566+
1567+
/* These would be invalid arguments, but have no version. */
1568+
if (pg_strcasecmp("c",collcollate)==0||
1569+
pg_strcasecmp("posix",collcollate)==0)
1570+
returnNULL;
1571+
1572+
/* For all other names, ask the OS. */
1573+
MultiByteToWideChar(CP_ACP,0,collcollate,-1,wide_collcollate,
1574+
LOCALE_NAME_MAX_LENGTH);
1575+
if (!GetNLSVersionEx(COMPARE_STRING,wide_collcollate,&version))
1576+
ereport(ERROR,
1577+
(errmsg("could not get collation version for locale \"%s\": error code %lu",
1578+
collcollate,
1579+
GetLastError())));
1580+
collversion=psprintf("%d.%d,%d.%d",
1581+
(version.dwNLSVersion >>8)&0xFFFF,
1582+
version.dwNLSVersion&0xFF,
1583+
(version.dwDefinedVersion >>8)&0xFFFF,
1584+
version.dwDefinedVersion&0xFF);
15581585
#endif
15591586
}
15601587

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp