aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-05-07 00:24:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-05-07 00:24:59 +0000
commit0bd61548ab8d1ac5fee63f48ee9b384502a51ad6 (patch)
treeb0c63b75585d0c396e67a3acd204e226b13eae4b /src/backend/commands/variable.c
parent4d46274b33db52618ccf49550213b4d5ce4a7981 (diff)
downloadpostgresql-0bd61548ab8d1ac5fee63f48ee9b384502a51ad6.tar.gz
postgresql-0bd61548ab8d1ac5fee63f48ee9b384502a51ad6.zip
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.
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r--src/backend/commands/variable.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 14c408e0010..f83ce51baca 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.93 2004/01/19 19:04:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.94 2004/05/07 00:24:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,6 +23,7 @@
#include "catalog/pg_shadow.h"
#include "commands/variable.h"
#include "miscadmin.h"
+#include "parser/scansup.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/syscache.h"
@@ -82,22 +83,22 @@ assign_datestyle(const char *value, bool doit, GucSource source)
/* Ugh. Somebody ought to write a table driven version -- mjl */
- if (strcasecmp(tok, "ISO") == 0)
+ if (pg_strcasecmp(tok, "ISO") == 0)
{
newDateStyle = USE_ISO_DATES;
scnt++;
}
- else if (strcasecmp(tok, "SQL") == 0)
+ else if (pg_strcasecmp(tok, "SQL") == 0)
{
newDateStyle = USE_SQL_DATES;
scnt++;
}
- else if (strncasecmp(tok, "POSTGRES", 8) == 0)
+ else if (pg_strncasecmp(tok, "POSTGRES", 8) == 0)
{
newDateStyle = USE_POSTGRES_DATES;
scnt++;
}
- else if (strcasecmp(tok, "GERMAN") == 0)
+ else if (pg_strcasecmp(tok, "GERMAN") == 0)
{
newDateStyle = USE_GERMAN_DATES;
scnt++;
@@ -105,25 +106,25 @@ assign_datestyle(const char *value, bool doit, GucSource source)
if (ocnt == 0)
newDateOrder = DATEORDER_DMY;
}
- else if (strcasecmp(tok, "YMD") == 0)
+ else if (pg_strcasecmp(tok, "YMD") == 0)
{
newDateOrder = DATEORDER_YMD;
ocnt++;
}
- else if (strcasecmp(tok, "DMY") == 0 ||
- strncasecmp(tok, "EURO", 4) == 0)
+ else if (pg_strcasecmp(tok, "DMY") == 0 ||
+ pg_strncasecmp(tok, "EURO", 4) == 0)
{
newDateOrder = DATEORDER_DMY;
ocnt++;
}
- else if (strcasecmp(tok, "MDY") == 0 ||
- strcasecmp(tok, "US") == 0 ||
- strncasecmp(tok, "NONEURO", 7) == 0)
+ else if (pg_strcasecmp(tok, "MDY") == 0 ||
+ pg_strcasecmp(tok, "US") == 0 ||
+ pg_strncasecmp(tok, "NONEURO", 7) == 0)
{
newDateOrder = DATEORDER_MDY;
ocnt++;
}
- else if (strcasecmp(tok, "DEFAULT") == 0)
+ else if (pg_strcasecmp(tok, "DEFAULT") == 0)
{
/*
* Easiest way to get the current DEFAULT state is to fetch
@@ -321,8 +322,7 @@ clear_tz(void)
static bool
tzset_succeeded(const char *tz)
{
- char tztmp[TZBUF_LEN];
- char *cp;
+ char *tztmp;
int tzval;
/*
@@ -339,9 +339,7 @@ tzset_succeeded(const char *tz)
* Check for known spellings of "UTC". Note we must downcase the
* input before passing it to DecodePosixTimezone().
*/
- StrNCpy(tztmp, tz, sizeof(tztmp));
- for (cp = tztmp; *cp; cp++)
- *cp = tolower((unsigned char) *cp);
+ tztmp = downcase_truncate_identifier(tz, strlen(tz), false);
if (DecodePosixTimezone(tztmp, &tzval) == 0)
if (tzval == 0)
return true;
@@ -410,7 +408,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
/*
* Check for INTERVAL 'foo'
*/
- if (strncasecmp(value, "interval", 8) == 0)
+ if (pg_strncasecmp(value, "interval", 8) == 0)
{
const char *valueptr = value;
char *val;
@@ -474,7 +472,7 @@ assign_timezone(const char *value, bool doit, GucSource source)
HasCTZSet = true;
}
}
- else if (strcasecmp(value, "UNKNOWN") == 0)
+ else if (pg_strcasecmp(value, "UNKNOWN") == 0)
{
/*
* UNKNOWN is the value shown as the "default" for TimeZone in