|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <time.h>#include "access/htup_details.h"#include "catalog/pg_collation.h"#include "catalog/pg_database.h"#include "common/hashfn.h"#include "common/string.h"#include "mb/pg_wchar.h"#include "miscadmin.h"#include "utils/builtins.h"#include "utils/guc_hooks.h"#include "utils/lsyscache.h"#include "utils/memutils.h"#include "utils/pg_locale.h"#include "utils/pg_locale_c.h"#include "utils/relcache.h"#include "utils/syscache.h"#include "lib/simplehash.h"
Go to the source code of this file.
Data Structures | |
| struct | collation_cache_entry |
Macros | |
| #define | PGLOCALE_SUPPORT_ERROR(provider) elog(ERROR, "unsupported collprovider for %s: %c", __func__, provider) |
| #define | TEXTBUFLEN 1024 |
| #define | MAX_L10N_DATA 80 |
| #define | SH_PREFIX collation_cache |
| #define | SH_ELEMENT_TYPE collation_cache_entry |
| #define | SH_KEY_TYPE Oid |
| #define | SH_KEY collid |
| #define | SH_HASH_KEY(tb, key) murmurhash32((uint32) key) |
| #define | SH_EQUAL(tb, a, b) (a == b) |
| #define | SH_GET_HASH(tb, a) a->hash |
| #define | SH_SCOPE static inline |
| #define | SH_STORE_HASH |
| #define | SH_DECLARE |
| #define | SH_DEFINE |
| #define MAX_L10N_DATA 80 |
Definition at line 69 of file pg_locale.c.
| #define PGLOCALE_SUPPORT_ERROR | ( | provider | ) | elog(ERROR, "unsupported collprovider for %s: %c", __func__, provider) |
Definition at line 60 of file pg_locale.c.
| #define SH_DECLARE |
Definition at line 139 of file pg_locale.c.
| #define SH_DEFINE |
Definition at line 140 of file pg_locale.c.
| #define SH_ELEMENT_TYPE collation_cache_entry |
Definition at line 131 of file pg_locale.c.
| #define SH_HASH_KEY | ( | tb, | |
| key | |||
| ) | murmurhash32((uint32) key) |
Definition at line 134 of file pg_locale.c.
Definition at line 133 of file pg_locale.c.
Definition at line 132 of file pg_locale.c.
| #define SH_PREFIX collation_cache |
Definition at line 130 of file pg_locale.c.
Definition at line 137 of file pg_locale.c.
| #define SH_STORE_HASH |
Definition at line 138 of file pg_locale.c.
| #define TEXTBUFLEN 1024 |
Definition at line 67 of file pg_locale.c.
Definition at line 409 of file pg_locale.c.
References fb(), newval, and pg_perm_setlocale().
Definition at line 358 of file pg_locale.c.
References CurrentLocaleConvValid.
Definition at line 1667 of file pg_locale.c.
References ereport, errcode(), errmsg(), ERROR, fb(), and PG_UTF8.
Referenced by builtin_validate_locale(), and DefineCollation().
Definition at line 1691 of file pg_locale.c.
References builtin_locale_encoding(), encoding, ereport, errcode(), errmsg(), ERROR, fb(), and pg_encoding_to_char.
Referenced by create_pg_locale_builtin(), createdb(), and DefineCollation().
Definition at line 702 of file pg_locale.c.
References _dosmaperr(), buf, cache_single_string(), CurrentLCTimeValid, DEBUG3, elog, encoding, ERROR, fb(), i, 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().
Definition at line 679 of file pg_locale.c.
References encoding, fb(), MemoryContextStrdup(), pfree(), pg_any_to_server(), and TopMemoryContext.
Referenced by cache_locale_time().
Definition at line 275 of file pg_locale.c.
References elog, ereport, errcode(), errmsg(), fb(), pg_locale_struct::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().
Definition at line 386 of file pg_locale.c.
References check_locale(), fb(), newval, PGC_S_DEFAULT, and source.
Definition at line 340 of file pg_locale.c.
References check_locale(), fb(), and newval.
Definition at line 352 of file pg_locale.c.
References check_locale(), fb(), and newval.
Definition at line 364 of file pg_locale.c.
References check_locale(), fb(), and newval.
|
static |
Definition at line 1049 of file pg_locale.c.
References Assert, pg_locale_struct::collate, pg_locale_struct::collate_is_c, collid, create_pg_locale_builtin(), create_pg_locale_icu(), create_pg_locale_libc(), pg_locale_struct::ctype, pg_locale_struct::ctype_is_c, elog, ereport, errdetail(), errhint(), errmsg(), ERROR, fb(), get_collation_actual_version(), get_namespace_name(), GETSTRUCT(), HeapTupleIsValid, pg_locale_struct::is_default, NameStr, ObjectIdGetDatum(), PGLOCALE_SUPPORT_ERROR, quote_qualified_identifier(), ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), SysCacheGetAttrNotNull(), TextDatumGetCString, and WARNING.
Referenced by pg_newlocale_from_collation().
|
extern |
Definition at line 229 of file pg_locale_builtin.c.
References pg_locale_struct::builtin, builtin_validate_locale(), pg_locale_struct::casemap_full, pg_locale_struct::collate_is_c, collid, pg_locale_struct::ctype, pg_locale_struct::ctype_is_c, ctype_methods_builtin, pg_locale_struct::deterministic, elog, ERROR, fb(), GetDatabaseEncoding(), HeapTupleIsValid, pg_locale_struct::locale, MemoryContextAllocZero(), MemoryContextStrdup(), MyDatabaseId, ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttrNotNull(), and TextDatumGetCString.
Referenced by create_pg_locale(), and init_database_collation().
|
extern |
Definition at line 307 of file pg_locale_icu.c.
References pg_locale_struct::collate, pg_locale_struct::collate_is_c, collid, pg_locale_struct::ctype, pg_locale_struct::ctype_is_c, pg_locale_struct::deterministic, elog, ereport, errcode(), errmsg(), ERROR, fb(), GetDatabaseEncoding(), GETSTRUCT(), HeapTupleIsValid, pg_locale_struct::locale, locale_t, pg_locale_struct::lt, MemoryContextAllocZero(), MemoryContextStrdup(), MyDatabaseId, ObjectIdGetDatum(), pg_database_encoding_max_length(), PG_UTF8, ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), SysCacheGetAttrNotNull(), and TextDatumGetCString.
Referenced by create_pg_locale(), and init_database_collation().
|
extern |
Definition at line 741 of file pg_locale_libc.c.
References pg_locale_struct::collate, pg_locale_struct::collate_is_c, collate_methods_libc, collid, pg_locale_struct::ctype, pg_locale_struct::ctype_is_c, ctype_methods_libc_other_mb, ctype_methods_libc_sb, ctype_methods_libc_utf8, pg_locale_struct::deterministic, elog, ERROR, fb(), GetDatabaseEncoding(), HeapTupleIsValid, locale_t, pg_locale_struct::lt, make_libc_collator(), MemoryContextAllocZero(), MyDatabaseId, ObjectIdGetDatum(), pg_database_encoding_max_length(), PG_UTF8, ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttrNotNull(), and TextDatumGetCString.
Referenced by create_pg_locale(), and init_database_collation().
Definition at line 476 of file pg_locale.c.
References encoding, ereport, errcode(), errmsg(), ERROR, fb(), free, pfree(), pg_any_to_server(), and str.
Referenced by PGLC_localeconv().
Definition at line 426 of file pg_locale.c.
References free.
Referenced by PGLC_localeconv().
Definition at line 1247 of file pg_locale.c.
References fb(), 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().
Definition at line 277 of file pg_locale_builtin.c.
References ereport, errcode(), errmsg(), ERROR, and fb().
Referenced by get_collation_actual_version().
Definition at line 983 of file pg_locale_libc.c.
References ereport, errmsg(), ERROR, fb(), locale_t, pg_strcasecmp(), pg_strncasecmp(), psprintf(), and pstrdup().
Referenced by get_collation_actual_version().
Definition at line 1731 of file pg_locale.c.
References ereport, errcode(), errmsg(), ERROR, fb(), MaxAllocSize, Min, palloc(), pfree(), and repalloc().
Referenced by createdb(), DefineCollation(), and pg_import_system_collations().
Definition at line 1789 of file pg_locale.c.
References ereport, errcode(), errhint(), errmsg(), ERROR, fb(), i, icu_validation_level, IsBinaryUpgrade, and WARNING.
Referenced by createdb(), and DefineCollation().
Definition at line 1131 of file pg_locale.c.
References Assert, pg_locale_struct::collate, pg_locale_struct::collate_is_c, create_pg_locale_builtin(), create_pg_locale_icu(), create_pg_locale_libc(), pg_locale_struct::ctype, pg_locale_struct::ctype_is_c, default_locale, elog, ERROR, fb(), GETSTRUCT(), HeapTupleIsValid, pg_locale_struct::is_default, MyDatabaseId, ObjectIdGetDatum(), PGLOCALE_SUPPORT_ERROR, ReleaseSysCache(), SearchSysCache1(), and TopMemoryContext.
Referenced by CheckMyDatabase().
| pg_locale_t pg_database_locale | ( | void | ) |
Definition at line 1175 of file pg_locale.c.
References fb(), and pg_newlocale_from_collation().
Referenced by ltree_crc32_sz(), ltree_prefix_eq_ci(), t_isalnum(), and t_isalpha().
Definition at line 1366 of file pg_locale.c.
References pg_locale_struct::ctype, default_locale, ctype_methods::downcase_ident, fb(), and strlower_c().
Referenced by downcase_identifier().
Definition at line 1653 of file pg_locale.c.
References fb().
Referenced by icu_unicode_version().
| bool pg_iswalnum | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1533 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISALNUM, and ctype_methods::wc_isalnum.
Referenced by t_isalnum().
| bool pg_iswalpha | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1523 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISALPHA, and ctype_methods::wc_isalpha.
Referenced by t_isalpha().
| bool pg_iswcased | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1615 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISALPHA, and ctype_methods::wc_iscased.
Referenced by like_fixed_prefix_ci().
| bool pg_iswdigit | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1513 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISDIGIT, and ctype_methods::wc_isdigit.
| bool pg_iswgraph | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1563 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISGRAPH, and ctype_methods::wc_isgraph.
| bool pg_iswlower | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1553 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISLOWER, and ctype_methods::wc_islower.
| bool pg_iswprint | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1573 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISPRINT, and ctype_methods::wc_isprint.
| bool pg_iswpunct | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1583 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISPUNCT, and ctype_methods::wc_ispunct.
| bool pg_iswspace | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1593 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISSPACE, and ctype_methods::wc_isspace.
| bool pg_iswupper | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1543 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISUPPER, and ctype_methods::wc_isupper.
| bool pg_iswxdigit | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1603 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_char_properties, PG_ISDIGIT, and ctype_methods::wc_isxdigit.
| pg_locale_t pg_newlocale_from_collation | ( | Oid | collid | ) |
Definition at line 1189 of file pg_locale.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, AssertCouldGetRelation(), c_locale, CollationCache, CollationCacheContext, collid, create_pg_locale(), default_locale, elog, ERROR, fb(), last_collation_cache_locale, last_collation_cache_oid, pg_locale_struct::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_ci(), make_greater_string(), match_pattern_prefix(), pg_database_locale(), 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().
Definition at line 172 of file pg_locale.c.
References DEBUG3, elog, FATAL, fb(), GetDatabaseEncoding(), pg_locale_struct::locale, LOCALE_NAME_BUFLEN, setenv, setlocale, SetMessageEncoding(), and strlcpy().
Referenced by assign_locale_messages(), CheckMyDatabase(), and init_locale().
Definition at line 1384 of file pg_locale.c.
References pg_locale_struct::collate, fb(), and collate_methods::strncoll.
Referenced by varstrfastcmp_locale().
| size_t pg_strfold | ( | char * | dst, |
| size_t | dstsize, | ||
| const char * | src, | ||
| ssize_t | srclen, | ||
| pg_locale_t | locale | ||
| ) |
Definition at line 1348 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), ctype_methods::strfold, and strlower_c().
Referenced by ltree_crc32_sz(), ltree_prefix_eq_ci(), and str_casefold().
| size_t pg_strlower | ( | char * | dst, |
| size_t | dstsize, | ||
| const char * | src, | ||
| ssize_t | srclen, | ||
| pg_locale_t | locale | ||
| ) |
Definition at line 1318 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), ctype_methods::strlower, and strlower_c().
Referenced by str_tolower().
| int pg_strncoll | ( | const char * | arg1, |
| ssize_t | len1, | ||
| const char * | arg2, | ||
| ssize_t | len2, | ||
| pg_locale_t | locale | ||
| ) |
Definition at line 1404 of file pg_locale.c.
References pg_locale_struct::collate, fb(), and collate_methods::strncoll.
Referenced by MatchText(), text_position_next_internal(), and varstr_cmp().
| size_t pg_strnxfrm | ( | char * | dest, |
| size_t | destsize, | ||
| const char * | src, | ||
| ssize_t | srclen, | ||
| pg_locale_t | locale | ||
| ) |
Definition at line 1459 of file pg_locale.c.
References pg_locale_struct::collate, fb(), and collate_methods::strnxfrm.
Referenced by hashbpchar(), hashbpcharextended(), hashtext(), and hashtextextended().
| size_t pg_strnxfrm_prefix | ( | char * | dest, |
| size_t | destsize, | ||
| const char * | src, | ||
| ssize_t | srclen, | ||
| pg_locale_t | locale | ||
| ) |
Definition at line 1506 of file pg_locale.c.
References pg_locale_struct::collate, fb(), and collate_methods::strnxfrm_prefix.
| size_t pg_strtitle | ( | char * | dst, |
| size_t | dstsize, | ||
| const char * | src, | ||
| ssize_t | srclen, | ||
| pg_locale_t | locale | ||
| ) |
Definition at line 1328 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), ctype_methods::strtitle, and strtitle_c().
Referenced by str_initcap().
| size_t pg_strupper | ( | char * | dst, |
| size_t | dstsize, | ||
| const char * | src, | ||
| ssize_t | srclen, | ||
| pg_locale_t | locale | ||
| ) |
Definition at line 1338 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), ctype_methods::strupper, and strupper_c().
Referenced by str_toupper().
Definition at line 1434 of file pg_locale.c.
References pg_locale_struct::collate, fb(), and collate_methods::strnxfrm.
Referenced by convert_string_datum(), and varstr_abbrev_convert().
| bool pg_strxfrm_enabled | ( | pg_locale_t | locale | ) |
Definition at line 1418 of file pg_locale.c.
References pg_locale_struct::collate, and collate_methods::strxfrm_is_safe.
Referenced by varstr_sortsupport().
Definition at line 1481 of file pg_locale.c.
References pg_locale_struct::collate, fb(), and collate_methods::strnxfrm_prefix.
Referenced by varstr_abbrev_convert().
| bool pg_strxfrm_prefix_enabled | ( | pg_locale_t | locale | ) |
Definition at line 1470 of file pg_locale.c.
References pg_locale_struct::collate, fb(), and collate_methods::strnxfrm_prefix.
Referenced by varstr_abbrev_convert().
| pg_wchar pg_towlower | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1639 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_ascii_tolower(), and ctype_methods::wc_tolower.
| pg_wchar pg_towupper | ( | pg_wchar | wc, |
| pg_locale_t | locale | ||
| ) |
Definition at line 1626 of file pg_locale.c.
References pg_locale_struct::ctype, fb(), pg_ascii_toupper(), and ctype_methods::wc_toupper.
Definition at line 506 of file pg_locale.c.
References CurrentLocaleConvValid, db_encoding_convert(), elog, encoding, ereport, errcode(), errmsg(), ERROR, fb(), 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().
Definition at line 1265 of file pg_locale.c.
References fb(), i, and pg_ascii_tolower().
Referenced by pg_downcase_ident(), pg_strfold(), and pg_strlower().
Definition at line 1279 of file pg_locale.c.
References fb(), i, pg_ascii_tolower(), and pg_ascii_toupper().
Referenced by pg_strtitle().
Definition at line 445 of file pg_locale.c.
References fb().
Referenced by PGLC_localeconv().
Definition at line 1305 of file pg_locale.c.
References fb(), i, and pg_ascii_toupper().
Referenced by pg_strupper().
|
static |
Definition at line 112 of file pg_locale.c.
Referenced by pg_newlocale_from_collation().
|
static |
Definition at line 144 of file pg_locale.c.
Referenced by pg_newlocale_from_collation().
|
static |
Definition at line 143 of file pg_locale.c.
Referenced by pg_newlocale_from_collation().
Definition at line 110 of file pg_locale.c.
Referenced by assign_locale_time(), and cache_locale_time().
Definition at line 109 of file pg_locale.c.
Referenced by assign_locale_monetary(), assign_locale_numeric(), and PGLC_localeconv().
|
static |
Definition at line 106 of file pg_locale.c.
Referenced by init_database_collation(), pg_downcase_ident(), and pg_newlocale_from_collation().
Definition at line 92 of file pg_locale.c.
Referenced by createdb(), DefineCollation(), and icu_validate_locale().
|
static |
Definition at line 151 of file pg_locale.c.
Referenced by pg_newlocale_from_collation().
|
static |
Definition at line 150 of file pg_locale.c.
Referenced by pg_newlocale_from_collation().
| char* locale_messages |
Definition at line 87 of file pg_locale.c.
| char* locale_monetary |
Definition at line 88 of file pg_locale.c.
Referenced by PGLC_localeconv().
| char* locale_numeric |
Definition at line 89 of file pg_locale.c.
Referenced by PGLC_localeconv().
| char* locale_time |
Definition at line 90 of file pg_locale.c.
Referenced by cache_locale_time().
| char* localized_abbrev_days[7+1] |
Definition at line 101 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 103 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 102 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 104 of file pg_locale.c.
Referenced by cache_locale_time(), DCH_from_char(), and DCH_to_char().