summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-11-04 16:54:58 +0100
committerSergei Golubchik <serg@mariadb.org>2016-12-12 20:27:22 +0100
commit0980627fcae1586573670f3f2d4ed45fcc751161 (patch)
tree7d202e65aa3135b4456edba877f65b4c7b6bccd9
parent232dc91bc957bfc3e08d08cec940d5fc8021799e (diff)
downloadmariadb-git-0980627fcae1586573670f3f2d4ed45fcc751161.tar.gz
bugfix: Item_func_weight_string::print()
-rw-r--r--mysql-test/r/ctype_binary.result2
-rw-r--r--mysql-test/r/func_weight_string.result13
-rw-r--r--mysql-test/t/func_weight_string.test7
-rw-r--r--sql/item_strfunc.cc15
-rw-r--r--sql/item_strfunc.h1
5 files changed, 33 insertions, 5 deletions
diff --git a/mysql-test/r/ctype_binary.result b/mysql-test/r/ctype_binary.result
index e7c40b5ed91..eb1746b933b 100644
--- a/mysql-test/r/ctype_binary.result
+++ b/mysql-test/r/ctype_binary.result
@@ -3145,7 +3145,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a' AND a='a';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (weight_string(`test`.`t1`.`a`) = 'a'))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (weight_string(`test`.`t1`.`a`,0,0,1) = 'a'))
DROP TABLE t1;
#
# End of 10.1 tests
diff --git a/mysql-test/r/func_weight_string.result b/mysql-test/r/func_weight_string.result
index 0f52e793843..14737a2e62e 100644
--- a/mysql-test/r/func_weight_string.result
+++ b/mysql-test/r/func_weight_string.result
@@ -119,7 +119,7 @@ SELECT * FROM t1 WHERE a=1 AND WEIGHT_STRING(a) IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and isnull(weight_string(`test`.`t1`.`a`)))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and isnull(weight_string(`test`.`t1`.`a`,0,0,1)))
ALTER TABLE t1 MODIFY a DOUBLE ZEROFILL;
SELECT * FROM t1 WHERE a=1 AND WEIGHT_STRING(a) IS NULL;
a
@@ -129,7 +129,7 @@ SELECT * FROM t1 WHERE a=1 AND WEIGHT_STRING(a) IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and isnull(weight_string(`test`.`t1`.`a`)))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and isnull(weight_string(`test`.`t1`.`a`,0,0,1)))
ALTER TABLE t1 MODIFY a DECIMAL(10,1) ZEROFILL;
SELECT * FROM t1 WHERE a=1 AND WEIGHT_STRING(a) IS NULL;
a
@@ -139,7 +139,7 @@ SELECT * FROM t1 WHERE a=1 AND WEIGHT_STRING(a) IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and isnull(weight_string(`test`.`t1`.`a`)))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and isnull(weight_string(`test`.`t1`.`a`,0,0,1)))
DROP TABLE t1;
#
# End of 10.1 tests
@@ -155,13 +155,18 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(10) DEFAULT NULL,
- `b` varbinary(10) DEFAULT WEIGHT_STRING(a AS CHAR(10))
+ `b` varbinary(10) DEFAULT weight_string(`a`,0,10,65)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 (a) VALUES ('a');
SELECT a, HEX(b) FROM t1;
a HEX(b)
a 41202020202020202020
DROP TABLE t1;
+create view v1 as select weight_string("MySQL" as char(4));
+select * from v1;
+weight_string("MySQL" as char(4))
+MYSQ
+drop view v1;
#
# End of 10.2 tests
#
diff --git a/mysql-test/t/func_weight_string.test b/mysql-test/t/func_weight_string.test
index ddaf14dc75d..b376b996556 100644
--- a/mysql-test/t/func_weight_string.test
+++ b/mysql-test/t/func_weight_string.test
@@ -161,6 +161,13 @@ INSERT INTO t1 (a) VALUES ('a');
SELECT a, HEX(b) FROM t1;
DROP TABLE t1;
+#
+# Item_func_weight_string::print()
+#
+create view v1 as select weight_string("MySQL" as char(4));
+select * from v1;
+drop view v1;
+
--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 162da17eb76..500a8e94e4b 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -3621,6 +3621,21 @@ nl:
}
+void Item_func_weight_string::print(String *str, enum_query_type query_type)
+{
+ str->append(func_name());
+ str->append('(');
+ args[0]->print(str, query_type);
+ str->append(',');
+ str->append_ulonglong(result_length);
+ str->append(',');
+ str->append_ulonglong(nweights);
+ str->append(',');
+ str->append_ulonglong(flags);
+ str->append(')');
+}
+
+
String *Item_func_hex::val_str_ascii(String *str)
{
String *res;
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 25b63ebe73d..ac7d820f2cf 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -1254,6 +1254,7 @@ public:
}
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
{ return this; }
+ void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_weight_string>(thd, mem_root, this); }
};