Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
PostgreSQL Source Code git master
pg_locale.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  collate_methods
 
struct  pg_locale_struct
 

Macros

#define LOCALE_NAME_BUFLEN   128
 

Typedefs

typedef struct pg_locale_structpg_locale_t
 

Functions

bool check_locale (int category, const char *locale, char **canonname)
 
char * pg_perm_setlocale (int category, const char *locale)
 
struct lconv * PGLC_localeconv (void)
 
void cache_locale_time (void)
 
void init_database_collation (void)
 
pg_locale_t pg_newlocale_from_collation (Oid collid)
 
char * get_collation_actual_version (char collprovider, const char *collcollate)
 
size_t pg_strlower (char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
size_t pg_strtitle (char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
size_t pg_strupper (char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
size_t pg_strfold (char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
int pg_strcoll (const char *arg1, const char *arg2, pg_locale_t locale)
 
int pg_strncoll (const char *arg1, ssize_t len1, const char *arg2, ssize_t len2, pg_locale_t locale)
 
bool pg_strxfrm_enabled (pg_locale_t locale)
 
size_t pg_strxfrm (char *dest, const char *src, size_t destsize, pg_locale_t locale)
 
size_t pg_strnxfrm (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
bool pg_strxfrm_prefix_enabled (pg_locale_t locale)
 
size_t pg_strxfrm_prefix (char *dest, const char *src, size_t destsize, pg_locale_t locale)
 
size_t pg_strnxfrm_prefix (char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
 
int builtin_locale_encoding (const char *locale)
 
const char * builtin_validate_locale (int encoding, const char *locale)
 
void icu_validate_locale (const char *loc_str)
 
char * icu_language_tag (const char *loc_str, int elevel)
 
void report_newlocale_failure (const char *localename)
 
size_t wchar2char (char *to, const wchar_t *from, size_t tolen, pg_locale_t locale)
 
size_t char2wchar (wchar_t *to, size_t tolen, const char *from, size_t fromlen, pg_locale_t locale)
 

Variables

PGDLLIMPORT char * locale_messages
 
PGDLLIMPORT char * locale_monetary
 
PGDLLIMPORT char * locale_numeric
 
PGDLLIMPORT char * locale_time
 
PGDLLIMPORT int icu_validation_level
 
PGDLLIMPORT char * localized_abbrev_days []
 
PGDLLIMPORT char * localized_full_days []
 
PGDLLIMPORT char * localized_abbrev_months []
 
PGDLLIMPORT char * localized_full_months []
 
PGDLLIMPORT bool database_ctype_is_c
 

Macro Definition Documentation

◆ LOCALE_NAME_BUFLEN

#define LOCALE_NAME_BUFLEN   128

Definition at line 20 of file pg_locale.h.

Typedef Documentation

◆ pg_locale_t

typedef struct pg_locale_struct* pg_locale_t

Definition at line 51 of file pg_locale.h.

Function Documentation

◆ builtin_locale_encoding()

int builtin_locale_encoding ( const char *  locale)

Definition at line 1472 of file pg_locale.c.

1473{
1474 if (strcmp(locale, "C") == 0)
1475 return -1;
1476 else if (strcmp(locale, "C.UTF-8") == 0)
1477 return PG_UTF8;
1478 else if (strcmp(locale, "PG_UNICODE_FAST") == 0)
1479 return PG_UTF8;
1480
1481
1482 ereport(ERROR,
1483 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
1484 errmsg("invalid locale name \"%s\" for builtin provider",
1485 locale)));
1486
1487 return 0; /* keep compiler quiet */
1488}
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
static char * locale
Definition: initdb.c:140
@ PG_UTF8
Definition: pg_wchar.h:232

References ereport, errcode(), errmsg(), ERROR, locale, and PG_UTF8.

Referenced by builtin_validate_locale(), and DefineCollation().

◆ builtin_validate_locale()

const char * builtin_validate_locale ( int  encoding,
const char *  locale 
)

Definition at line 1496 of file pg_locale.c.

1497{
1498 const char *canonical_name = NULL;
1499 int required_encoding;
1500
1501 if (strcmp(locale, "C") == 0)
1502 canonical_name = "C";
1503 else if (strcmp(locale, "C.UTF-8") == 0 || strcmp(locale, "C.UTF8") == 0)
1504 canonical_name = "C.UTF-8";
1505 else if (strcmp(locale, "PG_UNICODE_FAST") == 0)
1506 canonical_name = "PG_UNICODE_FAST";
1507
1508 if (!canonical_name)
1509 ereport(ERROR,
1510 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
1511 errmsg("invalid locale name \"%s\" for builtin provider",
1512 locale)));
1513
1514 required_encoding = builtin_locale_encoding(canonical_name);
1515 if (required_encoding >= 0 && encoding != required_encoding)
1516 ereport(ERROR,
1517 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
1518 errmsg("encoding \"%s\" does not match locale \"%s\"",
1520
1521 return canonical_name;
1522}
int32 encoding
Definition: pg_database.h:41
int builtin_locale_encoding(const char *locale)
Definition: pg_locale.c:1472
#define pg_encoding_to_char
Definition: pg_wchar.h:630

References builtin_locale_encoding(), encoding, ereport, errcode(), errmsg(), ERROR, locale, and pg_encoding_to_char.

Referenced by create_pg_locale_builtin(), createdb(), and DefineCollation().

◆ cache_locale_time()

void cache_locale_time ( void  )

Definition at line 721 of file pg_locale.c.

722{
723 char buf[(2 * 7 + 2 * 12) * MAX_L10N_DATA];
724 char *bufptr;
725 time_t timenow;
726 struct tm *timeinfo;
727 struct tm timeinfobuf;
728 bool strftimefail = false;
729 int encoding;
730 int i;
732
733 /* did we do this already? */
735 return;
736
737 elog(DEBUG3, "cache_locale_time() executed; locale: \"%s\"", locale_time);
738
739 errno = ENOENT;
740#ifdef WIN32
741 locale = _create_locale(LC_ALL, locale_time);
742 if (locale == (locale_t) 0)
743 _dosmaperr(GetLastError());
744#else
745 locale = newlocale(LC_ALL_MASK, locale_time, (locale_t) 0);
746#endif
747 if (!locale)
749
750 /* We use times close to current time as data for strftime(). */
751 timenow = time(NULL);
752 timeinfo = gmtime_r(&timenow, &timeinfobuf);
753
754 /* Store the strftime results in MAX_L10N_DATA-sized portions of buf[] */
755 bufptr = buf;
756
757 /*
758 * MAX_L10N_DATA is sufficient buffer space for every known locale, and
759 * POSIX defines no strftime() errors. (Buffer space exhaustion is not an
760 * error.) An implementation might report errors (e.g. ENOMEM) by
761 * returning 0 (or, less plausibly, a negative value) and setting errno.
762 * Report errno just in case the implementation did that, but clear it in
763 * advance of the calls so we don't emit a stale, unrelated errno.
764 */
765 errno = 0;
766
767 /* localized days */
768 for (i = 0; i < 7; i++)
769 {
770 timeinfo->tm_wday = i;
771 if (strftime_l(bufptr, MAX_L10N_DATA, "%a", timeinfo, locale) <= 0)
772 strftimefail = true;
773 bufptr += MAX_L10N_DATA;
774 if (strftime_l(bufptr, MAX_L10N_DATA, "%A", timeinfo, locale) <= 0)
775 strftimefail = true;
776 bufptr += MAX_L10N_DATA;
777 }
778
779 /* localized months */
780 for (i = 0; i < 12; i++)
781 {
782 timeinfo->tm_mon = i;
783 timeinfo->tm_mday = 1; /* make sure we don't have invalid date */
784 if (strftime_l(bufptr, MAX_L10N_DATA, "%b", timeinfo, locale) <= 0)
785 strftimefail = true;
786 bufptr += MAX_L10N_DATA;
787 if (strftime_l(bufptr, MAX_L10N_DATA, "%B", timeinfo, locale) <= 0)
788 strftimefail = true;
789 bufptr += MAX_L10N_DATA;
790 }
791
792#ifdef WIN32
793 _free_locale(locale);
794#else
795 freelocale(locale);
796#endif
797
798 /*
799 * At this point we've done our best to clean up, and can throw errors, or
800 * call functions that might throw errors, with a clean conscience.
801 */
802 if (strftimefail)
803 elog(ERROR, "strftime_l() failed");
804
805#ifndef WIN32
806
807 /*
808 * As in PGLC_localeconv(), we must convert strftime()'s output from the
809 * encoding implied by LC_TIME to the database encoding. If we can't
810 * identify the LC_TIME encoding, just perform encoding validation.
811 */
813 if (encoding < 0)
815
816#else
817
818 /*
819 * On Windows, strftime_win32() always returns UTF8 data, so convert from
820 * that if necessary.
821 */
823
824#endif /* WIN32 */
825
826 bufptr = buf;
827
828 /* localized days */
829 for (i = 0; i < 7; i++)
830 {
832 bufptr += MAX_L10N_DATA;
834 bufptr += MAX_L10N_DATA;
835 }
836 localized_abbrev_days[7] = NULL;
837 localized_full_days[7] = NULL;
838
839 /* localized months */
840 for (i = 0; i < 12; i++)
841 {
843 bufptr += MAX_L10N_DATA;
845 bufptr += MAX_L10N_DATA;
846 }
847 localized_abbrev_months[12] = NULL;
848 localized_full_months[12] = NULL;
849
850 CurrentLCTimeValid = true;
851}
#define DEBUG3
Definition: elog.h:28
#define elog(elevel,...)
Definition: elog.h:225
int i
Definition: isn.c:77
static struct pg_tm tm
Definition: localtime.c:104
char * localized_full_months[12+1]
Definition: pg_locale.c:126
static bool CurrentLCTimeValid
Definition: pg_locale.c:135
char * locale_time
Definition: pg_locale.c:112
static void cache_single_string(char **dst, const char *src, int encoding)
Definition: pg_locale.c:698
#define MAX_L10N_DATA
Definition: pg_locale.c:66
char * localized_abbrev_months[12+1]
Definition: pg_locale.c:125
char * localized_full_days[7+1]
Definition: pg_locale.c:124
char * localized_abbrev_days[7+1]
Definition: pg_locale.c:123
void report_newlocale_failure(const char *localename)
static char * buf
Definition: pg_test_fsync.c:72
@ PG_SQL_ASCII
Definition: pg_wchar.h:226
int pg_get_encoding_from_locale(const char *ctype, bool write_message)
Definition: chklocale.c:301
#define locale_t
Definition: win32_port.h:432
void _dosmaperr(unsigned long)
Definition: win32error.c:177

References _dosmaperr(), buf, cache_single_string(), CurrentLCTimeValid, DEBUG3, elog, encoding, ERROR, i, locale, locale_t, locale_time, localized_abbrev_days, localized_abbrev_months, localized_full_days, localized_full_months, MAX_L10N_DATA, pg_get_encoding_from_locale(), PG_SQL_ASCII, PG_UTF8, report_newlocale_failure(), and tm.

Referenced by DCH_from_char(), and DCH_to_char().

◆ char2wchar()

size_t char2wchar ( wchar_t *  to,
size_t  tolen,
const char *  from,
size_t  fromlen,
pg_locale_t  locale 
)

Definition at line 936 of file pg_locale_libc.c.

938{
939 size_t result;
940
941 if (tolen == 0)
942 return 0;
943
944#ifdef WIN32
945 /* See WIN32 "Unicode" comment above */
947 {
948 /* Win32 API does not work for zero-length input */
949 if (fromlen == 0)
950 result = 0;
951 else
952 {
953 result = MultiByteToWideChar(CP_UTF8, 0, from, fromlen, to, tolen - 1);
954 /* A zero return is failure */
955 if (result == 0)
956 result = -1;
957 }
958
959 if (result != -1)
960 {
961 Assert(result < tolen);
962 /* Append trailing null wchar (MultiByteToWideChar() does not) */
963 to[result] = 0;
964 }
965 }
966 else
967#endif /* WIN32 */
968 {
969 /* mbstowcs requires ending '\0' */
970 char *str = pnstrdup(from, fromlen);
971
972 if (locale == (pg_locale_t) 0)
973 {
974 /* Use mbstowcs directly for the default locale */
975 result = mbstowcs(to, str, tolen);
976 }
977 else
978 {
979 /* Use mbstowcs_l for nondefault locales */
980 result = mbstowcs_l(to, str, tolen, locale->info.lt);
981 }
982
983 pfree(str);
984 }
985
986 if (result == -1)
987 {
988 /*
989 * Invalid multibyte character encountered. We try to give a useful
990 * error message by letting pg_verifymbstr check the string. But it's
991 * possible that the string is OK to us, and not OK to mbstowcs ---
992 * this suggests that the LC_CTYPE locale is different from the
993 * database encoding. Give a generic error message if pg_verifymbstr
994 * can't find anything wrong.
995 */
996 pg_verifymbstr(from, fromlen, false); /* might not return */
997 /* but if it does ... */
999 (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
1000 errmsg("invalid multibyte character for locale"),
1001 errhint("The server's LC_CTYPE locale is probably incompatible with the database encoding.")));
1002 }
1003
1004 return result;
1005}
int errhint(const char *fmt,...)
Definition: elog.c:1318
Assert(PointerIsAligned(start, uint64))
const char * str
int GetDatabaseEncoding(void)
Definition: mbutils.c:1262
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
Definition: mbutils.c:1557
void pfree(void *pointer)
Definition: mcxt.c:1528
char * pnstrdup(const char *in, Size len)
Definition: mcxt.c:1714
static size_t mbstowcs_l(wchar_t *dest, const char *src, size_t n, locale_t loc)

References Assert(), ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), locale, mbstowcs_l(), pfree(), PG_UTF8, pg_verifymbstr(), pnstrdup(), and str.

Referenced by strlower_libc_mb(), strtitle_libc_mb(), strupper_libc_mb(), t_isalnum(), t_isalpha(), and TParserInit().

◆ check_locale()

bool check_locale ( int  category,
const char *  locale,
char **  canonname 
)

Definition at line 294 of file pg_locale.c.

295{
296 char *save;
297 char *res;
298
299 /* Don't let Windows' non-ASCII locale names in. */
300 if (!pg_is_ascii(locale))
301 {
303 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
304 errmsg("locale name \"%s\" contains non-ASCII characters",
305 locale)));
306 return false;
307 }
308
309 if (canonname)
310 *canonname = NULL; /* in case of failure */
311
312 save = setlocale(category, NULL);
313 if (!save)
314 return false; /* won't happen, we hope */
315
316 /* save may be pointing at a modifiable scratch variable, see above. */
317 save = pstrdup(save);
318
319 /* set the locale with setlocale, to see if it accepts it. */
320 res = setlocale(category, locale);
321
322 /* save canonical name if requested. */
323 if (res && canonname)
324 *canonname = pstrdup(res);
325
326 /* restore old value. */
327 if (!setlocale(category, save))
328 elog(WARNING, "failed to restore old locale \"%s\"", save);
329 pfree(save);
330
331 /* Don't let Windows' non-ASCII locale names out. */
332 if (canonname && *canonname && !pg_is_ascii(*canonname))
333 {
335 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
336 errmsg("locale name \"%s\" contains non-ASCII characters",
337 *canonname)));
338 pfree(*canonname);
339 *canonname = NULL;
340 return false;
341 }
342
343 return (res != NULL);
344}
#define WARNING
Definition: elog.h:36
char * pstrdup(const char *in)
Definition: mcxt.c:1703
bool pg_is_ascii(const char *str)
Definition: string.c:132
#define setlocale(a, b)
Definition: win32_port.h:475

