70 #include <unicode/ucnv.h>
74 #include <gnu/libc-version.h>
81 #define MAX_L10N_DATA 80
120 #if defined(WIN32) && defined(LC_MESSAGES)
121 static char *IsoLocaleName(
const char *);
125 static void icu_set_collation_attributes(UCollator *collator,
const char *loc);
159 if (category == LC_MESSAGES)
180 if (category == LC_CTYPE)
185 strlcpy(save_lc_ctype, result,
sizeof(save_lc_ctype));
186 result = save_lc_ctype;
198 envvar =
"LC_COLLATE";
205 envvar =
"LC_MESSAGES";
207 result = IsoLocaleName(
locale);
210 elog(
DEBUG3,
"IsoLocaleName() executed; locale: \"%s\"", result);
215 envvar =
"LC_MONETARY";
218 envvar =
"LC_NUMERIC";
224 elog(
FATAL,
"unrecognized LC category: %d", category);
228 if (
setenv(envvar, result, 1) != 0)
265 if (
res && canonname)
270 elog(
WARNING,
"failed to restore old locale \"%s\"", save);
273 return (
res != NULL);
350 #if defined(LC_MESSAGES) && !defined(WIN32)
377 if (s->decimal_point)
378 free(s->decimal_point);
379 if (s->thousands_sep)
380 free(s->thousands_sep);
383 if (s->int_curr_symbol)
384 free(s->int_curr_symbol);
385 if (s->currency_symbol)
386 free(s->currency_symbol);
387 if (s->mon_decimal_point)
388 free(s->mon_decimal_point);
389 if (s->mon_thousands_sep)
390 free(s->mon_thousands_sep);
392 free(s->mon_grouping);
393 if (s->positive_sign)
394 free(s->positive_sign);
395 if (s->negative_sign)
396 free(s->negative_sign);
406 if (s->decimal_point == NULL)
408 if (s->thousands_sep == NULL)
410 if (s->grouping == NULL)
412 if (s->int_curr_symbol == NULL)
414 if (s->currency_symbol == NULL)
416 if (s->mon_decimal_point == NULL)
418 if (s->mon_thousands_sep == NULL)
420 if (s->mon_grouping == NULL)
422 if (s->positive_sign == NULL)
424 if (s->negative_sign == NULL)
449 (
errcode(ERRCODE_OUT_OF_MEMORY),
450 errmsg(
"out of memory")));
467 static struct lconv CurrentLocaleConv;
468 static bool CurrentLocaleConvAllocated =
false;
469 struct lconv *extlconv;
470 struct lconv worklconv;
471 char *save_lc_monetary;
472 char *save_lc_numeric;
479 return &CurrentLocaleConv;
482 if (CurrentLocaleConvAllocated)
485 CurrentLocaleConvAllocated =
false;
500 memset(&worklconv, 0,
sizeof(worklconv));
503 save_lc_monetary =
setlocale(LC_MONETARY, NULL);
504 if (!save_lc_monetary)
506 save_lc_monetary =
pstrdup(save_lc_monetary);
508 save_lc_numeric =
setlocale(LC_NUMERIC, NULL);
509 if (!save_lc_numeric)
511 save_lc_numeric =
pstrdup(save_lc_numeric);
530 save_lc_ctype =
setlocale(LC_CTYPE, NULL);
533 save_lc_ctype =
pstrdup(save_lc_ctype);
543 extlconv = localeconv();
546 worklconv.decimal_point = strdup(extlconv->decimal_point);
547 worklconv.thousands_sep = strdup(extlconv->thousands_sep);
548 worklconv.grouping = strdup(extlconv->grouping);
557 extlconv = localeconv();
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);
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;
587 elog(
FATAL,
"failed to restore LC_CTYPE to \"%s\"", save_lc_ctype);
589 if (!
setlocale(LC_MONETARY, save_lc_monetary))
590 elog(
FATAL,
"failed to restore LC_MONETARY to \"%s\"", save_lc_monetary);
591 if (!
setlocale(LC_NUMERIC, save_lc_numeric))
592 elog(
FATAL,
"failed to restore LC_NUMERIC to \"%s\"", save_lc_numeric);
604 pfree(save_lc_monetary);
605 pfree(save_lc_numeric);
607 pfree(save_lc_ctype);
613 (
errcode(ERRCODE_OUT_OF_MEMORY),
614 errmsg(
"out of memory")));
653 CurrentLocaleConv = worklconv;
654 CurrentLocaleConvAllocated =
true;
656 return &CurrentLocaleConv;
676 strftime_win32(
char *dst,
size_t dstlen,
687 len = MultiByteToWideChar(CP_UTF8, 0,
format, -1,
690 elog(
ERROR,
"could not convert format string from UTF-8: error code %lu",
703 len = WideCharToMultiByte(CP_UTF8, 0, wbuf,
len, dst, dstlen - 1,
706 elog(
ERROR,
"could not convert string to UTF-8: error code %lu",
715 #define strftime(a,b,c,d) strftime_win32(a,b,c,d)
753 bool strftimefail =
false;
778 save_lc_time =
pstrdup(save_lc_time);
790 save_lc_ctype =
setlocale(LC_CTYPE, NULL);
793 save_lc_ctype =
pstrdup(save_lc_ctype);
802 timenow = time(NULL);
803 timeinfo = localtime(&timenow);
819 for (
i = 0;
i < 7;
i++)
821 timeinfo->tm_wday =
i;
831 for (
i = 0;
i < 12;
i++)
833 timeinfo->tm_mon =
i;
834 timeinfo->tm_mday = 1;
849 elog(
FATAL,
"failed to restore LC_CTYPE to \"%s\"", save_lc_ctype);
852 elog(
FATAL,
"failed to restore LC_TIME to \"%s\"", save_lc_time);
864 pfree(save_lc_ctype);
891 for (
i = 0;
i < 7;
i++)
902 for (
i = 0;
i < 12;
i++)
916 #if defined(WIN32) && defined(LC_MESSAGES)
977 search_locale_enum(LPWSTR pStr, DWORD dwFlags, LPARAM lparam)
979 wchar_t test_locale[LOCALE_NAME_MAX_LENGTH];
984 argv = (
wchar_t **) lparam;
985 *argv[2] = (wchar_t) 0;
987 memset(test_locale, 0,
sizeof(test_locale));
990 if (GetLocaleInfoEx(pStr, LOCALE_SENGLISHLANGUAGENAME,
991 test_locale, LOCALE_NAME_MAX_LENGTH))
998 if (wcsrchr(pStr,
'-') == NULL || wcsrchr(argv[0],
'_') == NULL)
1000 if (_wcsicmp(argv[0], test_locale) == 0)
1002 wcscpy(argv[1], pStr);
1003 *argv[2] = (wchar_t) 1;
1017 wcscat(test_locale, L
"_");
1018 len = wcslen(test_locale);
1019 if (GetLocaleInfoEx(pStr, LOCALE_SENGLISHCOUNTRYNAME,
1021 LOCALE_NAME_MAX_LENGTH -
len))
1023 if (_wcsicmp(argv[0], test_locale) == 0)
1025 wcscpy(argv[1], pStr);
1026 *argv[2] = (wchar_t) 1;
1043 get_iso_localename(
const char *winlocname)
1045 wchar_t wc_locale_name[LOCALE_NAME_MAX_LENGTH];
1046 wchar_t buffer[LOCALE_NAME_MAX_LENGTH];
1047 static char iso_lc_messages[LOCALE_NAME_MAX_LENGTH];
1059 period = strchr(winlocname,
'.');
1061 len = period - winlocname;
1065 memset(wc_locale_name, 0,
sizeof(wc_locale_name));
1066 memset(buffer, 0,
sizeof(buffer));
1067 MultiByteToWideChar(CP_ACP, 0, winlocname,
len, wc_locale_name,
1068 LOCALE_NAME_MAX_LENGTH);
1074 ret_val = GetLocaleInfoEx(wc_locale_name, LOCALE_SNAME, (LPWSTR) &buffer,
1075 LOCALE_NAME_MAX_LENGTH);
1084 argv[0] = wc_locale_name;
1086 argv[2] = (
wchar_t *) &ret_val;
1087 EnumSystemLocalesEx(search_locale_enum, LOCALE_WINDOWS, (LPARAM) argv,
1097 rc =
wchar2char(iso_lc_messages, buffer,
sizeof(iso_lc_messages), NULL);
1098 if (rc == -1 || rc ==
sizeof(iso_lc_messages))
1105 hyphen = strchr(iso_lc_messages,
'-');
1108 return iso_lc_messages;
1116 IsoLocaleName(
const char *winlocname)
1118 #if defined(_MSC_VER)
1119 static char iso_lc_messages[LOCALE_NAME_MAX_LENGTH];
1124 strcpy(iso_lc_messages,
"C");
1125 return iso_lc_messages;
1129 #if (_MSC_VER >= 1900)
1130 return get_iso_localename(winlocname);
1134 loct = _create_locale(LC_CTYPE, winlocname);
1141 rc =
wchar2char(iso_lc_messages, loct->locinfo->locale_name[LC_CTYPE],
1142 sizeof(iso_lc_messages), NULL);
1144 if (rc == -1 || rc ==
sizeof(iso_lc_messages))
1161 hyphen = strchr(iso_lc_messages,
'-');
1164 return iso_lc_messages;
1190 const int canary = 0x7F;
1204 (void) strxfrm(
buf,
"ab", 7);
1205 if (
buf[7] != canary)
1219 (void) strxfrm(
buf,
"a", 1);
1220 if (
buf[1] != canary)
1225 (
errcode(ERRCODE_SYSTEM_ERROR),
1226 errmsg_internal(
"strxfrm(), in locale \"%s\", writes past the specified array length",
1228 errhint(
"Apply system library package updates.")));
1263 Assert(collation != DEFAULT_COLLATION_OID);
1295 elog(
ERROR,
"cache lookup failed for collation %u", collation);
1298 if (collform->collprovider == COLLPROVIDER_LIBC)
1302 const char *collcollate;
1303 const char *collctype;
1312 cache_entry->
collate_is_c = ((strcmp(collcollate,
"C") == 0) ||
1313 (strcmp(collcollate,
"POSIX") == 0));
1314 cache_entry->
ctype_is_c = ((strcmp(collctype,
"C") == 0) ||
1315 (strcmp(collctype,
"POSIX") == 0));
1349 if (collation == DEFAULT_COLLATION_OID)
1351 static int result = -1;
1358 return (
bool) result;
1359 localeptr =
setlocale(LC_COLLATE, NULL);
1361 elog(
ERROR,
"invalid LC_COLLATE setting");
1363 if (strcmp(localeptr,
"C") == 0)
1365 else if (strcmp(localeptr,
"POSIX") == 0)
1369 return (
bool) result;
1375 if (collation == C_COLLATION_OID ||
1376 collation == POSIX_COLLATION_OID)
1402 if (collation == DEFAULT_COLLATION_OID)
1404 static int result = -1;
1411 return (
bool) result;
1414 elog(
ERROR,
"invalid LC_CTYPE setting");
1416 if (strcmp(localeptr,
"C") == 0)
1418 else if (strcmp(localeptr,
"POSIX") == 0)
1422 return (
bool) result;
1428 if (collation == C_COLLATION_OID ||
1429 collation == POSIX_COLLATION_OID)
1445 UCollator *collator;
1449 collator = ucol_open(iculocstr, &
status);
1452 (
errmsg(
"could not open collator for locale \"%s\": %s",
1453 iculocstr, u_errorName(
status))));
1455 if (U_ICU_VERSION_MAJOR_NUM < 54)
1456 icu_set_collation_attributes(collator, iculocstr);
1460 resultp->
info.icu.ucol = collator;
1464 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1465 errmsg(
"ICU is not supported in this build")));
1471 #ifdef HAVE_LOCALE_T
1473 report_newlocale_failure(
const char *localename)
1493 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1494 errmsg(
"could not create locale \"%s\": %m",
1496 (save_errno == ENOENT ?
1497 errdetail(
"The operating system could not find any locale data for the locale name \"%s\".",
1525 if (collid == DEFAULT_COLLATION_OID)
1535 if (cache_entry->
locale == 0)
1547 elog(
ERROR,
"cache lookup failed for collation %u", collid);
1551 memset(&result, 0,
sizeof(result));
1552 result.
provider = collform->collprovider;
1555 if (collform->collprovider == COLLPROVIDER_LIBC)
1557 #ifdef HAVE_LOCALE_T
1558 const char *collcollate;
1569 if (strcmp(collcollate, collctype) == 0)
1574 loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, collcollate,
1577 loc = _create_locale(LC_ALL, collcollate);
1580 report_newlocale_failure(collcollate);
1589 loc1 = newlocale(LC_COLLATE_MASK, collcollate, NULL);
1591 report_newlocale_failure(collcollate);
1593 loc = newlocale(LC_CTYPE_MASK, collctype, loc1);
1595 report_newlocale_failure(collctype);
1604 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1605 errmsg(
"collations with different collate and ctype values are not supported on this platform")));
1609 result.
info.lt = loc;
1613 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1614 errmsg(
"collation provider LIBC is not supported on this platform")));
1617 else if (collform->collprovider == COLLPROVIDER_ICU)
1619 const char *iculocstr;
1631 char *actual_versionstr;
1632 char *collversionstr;
1636 datum =
SysCacheGetAttr(
COLLOID, tp, collform->collprovider == COLLPROVIDER_ICU ? Anum_pg_collation_colliculocale : Anum_pg_collation_collcollate, &isnull);
1641 if (!actual_versionstr)
1649 (
errmsg(
"collation \"%s\" has no actual version, but a version was recorded",
1650 NameStr(collform->collname))));
1653 if (strcmp(actual_versionstr, collversionstr) != 0)
1655 (
errmsg(
"collation \"%s\" has version mismatch",
1657 errdetail(
"The collation in the database was created using version %s, "
1658 "but the operating system provides version %s.",
1659 collversionstr, actual_versionstr),
1660 errhint(
"Rebuild all objects affected by this collation and run "
1661 "ALTER COLLATION %s REFRESH VERSION, "
1662 "or build PostgreSQL with the right library version.",
1664 NameStr(collform->collname)))));
1673 cache_entry->
locale = resultp;
1676 return cache_entry->
locale;
1686 char *collversion = NULL;
1689 if (collprovider == COLLPROVIDER_ICU)
1691 UCollator *collator;
1693 UVersionInfo versioninfo;
1694 char buf[U_MAX_VERSION_STRING_LENGTH];
1697 collator = ucol_open(collcollate, &
status);
1700 (
errmsg(
"could not open collator for locale \"%s\": %s",
1701 collcollate, u_errorName(
status))));
1702 ucol_getVersion(collator, versioninfo);
1703 ucol_close(collator);
1705 u_versionToString(versioninfo,
buf);
1710 if (collprovider == COLLPROVIDER_LIBC &&
1715 #if defined(__GLIBC__)
1717 collversion =
pstrdup(gnu_get_libc_version());
1718 #elif defined(LC_VERSION_MASK)
1722 loc = newlocale(LC_COLLATE, collcollate, NULL);
1726 pstrdup(querylocale(LC_COLLATE_MASK | LC_VERSION_MASK, loc));
1731 (
errmsg(
"could not load locale \"%s\"", collcollate)));
1732 #elif defined(WIN32) && _WIN32_WINNT >= 0x0600
1738 NLSVERSIONINFOEX version = {
sizeof(NLSVERSIONINFOEX)};
1739 WCHAR wide_collcollate[LOCALE_NAME_MAX_LENGTH];
1741 MultiByteToWideChar(CP_ACP, 0, collcollate, -1, wide_collcollate,
1742 LOCALE_NAME_MAX_LENGTH);
1743 if (!GetNLSVersionEx(COMPARE_STRING, wide_collcollate, &version))
1752 if (GetLastError() == ERROR_INVALID_PARAMETER)
1756 (
errmsg(
"could not get collation version for locale \"%s\": error code %lu",
1760 collversion =
psprintf(
"%d.%d,%d.%d",
1761 (version.dwNLSVersion >> 8) & 0xFFFF,
1762 version.dwNLSVersion & 0xFF,
1763 (version.dwDefinedVersion >> 8) & 0xFFFF,
1764 version.dwDefinedVersion & 0xFF);
1778 static UConverter *icu_converter = NULL;
1781 init_icu_converter(
void)
1783 const char *icu_encoding_name;
1791 if (!icu_encoding_name)
1793 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1794 errmsg(
"encoding \"%s\" not supported by ICU",
1798 conv = ucnv_open(icu_encoding_name, &
status);
1801 (
errmsg(
"could not open ICU converter for encoding \"%s\": %s",
1802 icu_encoding_name, u_errorName(
status))));
1804 icu_converter = conv;
1820 icu_to_uchar(UChar **buff_uchar,
const char *buff,
size_t nbytes)
1825 init_icu_converter();
1828 len_uchar = ucnv_toUChars(icu_converter, NULL, 0,
1830 if (U_FAILURE(
status) &&
status != U_BUFFER_OVERFLOW_ERROR)
1832 (
errmsg(
"%s failed: %s",
"ucnv_toUChars", u_errorName(
status))));
1834 *buff_uchar =
palloc((len_uchar + 1) *
sizeof(**buff_uchar));
1837 len_uchar = ucnv_toUChars(icu_converter, *buff_uchar, len_uchar + 1,
1841 (
errmsg(
"%s failed: %s",
"ucnv_toUChars", u_errorName(
status))));
1858 icu_from_uchar(
char **result,
const UChar *buff_uchar, int32_t len_uchar)
1863 init_icu_converter();
1866 len_result = ucnv_fromUChars(icu_converter, NULL, 0,
1867 buff_uchar, len_uchar, &
status);
1868 if (U_FAILURE(
status) &&
status != U_BUFFER_OVERFLOW_ERROR)
1870 (
errmsg(
"%s failed: %s",
"ucnv_fromUChars",
1873 *result =
palloc(len_result + 1);
1876 len_result = ucnv_fromUChars(icu_converter, *result, len_result + 1,
1877 buff_uchar, len_uchar, &
status);
1880 (
errmsg(
"%s failed: %s",
"ucnv_fromUChars",
1897 icu_set_collation_attributes(UCollator *collator, const
char *loc)
1906 for (
char *token = strtok(
str,
";"); token; token = strtok(NULL,
";"))
1908 char *
e = strchr(token,
'=');
1914 UColAttribute uattr;
1915 UColAttributeValue uvalue;
1927 if (strcmp(
name,
"colstrength") == 0)
1928 uattr = UCOL_STRENGTH;
1929 else if (strcmp(
name,
"colbackwards") == 0)
1930 uattr = UCOL_FRENCH_COLLATION;
1931 else if (strcmp(
name,
"colcaselevel") == 0)
1932 uattr = UCOL_CASE_LEVEL;
1933 else if (strcmp(
name,
"colcasefirst") == 0)
1934 uattr = UCOL_CASE_FIRST;
1935 else if (strcmp(
name,
"colalternate") == 0)
1936 uattr = UCOL_ALTERNATE_HANDLING;
1937 else if (strcmp(
name,
"colnormalization") == 0)
1938 uattr = UCOL_NORMALIZATION_MODE;
1939 else if (strcmp(
name,
"colnumeric") == 0)
1940 uattr = UCOL_NUMERIC_COLLATION;
1945 if (strcmp(
value,
"primary") == 0)
1946 uvalue = UCOL_PRIMARY;
1947 else if (strcmp(
value,
"secondary") == 0)
1948 uvalue = UCOL_SECONDARY;
1949 else if (strcmp(
value,
"tertiary") == 0)
1950 uvalue = UCOL_TERTIARY;
1951 else if (strcmp(
value,
"quaternary") == 0)
1952 uvalue = UCOL_QUATERNARY;
1953 else if (strcmp(
value,
"identical") == 0)
1954 uvalue = UCOL_IDENTICAL;
1955 else if (strcmp(
value,
"no") == 0)
1957 else if (strcmp(
value,
"yes") == 0)
1959 else if (strcmp(
value,
"shifted") == 0)
1960 uvalue = UCOL_SHIFTED;
1961 else if (strcmp(
value,
"non-ignorable") == 0)
1962 uvalue = UCOL_NON_IGNORABLE;
1963 else if (strcmp(
value,
"lower") == 0)
1964 uvalue = UCOL_LOWER_FIRST;
1965 else if (strcmp(
value,
"upper") == 0)
1966 uvalue = UCOL_UPPER_FIRST;
1968 status = U_ILLEGAL_ARGUMENT_ERROR;
1970 if (
status == U_ZERO_ERROR)
1971 ucol_setAttribute(collator, uattr, uvalue, &
status);
1979 (
errmsg(
"could not open collator for locale \"%s\": %s",
1980 loc, u_errorName(
status))));
1994 UCollator *collator;
2001 (
errmsg(
"could not open collator for locale \"%s\": %s",
2004 if (U_ICU_VERSION_MAJOR_NUM < 54)
2005 icu_set_collation_attributes(collator,
icu_locale);
2006 ucol_close(collator);
2009 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2010 errmsg(
"ICU is not supported in this build")));
2045 result = WideCharToMultiByte(CP_UTF8, 0, from, -1, to, tolen,
2062 result = wcstombs(to, from, tolen);
2066 #ifdef HAVE_LOCALE_T
2067 #ifdef HAVE_WCSTOMBS_L
2074 result = wcstombs(to, from, tolen);
2076 uselocale(save_locale);
2080 elog(
ERROR,
"wcstombs_l is not available");
2098 char2wchar(
wchar_t *to,
size_t tolen,
const char *from,
size_t fromlen,
2117 result = MultiByteToWideChar(CP_UTF8, 0, from, fromlen, to, tolen - 1);
2139 result = mbstowcs(to,
str, tolen);
2143 #ifdef HAVE_LOCALE_T
2144 #ifdef HAVE_MBSTOWCS_L
2151 result = mbstowcs(to,
str, tolen);
2153 uselocale(save_locale);
2157 elog(
ERROR,
"mbstowcs_l is not available");
2178 (
errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
2179 errmsg(
"invalid multibyte character for locale"),
2180 errhint(
"The server's LC_CTYPE locale is probably incompatible with the database encoding.")));
#define TextDatumGetCString(d)
#define OidIsValid(objectId)
static void PGresult * res
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
const char * get_encoding_name_for_icu(int encoding)
const char * pg_encoding_to_char(int encoding)
#define HeapTupleIsValid(tuple)
pg_attribute_unused() static bool check_table(const char *(*TABLE)[2]
Assert(fmt[strlen(fmt) - 1] !='\n')
char * get_namespace_name(Oid nspid)
char * pg_any_to_server(const char *s, int len, int encoding)
int GetDatabaseEncoding(void)
int pg_mbstrlen(const char *mbstr)
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
void SetMessageEncoding(int encoding)
char * pnstrdup(const char *in, Size len)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * MemoryContextAlloc(MemoryContext context, Size size)
char * MemoryContextStrdup(MemoryContext context, const char *string)
FormData_pg_collation * Form_pg_collation
void make_icu_collator(const char *iculocstr, struct pg_locale_struct *resultp)
void cache_locale_time(void)
char * localized_full_months[12+1]
size_t wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale)
struct lconv * PGLC_localeconv(void)
bool lc_collate_is_c(Oid collation)
struct pg_locale_struct default_locale
void check_strxfrm_bug(void)
static bool CurrentLCTimeValid
void assign_locale_time(const char *newval, void *extra)
bool check_locale_time(char **newval, void **extra, GucSource source)
pg_locale_t pg_newlocale_from_collation(Oid collid)
static void cache_single_string(char **dst, const char *src, int encoding)
bool lc_ctype_is_c(Oid collation)
bool check_locale_numeric(char **newval, void **extra, GucSource source)
static void db_encoding_convert(int encoding, char **str)
void assign_locale_numeric(const char *newval, void *extra)
bool check_locale_messages(char **newval, void **extra, GucSource source)
char * get_collation_actual_version(char collprovider, const char *collcollate)
static void free_struct_lconv(struct lconv *s)
char * pg_perm_setlocale(int category, const char *locale)
void assign_locale_messages(const char *newval, void *extra)
static bool CurrentLocaleConvValid
static HTAB * collation_cache
char * localized_abbrev_months[12+1]
static bool struct_lconv_is_valid(struct lconv *s)
char * localized_full_days[7+1]
void check_icu_locale(const char *icu_locale)
static collation_cache_entry * lookup_collation_cache(Oid collation, bool set_flags)
void assign_locale_monetary(const char *newval, void *extra)
bool check_locale(int category, const char *locale, char **canonname)
char * localized_abbrev_days[7+1]
size_t char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, pg_locale_t locale)
bool check_locale_monetary(char **newval, void **extra, GucSource source)
#define LOCALE_NAME_BUFLEN
static void static void status(const char *fmt,...) pg_attribute_printf(1
static rewind_source * source
int pg_strcasecmp(const char *s1, const char *s2)
int pg_get_encoding_from_locale(const char *ctype, bool write_message)
size_t strlcpy(char *dst, const char *src, size_t siz)
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
#define ObjectIdGetDatum(X)
char * psprintf(const char *fmt,...)
char * quote_qualified_identifier(const char *qualifier, const char *ident)
union pg_locale_struct::@150 info
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)