PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <time.h>
#include "access/htup_details.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_control.h"
#include "mb/pg_wchar.h"
#include "utils/builtins.h"
#include "utils/formatting.h"
#include "utils/guc_hooks.h"
#include "utils/hsearch.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | collation_cache_entry |
Macros | |
#define | TEXTBUFLEN 1024 |
#define | MAX_L10N_DATA 80 |
Functions | |
char * | pg_perm_setlocale (int category, const char *locale) |
bool | check_locale (int category, const char *locale, char **canonname) |
bool | check_locale_monetary (char **newval, void **extra, GucSource source) |
void | assign_locale_monetary (const char *newval, void *extra) |
bool | check_locale_numeric (char **newval, void **extra, GucSource source) |
void | assign_locale_numeric (const char *newval, void *extra) |
bool | check_locale_time (char **newval, void **extra, GucSource source) |
void | assign_locale_time (const char *newval, void *extra) |
bool | check_locale_messages (char **newval, void **extra, GucSource source) |
void | assign_locale_messages (const char *newval, void *extra) |
static void | free_struct_lconv (struct lconv *s) |
static bool | struct_lconv_is_valid (struct lconv *s) |
static void | db_encoding_convert (int encoding, char **str) |
struct lconv * | PGLC_localeconv (void) |
static void | cache_single_string (char **dst, const char *src, int encoding) |
void | cache_locale_time (void) |
void | check_strxfrm_bug (void) |
static collation_cache_entry * | lookup_collation_cache (Oid collation, bool set_flags) |
bool | lc_collate_is_c (Oid collation) |
bool | lc_ctype_is_c (Oid collation) |
void | make_icu_collator (const char *iculocstr, const char *icurules, struct pg_locale_struct *resultp) |
bool | pg_locale_deterministic (pg_locale_t locale) |
pg_locale_t | pg_newlocale_from_collation (Oid collid) |
char * | get_collation_actual_version (char collprovider, const char *collcollate) |
static int | pg_strcoll_libc (const char *arg1, const char *arg2, pg_locale_t locale) |
static int | pg_strncoll_libc (const char *arg1, size_t len1, const char *arg2, size_t len2, pg_locale_t locale) |
int | pg_strcoll (const char *arg1, const char *arg2, pg_locale_t locale) |
int | pg_strncoll (const char *arg1, size_t len1, const char *arg2, size_t len2, pg_locale_t locale) |
static size_t | pg_strxfrm_libc (char *dest, const char *src, size_t destsize, pg_locale_t locale) |
static size_t | pg_strnxfrm_libc (char *dest, const char *src, size_t srclen, size_t destsize, 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, size_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, size_t srclen, pg_locale_t locale) |
void | check_icu_locale (const char *icu_locale) |
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 | |
char * | locale_messages |
char * | locale_monetary |
char * | locale_numeric |
char * | locale_time |
char * | localized_abbrev_days [7+1] |
char * | localized_full_days [7+1] |
char * | localized_abbrev_months [12+1] |
char * | localized_full_months [12+1] |
bool | database_ctype_is_c = false |
static bool | CurrentLocaleConvValid = false |
static bool | CurrentLCTimeValid = false |
static HTAB * | collation_cache = NULL |
struct pg_locale_struct | default_locale |
#define MAX_L10N_DATA 80 |
Definition at line 89 of file pg_locale.c.
#define TEXTBUFLEN 1024 |
Definition at line 87 of file pg_locale.c.
void assign_locale_messages | ( | const char * | newval, |
void * | extra | ||
) |
Definition at line 382 of file pg_locale.c.
References newval, and pg_perm_setlocale().
void assign_locale_monetary | ( | const char * | newval, |
void * | extra | ||
) |
void assign_locale_numeric | ( | const char * | newval, |
void * | extra | ||
) |
Definition at line 331 of file pg_locale.c.
References CurrentLocaleConvValid.
void assign_locale_time | ( | const char * | newval, |
void * | extra | ||
) |
void cache_locale_time | ( | void | ) |
Definition at line 761 of file pg_locale.c.
References buf, cache_single_string(), CurrentLCTimeValid, DEBUG3, elog(), encoding, ERROR, FATAL, i, locale_time, localized_abbrev_days, localized_abbrev_months, localized_full_days, localized_full_months, MAX_L10N_DATA, pfree(), pg_get_encoding_from_locale(), PG_SQL_ASCII, PG_UTF8, pstrdup(), setlocale, and tm.
Referenced by DCH_from_char(), and DCH_to_char().
|
static |
Definition at line 738 of file pg_locale.c.
References encoding, MemoryContextStrdup(), pfree(), pg_any_to_server(), and TopMemoryContext.
Referenced by cache_locale_time().
size_t char2wchar | ( | wchar_t * | to, |
size_t | tolen, | ||
const char * | from, | ||
size_t | fromlen, | ||
pg_locale_t | locale | ||
) |
Definition at line 2877 of file pg_locale.c.
References Assert(), elog(), ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), locale, locale_t, mbstowcs_l, pfree(), PG_UTF8, pg_verifymbstr(), pnstrdup(), and generate_unaccent_rules::str.
Referenced by lowerstr_with_len(), str_initcap(), str_tolower(), str_toupper(), t_isalnum(), t_isalpha(), t_isdigit(), t_isprint(), t_isspace(), and TParserInit().
void check_icu_locale | ( | const char * | icu_locale | ) |
Definition at line 2770 of file pg_locale.c.
References ereport, errcode(), errmsg(), ERROR, icu_locale, and status().
Referenced by createdb().
bool check_locale | ( | int | category, |
const char * | locale, | ||
char ** | canonname | ||
) |
Definition at line 270 of file pg_locale.c.
References elog(), locale, pfree(), pstrdup(), res, setlocale, and WARNING.
Referenced by check_locale_messages(), check_locale_monetary(), check_locale_numeric(), check_locale_time(), and createdb().
Definition at line 359 of file pg_locale.c.
References check_locale(), newval, PGC_S_DEFAULT, and source.
Definition at line 313 of file pg_locale.c.
References check_locale(), and newval.
Definition at line 325 of file pg_locale.c.
References check_locale(), and newval.
Definition at line 337 of file pg_locale.c.
References check_locale(), and newval.
void check_strxfrm_bug | ( | void | ) |
Definition at line 1173 of file pg_locale.c.
References buf, ereport, errcode(), errhint(), errmsg_internal(), ERROR, and setlocale.
Referenced by CheckMyDatabase(), and main().
|
static |
Definition at line 449 of file pg_locale.c.
References encoding, ereport, errcode(), errmsg(), ERROR, free, pfree(), pg_any_to_server(), and generate_unaccent_rules::str.
Referenced by PGLC_localeconv().
|
static |
char* get_collation_actual_version | ( | char | collprovider, |
const char * | collcollate | ||
) |
Definition at line 1717 of file pg_locale.c.
References buf, ereport, errmsg(), ERROR, locale_t, pg_strcasecmp(), pg_strncasecmp(), psprintf(), pstrdup(), and status().
Referenced by AlterCollation(), AlterDatabaseRefreshColl(), CheckMyDatabase(), createdb(), DefineCollation(), pg_collation_actual_version(), pg_database_collation_actual_version(), pg_import_system_collations(), and pg_newlocale_from_collation().
Definition at line 1322 of file pg_locale.c.
References default_locale, elog(), ERROR, lookup_collation_cache(), OidIsValid, pg_locale_struct::provider, and setlocale.
Referenced by bpchareq(), bpcharne(), btvarstrequalimage(), convert_string_datum(), DefineCollation(), hashbpchar(), hashbpcharextended(), hashtext(), hashtextextended(), make_greater_string(), match_pattern_prefix(), spg_text_inner_consistent(), text_position_setup(), text_starts_with(), texteq(), textne(), varstr_cmp(), and varstr_sortsupport().
Definition at line 1375 of file pg_locale.c.
Referenced by DefineCollation(), Generic_Text_IC_like(), GenericMatchText(), like_fixed_prefix(), pg_set_regex_collation(), str_initcap(), str_tolower(), and str_toupper().
|
static |
Definition at line 1243 of file pg_locale.c.
References Assert(), collation_cache_entry::collate_is_c, collation_cache, COLLOID, collation_cache_entry::ctype_is_c, elog(), HASHCTL::entrysize, ERROR, collation_cache_entry::flags_valid, GETSTRUCT, HASH_BLOBS, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HeapTupleIsValid, HASHCTL::keysize, collation_cache_entry::locale, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), and TextDatumGetCString.
Referenced by lc_collate_is_c(), and pg_newlocale_from_collation().
void make_icu_collator | ( | const char * | iculocstr, |
const char * | icurules, | ||
struct pg_locale_struct * | resultp | ||
) |
Definition at line 1427 of file pg_locale.c.
References ereport, errcode(), errmsg(), ERROR, pg_locale_struct::info, MemoryContextStrdup(), palloc_array, status(), and TopMemoryContext.
Referenced by CheckMyDatabase(), and pg_newlocale_from_collation().
bool pg_locale_deterministic | ( | pg_locale_t | locale | ) |
Definition at line 1519 of file pg_locale.c.
References locale.
Referenced by bpchareq(), bpcharne(), Generic_Text_IC_like(), GenericMatchText(), hashbpchar(), hashbpcharextended(), hashtext(), hashtextextended(), pg_set_regex_collation(), text_position_setup(), text_starts_with(), texteq(), textne(), varstr_cmp(), and varstrfastcmp_locale().
pg_locale_t pg_newlocale_from_collation | ( | Oid | collid | ) |
Definition at line 1543 of file pg_locale.c.
References Assert(), collid, COLLOID, default_locale, pg_locale_struct::deterministic, elog(), ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, get_collation_actual_version(), get_namespace_name(), GETSTRUCT, HeapTupleIsValid, pg_locale_struct::info, collation_cache_entry::locale, locale_t, lookup_collation_cache(), make_icu_collator(), MemoryContextAlloc(), NameStr, ObjectIdGetDatum(), OidIsValid, pg_attribute_unused, pg_locale_struct::provider, quote_qualified_identifier(), ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), TextDatumGetCString, TopMemoryContext, and WARNING.
Referenced by bpchareq(), bpcharne(), DefineCollation(), Generic_Text_IC_like(), GenericMatchText(), hashbpchar(), hashbpcharextended(), hashtext(), hashtextextended(), like_fixed_prefix(), pg_set_regex_collation(), str_initcap(), str_tolower(), str_toupper(), text_position_setup(), text_starts_with(), texteq(), textne(), varstr_cmp(), and varstr_sortsupport().
char* pg_perm_setlocale | ( | int | category, |
const char * | locale | ||
) |
Definition at line 167 of file pg_locale.c.
References DEBUG3, elog(), FATAL, GetDatabaseEncoding(), locale, LOCALE_NAME_BUFLEN, setenv, setlocale, SetMessageEncoding(), and strlcpy().
Referenced by assign_locale_messages(), CheckMyDatabase(), and init_locale().
int pg_strcoll | ( | const char * | arg1, |
const char * | arg2, | ||
pg_locale_t | locale | ||
) |
Definition at line 2080 of file pg_locale.c.
References elog(), ERROR, locale, and pg_strcoll_libc().
Referenced by varstrfastcmp_locale().
|
static |
Definition at line 1892 of file pg_locale.c.
References Assert(), elog(), ERROR, GetDatabaseEncoding(), locale, PG_UTF8, and strcoll_l.
Referenced by pg_strcoll(), and pg_strncoll_libc().
int pg_strncoll | ( | const char * | arg1, |
size_t | len1, | ||
const char * | arg2, | ||
size_t | len2, | ||
pg_locale_t | locale | ||
) |
Definition at line 2115 of file pg_locale.c.
References elog(), ERROR, locale, and pg_strncoll_libc().
Referenced by varstr_cmp().
|
static |
Definition at line 1927 of file pg_locale.c.
References Assert(), buf, GetDatabaseEncoding(), locale, palloc(), pfree(), pg_strcoll_libc(), PG_UTF8, and TEXTBUFLEN.
Referenced by pg_strncoll().
size_t pg_strnxfrm | ( | char * | dest, |
size_t | destsize, | ||
const char * | src, | ||
size_t | srclen, | ||
pg_locale_t | locale | ||
) |
Definition at line 2401 of file pg_locale.c.
References generate_unaccent_rules::dest, elog(), ERROR, locale, and pg_strnxfrm_libc().
Referenced by hashbpchar(), hashbpcharextended(), hashtext(), and hashtextextended().
|
static |
Definition at line 2155 of file pg_locale.c.
References Assert(), buf, bufsize, generate_unaccent_rules::dest, locale, palloc(), pfree(), pg_strxfrm_libc(), and TEXTBUFLEN.
Referenced by pg_strnxfrm().
size_t pg_strnxfrm_prefix | ( | char * | dest, |
size_t | destsize, | ||
const char * | src, | ||
size_t | srclen, | ||
pg_locale_t | locale | ||
) |
Definition at line 2488 of file pg_locale.c.
References generate_unaccent_rules::dest, elog(), ERROR, and locale.
size_t pg_strxfrm | ( | char * | dest, |
const char * | src, | ||
size_t | destsize, | ||
pg_locale_t | locale | ||
) |
Definition at line 2365 of file pg_locale.c.
References generate_unaccent_rules::dest, elog(), ERROR, locale, and pg_strxfrm_libc().
Referenced by varstr_abbrev_convert().
bool pg_strxfrm_enabled | ( | pg_locale_t | locale | ) |
Definition at line 2333 of file pg_locale.c.
References elog(), ERROR, and locale.
Referenced by varstr_sortsupport().
|
static |
Definition at line 2135 of file pg_locale.c.
References Assert(), generate_unaccent_rules::dest, elog(), ERROR, locale, and strxfrm_l.
Referenced by pg_strnxfrm_libc(), and pg_strxfrm().
size_t pg_strxfrm_prefix | ( | char * | dest, |
const char * | src, | ||
size_t | destsize, | ||
pg_locale_t | locale | ||
) |
Definition at line 2451 of file pg_locale.c.
References generate_unaccent_rules::dest, elog(), ERROR, and locale.
Referenced by varstr_abbrev_convert().
bool pg_strxfrm_prefix_enabled | ( | pg_locale_t | locale | ) |
Definition at line 2424 of file pg_locale.c.
References elog(), ERROR, and locale.
Referenced by varstr_abbrev_convert().
struct lconv* PGLC_localeconv | ( | void | ) |
Definition at line 479 of file pg_locale.c.
References CurrentLocaleConvValid, db_encoding_convert(), elog(), encoding, ereport, errcode(), errmsg(), ERROR, FATAL, free_struct_lconv(), locale_monetary, locale_numeric, pfree(), PG_CATCH, PG_END_TRY, pg_get_encoding_from_locale(), PG_RE_THROW, PG_SQL_ASCII, PG_TRY, pstrdup(), setlocale, and struct_lconv_is_valid().
Referenced by cash_in(), cash_numeric(), cash_out(), int4_cash(), int8_cash(), NUM_prepare_locale(), and numeric_cash().
|
static |
size_t wchar2char | ( | char * | to, |
const wchar_t * | from, | ||
size_t | tolen, | ||
pg_locale_t | locale | ||
) |
Definition at line 2806 of file pg_locale.c.
References Assert(), elog(), ERROR, GetDatabaseEncoding(), locale, locale_t, PG_UTF8, and wcstombs_l.
Referenced by lowerstr_with_len(), str_initcap(), str_tolower(), and str_toupper().
|
static |
Definition at line 128 of file pg_locale.c.
Referenced by lookup_collation_cache().
Definition at line 115 of file pg_locale.c.
Referenced by assign_locale_time(), and cache_locale_time().
Definition at line 114 of file pg_locale.c.
Referenced by assign_locale_monetary(), assign_locale_numeric(), and PGLC_localeconv().
Definition at line 111 of file pg_locale.c.
Referenced by CheckMyDatabase(), lowerstr_with_len(), t_isalnum(), t_isalpha(), t_isdigit(), t_isprint(), t_isspace(), and TParserInit().
struct pg_locale_struct default_locale |
Definition at line 1375 of file pg_locale.c.
Referenced by check_icu_locale(), CheckMyDatabase(), lc_collate_is_c(), and pg_newlocale_from_collation().
char* locale_messages |
Definition at line 93 of file pg_locale.c.
char* locale_monetary |
Definition at line 94 of file pg_locale.c.
Referenced by PGLC_localeconv().
char* locale_numeric |
Definition at line 95 of file pg_locale.c.
Referenced by PGLC_localeconv().
char* locale_time |
Definition at line 96 of file pg_locale.c.
Referenced by cache_locale_time().
char* localized_abbrev_days[7+1] |
Definition at line 105 of file pg_locale.c.
Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().
char* localized_abbrev_months[12+1] |
Definition at line 107 of file pg_locale.c.
Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().
char* localized_full_days[7+1] |
Definition at line 106 of file pg_locale.c.
Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().
char* localized_full_months[12+1] |
Definition at line 108 of file pg_locale.c.
Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().