mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Fix unintentional behavior change in commit e9931bfb75
.
Prior to that commit, there was special case to use ASCII case mapping
behavior for the libc provider with a single-byte encoding when that's
the default collation. Commit e9931bfb75
mistakenly eliminated that
special case; this commit restores it.
Discussion: https://postgr.es/m/01a104f0d2179d756261e90d96fd65c36ad6fcf0.camel@j-davis.com
This commit is contained in:
@ -1755,7 +1755,12 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
|
|||||||
* collations you get exactly what the collation says.
|
* collations you get exactly what the collation says.
|
||||||
*/
|
*/
|
||||||
for (p = result; *p; p++)
|
for (p = result; *p; p++)
|
||||||
*p = tolower_l((unsigned char) *p, mylocale->info.lt);
|
{
|
||||||
|
if (mylocale->is_default)
|
||||||
|
*p = pg_tolower((unsigned char) *p);
|
||||||
|
else
|
||||||
|
*p = tolower_l((unsigned char) *p, mylocale->info.lt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1892,7 +1897,12 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
|
|||||||
* collations you get exactly what the collation says.
|
* collations you get exactly what the collation says.
|
||||||
*/
|
*/
|
||||||
for (p = result; *p; p++)
|
for (p = result; *p; p++)
|
||||||
*p = toupper_l((unsigned char) *p, mylocale->info.lt);
|
{
|
||||||
|
if (mylocale->is_default)
|
||||||
|
*p = pg_toupper((unsigned char) *p);
|
||||||
|
else
|
||||||
|
*p = toupper_l((unsigned char) *p, mylocale->info.lt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2090,10 +2100,20 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
|
|||||||
*/
|
*/
|
||||||
for (p = result; *p; p++)
|
for (p = result; *p; p++)
|
||||||
{
|
{
|
||||||
if (wasalnum)
|
if (mylocale->is_default)
|
||||||
*p = tolower_l((unsigned char) *p, mylocale->info.lt);
|
{
|
||||||
|
if (wasalnum)
|
||||||
|
*p = pg_tolower((unsigned char) *p);
|
||||||
|
else
|
||||||
|
*p = pg_toupper((unsigned char) *p);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*p = toupper_l((unsigned char) *p, mylocale->info.lt);
|
{
|
||||||
|
if (wasalnum)
|
||||||
|
*p = tolower_l((unsigned char) *p, mylocale->info.lt);
|
||||||
|
else
|
||||||
|
*p = toupper_l((unsigned char) *p, mylocale->info.lt);
|
||||||
|
}
|
||||||
wasalnum = isalnum_l((unsigned char) *p, mylocale->info.lt);
|
wasalnum = isalnum_l((unsigned char) *p, mylocale->info.lt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,8 @@ SB_lower_char(unsigned char c, pg_locale_t locale)
|
|||||||
{
|
{
|
||||||
if (locale->ctype_is_c)
|
if (locale->ctype_is_c)
|
||||||
return pg_ascii_tolower(c);
|
return pg_ascii_tolower(c);
|
||||||
|
else if (locale->is_default)
|
||||||
|
return pg_tolower(c);
|
||||||
else
|
else
|
||||||
return tolower_l(c, locale->info.lt);
|
return tolower_l(c, locale->info.lt);
|
||||||
}
|
}
|
||||||
|
@ -1216,6 +1216,7 @@ create_pg_locale(Oid collid, MemoryContext context)
|
|||||||
|
|
||||||
result->provider = collform->collprovider;
|
result->provider = collform->collprovider;
|
||||||
result->deterministic = collform->collisdeterministic;
|
result->deterministic = collform->collisdeterministic;
|
||||||
|
result->is_default = false;
|
||||||
|
|
||||||
if (collform->collprovider == COLLPROVIDER_BUILTIN)
|
if (collform->collprovider == COLLPROVIDER_BUILTIN)
|
||||||
{
|
{
|
||||||
@ -1409,6 +1410,7 @@ init_database_collation(void)
|
|||||||
|
|
||||||
|
|
||||||
default_locale.provider = dbform->datlocprovider;
|
default_locale.provider = dbform->datlocprovider;
|
||||||
|
default_locale.is_default = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default locale is currently always deterministic. Nondeterministic
|
* Default locale is currently always deterministic. Nondeterministic
|
||||||
|
@ -82,6 +82,7 @@ struct pg_locale_struct
|
|||||||
bool deterministic;
|
bool deterministic;
|
||||||
bool collate_is_c;
|
bool collate_is_c;
|
||||||
bool ctype_is_c;
|
bool ctype_is_c;
|
||||||
|
bool is_default;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
Reference in New Issue
Block a user