@@ -1555,6 +1555,33 @@ get_collation_actual_version(char collprovider, const char *collcollate)
1555
1555
1556
1556
/* Use the glibc version because we don't have anything better. */
1557
1557
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
+ NLSVERSIONINFOEX version = {sizeof (NLSVERSIONINFOEX )};
1565
+ WCHAR wide_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
+ return NULL ;
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 );
1558
1585
#endif
1559
1586
}
1560
1587
0 commit comments