References elog, ereport, errcode(), errmsg(), locale, pfree(), pg_is_ascii(), pstrdup(), setlocale, and WARNING.

Referenced by check_locale_messages(), check_locale_monetary(), check_locale_numeric(), check_locale_time(), and createdb().

◆ get_collation_actual_version()

char * get_collation_actual_version ( char  collprovider,
const char *  collcollate 
)

Definition at line 1240 of file pg_locale.c.

1241{
1242 char *collversion = NULL;
1243
1244 if (collprovider == COLLPROVIDER_BUILTIN)
1245 collversion = get_collation_actual_version_builtin(collcollate);
1246#ifdef USE_ICU
1247 else if (collprovider == COLLPROVIDER_ICU)
1248 collversion = get_collation_actual_version_icu(collcollate);
1249#endif
1250 else if (collprovider == COLLPROVIDER_LIBC)
1251 collversion = get_collation_actual_version_libc(collcollate);
1252
1253 return collversion;
1254}
char * get_collation_actual_version_libc(const char *collcollate)
char * get_collation_actual_version_builtin(const char *collcollate)

References get_collation_actual_version_builtin(), and get_collation_actual_version_libc().

Referenced by AlterCollation(), AlterDatabaseRefreshColl(), CheckMyDatabase(), create_pg_locale(), createdb(), DefineCollation(), pg_collation_actual_version(), pg_database_collation_actual_version(), and pg_import_system_collations().

