summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2013-03-05 18:02:35 +0000
committerTom Lane2013-03-05 18:02:35 +0000
commit1db236c74a2bc21178e4275bba7329d5cf3aaf55 (patch)
treed859dff4be914032e5c4d5f28b5b3238f91847d0 /src/include
parentfa852303f0cda557e620af775c2e96b56eb365ba (diff)
Fix to_char() to use ASCII-only case-folding rules where appropriate.
formatting.c used locale-dependent case folding rules in some code paths where the result isn't supposed to be locale-dependent, for example to_char(timestamp, 'DAY'). Since the source data is always just ASCII in these cases, that usually didn't matter ... but it does matter in Turkish locales, which have unusual treatment of "i" and "I". To confuse matters even more, the misbehavior was only visible in UTF8 encoding, because in single-byte encodings we used pg_toupper/pg_tolower which don't have locale-specific behavior for ASCII characters. Fix by providing intentionally ASCII-only case-folding functions and using these where appropriate. Per bug #7913 from Adnan Dursun. Back-patch to all active branches, since it's been like this for a long time.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/utils/formatting.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/include/utils/formatting.h b/src/include/utils/formatting.h
index ce571957fe6..b59469276d0 100644
--- a/src/include/utils/formatting.h
+++ b/src/include/utils/formatting.h
@@ -24,6 +24,10 @@ extern char *str_tolower(const char *buff, size_t nbytes, Oid collid);
extern char *str_toupper(const char *buff, size_t nbytes, Oid collid);
extern char *str_initcap(const char *buff, size_t nbytes, Oid collid);
+extern char *asc_tolower(const char *buff, size_t nbytes);
+extern char *asc_toupper(const char *buff, size_t nbytes);
+extern char *asc_initcap(const char *buff, size_t nbytes);
+
extern Datum timestamp_to_char(PG_FUNCTION_ARGS);
extern Datum timestamptz_to_char(PG_FUNCTION_ARGS);
extern Datum interval_to_char(PG_FUNCTION_ARGS);