diff options
Diffstat (limited to 'src/backend/regex/regc_pg_locale.c')
-rw-r--r-- | src/backend/regex/regc_pg_locale.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c index e0d93eab321..6e84f42cb24 100644 --- a/src/backend/regex/regc_pg_locale.c +++ b/src/backend/regex/regc_pg_locale.c @@ -231,6 +231,18 @@ static const unsigned char pg_char_properties[128] = { void pg_set_regex_collation(Oid collation) { + if (!OidIsValid(collation)) + { + /* + * This typically means that the parser could not resolve a + * conflict of implicit collations, so report it that way. + */ + ereport(ERROR, + (errcode(ERRCODE_INDETERMINATE_COLLATION), + errmsg("could not determine which collation to use for regular expression"), + errhint("Use the COLLATE clause to set the collation explicitly."))); + } + if (lc_ctype_is_c(collation)) { /* C/POSIX collations use this path regardless of database encoding */ @@ -240,28 +252,12 @@ pg_set_regex_collation(Oid collation) } else { - if (collation == DEFAULT_COLLATION_OID) - pg_regex_locale = 0; - else if (OidIsValid(collation)) - { - /* - * NB: pg_newlocale_from_collation will fail if not HAVE_LOCALE_T; - * the case of pg_regex_locale != 0 but not HAVE_LOCALE_T does not - * have to be considered below. - */ - pg_regex_locale = pg_newlocale_from_collation(collation); - } - else - { - /* - * This typically means that the parser could not resolve a - * conflict of implicit collations, so report it that way. - */ - ereport(ERROR, - (errcode(ERRCODE_INDETERMINATE_COLLATION), - errmsg("could not determine which collation to use for regular expression"), - errhint("Use the COLLATE clause to set the collation explicitly."))); - } + /* + * NB: pg_newlocale_from_collation will fail if not HAVE_LOCALE_T; + * the case of pg_regex_locale != 0 but not HAVE_LOCALE_T does not + * have to be considered below. + */ + pg_regex_locale = pg_newlocale_from_collation(collation); if (pg_regex_locale && !pg_regex_locale->deterministic) ereport(ERROR, |