mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
Control ctype behavior internally with a method table.
Previously, pattern matching and case mapping behavior branched based on the provider. Refactor to use a method table, which is less error-prone. This is also a step toward multiple provider versions, which we may want to support in the future. Reviewed-by: Andreas Karlsson <andreas@proxel.se> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/2830211e1b6e6a2e26d845780b03e125281ea17b.camel%40j-davis.com
This commit is contained in:
@@ -98,7 +98,7 @@ SB_lower_char(unsigned char c, pg_locale_t locale)
|
||||
else if (locale->is_default)
|
||||
return pg_tolower(c);
|
||||
else
|
||||
return tolower_l(c, locale->info.lt);
|
||||
return char_tolower(c, locale);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,17 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
|
||||
* way.
|
||||
*/
|
||||
|
||||
if (pg_database_encoding_max_length() > 1 || (locale->provider == COLLPROVIDER_ICU))
|
||||
if (locale->ctype_is_c ||
|
||||
(char_tolower_enabled(locale) &&
|
||||
pg_database_encoding_max_length() == 1))
|
||||
{
|
||||
p = VARDATA_ANY(pat);
|
||||
plen = VARSIZE_ANY_EXHDR(pat);
|
||||
s = VARDATA_ANY(str);
|
||||
slen = VARSIZE_ANY_EXHDR(str);
|
||||
return SB_IMatchText(s, slen, p, plen, locale);
|
||||
}
|
||||
else
|
||||
{
|
||||
pat = DatumGetTextPP(DirectFunctionCall1Coll(lower, collation,
|
||||
PointerGetDatum(pat)));
|
||||
@@ -224,14 +234,6 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
|
||||
else
|
||||
return MB_MatchText(s, slen, p, plen, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = VARDATA_ANY(pat);
|
||||
plen = VARSIZE_ANY_EXHDR(pat);
|
||||
s = VARDATA_ANY(str);
|
||||
slen = VARSIZE_ANY_EXHDR(str);
|
||||
return SB_IMatchText(s, slen, p, plen, locale);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user