summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ram@gw.mysql.r18.ru>2004-03-09 16:52:37 +0400
committerunknown <ram@gw.mysql.r18.ru>2004-03-09 16:52:37 +0400
commita977474a6a1d9e350e6844e72ef9a73d6a119401 (patch)
tree33630f8ce3f1598742dbebac5e98e029904a7be9
parentfea8903b0cb85bb43502aae43fe8bd2543fccd5c (diff)
downloadmariadb-git-a977474a6a1d9e350e6844e72ef9a73d6a119401.tar.gz
Fix for the bug #3089: SUBSTRING bug when mixed with CONCAT and ORDER BY
-rw-r--r--mysql-test/r/func_str.result10
-rw-r--r--mysql-test/t/func_str.test13
-rw-r--r--sql/item_strfunc.cc2
3 files changed, 24 insertions, 1 deletions
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index d213883df76..eb09a746a1c 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -624,3 +624,13 @@ Note 1003 select high_priority md5(_latin1'hello') AS `md5('hello')`,sha(_latin1
SELECT lpad(12345, 5, "#");
lpad(12345, 5, "#")
12345
+create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
+insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
+create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
+insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
+select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2
+where t2.id=t1.id order by name;
+name
+aaaaaaaaaaccccc
+bbbbbbbbbbddddd
+drop table t1, t2;
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 6e4fc21f4b0..c9ead51c0a6 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -360,3 +360,16 @@ explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'moo
#
SELECT lpad(12345, 5, "#");
+
+
+#
+# Bug #3089
+#
+
+create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
+insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
+create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
+insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
+select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2
+where t2.id=t1.id order by name;
+drop table t1, t2;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index b9604cf900b..518b9ca624b 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1033,7 +1033,7 @@ void Item_func_substr::fix_length_and_dec()
}
if (arg_count == 3 && args[2]->const_item())
{
- int32 length= (int32) args[2]->val_int() * default_charset_info->mbmaxlen;
+ int32 length= (int32) args[2]->val_int() * collation.collation->mbmaxlen;
if (length <= 0)
max_length=0; /* purecov: inspected */
else