mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
Remove lc_ctype_is_c().
Instead always fetch the locale and look at the ctype_is_c field. hba.c relies on regexes working for the C locale without needing catalog access, which worked before due to a special case for C_COLLATION_OID in lc_ctype_is_c(). Move the special case to pg_set_regex_collation() now that lc_ctype_is_c() is gone. Author: Andreas Karlsson Discussion: https://postgr.es/m/60929555-4709-40a7-b136-bcb44cff5a3c@proxel.se
This commit is contained in:
@@ -100,7 +100,7 @@ static Selectivity regex_selectivity(const char *patt, int pattlen,
|
||||
bool case_insensitive,
|
||||
int fixed_prefix_len);
|
||||
static int pattern_char_isalpha(char c, bool is_multibyte,
|
||||
pg_locale_t locale, bool locale_is_c);
|
||||
pg_locale_t locale);
|
||||
static Const *make_greater_string(const Const *str_const, FmgrInfo *ltproc,
|
||||
Oid collation);
|
||||
static Datum string_to_datum(const char *str, Oid datatype);
|
||||
@@ -1000,7 +1000,6 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
|
||||
match_pos;
|
||||
bool is_multibyte = (pg_database_encoding_max_length() > 1);
|
||||
pg_locale_t locale = 0;
|
||||
bool locale_is_c = false;
|
||||
|
||||
/* the right-hand const is type text or bytea */
|
||||
Assert(typeid == BYTEAOID || typeid == TEXTOID);
|
||||
@@ -1024,11 +1023,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
|
||||
errhint("Use the COLLATE clause to set the collation explicitly.")));
|
||||
}
|
||||
|
||||
/* If case-insensitive, we need locale info */
|
||||
if (lc_ctype_is_c(collation))
|
||||
locale_is_c = true;
|
||||
else
|
||||
locale = pg_newlocale_from_collation(collation);
|
||||
locale = pg_newlocale_from_collation(collation);
|
||||
}
|
||||
|
||||
if (typeid != BYTEAOID)
|
||||
@@ -1065,7 +1060,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
|
||||
|
||||
/* Stop if case-varying character (it's sort of a wildcard) */
|
||||
if (case_insensitive &&
|
||||
pattern_char_isalpha(patt[pos], is_multibyte, locale, locale_is_c))
|
||||
pattern_char_isalpha(patt[pos], is_multibyte, locale))
|
||||
break;
|
||||
|
||||
match[match_pos++] = patt[pos];
|
||||
@@ -1499,16 +1494,16 @@ regex_selectivity(const char *patt, int pattlen, bool case_insensitive,
|
||||
*/
|
||||
static int
|
||||
pattern_char_isalpha(char c, bool is_multibyte,
|
||||
pg_locale_t locale, bool locale_is_c)
|
||||
pg_locale_t locale)
|
||||
{
|
||||
if (locale_is_c)
|
||||
if (locale->ctype_is_c)
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||||
else if (is_multibyte && IS_HIGHBIT_SET(c))
|
||||
return true;
|
||||
else if (locale && locale->provider == COLLPROVIDER_ICU)
|
||||
else if (locale->provider == COLLPROVIDER_ICU)
|
||||
return IS_HIGHBIT_SET(c) ||
|
||||
(c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||||
else if (locale && locale->provider == COLLPROVIDER_LIBC)
|
||||
else if (locale->provider == COLLPROVIDER_LIBC)
|
||||
return isalpha_l((unsigned char) c, locale->info.lt);
|
||||
else
|
||||
return isalpha((unsigned char) c);
|
||||
|
||||
Reference in New Issue
Block a user