diff --git a/mysql-test/main/item_types.result b/mysql-test/main/item_types.result index 40db01f2609..6a73549a886 100644 --- a/mysql-test/main/item_types.result +++ b/mysql-test/main/item_types.result @@ -27,4 +27,13 @@ a DROP TABLE t1; DROP VIEW v1, v2; +# +# MDEV-34771: Types mismatch when cloning items causes debug assertion +# +CREATE VIEW t AS SELECT 1 AS a; +SELECT * FROM t WHERE a=b''; +a +drop view t; +# # End of 10.5 tests +# diff --git a/mysql-test/main/item_types.test b/mysql-test/main/item_types.test index 6f10d6bf71a..56af975df9d 100644 --- a/mysql-test/main/item_types.test +++ b/mysql-test/main/item_types.test @@ -30,4 +30,14 @@ SELECT * FROM v2 WHERE a='' AND CASE '' WHEN '' THEN '' ELSE a END=''; DROP TABLE t1; DROP VIEW v1, v2; +--echo # +--echo # MDEV-34771: Types mismatch when cloning items causes debug assertion +--echo # + +CREATE VIEW t AS SELECT 1 AS a; +SELECT * FROM t WHERE a=b''; +drop view t; + +--echo # --echo # End of 10.5 tests +--echo # diff --git a/sql/item.h b/sql/item.h index 9af0a077f75..f5ef54382cb 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4946,6 +4946,9 @@ class Item_bin_string: public Item_hex_hybrid public: Item_bin_string(THD *thd, const char *str, size_t str_length); void print(String *str, enum_query_type query_type) override; + Item *do_get_copy(THD *thd) const override + { return get_item_copy(thd, this); } + Item *do_build_clone(THD *thd) const override { return get_copy(thd); } };