Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ca051d8

Browse files
committed
Add collation versions for FreeBSD.
On FreeBSD 13, use querylocale() to read the current version of libc collations. Similar to commits 352f6f2 for Windows and d5ac14f for GNU/Linux. Discussion: https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com
1 parent a4ef032 commit ca051d8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

doc/src/sgml/charset.sgml

+2-1
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,8 @@ CREATE COLLATION ignore_accents (provider = icu, locale = 'und-u-ks-level1-kc-tr
973973
Version information is available from the
974974
<literal>icu</literal> provider on all operating systems. For the
975975
<literal>libc</literal> provider, versions are currently only available
976-
on systems using the GNU C library (most Linux systems) and Windows.
976+
on systems using the GNU C library (most Linux systems), FreeBSD and
977+
Windows.
977978
</para>
978979

979980
<note>

src/backend/utils/adt/pg_locale.c

+20
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,26 @@ get_collation_actual_version(char collprovider, const char *collcollate)
16841684

16851685
/* Use the glibc version because we don't have anything better. */
16861686
collversion = pstrdup(gnu_get_libc_version());
1687+
#elif defined(LC_VERSION_MASK)
1688+
locale_t loc;
1689+
1690+
/* C[.encoding] and POSIX never change. */
1691+
if (strcmp("C", collcollate) == 0 ||
1692+
strncmp("C.", collcollate, 2) == 0 ||
1693+
strcmp("POSIX", collcollate) == 0)
1694+
return NULL;
1695+
1696+
/* Look up FreeBSD collation version. */
1697+
loc = newlocale(LC_COLLATE, collcollate, NULL);
1698+
if (loc)
1699+
{
1700+
collversion =
1701+
pstrdup(querylocale(LC_COLLATE_MASK | LC_VERSION_MASK, loc));
1702+
freelocale(loc);
1703+
}
1704+
else
1705+
ereport(ERROR,
1706+
(errmsg("could not load locale \"%s\"", collcollate)));
16871707
#elif defined(WIN32) && _WIN32_WINNT >= 0x0600
16881708
/*
16891709
* If we are targeting Windows Vista and above, we can ask for a name

0 commit comments

Comments
 (0)