summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2015-12-14 15:02:39 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2015-12-15 14:08:29 +0100
commita75ac82c2f24a6a7ffb2effe90455d367913b78d (patch)
treee87fa099c52859c3a88d13dae6283d33fc5c6d4e
parent98c9fbfa215242f2930990a0a80b9c5642d23e58 (diff)
downloadmariadb-git-a75ac82c2f24a6a7ffb2effe90455d367913b78d.tar.gz
MDEV-9147: Character set is ignored in Dynamic Column for saved string
Fixed moving charset from definition to the value.
-rw-r--r--mysql-test/r/dyncol.result20
-rw-r--r--mysql-test/t/dyncol.test7
-rw-r--r--sql/item_strfunc.cc2
3 files changed, 24 insertions, 5 deletions
diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result
index af7c3b7337c..c7eb303983a 100644
--- a/mysql-test/r/dyncol.result
+++ b/mysql-test/r/dyncol.result
@@ -6,16 +6,16 @@ hex(COLUMN_CREATE(1, NULL AS char character set utf8))
000000
select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8));
hex(COLUMN_CREATE(1, "afaf" AS char character set utf8))
-0001000100030861666166
+0001000100032161666166
select hex(COLUMN_CREATE(1, 1212 AS char character set utf8));
hex(COLUMN_CREATE(1, 1212 AS char character set utf8))
-0001000100030831323132
+0001000100032131323132
select hex(COLUMN_CREATE(1, 12.12 AS char character set utf8));
hex(COLUMN_CREATE(1, 12.12 AS char character set utf8))
-0001000100030831322E3132
+0001000100032131322E3132
select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS char character set utf8));
hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS char character set utf8))
-000100010003083939393939393939393939393939393939393939393939393939393939
+000100010003213939393939393939393939393939393939393939393939393939393939
select hex(COLUMN_CREATE(1, NULL AS unsigned int));
hex(COLUMN_CREATE(1, NULL AS unsigned int))
000000
@@ -144,7 +144,7 @@ hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
6, "2011-04-05" AS date,
7, "- 0:45:49.000001" AS time,
8, "2011-04-05 0:45:49.000001" AS datetime))
-01080001000300020029000300380004004A0005008C000600AE000700C7000800F5000861666166BC0478093D0AD7A3703D284002028C0C85B60F010010B7000485B60F010010B70000
+01080001000300020029000300380004004A0005008C000600AE000700C7000800F5002161666166BC0478093D0AD7A3703D284002028C0C85B60F010010B7000485B60F010010B70000
explain extended
select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
2, 1212 AS unsigned int,
@@ -1848,5 +1848,15 @@ select column_json(column_create('float', 1.23456789012345E+10 as double));
column_json(column_create('float', 1.23456789012345E+10 as double))
{"float":12345678901.2345}
#
+# MDEV-9147: Character set is ignored in Dynamic Column for saved string
+#
+SET NAMES utf8;
+SELECT COLUMN_GET(COLUMN_CREATE(1, 0xC2A2 AS CHAR CHARACTER SET latin1), 1 AS CHAR CHARACTER SET utf8) AS a;
+a
+¢
+SELECT COLUMN_GET(COLUMN_CREATE(1, 0xC2A2 AS CHAR CHARACTER SET utf8), 1 AS CHAR CHARACTER SET utf8) AS a;
+a
+#
# end of 10.0 tests
#
diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test
index 0f4058d4eef..f0b8e0444f1 100644
--- a/mysql-test/t/dyncol.test
+++ b/mysql-test/t/dyncol.test
@@ -902,5 +902,12 @@ select column_json(column_create('float', 1.23456789012345E+100 as double));
select column_json(column_create('float', 1.23456789012345E+10 as double));
--echo #
+--echo # MDEV-9147: Character set is ignored in Dynamic Column for saved string
+--echo #
+SET NAMES utf8;
+SELECT COLUMN_GET(COLUMN_CREATE(1, 0xC2A2 AS CHAR CHARACTER SET latin1), 1 AS CHAR CHARACTER SET utf8) AS a;
+SELECT COLUMN_GET(COLUMN_CREATE(1, 0xC2A2 AS CHAR CHARACTER SET utf8), 1 AS CHAR CHARACTER SET utf8) AS a;
+
+--echo #
--echo # end of 10.0 tests
--echo #
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 972ae5afb16..54ab8f6aca1 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -4448,6 +4448,8 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg)
case DYN_COL_DYNCOL:
case DYN_COL_STRING:
res= args[valpos]->val_str(&tmp);
+ if (res && defs[i].cs)
+ res->set_charset(defs[i].cs);
if (res &&
(vals[i].x.string.value.str= sql_strmake(res->ptr(), res->length())))
{