3357 Tor Didriksen 2011-04-01
Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
Reverting this patch:
# sp1r-gkodinov/kgeorge@stripped
# Addendum to fix of bug #22344 : removed dead code.
With the current set of optimizations, this is no longer dead code.
@ mysql-test/include/subquery_mat.inc
New test case.
@ mysql-test/r/subquery_mat.result
New test case.
@ mysql-test/r/subquery_mat_all.result
New test case.
@ mysql-test/r/subquery_mat_none.result
New test case.
@ sql/item.cc
Re-enable the code for handling Item_ref::result_field in Item_ref::save_in_field.
The actual type of the object was Item_direct_view_ref, which got its
result_field set by create_tmp_field()
modified:
mysql-test/include/subquery_mat.inc
mysql-test/r/subquery_mat.result
mysql-test/r/subquery_mat_all.result
mysql-test/r/subquery_mat_none.result
sql/item.cc
3356 Jorgen Loland 2011-03-29
Recorded result files after merge mysql-trunk -> opt-backporting.
modified:
mysql-test/r/innodb_icp_all.result
mysql-test/r/myisam_icp_all.result
mysql-test/r/subquery_all.result
mysql-test/r/subquery_all_jcl6.result
mysql-test/r/subquery_nomat_nosj_jcl6.result
=== modified file 'mysql-test/include/subquery_mat.inc'
--- a/mysql-test/include/subquery_mat.inc 2011-02-14 11:21:26 +0000
+++ b/mysql-test/include/subquery_mat.inc 2011-04-01 11:06:48 +0000
@@ -847,3 +847,38 @@ eval $query;
DROP TABLE t1, t2;
--echo # End Bug#59833
+
+--echo #
+--echo # Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+--echo #
+
+CREATE TABLE t1 (
+ col_varchar_key varchar(1) DEFAULT NULL,
+ col_varchar_nokey varchar(1) DEFAULT NULL,
+ KEY col_varchar_key (col_varchar_key))
+;
+
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+
+CREATE TABLE t2 (
+ col_varchar_key varchar(1) DEFAULT NULL,
+ col_varchar_nokey varchar(1) DEFAULT NULL,
+ KEY col_varchar_key(col_varchar_key))
+;
+
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+
+CREATE VIEW v3 AS SELECT * FROM t2;
+
+SELECT DISTINCT alias2.col_varchar_key
+FROM t1 AS alias1 JOIN v3 AS alias2
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+
+DROP TABLE t1, t2;
+DROP VIEW v3;
+
+--echo # End Bug#11852644
=== modified file 'mysql-test/r/subquery_mat.result'
--- a/mysql-test/r/subquery_mat.result 2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_mat.result 2011-04-01 11:06:48 +0000
@@ -1124,4 +1124,32 @@ WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORD
f1 pk pk
DROP TABLE t1, t2;
# End Bug#59833
+#
+# Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+#
+CREATE TABLE t1 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key (col_varchar_key))
+;
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+CREATE TABLE t2 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key))
+;
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+CREATE VIEW v3 AS SELECT * FROM t2;
+SELECT DISTINCT alias2.col_varchar_key
+FROM t1 AS alias1 JOIN v3 AS alias2
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+col_varchar_key
+r
+DROP TABLE t1, t2;
+DROP VIEW v3;
+# End Bug#11852644
set optimizer_switch=default;
=== modified file 'mysql-test/r/subquery_mat_all.result'
--- a/mysql-test/r/subquery_mat_all.result 2011-03-17 11:23:06 +0000
+++ b/mysql-test/r/subquery_mat_all.result 2011-04-01 11:06:48 +0000
@@ -1123,4 +1123,32 @@ WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORD
f1 pk pk
DROP TABLE t1, t2;
# End Bug#59833
+#
+# Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+#
+CREATE TABLE t1 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key (col_varchar_key))
+;
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+CREATE TABLE t2 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key))
+;
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+CREATE VIEW v3 AS SELECT * FROM t2;
+SELECT DISTINCT alias2.col_varchar_key
+FROM t1 AS alias1 JOIN v3 AS alias2
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+col_varchar_key
+r
+DROP TABLE t1, t2;
+DROP VIEW v3;
+# End Bug#11852644
set optimizer_switch=default;
=== modified file 'mysql-test/r/subquery_mat_none.result'
--- a/mysql-test/r/subquery_mat_none.result 2011-02-14 11:21:26 +0000
+++ b/mysql-test/r/subquery_mat_none.result 2011-04-01 11:06:48 +0000
@@ -1122,4 +1122,32 @@ WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORD
f1 pk pk
DROP TABLE t1, t2;
# End Bug#59833
+#
+# Bug#11852644 - CRASH IN ITEM_REF::SAVE_IN_FIELD ON SELECT DISTINCT
+#
+CREATE TABLE t1 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key (col_varchar_key))
+;
+INSERT INTO t1 VALUES
+('v','v'),('r','r');
+CREATE TABLE t2 (
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key))
+;
+INSERT INTO t2 VALUES
+('r','r'),('c','c');
+CREATE VIEW v3 AS SELECT * FROM t2;
+SELECT DISTINCT alias2.col_varchar_key
+FROM t1 AS alias1 JOIN v3 AS alias2
+ON alias2.col_varchar_key = alias1.col_varchar_key
+HAVING col_varchar_key IN (SELECT col_varchar_nokey FROM t2)
+;
+col_varchar_key
+r
+DROP TABLE t1, t2;
+DROP VIEW v3;
+# End Bug#11852644
set optimizer_switch=default;
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2011-03-22 11:44:40 +0000
+++ b/sql/item.cc 2011-04-01 11:06:48 +0000
@@ -6738,7 +6738,19 @@ my_decimal *Item_ref::val_decimal(my_dec
int Item_ref::save_in_field(Field *to, bool no_conversions)
{
int res;
- DBUG_ASSERT(!result_field);
+ if (result_field)
+ {
+ if (result_field->is_null())
+ {
+ null_value= 1;
+ res= set_field_to_null_with_conversions(to, no_conversions);
+ return res;
+ }
+ to->set_notnull();
+ res= field_conv(to, result_field);
+ null_value= 0;
+ return res;
+ }
res= (*ref)->save_in_field(to, no_conversions);
null_value= (*ref)->null_value;
return res;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (tor.didriksen:3356 to 3357) Bug#11852644 | Tor Didriksen | 1 Apr |