29#include <gnu/libc-version.h>
81#define TEXTBUFLEN 1024
190 return isupper_l((
unsigned char) wc, locale->
lt) ||
287 if (
sizeof(
wchar_t) >= 4 || wc <= (
pg_wchar) 0xFFFF)
315 if (
sizeof(
wchar_t) >= 4 || wc <= (
pg_wchar) 0xFFFF)
334 unsigned char ch = (
unsigned char) src[
i];
336 if (
ch >=
'A' &&
ch <=
'Z')
382 .downcase_ident =
NULL,
405 .downcase_ident =
NULL,
424 .strnxfrm_prefix =
NULL,
436 .strxfrm_is_safe =
true,
438 .strxfrm_is_safe =
false,
446 .strnxfrm_prefix =
NULL,
448 .strxfrm_is_safe =
true,
450 .strxfrm_is_safe =
false,
477 for (p = dest; *p; p++)
481 if (*p >=
'A' && *p <=
'Z')
512 errmsg(
"out of memory")));
526 result =
palloc(max_size + 1);
528 result_size =
wchar2char(result, workspace, max_size + 1, loc);
532 memcpy(dest, result, result_size);
533 dest[result_size] =
'\0';
565 for (p = dest; *p; p++)
571 if (*p >=
'A' && *p <=
'Z')
578 if (*p >=
'a' && *p <=
'z')
617 errmsg(
"out of memory")));
637 result =
palloc(max_size + 1);
639 result_size =
wchar2char(result, workspace, max_size + 1, loc);
643 memcpy(dest, result, result_size);
644 dest[result_size] =
'\0';
675 for (p = dest; *p; p++)
679 if (*p >=
'a' && *p <=
'z')
710 errmsg(
"out of memory")));
724 result =
palloc(max_size + 1);
726 result_size =
wchar2char(result, workspace, max_size + 1, loc);
730 memcpy(dest, result, result_size);
731 dest[result_size] =
'\0';
790 (
strcmp(collate,
"POSIX") == 0);
792 (
strcmp(ctype,
"POSIX") == 0);
829 if (
strcmp(collate, ctype) == 0)
831 if (
strcmp(ctype,
"C") != 0 &&
strcmp(ctype,
"POSIX") != 0)
851 if (
strcmp(collate,
"C") != 0 &&
strcmp(collate,
"POSIX") != 0)
859 if (
strcmp(ctype,
"C") != 0 &&
strcmp(ctype,
"POSIX") != 0)
881 errmsg(
"collations with different collate and ctype values are not supported on this platform")));
901 size_t bufsize1 = (len1 == -1) ? 0 : len1 + 1;
902 size_t bufsize2 = (len2 == -1) ? 0 : len2 + 1;
991#if defined(__GLIBC__)
994#elif defined(LC_VERSION_MASK)
1032 (
errmsg(
"could not get collation version for locale \"%s\": error code %lu",
1037 (version.dwNLSVersion >> 8) & 0xFFFF,
1038 version.dwNLSVersion & 0xFF,
1039 (version.dwDefinedVersion >> 8) & 0xFFFF,
1040 version.dwDefinedVersion & 0xFF);
1076 a1len = len1 * 2 + 2;
1077 a2len = len2 * 2 + 2;
1094 (
errmsg(
"could not convert string to UTF-16: error code %lu",
1107 (
errmsg(
"could not convert string to UTF-16: error code %lu",
1114 if (result == 2147483647)
1116 (
errmsg(
"could not compare Unicode strings: %m")));
1148 errmsg(
"could not create locale \"%s\": %m",
1151 errdetail(
"The operating system could not find any locale data for the locale name \"%s\".",
1159#ifndef HAVE_MBSTOWCS_L
1175#ifndef HAVE_WCSTOMBS_L
1323 errmsg(
"invalid multibyte character for locale"),
1324 errhint(
"The server's LC_CTYPE locale is probably incompatible with the database encoding.")));
#define TextDatumGetCString(d)
#define IS_HIGHBIT_SET(ch)
#define Assert(condition)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define palloc_array(type, count)
#define HeapTupleIsValid(tuple)
int GetDatabaseEncoding(void)
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
int pg_database_encoding_max_length(void)
void * MemoryContextAllocZero(MemoryContext context, Size size)
char * pstrdup(const char *in)
void pfree(void *pointer)
char * pnstrdup(const char *in, Size len)
static bool wc_isalpha_libc_mb(pg_wchar wc, pg_locale_t locale)
static size_t strtitle_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static bool wc_ispunct_libc_sb(pg_wchar wc, pg_locale_t locale)
static const struct ctype_methods ctype_methods_libc_other_mb
static const struct ctype_methods ctype_methods_libc_utf8
static pg_wchar toupper_libc_mb(pg_wchar wc, pg_locale_t locale)
static size_t downcase_ident_libc_sb(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
static bool wc_iscased_libc_sb(pg_wchar wc, pg_locale_t locale)
static size_t strupper_libc_sb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static bool wc_isprint_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isdigit_libc_sb(pg_wchar wc, pg_locale_t locale)
pg_locale_t create_pg_locale_libc(Oid collid, MemoryContext context)
size_t wchar2char(char *to, const wchar_t *from, size_t tolen, locale_t loc)
static bool wc_isspace_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_islower_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isupper_libc_mb(pg_wchar wc, pg_locale_t locale)
static pg_wchar toupper_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isgraph_libc_mb(pg_wchar wc, pg_locale_t locale)
static size_t char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, locale_t loc)
static bool wc_isalnum_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isalnum_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isalpha_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_isprint_libc_sb(pg_wchar wc, pg_locale_t locale)
char * get_collation_actual_version_libc(const char *collcollate)
static bool wc_isupper_libc_sb(pg_wchar wc, pg_locale_t locale)
static locale_t make_libc_collator(const char *collate, const char *ctype)
static bool wc_isgraph_libc_sb(pg_wchar wc, pg_locale_t locale)
static bool wc_iscased_libc_mb(pg_wchar wc, pg_locale_t locale)
static pg_wchar tolower_libc_sb(pg_wchar wc, pg_locale_t locale)
static size_t wcstombs_l(char *dest, const wchar_t *src, size_t n, locale_t loc)
static const struct collate_methods collate_methods_libc
static bool wc_ispunct_libc_mb(pg_wchar wc, pg_locale_t locale)
static size_t strupper_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static int strncoll_libc(const char *arg1, ssize_t len1, const char *arg2, ssize_t len2, pg_locale_t locale)
static size_t strlower_libc_sb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static bool wc_islower_libc_mb(pg_wchar wc, pg_locale_t locale)
static const struct ctype_methods ctype_methods_libc_sb
static size_t strnxfrm_libc(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static bool wc_isxdigit_libc_sb(pg_wchar wc, pg_locale_t locale)
void report_newlocale_failure(const char *localename)
static pg_wchar tolower_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isdigit_libc_mb(pg_wchar wc, pg_locale_t locale)
static bool wc_isspace_libc_mb(pg_wchar wc, pg_locale_t locale)
static size_t strtitle_libc_sb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static bool wc_isxdigit_libc_mb(pg_wchar wc, pg_locale_t locale)
static size_t mbstowcs_l(wchar_t *dest, const char *src, size_t n, locale_t loc)
static size_t strlower_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
static char buf[DEFAULT_XLOG_SEG_SIZE]
int pg_strcasecmp(const char *s1, const char *s2)
static unsigned char pg_ascii_tolower(unsigned char ch)
static unsigned char pg_ascii_toupper(unsigned char ch)
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
static Datum ObjectIdGetDatum(Oid X)
char * psprintf(const char *fmt,...)
int(* strncoll)(const char *arg1, ssize_t len1, const char *arg2, ssize_t len2, pg_locale_t locale)
size_t(* strlower)(char *dest, size_t destsize, const char *src, ssize_t srclen, pg_locale_t locale)
const struct ctype_methods * ctype
const struct collate_methods * collate
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)