summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-11-08 15:37:54 +0400
committerunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-11-08 15:37:54 +0400
commitd301b4a0a52db2d2b66a2bd9feb6f84de163d36b (patch)
tree40ea85ba7514f23191a8a9dc8a060e24fb5ecb35 /mysql-test
parentb227a3d3487802249408bb3edbc40d28e571b417 (diff)
downloadmariadb-git-d301b4a0a52db2d2b66a2bd9feb6f84de163d36b.tar.gz
Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
Problem: After introducing of LC_TIME_NAMES variable, the function date_format() can return international non-ascii characters in month and weekday names. Thus, it cannot return a binary string anymore, because inserting a result of date_format() into a column with non-utf8 character set produces garbage. Fix: date_format() now returns a character string, using "collation_connection" to detect character set and collation for the returned value. This allows to insert results of date_format() properly into columns with various character sets. mysql-test/r/ctype_utf8.result: Adding test case. Fixing old result. mysql-test/t/ctype_utf8.test: Adding test case. sql/item_timefunc.cc: DATE_FORMAT() now returns a character string instead of binary string: - make_date_time() now converts localte data from UTF8 to the character set of "str" argument, instead of copying as is. - fix_dec_and_length() now uses "collation_connection" instead of "binary" for the result, it also now multiplies to mbmaxlen when calculating max_length
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/ctype_utf8.result24
-rw-r--r--mysql-test/t/ctype_utf8.test20
2 files changed, 43 insertions, 1 deletions
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index fdf21a50a02..24f29b23e87 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -124,12 +124,34 @@ create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` binary(10) default NULL
+ `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` char(10) character set utf8 default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
date_format("2004-01-19 10:10:10", "%Y-%m-%d")
2004-01-19
drop table t1;
+set names utf8;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1);
+insert into t1 values (date_format('2004-02-02','%M'));
+select hex(s1) from t1;
+hex(s1)
+66E97672696572
+drop table t1;
+create table t1 (s1 char(20) character set koi8r);
+set LC_TIME_NAMES='ru_RU';
+insert into t1 values (date_format('2004-02-02','%M'));
+insert into t1 values (date_format('2004-02-02','%b'));
+insert into t1 values (date_format('2004-02-02','%W'));
+insert into t1 values (date_format('2004-02-02','%a'));
+select hex(s1), s1 from t1;
+hex(s1) s1
+E6C5D7D2C1CCD1 Февраля
+E6C5D7 Фев
+F0CFCEC5C4C5CCD8CEC9CB Понедельник
+F0CEC4 Пнд
+drop table t1;
+set LC_TIME_NAMES='en_US';
set names koi8r;
create table t1 (s1 char(1) character set utf8);
insert into t1 values (_koi8r'');
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index af40121852f..0b3f9ed2400 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -94,6 +94,26 @@ select * from t1;
drop table t1;
#
+# Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
+#
+set names utf8;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1);
+insert into t1 values (date_format('2004-02-02','%M'));
+select hex(s1) from t1;
+drop table t1;
+create table t1 (s1 char(20) character set koi8r);
+set LC_TIME_NAMES='ru_RU';
+insert into t1 values (date_format('2004-02-02','%M'));
+insert into t1 values (date_format('2004-02-02','%b'));
+insert into t1 values (date_format('2004-02-02','%W'));
+insert into t1 values (date_format('2004-02-02','%a'));
+select hex(s1), s1 from t1;
+drop table t1;
+set LC_TIME_NAMES='en_US';
+
+
+#
# Bug #2366 Wrong utf8 behaviour when data is truncated
#
set names koi8r;