Merge.
This commit is contained in:
commit
e0500dbc3a
@ -2372,8 +2372,11 @@ sub remove_stale_vardir () {
|
||||
mtr_report("WARNING: Using the 'mysql-test/var' symlink");
|
||||
|
||||
# Make sure the directory where it points exist
|
||||
mtr_error("The destination for symlink $opt_vardir does not exist")
|
||||
if ! -d readlink($opt_vardir);
|
||||
if (! -d readlink($opt_vardir))
|
||||
{
|
||||
mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory");
|
||||
unlink($opt_vardir);
|
||||
}
|
||||
|
||||
foreach my $bin ( glob("$opt_vardir/*") )
|
||||
{
|
||||
@ -2432,8 +2435,11 @@ sub setup_vardir() {
|
||||
# it's a symlink
|
||||
|
||||
# Make sure the directory where it points exist
|
||||
mtr_error("The destination for symlink $opt_vardir does not exist")
|
||||
if ! -d readlink($opt_vardir);
|
||||
if (! -d readlink($opt_vardir))
|
||||
{
|
||||
mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory");
|
||||
unlink($opt_vardir);
|
||||
}
|
||||
}
|
||||
elsif ( $opt_mem )
|
||||
{
|
||||
|
@ -105,9 +105,9 @@ cast("2011-02-03 10:11:12.123456" as datetime(6))
|
||||
select cast("2011-02-03 10:11:12" as datetime(6));
|
||||
cast("2011-02-03 10:11:12" as datetime(6))
|
||||
2011-02-03 10:11:12.000000
|
||||
select cast(cast(20010203101112.1 as double) as datetime(1));
|
||||
cast(cast(20010203101112.1 as double) as datetime(1))
|
||||
2001-02-03 10:11:12.1
|
||||
select cast(cast(20010203101112.5 as double) as datetime(1));
|
||||
cast(cast(20010203101112.5 as double) as datetime(1))
|
||||
2001-02-03 10:11:12.5
|
||||
select cast(cast(010203101112.12 as double) as datetime(2));
|
||||
cast(cast(010203101112.12 as double) as datetime(2))
|
||||
0001-02-03 10:11:12.12
|
||||
|
@ -989,10 +989,10 @@ SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
3 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` left join `test`.`t2` on((0 <> 0)) where <expr_cache><0>(<in_optimizer>(0,<exists>(select 0 from `test`.`t1` where (<cache>(0) = 0))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` semi join (`test`.`t1`) left join `test`.`t2` on((0 <> 0)) where 1
|
||||
SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
a a b
|
||||
@ -1002,10 +1002,10 @@ SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` left join `test`.`t2` on((0 <> 0)) where <expr_cache><0>(<in_optimizer>(0,<exists>(select 0 from `test`.`t1` where (<cache>(0) = 0))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` semi join (`test`.`t1`) left join `test`.`t2` on((0 <> 0)) where 1
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
@ -1147,7 +1147,7 @@ EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
|
||||
SELECT * FROM v2;
|
||||
a b
|
||||
@ -1167,7 +1167,7 @@ EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 6
|
||||
4 UNION t3 ALL NULL NULL NULL NULL 4
|
||||
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
|
||||
@ -1478,9 +1478,9 @@ SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
@ -1493,9 +1493,9 @@ SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY <derived3> ref key1 key1 10 const,const 0 Using where
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <derived3> ref key1 key1 10 const,const 0 Start temporary
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
@ -1517,7 +1517,7 @@ EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 test.t1.a 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
a b
|
||||
|
@ -199,16 +199,16 @@ insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1');
|
||||
flush tables;
|
||||
EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY INNR ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
flush tables;
|
||||
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL );
|
||||
dt
|
||||
flush tables;
|
||||
EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY INNR ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
flush tables;
|
||||
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
|
||||
dt
|
||||
|
@ -1542,8 +1542,8 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a IN
|
||||
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL PRIMARY 4 NULL 144 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where
|
||||
1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1)
|
||||
CREATE TABLE t2 (a INT, b INT, KEY(a));
|
||||
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
|
||||
EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2;
|
||||
@ -1555,8 +1555,8 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
EXPLAIN SELECT 1 FROM t2 WHERE a IN
|
||||
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where
|
||||
1 PRIMARY t2 index a a 5 NULL 4 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2)
|
||||
SHOW VARIABLES LIKE 'old';
|
||||
Variable_name Value
|
||||
old OFF
|
||||
|
@ -1432,7 +1432,7 @@ group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
3 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.b) and
|
||||
@ -1489,7 +1489,7 @@ group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
3 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.c) and
|
||||
|
@ -4,19 +4,19 @@
|
||||
#
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='index_merge=off,index_merge_union=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='index_merge_union=on';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,index_merge_sort_union=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch=4;
|
||||
ERROR 42000: Variable 'optimizer_switch' can't be set to the value of '4'
|
||||
set optimizer_switch=NULL;
|
||||
@ -43,60 +43,60 @@ set optimizer_switch=default;
|
||||
set optimizer_switch='index_merge=off,index_merge_union=off,default';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch=default;
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set @@global.optimizer_switch=default;
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
#
|
||||
# Check index_merge's @@optimizer_switch flags
|
||||
#
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
|
||||
BUG#37120 optimizer_switch allowable values not according to specification
|
||||
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,materialization=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,semijoin=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,semijoin=off,materialization=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,materialization=off,semijoin=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,semijoin=off,materialization=off,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,semijoin=off,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch='default,materialization=off,loosescan=off';
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
set optimizer_switch=default;
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off
|
||||
|
@ -2113,7 +2113,7 @@ CREATE TABLE t3 (a int, b int) ;
|
||||
INSERT INTO t3 VALUES (5,0),(7,0);
|
||||
CREATE TABLE t4 (a int);
|
||||
INSERT INTO t4 VALUES (2),(8);
|
||||
set @@optimizer_switch='in_to_exists=on,materialization=off,subquery_cache=off';
|
||||
set @@optimizer_switch='semijoin=off,in_to_exists=on,materialization=off,subquery_cache=off';
|
||||
SELECT * FROM t2
|
||||
WHERE t2.b IN (SELECT b FROM t3 WHERE t3.a = t2.a AND a < SOME (SELECT * FROM t4))
|
||||
OR ( t2.c > 242 );
|
||||
|
@ -1,3 +1,5 @@
|
||||
drop table if exists t1,t2,t3,t4,t5;
|
||||
drop view if exists v1;
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,2),(3,4),(1,2),(3,4),(3,4),(4,5),(4,5),(5,6),(5,6),(4,5);
|
||||
@ -3354,5 +3356,31 @@ f1 f2 f3 f3
|
||||
7 0 0 0
|
||||
7 0 0 0
|
||||
drop tables t1, t2, t3;
|
||||
#
|
||||
# Test of LP BUG#872775 view with "outer references" bug
|
||||
#
|
||||
set @@optimizer_switch= default;
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
CREATE TABLE t1 (a int) ;
|
||||
CREATE TABLE t2 (b int, c varchar(1) NOT NULL ) ;
|
||||
INSERT INTO t2 VALUES (1,'x'),(2,'y');
|
||||
CREATE TABLE t3 (a int) ;
|
||||
CREATE TABLE t4 ( pk int(11) NOT NULL , b int(11) NOT NULL ) ;
|
||||
INSERT INTO t4 VALUES (26,9),(27,5),(28,0),(29,3);
|
||||
CREATE OR REPLACE VIEW v1 AS
|
||||
SELECT t2.b
|
||||
FROM t1
|
||||
JOIN t2
|
||||
WHERE t2 .c > (
|
||||
SELECT t2.c FROM t3
|
||||
);
|
||||
SELECT * FROM t4 WHERE b NOT IN ( SELECT * FROM v1 );
|
||||
pk b
|
||||
26 9
|
||||
27 5
|
||||
28 0
|
||||
29 3
|
||||
drop view v1;
|
||||
drop table t1,t2,t3,t4;
|
||||
# restore default
|
||||
set @@optimizer_switch= default;
|
||||
|
@ -1,6 +1,5 @@
|
||||
drop table if exists t1,t2,t3,t4;
|
||||
set @subselect_extra_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on';
|
||||
drop view if exists v1,v2,v3;
|
||||
# From explain.test:
|
||||
#
|
||||
# Bug#37870: Usage of uninitialized value caused failed assertion.
|
||||
@ -320,4 +319,157 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 4 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2)
|
||||
DROP TABLE t1, t2;
|
||||
set optimizer_switch= @subselect_extra_tmp;
|
||||
#
|
||||
# From derived_view.test
|
||||
#
|
||||
set @tmp_subselect_extra_derived=@@optimizer_switch;
|
||||
set optimizer_switch='derived_merge=on,derived_with_keys=on';
|
||||
#
|
||||
# LP bug #806504: right join over a view/derived table
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int) ;
|
||||
INSERT INTO t1 VALUES (0,0);
|
||||
CREATE TABLE t2 (a int) ;
|
||||
INSERT INTO t2 VALUES (0), (0);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
a a b
|
||||
NULL 0 0
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` semi join (`test`.`t1`) left join `test`.`t2` on((0 <> 0)) where 1
|
||||
SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
a a b
|
||||
NULL 0 0
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` semi join (`test`.`t1`) left join `test`.`t2` on((0 <> 0)) where 1
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LP bug #793448: materialized view accessed by two-component key
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (9,3), (2,5);
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES (9,3), (3,7), (9,1), (2,5), (2,4), (3,8);
|
||||
CREATE TABLE t3 (a int, b int);
|
||||
INSERT INTO t3 VALUES (10,3), (9,7), (9,1), (2,4);
|
||||
CREATE VIEW v1(a,b) AS SELECT a, MAX(b) FROM t2 GROUP BY a;
|
||||
CREATE VIEW v2(a,b) AS SELECT a,b FROM t2 UNION SELECT a,b FROM t3;
|
||||
SELECT * FROM v1;
|
||||
a b
|
||||
2 5
|
||||
3 8
|
||||
9 3
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
|
||||
a
|
||||
9
|
||||
2
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
|
||||
SELECT * FROM v2;
|
||||
a b
|
||||
9 3
|
||||
3 7
|
||||
9 1
|
||||
2 5
|
||||
2 4
|
||||
3 8
|
||||
10 3
|
||||
9 7
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
|
||||
a
|
||||
9
|
||||
2
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 6
|
||||
4 UNION t3 ALL NULL NULL NULL NULL 4
|
||||
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# LP bug #874006: materialized view used in IN subquery
|
||||
#
|
||||
CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1));
|
||||
INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r');
|
||||
CREATE TABLE t1 (a int, b varchar(1) , c varchar(1));
|
||||
INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y');
|
||||
CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1));
|
||||
INSERT INTO t2 VALUES (4,3,'r');
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
|
||||
SET SESSION optimizer_switch='derived_with_keys=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
a b c
|
||||
20 r r
|
||||
SET SESSION optimizer_switch='derived_with_keys=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <derived3> ref key1 key1 10 const,const 0 Start temporary
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
a b c
|
||||
20 r r
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# LP bug #873263: materialized view used in correlated IN subquery
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int) ;
|
||||
INSERT INTO t1 VALUES (5,4), (9,8);
|
||||
CREATE TABLE t2 (a int, b int) ;
|
||||
INSERT INTO t2 VALUES (4,5), (5,1);
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
|
||||
SET SESSION optimizer_switch='derived_with_keys=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
a b
|
||||
5 4
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1,t2;
|
||||
set optimizer_switch= @tmp_subselect_extra_derived;
|
||||
|
478
mysql-test/r/subselect_extra_no_semijoin.result
Normal file
478
mysql-test/r/subselect_extra_no_semijoin.result
Normal file
@ -0,0 +1,478 @@
|
||||
set @subselect_extra_no_sj_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on';
|
||||
drop table if exists t1,t2,t3,t4;
|
||||
drop view if exists v1,v2,v3;
|
||||
# From explain.test:
|
||||
#
|
||||
# Bug#37870: Usage of uninitialized value caused failed assertion.
|
||||
#
|
||||
create table t1 (dt datetime not null, t time not null);
|
||||
create table t2 (dt datetime not null);
|
||||
insert into t1 values ('2001-01-01 1:1:1', '1:1:1'),
|
||||
('2001-01-01 1:1:1', '1:1:1');
|
||||
insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1');
|
||||
flush tables;
|
||||
EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
flush tables;
|
||||
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL );
|
||||
dt
|
||||
flush tables;
|
||||
EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
flush tables;
|
||||
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
|
||||
dt
|
||||
2001-01-01 01:01:01
|
||||
2001-01-01 01:01:01
|
||||
drop tables t1, t2;
|
||||
# From type_datetime.test:
|
||||
#
|
||||
# Bug #32694: NOT NULL table field in a subquery produces invalid results
|
||||
#
|
||||
create table t1 (id int(10) not null, cur_date datetime not null);
|
||||
create table t2 (id int(10) not null, cur_date date not null);
|
||||
insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22');
|
||||
insert into t2 (id, cur_date) values (1, '2007-04-25');
|
||||
explain extended
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where (('2007-04-25 18:30:22' = 0))
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id cur_date
|
||||
explain extended
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where (('2007-04-25' = 0))
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id cur_date
|
||||
insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22');
|
||||
insert into t2 (id, cur_date) values (2, '2007-04-26');
|
||||
explain extended
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
|
||||
1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where ((`test`.`x1`.`id` = `test`.`t1`.`id`) and (`test`.`t1`.`cur_date` = 0))
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id cur_date
|
||||
explain extended
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
|
||||
1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where ((`test`.`x1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`cur_date` = 0))
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id cur_date
|
||||
drop table t1,t2;
|
||||
#
|
||||
# From group_min_max.test
|
||||
#
|
||||
create table t1 (
|
||||
a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
|
||||
);
|
||||
insert into t1 (a1, a2, b, c, d) values
|
||||
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
||||
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
||||
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
||||
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
||||
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
||||
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
||||
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
||||
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
||||
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
||||
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
||||
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
||||
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
|
||||
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
|
||||
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
|
||||
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
|
||||
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
|
||||
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
||||
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
||||
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
||||
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
||||
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
||||
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
||||
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
||||
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
||||
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
||||
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
||||
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
||||
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
|
||||
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
|
||||
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
|
||||
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
|
||||
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
|
||||
create index idx_t1_0 on t1 (a1);
|
||||
create index idx_t1_1 on t1 (a1,a2,b,c);
|
||||
create index idx_t1_2 on t1 (a1,a2,b);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Table is already up to date
|
||||
create table t2 (
|
||||
a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(64) default ' '
|
||||
);
|
||||
insert into t2 select * from t1;
|
||||
insert into t2 (a1, a2, b, c, d) values
|
||||
('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
|
||||
('a','a','a',NULL,'xyz'),
|
||||
('a','a','b',NULL,'xyz'),
|
||||
('a','b','a',NULL,'xyz'),
|
||||
('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
|
||||
('d','b','b',NULL,'xyz'),
|
||||
('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
|
||||
('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),
|
||||
('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
|
||||
('a','a','a',NULL,'xyz'),
|
||||
('a','a','b',NULL,'xyz'),
|
||||
('a','b','a',NULL,'xyz'),
|
||||
('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
|
||||
('d','b','b',NULL,'xyz'),
|
||||
('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
|
||||
('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz');
|
||||
create index idx_t2_0 on t2 (a1);
|
||||
create index idx_t2_1 on t2 (a1,a2,b,c);
|
||||
create index idx_t2_2 on t2 (a1,a2,b);
|
||||
analyze table t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status Table is already up to date
|
||||
create table t3 (
|
||||
a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' '
|
||||
);
|
||||
insert into t3 (a1, a2, b, c, d) values
|
||||
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
||||
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
||||
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
||||
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
||||
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
||||
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
||||
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
||||
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
||||
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
||||
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
||||
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
||||
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
|
||||
insert into t3 (a1, a2, b, c, d) values
|
||||
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
||||
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
||||
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
||||
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
||||
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
||||
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
||||
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
||||
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
||||
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
||||
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
||||
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
||||
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
|
||||
insert into t3 (a1, a2, b, c, d) values
|
||||
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
||||
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
||||
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
||||
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
||||
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
||||
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
||||
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
||||
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
||||
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
||||
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
||||
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
||||
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
|
||||
insert into t3 (a1, a2, b, c, d) values
|
||||
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
||||
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
||||
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
||||
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
||||
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
||||
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
||||
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
||||
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
||||
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
||||
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
||||
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
||||
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
|
||||
create index idx_t3_0 on t3 (a1);
|
||||
create index idx_t3_1 on t3 (a1,a2,b,c);
|
||||
create index idx_t3_2 on t3 (a1,a2,b);
|
||||
analyze table t3;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t3 analyze status Table is already up to date
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.b) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.b) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b c min(c) max(c)
|
||||
a a a d111 a111 d111
|
||||
a a b h112 e112 h112
|
||||
a b a l121 i121 l121
|
||||
a b b p122 m122 p122
|
||||
b a a d211 a211 d211
|
||||
b a b h212 e212 h212
|
||||
b b a l221 i221 l221
|
||||
b b b p222 m222 p222
|
||||
c a a d311 a311 d311
|
||||
c a b h312 e312 h312
|
||||
c b a l321 i321 l321
|
||||
c b b p322 m322 p322
|
||||
d a a d411 a411 d411
|
||||
d a b h412 e412 h412
|
||||
d b a l421 i421 l421
|
||||
d b b p422 m422 p422
|
||||
explain select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.c) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
|
||||
select a1,a2,b,c,min(c), max(c) from t1
|
||||
where exists ( select * from t2
|
||||
where t2.c in (select c from t3 where t3.c > t1.c) and
|
||||
t2.c > 'b1' )
|
||||
group by a1,a2,b;
|
||||
a1 a2 b c min(c) max(c)
|
||||
a a a a111 a111 d111
|
||||
a a b e112 e112 h112
|
||||
a b a i121 i121 l121
|
||||
a b b m122 m122 p122
|
||||
b a a a211 a211 d211
|
||||
b a b e212 e212 h212
|
||||
b b a i221 i221 l221
|
||||
b b b m222 m222 p222
|
||||
c a a a311 a311 d311
|
||||
c a b e312 e312 h312
|
||||
c b a i321 i321 l321
|
||||
c b b m322 m322 o322
|
||||
d a a a411 a411 d411
|
||||
d a b e412 e412 h412
|
||||
d b a i421 i421 l421
|
||||
d b b m422 m422 o422
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# From group_by.test
|
||||
#
|
||||
# Bug #21174: Index degrades sort performance and
|
||||
# optimizer does not honor IGNORE INDEX.
|
||||
# a.k.a WL3527.
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT,
|
||||
PRIMARY KEY (a),
|
||||
KEY i2(a,b));
|
||||
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8);
|
||||
INSERT INTO t1 SELECT a + 8,b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 16,b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 32,b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 64,b FROM t1;
|
||||
INSERT INTO t1 SELECT a + 128,b FROM t1 limit 16;
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a IN
|
||||
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1)
|
||||
CREATE TABLE t2 (a INT, b INT, KEY(a));
|
||||
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
|
||||
EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL a 5 NULL 2
|
||||
EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
|
||||
EXPLAIN SELECT 1 FROM t2 WHERE a IN
|
||||
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 4 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2)
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# From derived_view.test
|
||||
#
|
||||
set @tmp_subselect_extra_derived=@@optimizer_switch;
|
||||
set optimizer_switch='derived_merge=on,derived_with_keys=on';
|
||||
#
|
||||
# LP bug #806504: right join over a view/derived table
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int) ;
|
||||
INSERT INTO t1 VALUES (0,0);
|
||||
CREATE TABLE t2 (a int) ;
|
||||
INSERT INTO t2 VALUES (0), (0);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
a a b
|
||||
NULL 0 0
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` semi join (`test`.`t1`) left join `test`.`t2` on((0 <> 0)) where 1
|
||||
SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
a a b
|
||||
NULL 0 0
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t1` semi join (`test`.`t1`) left join `test`.`t2` on((0 <> 0)) where 1
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LP bug #793448: materialized view accessed by two-component key
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (9,3), (2,5);
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES (9,3), (3,7), (9,1), (2,5), (2,4), (3,8);
|
||||
CREATE TABLE t3 (a int, b int);
|
||||
INSERT INTO t3 VALUES (10,3), (9,7), (9,1), (2,4);
|
||||
CREATE VIEW v1(a,b) AS SELECT a, MAX(b) FROM t2 GROUP BY a;
|
||||
CREATE VIEW v2(a,b) AS SELECT a,b FROM t2 UNION SELECT a,b FROM t3;
|
||||
SELECT * FROM v1;
|
||||
a b
|
||||
2 5
|
||||
3 8
|
||||
9 3
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
|
||||
a
|
||||
9
|
||||
2
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
|
||||
SELECT * FROM v2;
|
||||
a b
|
||||
9 3
|
||||
3 7
|
||||
9 1
|
||||
2 5
|
||||
2 4
|
||||
3 8
|
||||
10 3
|
||||
9 7
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
|
||||
a
|
||||
9
|
||||
2
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 6
|
||||
4 UNION t3 ALL NULL NULL NULL NULL 4
|
||||
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# LP bug #874006: materialized view used in IN subquery
|
||||
#
|
||||
CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1));
|
||||
INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r');
|
||||
CREATE TABLE t1 (a int, b varchar(1) , c varchar(1));
|
||||
INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y');
|
||||
CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1));
|
||||
INSERT INTO t2 VALUES (4,3,'r');
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
|
||||
SET SESSION optimizer_switch='derived_with_keys=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; Start temporary
|
||||
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
a b c
|
||||
20 r r
|
||||
SET SESSION optimizer_switch='derived_with_keys=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <derived3> ref key1 key1 10 const,const 0 Start temporary
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
a b c
|
||||
20 r r
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# LP bug #873263: materialized view used in correlated IN subquery
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int) ;
|
||||
INSERT INTO t1 VALUES (5,4), (9,8);
|
||||
CREATE TABLE t2 (a int, b int) ;
|
||||
INSERT INTO t2 VALUES (4,5), (5,1);
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
|
||||
SET SESSION optimizer_switch='derived_with_keys=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 2 FirstMatch(t1)
|
||||
3 DERIVED t2 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
a b
|
||||
5 4
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1,t2;
|
||||
set optimizer_switch= @tmp_subselect_extra_derived;
|
||||
set optimizer_switch= @subselect_extra_no_sj_tmp;
|
@ -1,5 +1,7 @@
|
||||
drop table if exists x1;
|
||||
drop table if exists x2;
|
||||
set @tmp_subselect_nulls=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off';
|
||||
create table x1(k int primary key, d1 int, d2 int);
|
||||
create table x2(k int primary key, d1 int, d2 int);
|
||||
insert into x1 values
|
||||
@ -110,5 +112,6 @@ where x1.d1=x2.d1 and x1.d2=x2.d2);
|
||||
k d1 d2
|
||||
10 10 10
|
||||
20 20 20
|
||||
set optimizer_switch= @tmp_subselect_nulls;
|
||||
drop table x1;
|
||||
drop table x2;
|
||||
|
@ -1994,4 +1994,28 @@ a
|
||||
20
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp_877288;
|
||||
#
|
||||
# BUG#878753: Assertion '0' failed in replace_where_subcondition with derived_merge
|
||||
#
|
||||
set @tmp878753= @@optimizer_switch;
|
||||
set optimizer_switch= 'semijoin=on,derived_merge=on';
|
||||
CREATE TABLE t1 (b int(11)) ;
|
||||
CREATE TABLE t2 (c int, b int, d varchar(52) NOT NULL) ;
|
||||
CREATE TABLE t3 (b int(11)) ;
|
||||
PREPARE st1 FROM '
|
||||
SELECT * FROM t1
|
||||
JOIN (
|
||||
SELECT t2.* FROM t2
|
||||
WHERE t2.d <> "a"
|
||||
AND t2.c IN (
|
||||
SELECT t3.b
|
||||
FROM t3
|
||||
)
|
||||
) AS alias2
|
||||
ON ( alias2.b = t1.b );
|
||||
';
|
||||
EXECUTE st1;
|
||||
b c b d
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp878753;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
@ -2005,6 +2005,30 @@ a
|
||||
20
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp_877288;
|
||||
#
|
||||
# BUG#878753: Assertion '0' failed in replace_where_subcondition with derived_merge
|
||||
#
|
||||
set @tmp878753= @@optimizer_switch;
|
||||
set optimizer_switch= 'semijoin=on,derived_merge=on';
|
||||
CREATE TABLE t1 (b int(11)) ;
|
||||
CREATE TABLE t2 (c int, b int, d varchar(52) NOT NULL) ;
|
||||
CREATE TABLE t3 (b int(11)) ;
|
||||
PREPARE st1 FROM '
|
||||
SELECT * FROM t1
|
||||
JOIN (
|
||||
SELECT t2.* FROM t2
|
||||
WHERE t2.d <> "a"
|
||||
AND t2.c IN (
|
||||
SELECT t3.b
|
||||
FROM t3
|
||||
)
|
||||
) AS alias2
|
||||
ON ( alias2.b = t1.b );
|
||||
';
|
||||
EXECUTE st1;
|
||||
b c b d
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp878753;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
|
@ -514,11 +514,10 @@ explain extended
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select `test`.`x1`.`id` from `test`.`t1` `x1` where 0)))
|
||||
Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where (('2007-04-25 18:30:22' = 0))
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id cur_date
|
||||
@ -526,11 +525,10 @@ explain extended
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` where <expr_cache><1>(<in_optimizer>(1,<exists>(select `test`.`x1`.`id` from `test`.`t2` `x1` where 0)))
|
||||
Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where (('2007-04-25' = 0))
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id cur_date
|
||||
@ -540,11 +538,11 @@ explain extended
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
|
||||
1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where <expr_cache><`test`.`t1`.`id`,`test`.`t1`.`cur_date`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(select `test`.`x1`.`id` from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = 0) and (<cache>(`test`.`t1`.`id`) = `test`.`x1`.`id`)))))
|
||||
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where ((`test`.`x1`.`id` = `test`.`t1`.`id`) and (`test`.`t1`.`cur_date` = 0))
|
||||
select * from t1
|
||||
where id in (select id from t1 as x1 where (t1.cur_date is null));
|
||||
id cur_date
|
||||
@ -552,11 +550,11 @@ explain extended
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
|
||||
1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where <expr_cache><`test`.`t2`.`id`,`test`.`t2`.`cur_date`>(<in_optimizer>(`test`.`t2`.`id`,<exists>(select `test`.`x1`.`id` from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = 0) and (<cache>(`test`.`t2`.`id`) = `test`.`x1`.`id`)))))
|
||||
Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where ((`test`.`x1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`cur_date` = 0))
|
||||
select * from t2
|
||||
where id in (select id from t2 as x1 where (t2.cur_date is null));
|
||||
id cur_date
|
||||
|
@ -3692,8 +3692,8 @@ NULL 1.7976931348623e+308 3
|
||||
-00:00:01 -1 5
|
||||
00:17:58 1758 25
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
@ -4044,10 +4044,10 @@ NULL 1.7976931348623e+308 3
|
||||
NULL -1 5
|
||||
NULL 200506271758 19
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
|
||||
Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 19
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
@ -4405,9 +4405,9 @@ NULL 1.7976931348623e+308 3
|
||||
NULL -1 5
|
||||
2005-06-27 20050627 13
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
|
@ -3693,8 +3693,8 @@ NULL 1.7976931348623e+308 3
|
||||
-00:00:01 -1 5
|
||||
00:17:58 1758 25
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
@ -4045,10 +4045,10 @@ NULL 1.7976931348623e+308 3
|
||||
NULL -1 5
|
||||
NULL 200506271758 19
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
|
||||
Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 6
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
@ -4406,9 +4406,9 @@ NULL 1.7976931348623e+308 3
|
||||
NULL -1 5
|
||||
2005-06-27 20050627 13
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
|
@ -3693,8 +3693,8 @@ NULL 1.7976931348623e+308 3
|
||||
-00:00:01 -1 5
|
||||
00:17:58 1758 25
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
@ -4045,10 +4045,10 @@ NULL 1.7976931348623e+308 3
|
||||
NULL -1 5
|
||||
NULL 200506271758 19
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
|
||||
Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 6
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
@ -4406,9 +4406,9 @@ NULL 1.7976931348623e+308 3
|
||||
NULL -1 5
|
||||
2005-06-27 20050627 13
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
|
||||
Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
|
||||
Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
|
||||
DROP VIEW v1;
|
||||
|
||||
|
||||
|
@ -1301,31 +1301,31 @@ a
|
||||
4
|
||||
explain extended select * from t2 where t2.a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
|
||||
1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
|
||||
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)
|
||||
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
a
|
||||
2
|
||||
4
|
||||
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where
|
||||
1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
|
||||
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
|
||||
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
a
|
||||
2
|
||||
3
|
||||
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
|
||||
1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
|
||||
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`))
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int, b int, index a (a,b));
|
||||
create table t2 (a int, index a (a));
|
||||
@ -1340,31 +1340,31 @@ a
|
||||
4
|
||||
explain extended select * from t2 where t2.a in (select a from t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index
|
||||
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
|
||||
1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using index; FirstMatch(t2)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`)
|
||||
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
a
|
||||
2
|
||||
4
|
||||
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index; Using where
|
||||
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
|
||||
1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using where; Using index; FirstMatch(t2)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
|
||||
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
a
|
||||
2
|
||||
3
|
||||
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 ref a a 5 test.t1.b 1 100.00 Using index
|
||||
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index; Start temporary
|
||||
1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using index
|
||||
1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index; End temporary; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`))
|
||||
insert into t1 values (3,31);
|
||||
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
a
|
||||
@ -1377,10 +1377,10 @@ a
|
||||
4
|
||||
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index; Using where
|
||||
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
|
||||
1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using where; Using index; FirstMatch(t2)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int, b int);
|
||||
create table t2 (a int, b int);
|
||||
@ -2834,10 +2834,10 @@ Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1`
|
||||
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; FirstMatch(t1)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = 'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`)))))
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N'))
|
||||
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
|
||||
@ -4224,8 +4224,8 @@ CREATE INDEX I1 ON t1 (a);
|
||||
CREATE INDEX I2 ON t1 (b);
|
||||
EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where
|
||||
1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t1 ref I1 I1 2 test.t1.b 1 Using where; Using index; FirstMatch(t1)
|
||||
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
|
||||
a b
|
||||
CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
|
||||
@ -4234,15 +4234,15 @@ CREATE INDEX I1 ON t2 (a);
|
||||
CREATE INDEX I2 ON t2 (b);
|
||||
EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 1 Using index; Using where
|
||||
1 PRIMARY t2 ALL I2 NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t2 ref I1 I1 4 test.t2.b 1 Using where; Using index; FirstMatch(t2)
|
||||
SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
|
||||
a b
|
||||
EXPLAIN
|
||||
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where
|
||||
1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t1 ref I1 I1 2 test.t1.b 1 Using where; Using index; FirstMatch(t1)
|
||||
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
|
||||
a b
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -63,8 +63,8 @@ a b c
|
||||
3 -3 -3
|
||||
explain select * from t1 where b in (select c from t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index
|
||||
1 PRIMARY t3 index c c 5 NULL 3 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
# select_type=PRIMARY, type=range,ref
|
||||
select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
a b c
|
||||
@ -73,8 +73,8 @@ a b c
|
||||
1 -1 -1
|
||||
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index; Using where
|
||||
1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index
|
||||
1 PRIMARY t1 ref c c 5 test.t3.c 1
|
||||
# select_type=UNION, type=system
|
||||
# select_type=UNION RESULT, type=<union1,2>
|
||||
select * from t1 union select * from t2;
|
||||
|
@ -63,8 +63,8 @@ a b c
|
||||
3 -3 -3
|
||||
explain select * from t1 where b in (select c from t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index
|
||||
1 PRIMARY t3 index c c 5 NULL 3 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
# select_type=PRIMARY, type=range,ref
|
||||
select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
a b c
|
||||
@ -73,8 +73,8 @@ a b c
|
||||
1 -1 -1
|
||||
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index; Using where
|
||||
1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index
|
||||
1 PRIMARY t1 ref c c 5 test.t3.c 2
|
||||
# select_type=UNION, type=system
|
||||
# select_type=UNION RESULT, type=<union1,2>
|
||||
select * from t1 union select * from t2;
|
||||
|
@ -37,7 +37,7 @@ select cast("2011-02-03 10:11:12.123456" as datetime(0));
|
||||
select cast("2011-02-03 10:11:12.123456" as datetime(5));
|
||||
select cast("2011-02-03 10:11:12.123456" as datetime(6));
|
||||
select cast("2011-02-03 10:11:12" as datetime(6));
|
||||
select cast(cast(20010203101112.1 as double) as datetime(1));
|
||||
select cast(cast(20010203101112.5 as double) as datetime(1));
|
||||
select cast(cast(010203101112.12 as double) as datetime(2));
|
||||
select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime(6));
|
||||
select cast(20010203101112.121314 as datetime(6));
|
||||
|
@ -1749,7 +1749,7 @@ INSERT INTO t3 VALUES (5,0),(7,0);
|
||||
CREATE TABLE t4 (a int);
|
||||
INSERT INTO t4 VALUES (2),(8);
|
||||
|
||||
set @@optimizer_switch='in_to_exists=on,materialization=off,subquery_cache=off';
|
||||
set @@optimizer_switch='semijoin=off,in_to_exists=on,materialization=off,subquery_cache=off';
|
||||
|
||||
SELECT * FROM t2
|
||||
WHERE t2.b IN (SELECT b FROM t3 WHERE t3.a = t2.a AND a < SOME (SELECT * FROM t4))
|
||||
|
@ -1,4 +1,10 @@
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2,t3,t4,t5;
|
||||
drop view if exists v1;
|
||||
--enable_warnings
|
||||
|
||||
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
|
||||
create table t1 (a int, b int);
|
||||
@ -1664,5 +1670,33 @@ FROM t1
|
||||
WHERE t2.f1 OR t2.f3 );
|
||||
drop tables t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # Test of LP BUG#872775 view with "outer references" bug
|
||||
--echo #
|
||||
set @@optimizer_switch= default;
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
CREATE TABLE t1 (a int) ;
|
||||
|
||||
CREATE TABLE t2 (b int, c varchar(1) NOT NULL ) ;
|
||||
INSERT INTO t2 VALUES (1,'x'),(2,'y');
|
||||
|
||||
CREATE TABLE t3 (a int) ;
|
||||
|
||||
CREATE TABLE t4 ( pk int(11) NOT NULL , b int(11) NOT NULL ) ;
|
||||
INSERT INTO t4 VALUES (26,9),(27,5),(28,0),(29,3);
|
||||
|
||||
CREATE OR REPLACE VIEW v1 AS
|
||||
SELECT t2.b
|
||||
FROM t1
|
||||
JOIN t2
|
||||
WHERE t2 .c > (
|
||||
SELECT t2.c FROM t3
|
||||
);
|
||||
|
||||
SELECT * FROM t4 WHERE b NOT IN ( SELECT * FROM v1 );
|
||||
|
||||
drop view v1;
|
||||
drop table t1,t2,t3,t4;
|
||||
|
||||
--echo # restore default
|
||||
set @@optimizer_switch= default;
|
||||
|
@ -9,11 +9,9 @@
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2,t3,t4;
|
||||
drop view if exists v1,v2,v3;
|
||||
--enable_warnings
|
||||
|
||||
set @subselect_extra_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on';
|
||||
|
||||
|
||||
--echo # From explain.test:
|
||||
--echo #
|
||||
@ -273,6 +271,123 @@ EXPLAIN SELECT 1 FROM t2 WHERE a IN
|
||||
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # From derived_view.test
|
||||
--echo #
|
||||
set @tmp_subselect_extra_derived=@@optimizer_switch;
|
||||
set optimizer_switch='derived_merge=on,derived_with_keys=on';
|
||||
|
||||
set optimizer_switch= @subselect_extra_tmp;
|
||||
--echo #
|
||||
--echo # LP bug #806504: right join over a view/derived table
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int, b int) ;
|
||||
INSERT INTO t1 VALUES (0,0);
|
||||
|
||||
CREATE TABLE t2 (a int) ;
|
||||
INSERT INTO t2 VALUES (0), (0);
|
||||
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
|
||||
SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0
|
||||
WHERE t.a IN (SELECT b FROM t1);
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug #793448: materialized view accessed by two-component key
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (9,3), (2,5);
|
||||
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES (9,3), (3,7), (9,1), (2,5), (2,4), (3,8);
|
||||
|
||||
CREATE TABLE t3 (a int, b int);
|
||||
INSERT INTO t3 VALUES (10,3), (9,7), (9,1), (2,4);
|
||||
|
||||
CREATE VIEW v1(a,b) AS SELECT a, MAX(b) FROM t2 GROUP BY a;
|
||||
CREATE VIEW v2(a,b) AS SELECT a,b FROM t2 UNION SELECT a,b FROM t3;
|
||||
|
||||
SELECT * FROM v1;
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1);
|
||||
|
||||
SELECT * FROM v2;
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
|
||||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2);
|
||||
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug #874006: materialized view used in IN subquery
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1));
|
||||
INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r');
|
||||
|
||||
CREATE TABLE t1 (a int, b varchar(1) , c varchar(1));
|
||||
INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y');
|
||||
|
||||
CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1));
|
||||
INSERT INTO t2 VALUES (4,3,'r');
|
||||
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
SET SESSION optimizer_switch='derived_with_keys=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
|
||||
SET SESSION optimizer_switch='derived_with_keys=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
SELECT * FROM t3
|
||||
WHERE t3.b IN (SELECT v1.b FROM v1, t2
|
||||
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug #873263: materialized view used in correlated IN subquery
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int, b int) ;
|
||||
INSERT INTO t1 VALUES (5,4), (9,8);
|
||||
|
||||
CREATE TABLE t2 (a int, b int) ;
|
||||
INSERT INTO t2 VALUES (4,5), (5,1);
|
||||
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
|
||||
|
||||
SET SESSION optimizer_switch='derived_with_keys=on';
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a);
|
||||
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
set optimizer_switch= @tmp_subselect_extra_derived;
|
||||
|
||||
|
7
mysql-test/t/subselect_extra_no_semijoin.test
Normal file
7
mysql-test/t/subselect_extra_no_semijoin.test
Normal file
@ -0,0 +1,7 @@
|
||||
set @subselect_extra_no_sj_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on';
|
||||
|
||||
--source t/subselect_extra.test
|
||||
|
||||
set optimizer_switch= @subselect_extra_no_sj_tmp;
|
||||
|
@ -1,5 +1,7 @@
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
# Note: the tests uses only non-semijoin subqueries so semi-join switch
|
||||
# settings are not relevant.
|
||||
set @subselect_innodb_tmp=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
--disable_warnings
|
||||
|
@ -5,6 +5,9 @@ drop table if exists x1;
|
||||
drop table if exists x2;
|
||||
--enable_warnings
|
||||
|
||||
set @tmp_subselect_nulls=@@optimizer_switch;
|
||||
set optimizer_switch='semijoin=off';
|
||||
|
||||
create table x1(k int primary key, d1 int, d2 int);
|
||||
create table x2(k int primary key, d1 int, d2 int);
|
||||
|
||||
@ -90,5 +93,7 @@ where exists (select *
|
||||
from x2
|
||||
where x1.d1=x2.d1 and x1.d2=x2.d2);
|
||||
|
||||
set optimizer_switch= @tmp_subselect_nulls;
|
||||
|
||||
drop table x1;
|
||||
drop table x2;
|
||||
|
@ -1827,5 +1827,30 @@ SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a);
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp_877288;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#878753: Assertion '0' failed in replace_where_subcondition with derived_merge
|
||||
--echo #
|
||||
set @tmp878753= @@optimizer_switch;
|
||||
set optimizer_switch= 'semijoin=on,derived_merge=on';
|
||||
CREATE TABLE t1 (b int(11)) ;
|
||||
CREATE TABLE t2 (c int, b int, d varchar(52) NOT NULL) ;
|
||||
CREATE TABLE t3 (b int(11)) ;
|
||||
|
||||
PREPARE st1 FROM '
|
||||
SELECT * FROM t1
|
||||
JOIN (
|
||||
SELECT t2.* FROM t2
|
||||
WHERE t2.d <> "a"
|
||||
AND t2.c IN (
|
||||
SELECT t3.b
|
||||
FROM t3
|
||||
)
|
||||
) AS alias2
|
||||
ON ( alias2.b = t1.b );
|
||||
';
|
||||
EXECUTE st1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp878753;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
@ -755,7 +755,9 @@ bool Item_ident::remove_dependence_processor(uchar * arg)
|
||||
bool Item_ident::collect_outer_ref_processor(uchar *param)
|
||||
{
|
||||
Collect_deps_prm *prm= (Collect_deps_prm *)param;
|
||||
if (depended_from && depended_from->nest_level < prm->nest_level)
|
||||
if (depended_from &&
|
||||
depended_from->nest_level_base == prm->nest_level_base &&
|
||||
depended_from->nest_level < prm->nest_level)
|
||||
prm->parameters->add_unique(this, &cmp_items);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -505,6 +505,7 @@ typedef void (*Cond_traverser) (const Item *item, void *arg);
|
||||
class Item_equal;
|
||||
class COND_EQUAL;
|
||||
|
||||
class st_select_lex_unit;
|
||||
|
||||
class Item {
|
||||
Item(const Item &); /* Prevent use of these */
|
||||
@ -1159,8 +1160,10 @@ public:
|
||||
}
|
||||
struct Collect_deps_prm
|
||||
{
|
||||
int nest_level;
|
||||
List<Item> *parameters;
|
||||
/* unit from which we count nest_level */
|
||||
st_select_lex_unit *nest_level_base;
|
||||
int nest_level;
|
||||
};
|
||||
/**
|
||||
Collect outer references
|
||||
|
@ -599,7 +599,9 @@ bool Item_subselect::exec()
|
||||
|
||||
void Item_subselect::get_cache_parameters(List<Item> ¶meters)
|
||||
{
|
||||
Collect_deps_prm prm= { unit->first_select()->nest_level, ¶meters };
|
||||
Collect_deps_prm prm= {¶meters,
|
||||
unit->first_select()->nest_level_base,
|
||||
unit->first_select()->nest_level};
|
||||
walk(&Item::collect_outer_ref_processor, TRUE, (uchar*)&prm);
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,9 @@ bool Item_sum::collect_outer_ref_processor(uchar *param)
|
||||
{
|
||||
Collect_deps_prm *prm= (Collect_deps_prm *)param;
|
||||
SELECT_LEX *ds;
|
||||
if ((ds= depended_from()) && ds->nest_level < prm->nest_level)
|
||||
if ((ds= depended_from()) &&
|
||||
ds->nest_level_base == prm->nest_level_base &&
|
||||
ds->nest_level < prm->nest_level)
|
||||
prm->parameters->add_unique(this, &cmp_items);
|
||||
return FALSE;
|
||||
}
|
||||
|
19
sql/log.cc
19
sql/log.cc
@ -70,7 +70,7 @@ static LEX_STRING const write_error_msg=
|
||||
static my_bool opt_optimize_thread_scheduling= TRUE;
|
||||
ulong binlog_checksum_options;
|
||||
#ifndef DBUG_OFF
|
||||
static ulong opt_binlog_dbug_fsync_sleep= 0;
|
||||
ulong opt_binlog_dbug_fsync_sleep= 0;
|
||||
#endif
|
||||
|
||||
static my_bool mutexes_inited;
|
||||
@ -7067,27 +7067,10 @@ static MYSQL_SYSVAR_ENUM(
|
||||
BINLOG_CHECKSUM_ALG_OFF,
|
||||
&binlog_checksum_typelib);
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
static MYSQL_SYSVAR_ULONG(
|
||||
dbug_fsync_sleep,
|
||||
opt_binlog_dbug_fsync_sleep,
|
||||
PLUGIN_VAR_RQCMDARG,
|
||||
"Extra sleep (in microseconds) to add to binlog fsync(), for debugging",
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
ULONG_MAX,
|
||||
0);
|
||||
#endif
|
||||
|
||||
static struct st_mysql_sys_var *binlog_sys_vars[]=
|
||||
{
|
||||
MYSQL_SYSVAR(optimize_thread_scheduling),
|
||||
MYSQL_SYSVAR(checksum),
|
||||
#ifndef DBUG_OFF
|
||||
MYSQL_SYSVAR(dbug_fsync_sleep),
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -609,7 +609,10 @@ enabled by default, add OPTIMIZER_SWITCH_MATERIALIZATION
|
||||
OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL | \
|
||||
OPTIMIZER_SWITCH_JOIN_CACHE_HASHED | \
|
||||
OPTIMIZER_SWITCH_JOIN_CACHE_BKA | \
|
||||
OPTIMIZER_SWITCH_SUBQUERY_CACHE)
|
||||
OPTIMIZER_SWITCH_SUBQUERY_CACHE |\
|
||||
OPTIMIZER_SWITCH_SEMIJOIN | \
|
||||
OPTIMIZER_SWITCH_FIRSTMATCH | \
|
||||
OPTIMIZER_SWITCH_LOOSE_SCAN )
|
||||
|
||||
/*
|
||||
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
|
||||
@ -2160,7 +2163,7 @@ extern ulong query_buff_size;
|
||||
extern ulong max_prepared_stmt_count, prepared_stmt_count;
|
||||
extern ulong binlog_cache_size, open_files_limit;
|
||||
extern ulonglong max_binlog_cache_size;
|
||||
extern ulong max_binlog_size, max_relay_log_size;
|
||||
extern ulong max_binlog_size, max_relay_log_size, opt_binlog_dbug_fsync_sleep;
|
||||
extern ulong opt_binlog_rows_event_max_size;
|
||||
extern my_bool opt_master_verify_checksum;
|
||||
extern my_bool opt_slave_sql_verify_checksum;
|
||||
|
@ -484,11 +484,11 @@ static const char *optimizer_switch_str="index_merge=on,index_merge_union=on,"
|
||||
"index_condition_pushdown=off,"
|
||||
"derived_merge=off,"
|
||||
"derived_with_keys=off,"
|
||||
"firstmatch=off,"
|
||||
"loosescan=off,"
|
||||
"firstmatch=on,"
|
||||
"loosescan=on,"
|
||||
"materialization=off,"
|
||||
"in_to_exists=on,"
|
||||
"semijoin=off,"
|
||||
"semijoin=on,"
|
||||
"partial_match_rowid_merge=on,"
|
||||
"partial_match_table_scan=on,"
|
||||
"subquery_cache=on,"
|
||||
@ -707,6 +707,7 @@ char mysql_real_data_home[FN_REFLEN],
|
||||
language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
|
||||
*opt_init_file, *opt_tc_log_file,
|
||||
def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
|
||||
const char *opt_basename;
|
||||
char mysql_unpacked_real_data_home[FN_REFLEN];
|
||||
int mysql_unpacked_real_data_home_len;
|
||||
uint reg_ext_length;
|
||||
@ -3509,7 +3510,6 @@ static int init_common_variables(const char *conf_file_name, int argc,
|
||||
char **argv, const char **groups)
|
||||
{
|
||||
char buff[FN_REFLEN], *s;
|
||||
const char *basename;
|
||||
umask(((~my_umask) & 0666));
|
||||
tzset(); // Set tzname
|
||||
|
||||
@ -3569,13 +3569,13 @@ static int init_common_variables(const char *conf_file_name, int argc,
|
||||
strmake(glob_hostname, STRING_WITH_LEN("localhost"));
|
||||
sql_print_warning("gethostname failed, using '%s' as hostname",
|
||||
glob_hostname);
|
||||
basename= "mysql";
|
||||
opt_basename= "mysql";
|
||||
}
|
||||
else
|
||||
{
|
||||
basename= glob_hostname;
|
||||
opt_basename= glob_hostname;
|
||||
}
|
||||
strmake(pidfile_name, basename, sizeof(pidfile_name)-5);
|
||||
strmake(pidfile_name, opt_basename, sizeof(pidfile_name)-5);
|
||||
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
|
||||
|
||||
/*
|
||||
@ -4305,11 +4305,13 @@ a file name for --log-bin-index option", opt_binlog_index_name);
|
||||
require a name. But as we don't want to break many existing setups, we
|
||||
only give warning, not error.
|
||||
*/
|
||||
sql_print_warning("No argument was provided to --log-bin, and "
|
||||
"--log-bin-index was not used; so replication "
|
||||
"may break when this MySQL server acts as a "
|
||||
"master and has his hostname changed!! Please "
|
||||
"use '--log-bin=%s' to avoid this problem.", ln);
|
||||
sql_print_warning("No argument was provided to --log-bin and "
|
||||
"neither --log-basename or --log-bin-index where "
|
||||
"used; This may cause repliction to break when this "
|
||||
"server acts as a master and has its hostname "
|
||||
"changed!! Please use '--log-basename=%s' or "
|
||||
"'--log-bin=%s' to avoid this problem.",
|
||||
opt_basename, ln);
|
||||
}
|
||||
if (ln == buf)
|
||||
{
|
||||
@ -6015,7 +6017,7 @@ enum options_mysqld
|
||||
OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB,
|
||||
OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES,
|
||||
OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB,
|
||||
OPT_BINLOG_FORMAT,
|
||||
OPT_BINLOG_FORMAT, OPT_DEBUG_BINLOG_FSYNC_SLEEP,
|
||||
OPT_BINLOG_ANNOTATE_ROWS_EVENTS,
|
||||
OPT_REPLICATE_ANNOTATE_ROWS_EVENTS,
|
||||
#ifndef DBUG_OFF
|
||||
@ -6241,6 +6243,12 @@ struct my_option my_long_options[] =
|
||||
{"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.",
|
||||
&my_bind_addr_str, &my_bind_addr_str, 0, GET_STR,
|
||||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifndef DBUG_OFF
|
||||
{"debug-binlog-fsync-sleep", OPT_DEBUG_BINLOG_FSYNC_SLEEP,
|
||||
"Extra sleep (in microseconds) to add to binlog fsync(), for debugging",
|
||||
&opt_binlog_dbug_fsync_sleep, &opt_binlog_dbug_fsync_sleep,
|
||||
0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
|
||||
#endif
|
||||
{"binlog_format", OPT_BINLOG_FORMAT,
|
||||
"Does not have any effect without '--log-bin'. "
|
||||
"Tell the master the form of binary logging to use: either 'row' for "
|
||||
|
@ -1026,7 +1026,6 @@ static bool replace_where_subcondition(JOIN *join, Item **expr,
|
||||
Item *old_cond, Item *new_cond,
|
||||
bool do_fix_fields)
|
||||
{
|
||||
//Item **expr= (emb_nest == (TABLE_LIST*)1)? &join->conds : &emb_nest->on_expr;
|
||||
if (*expr == old_cond)
|
||||
{
|
||||
*expr= new_cond;
|
||||
@ -1050,9 +1049,15 @@ static bool replace_where_subcondition(JOIN *join, Item **expr,
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we came here it means there were an error during prerequisites check.
|
||||
DBUG_ASSERT(0);
|
||||
return TRUE;
|
||||
/*
|
||||
We can come to here when
|
||||
- we're doing replace operations on both on_expr and prep_on_expr
|
||||
- on_expr is the same as prep_on_expr, or they share a sub-tree
|
||||
(so, when we do replace in on_expr, we replace in prep_on_expr, too,
|
||||
and when we try doing a replace in prep_on_expr, the item we wanted
|
||||
to replace there has already been replaced)
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2,
|
||||
|
@ -265,6 +265,9 @@ static sys_var_thd_ulong sys_deadlock_timeout_long(&vars,
|
||||
&SV::wt_timeout_long);
|
||||
#ifndef DBUG_OFF
|
||||
static sys_var_thd_dbug sys_dbug(&vars, "debug");
|
||||
static sys_var_long_ptr sys_var_debug_binlog_fsync_sleep(&vars,
|
||||
"debug_binlog_fsync_sleep",
|
||||
&opt_binlog_dbug_fsync_sleep);
|
||||
#endif
|
||||
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
|
||||
&delay_key_write_options,
|
||||
|
@ -339,6 +339,7 @@ void lex_start(THD *thd)
|
||||
lex->event_parse_data= NULL;
|
||||
lex->profile_options= PROFILE_NONE;
|
||||
lex->nest_level=0 ;
|
||||
lex->select_lex.nest_level_base= &lex->unit;
|
||||
lex->allow_sum_func= 0;
|
||||
lex->in_sum_func= NULL;
|
||||
lex->protect_against_global_read_lock= FALSE;
|
||||
|
@ -684,6 +684,13 @@ public:
|
||||
ulong table_join_options;
|
||||
uint in_sum_expr;
|
||||
uint select_number; /* number of select (used for EXPLAIN) */
|
||||
|
||||
/*
|
||||
nest_levels are local to the query or VIEW,
|
||||
and that view merge procedure does not re-calculate them.
|
||||
So we also have to remember unit against which we count levels.
|
||||
*/
|
||||
SELECT_LEX_UNIT *nest_level_base;
|
||||
int nest_level; /* nesting level of select */
|
||||
Item_sum *inner_sum_func_list; /* list of sum func in nested selects */
|
||||
uint with_wild; /* item list contain '*' */
|
||||
|
@ -5917,6 +5917,7 @@ mysql_new_select(LEX *lex, bool move_down)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
select_lex->nest_level= lex->nest_level;
|
||||
select_lex->nest_level_base= &thd->lex->unit;
|
||||
if (move_down)
|
||||
{
|
||||
SELECT_LEX_UNIT *unit;
|
||||
|
@ -2611,11 +2611,11 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer)
|
||||
i < buffer->size;
|
||||
i+= TRANSLOG_PAGE_SIZE, pg++)
|
||||
{
|
||||
TRANSLOG_ADDRESS addr= (buffer->offset + i);
|
||||
DBUG_PRINT("info", ("send log form %lu till %lu address: (%lu,0x%lx) "
|
||||
"page #: %lu buffer size: %lu buffer: 0x%lx",
|
||||
(ulong) i, (ulong) (i + TRANSLOG_PAGE_SIZE),
|
||||
LSN_IN_PARTS(addr), (ulong) pg, (ulong) buffer->size,
|
||||
LSN_IN_PARTS(buffer->offset + i), (ulong) pg,
|
||||
(ulong) buffer->size,
|
||||
(ulong) buffer));
|
||||
DBUG_ASSERT(log_descriptor.pagecache->block_size == TRANSLOG_PAGE_SIZE);
|
||||
DBUG_ASSERT(i + TRANSLOG_PAGE_SIZE <= buffer->size);
|
||||
|
@ -173,6 +173,7 @@ my_bool check_table_is_closed(const char *name, const char *where)
|
||||
DBUG_ENTER("check_table_is_closed");
|
||||
|
||||
(void) fn_format(filename,name,"",MI_NAME_IEXT,4+16+32);
|
||||
pthread_mutex_lock(&THR_LOCK_myisam);
|
||||
for (pos=myisam_open_list ; pos ; pos=pos->next)
|
||||
{
|
||||
MI_INFO *info=(MI_INFO*) pos->data;
|
||||
@ -183,10 +184,12 @@ my_bool check_table_is_closed(const char *name, const char *where)
|
||||
{
|
||||
fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where);
|
||||
DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
|
||||
pthread_mutex_unlock(&THR_LOCK_myisam);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&THR_LOCK_myisam);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif /* EXTRA_DEBUG */
|
||||
|
Loading…
x
Reference in New Issue
Block a user