◆ icu_language_tag()

char * icu_language_tag ( const char *  loc_str,
int  elevel 
)

Definition at line 1536 of file pg_locale.c.

1537{
1538#ifdef USE_ICU
1539 UErrorCode status;
1540 char *langtag;
1541 size_t buflen = 32; /* arbitrary starting buffer size */
1542 const bool strict = true;
1543
1544 /*
1545 * A BCP47 language tag doesn't have a clearly-defined upper limit (cf.
1546 * RFC5646 section 4.4). Additionally, in older ICU versions,
1547 * uloc_toLanguageTag() doesn't always return the ultimate length on the
1548 * first call, necessitating a loop.
1549 */
1550 langtag = palloc(buflen);
1551 while (true)
1552 {
1553 status = U_ZERO_ERROR;
1554 uloc_toLanguageTag(loc_str, langtag, buflen, strict, &status);
1555
1556 /* try again if the buffer is not large enough */
1557 if ((status == U_BUFFER_OVERFLOW_ERROR ||
1558 status == U_STRING_NOT_TERMINATED_WARNING) &&
1559 buflen < MaxAllocSize)
1560 {
1561 buflen = Min(buflen * 2, MaxAllocSize);
1562 langtag = repalloc(langtag, buflen);
1563 continue;
1564 }
1565
1566 break;
1567 }
1568
1569 if (U_FAILURE(status))
1570 {
1571 pfree(langtag);
1572
1573 if (elevel > 0)
1574 ereport(elevel,
1575 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1576 errmsg("could not convert locale name \"%s\" to language tag: %s",
1577 loc_str, u_errorName(status))));
1578 return NULL;
1579 }
1580
1581 return langtag;
1582#else /* not USE_ICU */
1583 ereport(ERROR,
1584 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1585 errmsg("ICU is not supported in this build")));
1586 return NULL; /* keep compiler quiet */
1587#endif /* not USE_ICU */
1588}
#define Min(x, y)
Definition: c.h:975
#define MaxAllocSize
Definition: fe_memutils.h:22
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1548
void * palloc(Size size)
Definition: mcxt.c:1321

