1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +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:
Jeff Davis
2024-12-02 21:59:02 -08:00
parent 4171c44c9b
commit e3fa2b037c
4 changed files with 30 additions and 5 deletions

View File

@ -1755,7 +1755,12 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
* collations you get exactly what the collation says.
*/
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.
*/
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++)
{
if (wasalnum)
*p = tolower_l((unsigned char) *p, mylocale->info.lt);
if (mylocale->is_default)
{
if (wasalnum)
*p = pg_tolower((unsigned char) *p);
else
*p = pg_toupper((unsigned char) *p);
}
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);
}
}