diff options
author | Jeff Davis | 2024-07-28 23:55:17 +0000 |
---|---|---|
committer | Jeff Davis | 2024-07-28 23:55:17 +0000 |
commit | 2e68077b07cc597ef6bdfacffb5acbd17e179237 (patch) | |
tree | 52a7d910b71cacabf6aa275588b65e8cb8ff66d4 /src/backend/regex | |
parent | da87dc07f16e7435edc601661a6ec71b38bccd25 (diff) |
Refactor pg_set_regex_collation() for clarity.
Discussion: https://postgr.es/m/[email protected]
Reviewed-by: Andreas Karlsson
Diffstat (limited to 'src/backend/regex')
-rw-r--r-- | src/backend/regex/regc_pg_locale.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c index 85f3238eb07..9d98d10a285 100644 --- a/src/backend/regex/regc_pg_locale.c +++ b/src/backend/regex/regc_pg_locale.c @@ -261,29 +261,33 @@ pg_set_regex_collation(Oid collation) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("nondeterministic collations are not supported for regular expressions"))); + if (pg_regex_locale && pg_regex_locale->provider == COLLPROVIDER_BUILTIN) + { + Assert(GetDatabaseEncoding() == PG_UTF8); + pg_regex_strategy = PG_REGEX_BUILTIN; + } #ifdef USE_ICU - if (pg_regex_locale && pg_regex_locale->provider == COLLPROVIDER_ICU) + else if (pg_regex_locale && pg_regex_locale->provider == COLLPROVIDER_ICU) + { pg_regex_strategy = PG_REGEX_LOCALE_ICU; - else + } #endif - if (GetDatabaseEncoding() == PG_UTF8) + else { - if (pg_regex_locale) + if (GetDatabaseEncoding() == PG_UTF8) { - if (pg_regex_locale->provider == COLLPROVIDER_BUILTIN) - pg_regex_strategy = PG_REGEX_BUILTIN; - else + if (pg_regex_locale) pg_regex_strategy = PG_REGEX_LOCALE_WIDE_L; + else + pg_regex_strategy = PG_REGEX_LOCALE_WIDE; } else - pg_regex_strategy = PG_REGEX_LOCALE_WIDE; - } - else - { - if (pg_regex_locale) - pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L; - else - pg_regex_strategy = PG_REGEX_LOCALE_1BYTE; + { + if (pg_regex_locale) + pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L; + else + pg_regex_strategy = PG_REGEX_LOCALE_1BYTE; + } } pg_regex_collation = collation; |