References ereport, errcode(), errmsg(), ERROR, MaxAllocSize, Min, palloc(), pfree(), and repalloc().

Referenced by createdb(), DefineCollation(), and pg_import_system_collations().

◆ icu_validate_locale()

void icu_validate_locale ( const char *  loc_str)

Definition at line 1594 of file pg_locale.c.

1595{
1596#ifdef USE_ICU
1597 UCollator *collator;
1598 UErrorCode status;
1599 char lang[ULOC_LANG_CAPACITY];
1600 bool found = false;
1601 int elevel = icu_validation_level;
1602
1603 /* no validation */
1604 if (elevel < 0)
1605 return;
1606
1607 /* downgrade to WARNING during pg_upgrade */
1608 if (IsBinaryUpgrade && elevel > WARNING)
1609 elevel = WARNING;
1610
1611 /* validate that we can extract the language */
1612 status = U_ZERO_ERROR;
1613 uloc_getLanguage(loc_str, lang, ULOC_LANG_CAPACITY, &status);
1614 if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING)
1615 {
1616 ereport(elevel,
1617 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1618 errmsg("could not get language from ICU locale \"%s\": %s",
1619 loc_str, u_errorName(status)),
1620 errhint("To disable ICU locale validation, set the parameter \"%s\" to \"%s\".",
1621 "icu_validation_level", "disabled")));
1622 return;
1623 }
1624
1625 /* check for special language name */
1626 if (strcmp(lang, "") == 0 ||
1627 strcmp(lang, "root") == 0 || strcmp(lang, "und") == 0)
1628 found = true;
1629
1630 /* search for matching language within ICU */
1631 for (int32_t i = 0; !found && i < uloc_countAvailable(); i++)
1632 {
1633 const char *otherloc = uloc_getAvailable(i);
1634 char otherlang[ULOC_LANG_CAPACITY];
1635
1636 status = U_ZERO_ERROR;
1637 uloc_getLanguage(otherloc, otherlang, ULOC_LANG_CAPACITY, &status);
1638 if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING)
1639 continue;
1640
1641 if (strcmp(lang, otherlang) == 0)
1642 found = true;
1643 }
1644
1645 if (!found)
1646 ereport(elevel,
1647 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1648 errmsg("ICU locale \"%s\" has unknown language \"%s\"",
1649 loc_str, lang),
1650 errhint("To disable ICU locale validation, set the parameter \"%s\" to \"%s\".",
1651 "icu_validation_level", "disabled")));
1652
1653 /* check that it can be opened */
1654 collator = pg_ucol_open(loc_str);
1655 ucol_close(collator);
1656#else /* not USE_ICU */
1657 /* could get here if a collation was created by a build with ICU */
1658 ereport(ERROR,
1659 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1660 errmsg("ICU is not supported in this build")));
1661#endif /* not USE_ICU */
1662}
bool IsBinaryUpgrade
Definition: globals.c:121
int icu_validation_level
Definition: pg_locale.c:114

References ereport, errcode(), errhint(), errmsg(), ERROR, i, icu_validation_level, IsBinaryUpgrade, and WARNING.

Referenced by createdb(), and DefineCollation().

◆ init_database_collation()

void init_database_collation ( void  )

Definition at line 1147 of file pg_locale.c.

