diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2011-10-01 00:56:42 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2011-10-01 00:56:42 +0400 |
commit | a14071970794b6a00208b30a1c20cece38de3b2e (patch) | |
tree | dc44df653922b5f84a24defc098ced763d08e6dd | |
parent | 15d40bb290b60dc015653c69424c71d6ae8fd37f (diff) | |
parent | b45beca3680bf545728382af90111fa76cd5abdd (diff) | |
download | mariadb-git-a14071970794b6a00208b30a1c20cece38de3b2e.tar.gz |
Merge
-rw-r--r-- | mysql-test/r/subselect_sj.result | 42 | ||||
-rw-r--r-- | mysql-test/r/subselect_sj_jcl6.result | 42 | ||||
-rw-r--r-- | mysql-test/t/subselect_sj.test | 51 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 3 |
4 files changed, 137 insertions, 1 deletions
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index 2bbfcd48838..e3a1575fd97 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -1920,4 +1920,46 @@ WHERE t2.b NOT IN (SELECT t4.b FROM t4 WHERE t4.b < t1.b) a 8 DROP TABLE t1, t2, t4, t5; +# +# BUG#861147: Assertion `fixed == 1' failed in Item_func_eq::val_int() with semijoin + materialization + max_join_size +# +CREATE TABLE t1 ( f2 int) ; +CREATE TABLE t2 ( f1 int, f3 int, f4 varchar(3), f5 varchar(35)) ; +INSERT INTO t2 VALUES (4057,9,'USA','Visalia'),(3993,11,'USA','Waco'), +(3948,14,'USA','Warren'),(3813,57,'USA','Washington'), +(4010,11,'USA','Waterbury'),(4017,11,'USA','West Covina'), +(4004,11,'USA','West Valley City'),(4033,10,'USA','Westminster'), +(3842,34,'USA','Wichita'),(4018,10,'USA','Wichita Falls'), +(3899,19,'USA','Winston-Salem'),(3914,17,'USA','Worcester'), +(3888,20,'USA','Yonkers'); +CREATE TABLE t3 ( f3 int, f4 varchar(3)) ; +INSERT INTO t3 VALUES (86,'USA'); +CREATE TABLE t4 ( f3 int, f4 varchar(3), f5 varchar(52)) ; +INSERT INTO t4 VALUES (0,'RUS','Belorussian'),(0,'USA','Portuguese'); +CREATE TABLE t5 ( f2 int) ; +CREATE TABLE t6 ( f4 varchar(3)); +INSERT INTO t6 VALUES ('RUS'),('USA'); +set @tmp_mjs_861147= @@max_join_size; +SET max_join_size=10; +set @tmp_os_861147= @@optimizer_switch; +set @@optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 +WHERE ( 1 , 3 ) IN ( +SELECT t2.f1 , MAX( t3.f3 ) +FROM t2 +JOIN t3 +WHERE t3.f4 IN ( +SELECT t4.f5 +FROM t4 +STRAIGHT_JOIN t5 +WHERE t4.f4 < t2.f5 +) +) AND ( 'p' , 'k' ) IN ( +SELECT f4 , f4 FROM t6 +); +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +set max_join_size= @tmp_mjs_861147; +set optimizer_switch= @tmp_os_861147; +DROP TABLE t1,t2,t3,t4,t5,t6; set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index 534a5aa358a..7acf47aeaed 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -1931,6 +1931,48 @@ WHERE t2.b NOT IN (SELECT t4.b FROM t4 WHERE t4.b < t1.b) a 8 DROP TABLE t1, t2, t4, t5; +# +# BUG#861147: Assertion `fixed == 1' failed in Item_func_eq::val_int() with semijoin + materialization + max_join_size +# +CREATE TABLE t1 ( f2 int) ; +CREATE TABLE t2 ( f1 int, f3 int, f4 varchar(3), f5 varchar(35)) ; +INSERT INTO t2 VALUES (4057,9,'USA','Visalia'),(3993,11,'USA','Waco'), +(3948,14,'USA','Warren'),(3813,57,'USA','Washington'), +(4010,11,'USA','Waterbury'),(4017,11,'USA','West Covina'), +(4004,11,'USA','West Valley City'),(4033,10,'USA','Westminster'), +(3842,34,'USA','Wichita'),(4018,10,'USA','Wichita Falls'), +(3899,19,'USA','Winston-Salem'),(3914,17,'USA','Worcester'), +(3888,20,'USA','Yonkers'); +CREATE TABLE t3 ( f3 int, f4 varchar(3)) ; +INSERT INTO t3 VALUES (86,'USA'); +CREATE TABLE t4 ( f3 int, f4 varchar(3), f5 varchar(52)) ; +INSERT INTO t4 VALUES (0,'RUS','Belorussian'),(0,'USA','Portuguese'); +CREATE TABLE t5 ( f2 int) ; +CREATE TABLE t6 ( f4 varchar(3)); +INSERT INTO t6 VALUES ('RUS'),('USA'); +set @tmp_mjs_861147= @@max_join_size; +SET max_join_size=10; +set @tmp_os_861147= @@optimizer_switch; +set @@optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 +WHERE ( 1 , 3 ) IN ( +SELECT t2.f1 , MAX( t3.f3 ) +FROM t2 +JOIN t3 +WHERE t3.f4 IN ( +SELECT t4.f5 +FROM t4 +STRAIGHT_JOIN t5 +WHERE t4.f4 < t2.f5 +) +) AND ( 'p' , 'k' ) IN ( +SELECT f4 , f4 FROM t6 +); +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +set max_join_size= @tmp_mjs_861147; +set optimizer_switch= @tmp_os_861147; +DROP TABLE t1,t2,t3,t4,t5,t6; set optimizer_switch=@subselect_sj_tmp; # # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index e4e8b03f4b2..415305c7d5e 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -1756,5 +1756,56 @@ select * from t5 where (a) in ( DROP TABLE t1, t2, t4, t5; +--echo # +--echo # BUG#861147: Assertion `fixed == 1' failed in Item_func_eq::val_int() with semijoin + materialization + max_join_size +--echo # +CREATE TABLE t1 ( f2 int) ; +CREATE TABLE t2 ( f1 int, f3 int, f4 varchar(3), f5 varchar(35)) ; +INSERT INTO t2 VALUES (4057,9,'USA','Visalia'),(3993,11,'USA','Waco'), + (3948,14,'USA','Warren'),(3813,57,'USA','Washington'), + (4010,11,'USA','Waterbury'),(4017,11,'USA','West Covina'), + (4004,11,'USA','West Valley City'),(4033,10,'USA','Westminster'), + (3842,34,'USA','Wichita'),(4018,10,'USA','Wichita Falls'), + (3899,19,'USA','Winston-Salem'),(3914,17,'USA','Worcester'), + (3888,20,'USA','Yonkers'); + +CREATE TABLE t3 ( f3 int, f4 varchar(3)) ; +INSERT INTO t3 VALUES (86,'USA'); + +CREATE TABLE t4 ( f3 int, f4 varchar(3), f5 varchar(52)) ; +INSERT INTO t4 VALUES (0,'RUS','Belorussian'),(0,'USA','Portuguese'); + +CREATE TABLE t5 ( f2 int) ; + +CREATE TABLE t6 ( f4 varchar(3)); +INSERT INTO t6 VALUES ('RUS'),('USA'); + +set @tmp_mjs_861147= @@max_join_size; +SET max_join_size=10; +set @tmp_os_861147= @@optimizer_switch; +set @@optimizer_switch='semijoin=on,materialization=on'; + +--error ER_TOO_BIG_SELECT +SELECT * +FROM t1 +WHERE ( 1 , 3 ) IN ( + SELECT t2.f1 , MAX( t3.f3 ) + FROM t2 + JOIN t3 + WHERE t3.f4 IN ( + SELECT t4.f5 + FROM t4 + STRAIGHT_JOIN t5 + WHERE t4.f4 < t2.f5 + ) +) AND ( 'p' , 'k' ) IN ( + SELECT f4 , f4 FROM t6 +); +set max_join_size= @tmp_mjs_861147; +set optimizer_switch= @tmp_os_861147; + +DROP TABLE t1,t2,t3,t4,t5,t6; + + # The following command must be the last one the file set optimizer_switch=@subselect_sj_tmp; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 1c317cea808..7c11f9c4aea 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -1425,7 +1425,8 @@ static bool convert_subq_to_jtbm(JOIN *parent_join, DBUG_ENTER("convert_subq_to_jtbm"); subq_pred->in_strategy &= ~SUBS_IN_TO_EXISTS; - subq_pred->optimize(&rows, &read_time); + if (subq_pred->optimize(&rows, &read_time)) + DBUG_RETURN(TRUE); subq_pred->jtbm_read_time= read_time; subq_pred->jtbm_record_count=rows; |