summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2011-02-14 00:11:46 +0200
committerunknown <timour@askmonty.org>2011-02-14 00:11:46 +0200
commit2aeb4170a0b77d9a2f3f10ec9974d34ec72a0426 (patch)
treee25d1354c04701c4b8d855723990921692ba21a1 /mysql-test
parentcd34946657b18582ab3dc9c6ad45e66d1e9bf2e2 (diff)
downloadmariadb-git-2aeb4170a0b77d9a2f3f10ec9974d34ec72a0426.tar.gz
Fix LP BUG#715027
Analysis: Before calling: write_record= (select->skip_record(thd) > 0); the function find_all_keys needs to restore the original read/write sets of the table that is sorted if the condition select->cond contains a subquery. This didn't happen in this test case because the flag "with_subselect" was not set properly for select->cond. The reason for the flag not being set properly, was that this condition was rewritten by add_cond_and_fix() inside make_join_select() by: /* Add conditions added by add_not_null_conds(). */ if (tab->select_cond) add_cond_and_fix(thd, &tmp, tab->select_cond); However, the function add_cond_and_fix() called the shortcut method Item::quick_fix_field() that didn't update the "with_subselect" property. Solution: Call the complete Item::fix_fields() to update all Item properties, including "with_subselect".
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/subselect_mat_cost.result33
-rw-r--r--mysql-test/t/subselect_mat_cost.test33
2 files changed, 66 insertions, 0 deletions
diff --git a/mysql-test/r/subselect_mat_cost.result b/mysql-test/r/subselect_mat_cost.result
index ba9993f97e5..914a308602d 100644
--- a/mysql-test/r/subselect_mat_cost.result
+++ b/mysql-test/r/subselect_mat_cost.result
@@ -3936,3 +3936,36 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
3 SUBQUERY t1 index NULL f3 5 NULL 2 Using index
2 DERIVED t2 ALL NULL NULL NULL NULL 2
+drop table t1,t2;
+#
+# LP BUG#715027 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
+#
+CREATE TABLE t1 ( f1 int(11), PRIMARY KEY (f1)) ;
+INSERT INTO t1 VALUES (28),(29);
+CREATE TABLE t2 ( f2 int(11), f3 int(11), f10 varchar(1)) ;
+INSERT INTO t2 VALUES (NULL,6,'f'),(4,2,'d');
+EXPLAIN
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+SELECT t2.f2
+FROM t2 JOIN t1 ON t1.f1
+WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where; Using filesort
+1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index
+3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
+3 DEPENDENT SUBQUERY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
+2 DERIVED t2 ALL NULL NULL NULL NULL 2
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+SELECT t2.f2
+FROM t2 JOIN t1 ON t1.f1
+WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+field1
+drop table t1,t2;
diff --git a/mysql-test/t/subselect_mat_cost.test b/mysql-test/t/subselect_mat_cost.test
index 5a707398fe8..38f8c900b99 100644
--- a/mysql-test/t/subselect_mat_cost.test
+++ b/mysql-test/t/subselect_mat_cost.test
@@ -385,3 +385,36 @@ insert into t2 values (1),(2);
EXPLAIN
SELECT * FROM (SELECT * FROM t2) AS a2
WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
+
+drop table t1,t2;
+
+--echo #
+--echo # LP BUG#715027 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
+--echo #
+
+CREATE TABLE t1 ( f1 int(11), PRIMARY KEY (f1)) ;
+INSERT INTO t1 VALUES (28),(29);
+
+CREATE TABLE t2 ( f2 int(11), f3 int(11), f10 varchar(1)) ;
+INSERT INTO t2 VALUES (NULL,6,'f'),(4,2,'d');
+
+EXPLAIN
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+ SELECT t2.f2
+ FROM t2 JOIN t1 ON t1.f1
+ WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+ SELECT t2.f2
+ FROM t2 JOIN t1 ON t1.f1
+ WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+
+drop table t1,t2;