1148{
1149 HeapTuple tup;
1150 Form_pg_database dbform;
1151 pg_locale_t result;
1152
1153 Assert(default_locale == NULL);
1154
1155 /* Fetch our pg_database row normally, via syscache */
1156 tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
1157 if (!HeapTupleIsValid(tup))
1158 elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
1159 dbform = (Form_pg_database) GETSTRUCT(tup);
1160
1161 if (dbform->datlocprovider == COLLPROVIDER_BUILTIN)
1162 result = create_pg_locale_builtin(DEFAULT_COLLATION_OID,
1164 else if (dbform->datlocprovider == COLLPROVIDER_ICU)
1165 result = create_pg_locale_icu(DEFAULT_COLLATION_OID,
1167 else if (dbform->datlocprovider == COLLPROVIDER_LIBC)
1168 result = create_pg_locale_libc(DEFAULT_COLLATION_OID,
1170 else
1171 /* shouldn't happen */
1172 PGLOCALE_SUPPORT_ERROR(dbform->datlocprovider);
1173
1174 result->is_default = true;
1175 ReleaseSysCache(tup);
1176
1177 default_locale = result;
1178}
Oid MyDatabaseId
Definition: globals.c:94
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
Definition: htup_details.h:728
MemoryContext TopMemoryContext
Definition: mcxt.c:149
FormData_pg_database * Form_pg_database
Definition: pg_database.h:96
pg_locale_t create_pg_locale_libc(Oid collid, MemoryContext context)
pg_locale_t create_pg_locale_builtin(Oid collid, MemoryContext context)
#define PGLOCALE_SUPPORT_ERROR(provider)
Definition: pg_locale.c:57
pg_locale_t create_pg_locale_icu(Oid collid, MemoryContext context)
static pg_locale_t default_locale
Definition: pg_locale.c:131
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:257
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:269
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:221

References Assert(), create_pg_locale_builtin(), create_pg_locale_icu(), create_pg_locale_libc(), default_locale, elog, ERROR, GETSTRUCT(), HeapTupleIsValid, pg_locale_struct::is_default, MyDatabaseId, ObjectIdGetDatum(), PGLOCALE_SUPPORT_ERROR, ReleaseSysCache(), SearchSysCache1(), and TopMemoryContext.

Referenced by CheckMyDatabase().

◆ pg_newlocale_from_collation()

pg_locale_t pg_newlocale_from_collation ( Oid  collid)

Definition at line 1189 of file pg_locale.c.

1190{
1191 collation_cache_entry *cache_entry;
1192 bool found;
1193
1194 if (collid == DEFAULT_COLLATION_OID)
1195 return default_locale;
1196
1197 if (!OidIsValid(collid))
1198 elog(ERROR, "cache lookup failed for collation %u", collid);
1199
1201
1204
1205 if (CollationCache == NULL)
1206 {
1208 "collation cache",
1210 CollationCache = collation_cache_create(CollationCacheContext,
1211 16, NULL);
1212 }
1213
1214 cache_entry = collation_cache_insert(CollationCache, collid, &found);
1215 if (!found)
1216 {
1217 /*
1218 * Make sure cache entry is marked invalid, in case we fail before
1219 * setting things.
1220 */
1221 cache_entry->locale = 0;
1222 }
1223
1224 if (cache_entry->locale == 0)
1225 {
1227 }
1228
1230 last_collation_cache_locale = cache_entry->locale;
1231
1232 return cache_entry->locale;
1233}
#define OidIsValid(objectId)
Definition: c.h:746
Oid collid
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
static pg_locale_t last_collation_cache_locale
Definition: pg_locale.c:170
static pg_locale_t create_pg_locale(Oid collid, MemoryContext context)
Definition: pg_locale.c:1068
static MemoryContext CollationCacheContext
Definition: pg_locale.c:162
static collation_cache_hash * CollationCache
Definition: pg_locale.c:163
static Oid last_collation_cache_oid
Definition: pg_locale.c:169
static void AssertCouldGetRelation(void)
Definition: relcache.h:44
Definition: pg_locale.c:140
pg_locale_t locale
Definition: pg_locale.c:142

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, AssertCouldGetRelation(), CollationCache, CollationCacheContext, collid, create_pg_locale(), default_locale, elog, ERROR, last_collation_cache_locale, last_collation_cache_oid, collation_cache_entry::locale, OidIsValid, and TopMemoryContext.

Referenced by bpchareq(), bpcharne(), btvarstrequalimage(), convert_string_datum(), DefineCollation(), Generic_Text_IC_like(), GenericMatchText(), hashbpchar(), hashbpcharextended(), hashtext(), hashtextextended(), like_fixed_prefix(), make_greater_string(), match_pattern_prefix(), pg_set_regex_collation(), spg_text_inner_consistent(), str_casefold(), str_initcap(), str_tolower(), str_toupper(), text_position(), text_position_setup(), text_starts_with(), texteq(), textne(), varstr_cmp(), and varstr_sortsupport().

◆ pg_perm_setlocale()

char * pg_perm_setlocale ( int  category,
const char *  locale 
)

Definition at line 191 of file pg_locale.c.

192{
193 char *result;
194 const char *envvar;
195
196#ifndef WIN32
197 result = setlocale(category, locale);
198#else
199
200 /*
201 * On Windows, setlocale(LC_MESSAGES) does not work, so just assume that
202 * the given value is good and set it in the environment variables. We
203 * must ignore attempts to set to "", which means "keep using the old
204 * environment value".
205 */
206#ifdef LC_MESSAGES
207 if (category == LC_MESSAGES)
208 {
209 result = (char *) locale;
210 if (locale == NULL || locale[0] == '\0')
211 return result;
212 }
213 else
214#endif
215 result = setlocale(category, locale);
216#endif /* WIN32 */
217
218 if (result == NULL)
219 return result; /* fall out immediately on failure */
220
221 /*
222 * Use the right encoding in translated messages. Under ENABLE_NLS, let
223 * pg_bind_textdomain_codeset() figure it out. Under !ENABLE_NLS, message
224 * format strings are ASCII, but database-encoding strings may enter the
225 * message via %s. This makes the overall message encoding equal to the
226 * database encoding.
227 */
228 if (category == LC_CTYPE)
229 {
230 static char save_lc_ctype[LOCALE_NAME_BUFLEN];
231
232 /* copy setlocale() return value before callee invokes it again */
233 strlcpy(save_lc_ctype, result, sizeof(save_lc_ctype));
234 result = save_lc_ctype;
235
236#ifdef ENABLE_NLS
237 SetMessageEncoding(pg_bind_textdomain_codeset(textdomain(NULL)));
238#else
240#endif
241 }
242
243 switch (category)
244 {
245 case LC_COLLATE:
246 envvar = "LC_COLLATE";
247 break;
248 case LC_CTYPE:
249 envvar = "LC_CTYPE";
250 break;
251#ifdef LC_MESSAGES
252 case LC_MESSAGES:
253 envvar = "LC_MESSAGES";
254#ifdef WIN32
255 result = IsoLocaleName(locale);
256 if (result == NULL)
257 result = (char *) locale;
258 elog(DEBUG3, "IsoLocaleName() executed; locale: \"%s\"", result);
259#endif /* WIN32 */
260 break;
261#endif /* LC_MESSAGES */
262 case LC_MONETARY:
263 envvar = "LC_MONETARY";
264 break;
265 case LC_NUMERIC:
266 envvar = "LC_NUMERIC";
267 break;
268 case LC_TIME:
269 envvar = "LC_TIME";
270 break;
271 default:
272 elog(FATAL, "unrecognized LC category: %d", category);
273 return NULL; /* keep compiler quiet */
274 }
275
276 if (setenv(envvar, result, 1) != 0)
277 return NULL;
278
279 return result;
280}
#define FATAL
Definition: elog.h:41
void SetMessageEncoding(int encoding)
Definition: mbutils.c:1172
#define LOCALE_NAME_BUFLEN
Definition: pg_locale.h:20
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
#define setenv(x, y, z)
Definition: win32_port.h:545

References DEBUG3, elog, FATAL, GetDatabaseEncoding(), locale, LOCALE_NAME_BUFLEN, setenv, setlocale, SetMessageEncoding(), and strlcpy().

Referenced by assign_locale_messages(), CheckMyDatabase(), and init_locale().

◆ pg_strcoll()

int pg_strcoll ( const char *  arg1,
const char *  arg2,
pg_locale_t  locale 
)

Definition at line 1339 of file pg_locale.c.

1340{
1341 return locale->collate->strncoll(arg1, -1, arg2, -1, locale);
1342}

References locale.

Referenced by varstrfastcmp_locale().

◆ pg_strfold()

size_t pg_strfold ( char *  dst,
size_t  dstsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)

Definition at line 1314 of file pg_locale.c.

1316{
1317 if (locale->provider == COLLPROVIDER_BUILTIN)
1318 return strfold_builtin(dst, dstsize, src, srclen, locale);
1319#ifdef USE_ICU
1320 else if (locale->provider == COLLPROVIDER_ICU)
1321 return strfold_icu(dst, dstsize, src, srclen, locale);
1322#endif
1323 /* for libc, just use strlower */
1324 else if (locale->provider == COLLPROVIDER_LIBC)
1325 return strlower_libc(dst, dstsize, src, srclen, locale);
1326 else
1327 /* shouldn't happen */
1328 PGLOCALE_SUPPORT_ERROR(locale->provider);
1329
1330 return 0; /* keep compiler quiet */
1331}
size_t strfold_icu(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t strlower_libc(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t strfold_builtin(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)

References locale, PGLOCALE_SUPPORT_ERROR, strfold_builtin(), strfold_icu(), and strlower_libc().

Referenced by str_casefold().

◆ pg_strlower()

size_t pg_strlower ( char *  dst,
size_t  dstsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)

Definition at line 1257 of file pg_locale.c.

1259{
1260 if (locale->provider == COLLPROVIDER_BUILTIN)
1261 return strlower_builtin(dst, dstsize, src, srclen, locale);
1262#ifdef USE_ICU
1263 else if (locale->provider == COLLPROVIDER_ICU)
1264 return strlower_icu(dst, dstsize, src, srclen, locale);
1265#endif
1266 else if (locale->provider == COLLPROVIDER_LIBC)
1267 return strlower_libc(dst, dstsize, src, srclen, locale);
1268 else
1269 /* shouldn't happen */
1270 PGLOCALE_SUPPORT_ERROR(locale->provider);
1271
1272 return 0; /* keep compiler quiet */
1273}
size_t strlower_icu(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t strlower_builtin(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)

References locale, PGLOCALE_SUPPORT_ERROR, strlower_builtin(), strlower_icu(), and strlower_libc().

Referenced by str_tolower().

◆ pg_strncoll()

int pg_strncoll ( const char *  arg1,
ssize_t  len1,
const char *  arg2,
ssize_t  len2,
pg_locale_t  locale 
)

Definition at line 1359 of file pg_locale.c.

1361{
1362 return locale->collate->strncoll(arg1, len1, arg2, len2, locale);
1363}

References locale.

Referenced by MatchText(), text_position_next_internal(), and varstr_cmp().

◆ pg_strnxfrm()

size_t pg_strnxfrm ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)

Definition at line 1414 of file pg_locale.c.

1416{
1417 return locale->collate->strnxfrm(dest, destsize, src, srclen, locale);
1418}

References generate_unaccent_rules::dest, and locale.

Referenced by hashbpchar(), hashbpcharextended(), hashtext(), and hashtextextended().

◆ pg_strnxfrm_prefix()

size_t pg_strnxfrm_prefix ( char *  dest,
size_t  destsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)

Definition at line 1461 of file pg_locale.c.

1463{
1464 return locale->collate->strnxfrm_prefix(dest, destsize, src, srclen, locale);
1465}

References generate_unaccent_rules::dest, and locale.

◆ pg_strtitle()

size_t pg_strtitle ( char *  dst,
size_t  dstsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)

Definition at line 1276 of file pg_locale.c.

1278{
1279 if (locale->provider == COLLPROVIDER_BUILTIN)
1280 return strtitle_builtin(dst, dstsize, src, srclen, locale);
1281#ifdef USE_ICU
1282 else if (locale->provider == COLLPROVIDER_ICU)
1283 return strtitle_icu(dst, dstsize, src, srclen, locale);
1284#endif
1285 else if (locale->provider == COLLPROVIDER_LIBC)
1286 return strtitle_libc(dst, dstsize, src, srclen, locale);
1287 else
1288 /* shouldn't happen */
1289 PGLOCALE_SUPPORT_ERROR(locale->provider);
1290
1291 return 0; /* keep compiler quiet */
1292}
size_t strtitle_libc(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t strtitle_icu(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t strtitle_builtin(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)

References locale, PGLOCALE_SUPPORT_ERROR, strtitle_builtin(), strtitle_icu(), and strtitle_libc().

Referenced by str_initcap().

◆ pg_strupper()

size_t pg_strupper ( char *  dst,
size_t  dstsize,
const char *  src,
ssize_t  srclen,
pg_locale_t  locale 
)

Definition at line 1295 of file pg_locale.c.

1297{
1298 if (locale->provider == COLLPROVIDER_BUILTIN)
1299 return strupper_builtin(dst, dstsize, src, srclen, locale);
1300#ifdef USE_ICU
1301 else if (locale->provider == COLLPROVIDER_ICU)
1302 return strupper_icu(dst, dstsize, src, srclen, locale);
1303#endif
1304 else if (locale->provider == COLLPROVIDER_LIBC)
1305 return strupper_libc(dst, dstsize, src, srclen, locale);
1306 else
1307 /* shouldn't happen */
1308 PGLOCALE_SUPPORT_ERROR(locale->provider);
1309
1310 return 0; /* keep compiler quiet */
1311}
size_t strupper_icu(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t strupper_libc(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t strupper_builtin(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)

References locale, PGLOCALE_SUPPORT_ERROR, strupper_builtin(), strupper_icu(), and strupper_libc().

Referenced by str_toupper().

◆ pg_strxfrm()

size_t pg_strxfrm ( char *  dest,
const char *  src,
size_t  destsize,
pg_locale_t  locale 
)

Definition at line 1389 of file pg_locale.c.

1390{
1391 return locale->collate->strnxfrm(dest, destsize, src, -1, locale);
1392}

References generate_unaccent_rules::dest, and locale.

Referenced by convert_string_datum(), and varstr_abbrev_convert().

◆ pg_strxfrm_enabled()

bool pg_strxfrm_enabled ( pg_locale_t  locale)

Definition at line 1373 of file pg_locale.c.

1374{
1375 /*
1376 * locale->collate->strnxfrm is still a required method, even if it may
1377 * have the wrong behavior, because the planner uses it for estimates in
1378 * some cases.
1379 */
1380 return locale->collate->strxfrm_is_safe;
1381}

References locale.

Referenced by varstr_sortsupport().

◆ pg_strxfrm_prefix()

size_t pg_strxfrm_prefix ( char *  dest,
const char *  src,
size_t  destsize,
pg_locale_t  locale 
)

Definition at line 1436 of file pg_locale.c.

1438{
1439 return locale->collate->strnxfrm_prefix(dest, destsize, src, -1, locale);
1440}

References generate_unaccent_rules::dest, and locale.

Referenced by varstr_abbrev_convert().

◆ pg_strxfrm_prefix_enabled()

bool pg_strxfrm_prefix_enabled ( pg_locale_t  locale)

Definition at line 1425 of file pg_locale.c.

1426{
1427 return (locale->collate->strnxfrm_prefix != NULL);
1428}

References locale.

Referenced by varstr_abbrev_convert().

◆ PGLC_localeconv()

struct lconv * PGLC_localeconv ( void  )

Definition at line 525 of file pg_locale.c.

526{
527 static struct lconv CurrentLocaleConv;
528 static bool CurrentLocaleConvAllocated = false;
529 struct lconv *extlconv;
530 struct lconv tmp;
531 struct lconv worklconv = {0};
532
533 /* Did we do it already? */
535 return &CurrentLocaleConv;
536
537 /* Free any already-allocated storage */
538 if (CurrentLocaleConvAllocated)
539 {
540 free_struct_lconv(&CurrentLocaleConv);
541 CurrentLocaleConvAllocated = false;
542 }
543
544 /*
545 * Use thread-safe method of obtaining a copy of lconv from the operating
546 * system.
547 */
550 &tmp) != 0)
551 elog(ERROR,
552 "could not get lconv for LC_MONETARY = \"%s\", LC_NUMERIC = \"%s\": %m",
554
555 /* Must copy data now so we can re-encode it. */
556 extlconv = &tmp;
557 worklconv.decimal_point = strdup(extlconv->decimal_point);
558 worklconv.thousands_sep = strdup(extlconv->thousands_sep);
559 worklconv.grouping = strdup(extlconv->grouping);
560 worklconv.int_curr_symbol = strdup(extlconv->int_curr_symbol);
561 worklconv.currency_symbol = strdup(extlconv->currency_symbol);
562 worklconv.mon_decimal_point = strdup(extlconv->mon_decimal_point);
563 worklconv.mon_thousands_sep = strdup(extlconv->mon_thousands_sep);
564 worklconv.mon_grouping = strdup(extlconv->mon_grouping);
565 worklconv.positive_sign = strdup(extlconv->positive_sign);
566 worklconv.negative_sign = strdup(extlconv->negative_sign);
567 /* Copy scalar fields as well */
568 worklconv.int_frac_digits = extlconv->int_frac_digits;
569 worklconv.frac_digits = extlconv->frac_digits;
570 worklconv.p_cs_precedes = extlconv->p_cs_precedes;
571 worklconv.p_sep_by_space = extlconv->p_sep_by_space;
572 worklconv.n_cs_precedes = extlconv->n_cs_precedes;
573 worklconv.n_sep_by_space = extlconv->n_sep_by_space;
574 worklconv.p_sign_posn = extlconv->p_sign_posn;
575 worklconv.n_sign_posn = extlconv->n_sign_posn;
576
577 /* Free the contents of the object populated by pg_localeconv_r(). */
578 pg_localeconv_free(&tmp);
579
580 /* If any of the preceding strdup calls failed, complain now. */
581 if (!struct_lconv_is_valid(&worklconv))
583 (errcode(ERRCODE_OUT_OF_MEMORY),
584 errmsg("out of memory")));
585
586 PG_TRY();
587 {
588 int encoding;
589
590 /*
591 * Now we must perform encoding conversion from whatever's associated
592 * with the locales into the database encoding. If we can't identify
593 * the encoding implied by LC_NUMERIC or LC_MONETARY (ie we get -1),
594 * use PG_SQL_ASCII, which will result in just validating that the
595 * strings are OK in the database encoding.
596 */
598 if (encoding < 0)
600
601 db_encoding_convert(encoding, &worklconv.decimal_point);
602 db_encoding_convert(encoding, &worklconv.thousands_sep);
603 /* grouping is not text and does not require conversion */
604
606 if (encoding < 0)
608
609 db_encoding_convert(encoding, &worklconv.int_curr_symbol);
610 db_encoding_convert(encoding, &worklconv.currency_symbol);
611 db_encoding_convert(encoding, &worklconv.mon_decimal_point);
612 db_encoding_convert(encoding, &worklconv.mon_thousands_sep);
613 /* mon_grouping is not text and does not require conversion */
614 db_encoding_convert(encoding, &worklconv.positive_sign);
615 db_encoding_convert(encoding, &worklconv.negative_sign);
616 }
617 PG_CATCH();
618 {
619 free_struct_lconv(&worklconv);
620 PG_RE_THROW();
621 }
622 PG_END_TRY();
623
624 /*
625 * Everything is good, so save the results.
626 */
627 CurrentLocaleConv = worklconv;
628 CurrentLocaleConvAllocated = true;
630 return &CurrentLocaleConv;
631}
#define PG_RE_THROW()
Definition: elog.h:404
#define PG_TRY(...)
Definition: elog.h:371
#define PG_END_TRY(...)
Definition: elog.h:396
#define PG_CATCH(...)
Definition: elog.h:381
char * locale_numeric
Definition: pg_locale.c:111
static void db_encoding_convert(int encoding, char **str)
Definition: pg_locale.c:495
static void free_struct_lconv(struct lconv *s)
Definition: pg_locale.c:445
static bool CurrentLocaleConvValid
Definition: pg_locale.c:134
static bool struct_lconv_is_valid(struct lconv *s)
Definition: pg_locale.c:464
char * locale_monetary
Definition: pg_locale.c:110
int pg_localeconv_r(const char *lc_monetary, const char *lc_numeric, struct lconv *output)
void pg_localeconv_free(struct lconv *lconv)

References CurrentLocaleConvValid, db_encoding_convert(), elog, encoding, ereport, errcode(), errmsg(), ERROR, free_struct_lconv(), locale_monetary, locale_numeric, PG_CATCH, PG_END_TRY, pg_get_encoding_from_locale(), pg_localeconv_free(), pg_localeconv_r(), PG_RE_THROW, PG_SQL_ASCII, PG_TRY, and struct_lconv_is_valid().

Referenced by cash_in(), cash_numeric(), cash_out(), int4_cash(), int8_cash(), NUM_prepare_locale(), and numeric_cash().

◆ report_newlocale_failure()

void report_newlocale_failure ( const char *  localename)

Definition at line 804 of file pg_locale_libc.c.

805{
806 int save_errno;
807
808 /*
809 * Windows doesn't provide any useful error indication from
810 * _create_locale(), and BSD-derived platforms don't seem to feel they
811 * need to set errno either (even though POSIX is pretty clear that
812 * newlocale should do so). So, if errno hasn't been set, assume ENOENT
813 * is what to report.
814 */
815 if (errno == 0)
816 errno = ENOENT;
817
818 /*
819 * ENOENT means "no such locale", not "no such file", so clarify that
820 * errno with an errdetail message.
821 */
822 save_errno = errno; /* auxiliary funcs might change errno */
824 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
825 errmsg("could not create locale \"%s\": %m",
826 localename),
827 (save_errno == ENOENT ?
828 errdetail("The operating system could not find any locale data for the locale name \"%s\".",
829 localename) : 0)));
830}
int errdetail(const char *fmt,...)
Definition: elog.c:1204

References ereport, errcode(), errdetail(), errmsg(), and ERROR.

Referenced by cache_locale_time(), and make_libc_collator().

◆ wchar2char()

size_t wchar2char ( char *  to,
const wchar_t *  from,
size_t  tolen,
pg_locale_t  locale 
)

Definition at line 882 of file pg_locale_libc.c.

883{
884 size_t result;
885
886 if (tolen == 0)
887 return 0;
888
889#ifdef WIN32
890
891 /*
892 * On Windows, the "Unicode" locales assume UTF16 not UTF8 encoding, and
893 * for some reason mbstowcs and wcstombs won't do this for us, so we use
894 * MultiByteToWideChar().
895 */
897 {
898 result = WideCharToMultiByte(CP_UTF8, 0, from, -1, to, tolen,
899 NULL, NULL);
900 /* A zero return is failure */
901 if (result <= 0)
902 result = -1;
903 else
904 {
905 Assert(result <= tolen);
906 /* Microsoft counts the zero terminator in the result */
907 result--;
908 }
909 }
910 else
911#endif /* WIN32 */
912 if (locale == (pg_locale_t) 0)
913 {
914 /* Use wcstombs directly for the default locale */
915 result = wcstombs(to, from, tolen);
916 }
917 else
918 {
919 /* Use wcstombs_l for nondefault locales */
920 result = wcstombs_l(to, from, tolen, locale->info.lt);
921 }
922
923 return result;
924}
static size_t wcstombs_l(char *dest, const wchar_t *src, size_t n, locale_t loc)

References Assert(), GetDatabaseEncoding(), locale, PG_UTF8, and wcstombs_l().

Referenced by strlower_libc_mb(), strtitle_libc_mb(), and strupper_libc_mb().

Variable Documentation

◆ database_ctype_is_c

PGDLLIMPORT bool database_ctype_is_c
extern

Definition at line 129 of file pg_locale.c.

Referenced by CheckMyDatabase(), t_isalnum(), t_isalpha(), and TParserInit().

◆ icu_validation_level

PGDLLIMPORT int icu_validation_level
extern

Definition at line 114 of file pg_locale.c.

Referenced by createdb(), DefineCollation(), and icu_validate_locale().

◆ locale_messages

PGDLLIMPORT char* locale_messages
extern

Definition at line 109 of file pg_locale.c.

◆ locale_monetary

PGDLLIMPORT char* locale_monetary
extern

Definition at line 110 of file pg_locale.c.

Referenced by PGLC_localeconv().

◆ locale_numeric

PGDLLIMPORT char* locale_numeric
extern

Definition at line 111 of file pg_locale.c.

Referenced by PGLC_localeconv().

◆ locale_time

PGDLLIMPORT char* locale_time
extern

Definition at line 112 of file pg_locale.c.

Referenced by cache_locale_time().

◆ localized_abbrev_days

PGDLLIMPORT char* localized_abbrev_days[]
extern

Definition at line 123 of file pg_locale.c.

Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().

◆ localized_abbrev_months

PGDLLIMPORT char* localized_abbrev_months[]
extern

Definition at line 125 of file pg_locale.c.

Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().

◆ localized_full_days

PGDLLIMPORT char* localized_full_days[]
extern

Definition at line 124 of file pg_locale.c.

Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().

◆ localized_full_months

PGDLLIMPORT char* localized_full_months[]
extern

Definition at line 126 of file pg_locale.c.

Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().