mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
Solve the 'Turkish problem' with undesirable locale behavior for case
conversion of basic ASCII letters. Remove all uses of strcasecmp and strncasecmp in favor of new functions pg_strcasecmp and pg_strncasecmp; remove most but not all direct uses of toupper and tolower in favor of pg_toupper and pg_tolower. These functions use the same notions of case folding already developed for identifier case conversion. I left the straight locale-based folding in place for situations where we are just manipulating user data and not trying to match it to built-in strings --- for example, the SQL upper() function is still locale dependent. Perhaps this will prove not to be what's wanted, but at the moment we can initdb and pass regression tests in Turkish locale.
This commit is contained in:
@@ -495,7 +495,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
|
||||
|
||||
/* convert the whole string to lower case */
|
||||
for (i = 0; str_copy[i]; i++)
|
||||
str_copy[i] = (char) tolower((unsigned char) str_copy[i]);
|
||||
str_copy[i] = (char) pg_tolower((unsigned char) str_copy[i]);
|
||||
}
|
||||
|
||||
/* look for numerical tokens */
|
||||
@@ -565,7 +565,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
|
||||
{
|
||||
for (j = 0; j < PGTYPES_DATE_MONTH_MAXLENGTH; j++)
|
||||
{
|
||||
month_lower_tmp[j] = (char) tolower((unsigned char) list[i][j]);
|
||||
month_lower_tmp[j] = (char) pg_tolower((unsigned char) list[i][j]);
|
||||
if (!month_lower_tmp[j])
|
||||
{
|
||||
/* properly terminated */
|
||||
|
||||
@@ -1847,7 +1847,7 @@ ParseDateTime(char *timestr, char *lowstr,
|
||||
{
|
||||
ftype[nf] = DTK_DATE;
|
||||
while (isalnum((unsigned char) *(*endstr)) || (*(*endstr) == *dp))
|
||||
*lp++ = tolower((unsigned char) *(*endstr)++);
|
||||
*lp++ = pg_tolower((unsigned char) *(*endstr)++);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1875,9 +1875,9 @@ ParseDateTime(char *timestr, char *lowstr,
|
||||
else if (isalpha((unsigned char) *(*endstr)))
|
||||
{
|
||||
ftype[nf] = DTK_STRING;
|
||||
*lp++ = tolower((unsigned char) *(*endstr)++);
|
||||
*lp++ = pg_tolower((unsigned char) *(*endstr)++);
|
||||
while (isalpha((unsigned char) *(*endstr)))
|
||||
*lp++ = tolower((unsigned char) *(*endstr)++);
|
||||
*lp++ = pg_tolower((unsigned char) *(*endstr)++);
|
||||
|
||||
/*
|
||||
* Full date string with leading text month? Could also be a
|
||||
@@ -1919,9 +1919,9 @@ ParseDateTime(char *timestr, char *lowstr,
|
||||
else if (isalpha((unsigned char) *(*endstr)))
|
||||
{
|
||||
ftype[nf] = DTK_SPECIAL;
|
||||
*lp++ = tolower((unsigned char) *(*endstr)++);
|
||||
*lp++ = pg_tolower((unsigned char) *(*endstr)++);
|
||||
while (isalpha((unsigned char) *(*endstr)))
|
||||
*lp++ = tolower((unsigned char) *(*endstr)++);
|
||||
*lp++ = pg_tolower((unsigned char) *(*endstr)++);
|
||||
}
|
||||
/* otherwise something wrong... */
|
||||
else
|
||||
@@ -3115,7 +3115,7 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d,
|
||||
*/
|
||||
for (j = 0; !err && j < szdatetktbl; j++)
|
||||
{
|
||||
if (strcasecmp(datetktbl[j].token, scan_val.str_val) == 0)
|
||||
if (pg_strcasecmp(datetktbl[j].token, scan_val.str_val) == 0)
|
||||
{
|
||||
/*
|
||||
* tz calculates the offset for the seconds, the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.279 2004/05/05 15:03:04 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.280 2004/05/07 00:24:59 tgl Exp $ */
|
||||
|
||||
/* Copyright comment */
|
||||
%{
|
||||
@@ -609,7 +609,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
|
||||
/* Informix also has a CLOSE DATABASE command that
|
||||
essantially works like a DISCONNECT CURRENT
|
||||
as far as I know. */
|
||||
if (strcasecmp($1+strlen("close "), "database") == 0)
|
||||
if (pg_strcasecmp($1+strlen("close "), "database") == 0)
|
||||
{
|
||||
if (connection)
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "no at option for close database statement.\n");
|
||||
|
||||
Reference in New Issue
Block a user