Fix unreachable code warning from commit 2d819a08a1.

Found by Coverity.

Discussion: https://postgr.es/m/3422201.1710711993@sss.pgh.pa.us
Reported-by: Tom Lane
This commit is contained in:
Jeff Davis 2024-03-18 09:15:47 -07:00
parent 5162f663fc
commit 61f352ece9
1 changed files with 9 additions and 14 deletions

View File

@ -2501,28 +2501,23 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
return result;
}
/*
* Validate the locale and encoding combination, and return the canonical form
* of the locale name.
*
* The only supported locale for the builtin provider is "C", and it's
* available for any encoding.
*/
const char *
builtin_validate_locale(int encoding, const char *locale)
{
const char *canonical_name = NULL;
int required_encoding = -1;
if (strcmp(locale, "C") == 0)
canonical_name = "C";
if (!canonical_name)
if (strcmp(locale, "C") != 0)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("invalid locale name \"%s\" for builtin provider",
locale)));
if (required_encoding >= 0 && encoding != required_encoding)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("encoding \"%s\" does not match locale \"%s\"",
pg_encoding_to_char(encoding), locale)));
return canonical_name;
return "C";
}