Commit 7382b84f authored by Guilhem Bichot's avatar Guilhem Bichot

Merge with latest next-mr-bugfixing

parents 9ffdd1cc 03d10b8c
...@@ -155,8 +155,8 @@ libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobj ...@@ -155,8 +155,8 @@ libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobj
if DARWIN_MWCC if DARWIN_MWCC
mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects) mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
else else
-rm -f libmysqld.a -rm -f libmysqld.a
if test "$(host_os)" = "netware" ; \ if test "$(host_os)" = "netware" ; \
then \ then \
$(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \ $(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \
else \ else \
......
...@@ -11,7 +11,8 @@ exec $MYSQLD_BOOTSTRAP_CMD --symbolic-links=0 --lower-case-table-names=1 --help ...@@ -11,7 +11,8 @@ exec $MYSQLD_BOOTSTRAP_CMD --symbolic-links=0 --lower-case-table-names=1 --help
perl; perl;
@skipvars=qw/basedir open-files-limit general-log-file log @skipvars=qw/basedir open-files-limit general-log-file log
log-slow-queries pid-file slow-query-log-file/; log-slow-queries pid-file slow-query-log-file
datadir slave-load-tmpdir tmpdir/;
@plugins=qw/innodb ndb ndbcluster safemalloc debug temp-pool ssl des-key-file @plugins=qw/innodb ndb ndbcluster safemalloc debug temp-pool ssl des-key-file
thread-concurrency super-large-pages mutex-deadlock-detector/; thread-concurrency super-large-pages mutex-deadlock-detector/;
@env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_SHAREDIR/; @env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_SHAREDIR/;
......
...@@ -1419,19 +1419,19 @@ drop table t1; ...@@ -1419,19 +1419,19 @@ drop table t1;
# #
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
set optimizer_switch='index_merge=off,index_merge_union=off'; set optimizer_switch='index_merge=off,index_merge_union=off';
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
set optimizer_switch='index_merge_union=on'; set optimizer_switch='index_merge_union=on';
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
set optimizer_switch='default,index_merge_sort_union=off'; set optimizer_switch='default,index_merge_sort_union=off';
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,engine_condition_pushdown=on
set optimizer_switch=4; set optimizer_switch=4;
set optimizer_switch=NULL; set optimizer_switch=NULL;
ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'NULL' ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'NULL'
...@@ -1457,21 +1457,21 @@ set optimizer_switch=default; ...@@ -1457,21 +1457,21 @@ set optimizer_switch=default;
set optimizer_switch='index_merge=off,index_merge_union=off,default'; set optimizer_switch='index_merge=off,index_merge_union=off,default';
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
set optimizer_switch=default; set optimizer_switch=default;
select @@global.optimizer_switch; select @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
set @@global.optimizer_switch=default; set @@global.optimizer_switch=default;
select @@global.optimizer_switch; select @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
# #
# Check index_merge's @@optimizer_switch flags # Check index_merge's @@optimizer_switch flags
# #
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
create table t0 (a int); create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int, b int, c int, filler char(100), create table t1 (a int, b int, c int, filler char(100),
...@@ -1581,5 +1581,5 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -1581,5 +1581,5 @@ id select_type table type possible_keys key key_len ref rows Extra
set optimizer_switch=default; set optimizer_switch=default;
show variables like 'optimizer_switch'; show variables like 'optimizer_switch';
Variable_name Value Variable_name Value
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
drop table t0, t1; drop table t0, t1;
...@@ -132,7 +132,8 @@ The following options may be given as the first argument: ...@@ -132,7 +132,8 @@ The following options may be given as the first argument:
on that value on that value
--enable-locking Deprecated option, use --external-locking instead. --enable-locking Deprecated option, use --external-locking instead.
--engine-condition-pushdown --engine-condition-pushdown
Push supported query conditions to the storage engine Push supported query conditions to the storage engine.
Deprecated, use --optimizer-switch instead.
(Defaults to on; use --skip-engine-condition-pushdown to disable.) (Defaults to on; use --skip-engine-condition-pushdown to disable.)
--event-scheduler[=name] --event-scheduler[=name]
Enable the event scheduler. Possible values are ON, OFF, Enable the event scheduler. Possible values are ON, OFF,
...@@ -413,8 +414,9 @@ The following options may be given as the first argument: ...@@ -413,8 +414,9 @@ The following options may be given as the first argument:
--optimizer-switch=name --optimizer-switch=name
optimizer_switch=option=val[,option=val...], where option optimizer_switch=option=val[,option=val...], where option
is one of {index_merge, index_merge_union, is one of {index_merge, index_merge_union,
index_merge_sort_union, index_merge_intersection} and val index_merge_sort_union, index_merge_intersection,
is one of {on, off, default} engine_condition_pushdown} and val is one of {on, off,
default}
--partition[=name] Enable or disable partition plugin. Possible values are --partition[=name] Enable or disable partition plugin. Possible values are
ON, OFF, FORCE (don't start if the plugin fails to load). ON, OFF, FORCE (don't start if the plugin fails to load).
--pid-file=name Pid file used by safe_mysqld --pid-file=name Pid file used by safe_mysqld
...@@ -742,7 +744,6 @@ completion-type NO_CHAIN ...@@ -742,7 +744,6 @@ completion-type NO_CHAIN
concurrent-insert AUTO concurrent-insert AUTO
connect-timeout 10 connect-timeout 10
console FALSE console FALSE
datadir MYSQLTEST_VARDIR/install.db/
date-format %Y-%m-%d date-format %Y-%m-%d
datetime-format %Y-%m-%d %H:%i:%s datetime-format %Y-%m-%d %H:%i:%s
default-character-set latin1 default-character-set latin1
...@@ -853,7 +854,7 @@ old-passwords FALSE ...@@ -853,7 +854,7 @@ old-passwords FALSE
old-style-user-limits FALSE old-style-user-limits FALSE
optimizer-prune-level 1 optimizer-prune-level 1
optimizer-search-depth 62 optimizer-search-depth 62
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
partition ON partition ON
plugin-dir MYSQL_LIBDIR/mysql/plugin plugin-dir MYSQL_LIBDIR/mysql/plugin
plugin-load (No default value) plugin-load (No default value)
...@@ -896,7 +897,6 @@ skip-show-database FALSE ...@@ -896,7 +897,6 @@ skip-show-database FALSE
skip-slave-start FALSE skip-slave-start FALSE
slave-compressed-protocol FALSE slave-compressed-protocol FALSE
slave-exec-mode STRICT slave-exec-mode STRICT
slave-load-tmpdir MYSQLTEST_VARDIR/tmp/
slave-net-timeout 3600 slave-net-timeout 3600
slave-skip-errors (No default value) slave-skip-errors (No default value)
slave-transaction-retries 10 slave-transaction-retries 10
...@@ -924,7 +924,6 @@ thread-stack 262144 ...@@ -924,7 +924,6 @@ thread-stack 262144
time-format %H:%i:%s time-format %H:%i:%s
timed-mutexes FALSE timed-mutexes FALSE
tmp-table-size 16777216 tmp-table-size 16777216
tmpdir MYSQLTEST_VARDIR/tmp/
transaction-alloc-block-size 8192 transaction-alloc-block-size 8192
transaction-isolation REPEATABLE-READ transaction-isolation REPEATABLE-READ
transaction-prealloc-size 4096 transaction-prealloc-size 4096
......
...@@ -132,7 +132,8 @@ The following options may be given as the first argument: ...@@ -132,7 +132,8 @@ The following options may be given as the first argument:
on that value on that value
--enable-locking Deprecated option, use --external-locking instead. --enable-locking Deprecated option, use --external-locking instead.
--engine-condition-pushdown --engine-condition-pushdown
Push supported query conditions to the storage engine Push supported query conditions to the storage engine.
Deprecated, use --optimizer-switch instead.
(Defaults to on; use --skip-engine-condition-pushdown to disable.) (Defaults to on; use --skip-engine-condition-pushdown to disable.)
--event-scheduler[=name] --event-scheduler[=name]
Enable the event scheduler. Possible values are ON, OFF, Enable the event scheduler. Possible values are ON, OFF,
...@@ -413,8 +414,9 @@ The following options may be given as the first argument: ...@@ -413,8 +414,9 @@ The following options may be given as the first argument:
--optimizer-switch=name --optimizer-switch=name
optimizer_switch=option=val[,option=val...], where option optimizer_switch=option=val[,option=val...], where option
is one of {index_merge, index_merge_union, is one of {index_merge, index_merge_union,
index_merge_sort_union, index_merge_intersection} and val index_merge_sort_union, index_merge_intersection,
is one of {on, off, default} engine_condition_pushdown} and val is one of {on, off,
default}
--partition[=name] Enable or disable partition plugin. Possible values are --partition[=name] Enable or disable partition plugin. Possible values are
ON, OFF, FORCE (don't start if the plugin fails to load). ON, OFF, FORCE (don't start if the plugin fails to load).
--pid-file=name Pid file used by safe_mysqld --pid-file=name Pid file used by safe_mysqld
...@@ -746,7 +748,6 @@ completion-type NO_CHAIN ...@@ -746,7 +748,6 @@ completion-type NO_CHAIN
concurrent-insert AUTO concurrent-insert AUTO
connect-timeout 10 connect-timeout 10
console FALSE console FALSE
datadir MYSQLTEST_VARDIR/install.db/
date-format %Y-%m-%d date-format %Y-%m-%d
datetime-format %Y-%m-%d %H:%i:%s datetime-format %Y-%m-%d %H:%i:%s
default-character-set latin1 default-character-set latin1
...@@ -857,7 +858,7 @@ old-passwords FALSE ...@@ -857,7 +858,7 @@ old-passwords FALSE
old-style-user-limits FALSE old-style-user-limits FALSE
optimizer-prune-level 1 optimizer-prune-level 1
optimizer-search-depth 62 optimizer-search-depth 62
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
partition ON partition ON
plugin-dir MYSQL_LIBDIR/plugin plugin-dir MYSQL_LIBDIR/plugin
plugin-load (No default value) plugin-load (No default value)
...@@ -902,7 +903,6 @@ skip-show-database FALSE ...@@ -902,7 +903,6 @@ skip-show-database FALSE
skip-slave-start FALSE skip-slave-start FALSE
slave-compressed-protocol FALSE slave-compressed-protocol FALSE
slave-exec-mode STRICT slave-exec-mode STRICT
slave-load-tmpdir MYSQLTEST_VARDIR/tmp/
slave-net-timeout 3600 slave-net-timeout 3600
slave-skip-errors (No default value) slave-skip-errors (No default value)
slave-transaction-retries 10 slave-transaction-retries 10
...@@ -930,7 +930,6 @@ thread-stack 262144 ...@@ -930,7 +930,6 @@ thread-stack 262144
time-format %H:%i:%s time-format %H:%i:%s
timed-mutexes FALSE timed-mutexes FALSE
tmp-table-size 16777216 tmp-table-size 16777216
tmpdir MYSQLTEST_VARDIR/tmp/
transaction-alloc-block-size 8192 transaction-alloc-block-size 8192
transaction-isolation REPEATABLE-READ transaction-isolation REPEATABLE-READ
transaction-prealloc-size 4096 transaction-prealloc-size 4096
......
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch
1 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch
0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=off index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=off
...@@ -51,8 +51,8 @@ CREATE TABLE t3 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NO ...@@ -51,8 +51,8 @@ CREATE TABLE t3 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NO
insert into t3 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); insert into t3 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f");
CREATE TABLE t4 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) , KEY (attr1)) ENGINE=ndbcluster; CREATE TABLE t4 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) , KEY (attr1)) ENGINE=ndbcluster;
insert into t4 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); insert into t4 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f");
set @old_ecpd = @@session.engine_condition_pushdown; set @old_optimizer_switch = @@session.optimizer_switch;
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select auto from t1 where select auto from t1 where
string = "aaaa" and string = "aaaa" and
vstring = "aaaa" and vstring = "aaaa" and
...@@ -484,7 +484,7 @@ pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 ...@@ -484,7 +484,7 @@ pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4
2 2 9223372036854775804 2 c 2 2 9223372036854775804 2 c 2 2 9223372036854775804 2 c 2 2 9223372036854775804 2 c
3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d
4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
explain explain
select auto from t1 where select auto from t1 where
string = "aaaa" and string = "aaaa" and
...@@ -1769,12 +1769,12 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -1769,12 +1769,12 @@ id select_type table type possible_keys key key_len ref rows Extra
create table t5 (a int primary key auto_increment, b tinytext not null) create table t5 (a int primary key auto_increment, b tinytext not null)
engine = ndb; engine = ndb;
insert into t5 (b) values ('jonas'), ('jensing'), ('johan'); insert into t5 (b) values ('jonas'), ('jensing'), ('johan');
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select * from t5 where b like '%jo%' order by a; select * from t5 where b like '%jo%' order by a;
a b a b
1 jonas 1 jonas
3 johan 3 johan
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
explain select * from t5 where b like '%jo%'; explain select * from t5 where b like '%jo%';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL # Using where 1 SIMPLE t5 ALL NULL NULL NULL NULL # Using where
...@@ -1782,7 +1782,7 @@ select * from t5 where b like '%jo%' order by a; ...@@ -1782,7 +1782,7 @@ select * from t5 where b like '%jo%' order by a;
a b a b
1 jonas 1 jonas
3 johan 3 johan
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select auto from t1 where date_time like '1902-02-02 %' order by auto; select auto from t1 where date_time like '1902-02-02 %' order by auto;
auto auto
2 2
...@@ -1790,7 +1790,7 @@ select auto from t1 where date_time not like '1902-02-02 %' order by auto; ...@@ -1790,7 +1790,7 @@ select auto from t1 where date_time not like '1902-02-02 %' order by auto;
auto auto
3 3
4 4
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
explain select auto from t1 where date_time like '1902-02-02 %'; explain select auto from t1 where date_time like '1902-02-02 %';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
...@@ -1808,7 +1808,7 @@ drop table t1; ...@@ -1808,7 +1808,7 @@ drop table t1;
create table t1 (a int, b varchar(3), primary key using hash(a)) create table t1 (a int, b varchar(3), primary key using hash(a))
engine=ndb; engine=ndb;
insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); insert into t1 values (1,'a'), (2,'ab'), (3,'abc');
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
a b a b
2 ab 2 ab
...@@ -1821,7 +1821,7 @@ a b ...@@ -1821,7 +1821,7 @@ a b
select * from t1 where b like 'abc' or b like 'abc'; select * from t1 where b like 'abc' or b like 'abc';
a b a b
3 abc 3 abc
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
a b a b
2 ab 2 ab
...@@ -1838,7 +1838,7 @@ drop table t1; ...@@ -1838,7 +1838,7 @@ drop table t1;
create table t1 (a int, b char(3), primary key using hash(a)) create table t1 (a int, b char(3), primary key using hash(a))
engine=ndb; engine=ndb;
insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); insert into t1 values (1,'a'), (2,'ab'), (3,'abc');
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
a b a b
2 ab 2 ab
...@@ -1851,7 +1851,7 @@ a b ...@@ -1851,7 +1851,7 @@ a b
select * from t1 where b like 'abc' or b like 'abc'; select * from t1 where b like 'abc' or b like 'abc';
a b a b
3 abc 3 abc
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
a b a b
2 ab 2 ab
...@@ -1868,11 +1868,11 @@ drop table t1; ...@@ -1868,11 +1868,11 @@ drop table t1;
create table t1 ( fname varchar(255), lname varchar(255) ) create table t1 ( fname varchar(255), lname varchar(255) )
engine=ndbcluster; engine=ndbcluster;
insert into t1 values ("Young","Foo"); insert into t1 values ("Young","Foo");
set engine_condition_pushdown = 0; set optimizer_switch = "engine_condition_pushdown=off";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
fname lname fname lname
Young Foo Young Foo
set engine_condition_pushdown = 1; set optimizer_switch = "engine_condition_pushdown=on";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
fname lname fname lname
Young Foo Young Foo
...@@ -1880,11 +1880,11 @@ insert into t1 values ("aaa", "aaa"); ...@@ -1880,11 +1880,11 @@ insert into t1 values ("aaa", "aaa");
insert into t1 values ("bbb", "bbb"); insert into t1 values ("bbb", "bbb");
insert into t1 values ("ccc", "ccc"); insert into t1 values ("ccc", "ccc");
insert into t1 values ("ddd", "ddd"); insert into t1 values ("ddd", "ddd");
set engine_condition_pushdown = 0; set optimizer_switch = "engine_condition_pushdown=off";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
fname lname fname lname
Young Foo Young Foo
set engine_condition_pushdown = 1; set optimizer_switch = "engine_condition_pushdown=on";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
fname lname fname lname
Young Foo Young Foo
...@@ -1896,7 +1896,7 @@ insert into t1 values (20,2,200,0+0x2222); ...@@ -1896,7 +1896,7 @@ insert into t1 values (20,2,200,0+0x2222);
insert into t1 values (30,3,300,0+0x3333); insert into t1 values (30,3,300,0+0x3333);
insert into t1 values (40,4,400,0+0x4444); insert into t1 values (40,4,400,0+0x4444);
insert into t1 values (50,5,500,0+0x5555); insert into t1 values (50,5,500,0+0x5555);
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
select a,b,d from t1 select a,b,d from t1
where b in (0,1,2,5) where b in (0,1,2,5)
order by b; order by b;
...@@ -1916,5 +1916,5 @@ a b d ...@@ -1916,5 +1916,5 @@ a b d
50 5 21845 50 5 21845
Warnings: Warnings:
Warning 4294 Scan filter is too large, discarded Warning 4294 Scan filter is too large, discarded
set engine_condition_pushdown = @old_ecpd; set optimizer_switch = @old_optimizer_switch;
DROP TABLE t1,t2,t3,t4,t5; DROP TABLE t1,t2,t3,t4,t5;
...@@ -548,7 +548,7 @@ Overlaps(@horiz1, @point2) ...@@ -548,7 +548,7 @@ Overlaps(@horiz1, @point2)
0 0
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT); CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING); CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
......
...@@ -181,8 +181,8 @@ a b c ...@@ -181,8 +181,8 @@ a b c
5 5 NULL 5 5 NULL
8 3 NULL 8 3 NULL
9 3 NULL 9 3 NULL
set @old_ecpd = @@session.engine_condition_pushdown; set @old_optimizer_switch = @@session.optimizer_switch;
set engine_condition_pushdown = true; set optimizer_switch = "engine_condition_pushdown=on";
explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range PRIMARY,b PRIMARY 4 NULL 1 Using where with pushed condition 1 SIMPLE t2 range PRIMARY,b PRIMARY 4 NULL 1 Using where with pushed condition
...@@ -191,7 +191,7 @@ a b c ...@@ -191,7 +191,7 @@ a b c
3 3 NULL 3 3 NULL
5 5 NULL 5 5 NULL
8 3 NULL 8 3 NULL
set engine_condition_pushdown = @old_ecpd; set optimizer_switch = @old_optimizer_switch;
drop table t2; drop table t2;
CREATE TABLE t3 ( CREATE TABLE t3 (
a int unsigned NOT NULL, a int unsigned NOT NULL,
......
...@@ -68,8 +68,8 @@ CREATE TABLE t4 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NO ...@@ -68,8 +68,8 @@ CREATE TABLE t4 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NO
insert into t4 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); insert into t4 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f");
set @old_ecpd = @@session.engine_condition_pushdown; set @old_optimizer_switch = @@session.optimizer_switch;
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
# Test all types and compare operators # Test all types and compare operators
select auto from t1 where select auto from t1 where
...@@ -453,7 +453,7 @@ select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 ...@@ -453,7 +453,7 @@ select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5
select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1;
select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1;
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
# Test all types and compare operators # Test all types and compare operators
--replace_column 9 # --replace_column 9 #
...@@ -1674,18 +1674,18 @@ select * from t3 left join t4 on t4.attr2 = t3.attr2 where t4.attr1 > 1 and t4.a ...@@ -1674,18 +1674,18 @@ select * from t3 left join t4 on t4.attr2 = t3.attr2 where t4.attr1 > 1 and t4.a
create table t5 (a int primary key auto_increment, b tinytext not null) create table t5 (a int primary key auto_increment, b tinytext not null)
engine = ndb; engine = ndb;
insert into t5 (b) values ('jonas'), ('jensing'), ('johan'); insert into t5 (b) values ('jonas'), ('jensing'), ('johan');
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select * from t5 where b like '%jo%' order by a; select * from t5 where b like '%jo%' order by a;
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
--replace_column 9 # --replace_column 9 #
explain select * from t5 where b like '%jo%'; explain select * from t5 where b like '%jo%';
select * from t5 where b like '%jo%' order by a; select * from t5 where b like '%jo%' order by a;
# bug#21056 ndb pushdown equal/setValue error on datetime # bug#21056 ndb pushdown equal/setValue error on datetime
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select auto from t1 where date_time like '1902-02-02 %' order by auto; select auto from t1 where date_time like '1902-02-02 %' order by auto;
select auto from t1 where date_time not like '1902-02-02 %' order by auto; select auto from t1 where date_time not like '1902-02-02 %' order by auto;
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
--replace_column 9 # --replace_column 9 #
explain select auto from t1 where date_time like '1902-02-02 %'; explain select auto from t1 where date_time like '1902-02-02 %';
select auto from t1 where date_time like '1902-02-02 %' order by auto; select auto from t1 where date_time like '1902-02-02 %' order by auto;
...@@ -1701,12 +1701,12 @@ insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); ...@@ -1701,12 +1701,12 @@ insert into t1 values (1,'a'), (2,'ab'), (3,'abc');
# in TUP the constants 'ab' 'abc' were expected in varchar format # in TUP the constants 'ab' 'abc' were expected in varchar format
# "like" returned error which became "false" # "like" returned error which became "false"
# scan filter negates "or" which exposes the bug # scan filter negates "or" which exposes the bug
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
select * from t1 where b like 'ab' or b like 'ab'; select * from t1 where b like 'ab' or b like 'ab';
select * from t1 where b like 'abc'; select * from t1 where b like 'abc';
select * from t1 where b like 'abc' or b like 'abc'; select * from t1 where b like 'abc' or b like 'abc';
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
select * from t1 where b like 'ab' or b like 'ab'; select * from t1 where b like 'ab' or b like 'ab';
select * from t1 where b like 'abc'; select * from t1 where b like 'abc';
...@@ -1719,12 +1719,12 @@ engine=ndb; ...@@ -1719,12 +1719,12 @@ engine=ndb;
insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); insert into t1 values (1,'a'), (2,'ab'), (3,'abc');
# test that incorrect MySQL behaviour is preserved # test that incorrect MySQL behaviour is preserved
# 'ab ' LIKE 'ab' is true in MySQL # 'ab ' LIKE 'ab' is true in MySQL
set engine_condition_pushdown = off; set optimizer_switch = "engine_condition_pushdown=off";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
select * from t1 where b like 'ab' or b like 'ab'; select * from t1 where b like 'ab' or b like 'ab';
select * from t1 where b like 'abc'; select * from t1 where b like 'abc';
select * from t1 where b like 'abc' or b like 'abc'; select * from t1 where b like 'abc' or b like 'abc';
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
select * from t1 where b like 'ab'; select * from t1 where b like 'ab';
select * from t1 where b like 'ab' or b like 'ab'; select * from t1 where b like 'ab' or b like 'ab';
select * from t1 where b like 'abc'; select * from t1 where b like 'abc';
...@@ -1736,9 +1736,9 @@ create table t1 ( fname varchar(255), lname varchar(255) ) ...@@ -1736,9 +1736,9 @@ create table t1 ( fname varchar(255), lname varchar(255) )
engine=ndbcluster; engine=ndbcluster;
insert into t1 values ("Young","Foo"); insert into t1 values ("Young","Foo");
set engine_condition_pushdown = 0; set optimizer_switch = "engine_condition_pushdown=off";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
set engine_condition_pushdown = 1; set optimizer_switch = "engine_condition_pushdown=on";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
# make sure optimizer does not do some crazy shortcut # make sure optimizer does not do some crazy shortcut
...@@ -1747,9 +1747,9 @@ insert into t1 values ("bbb", "bbb"); ...@@ -1747,9 +1747,9 @@ insert into t1 values ("bbb", "bbb");
insert into t1 values ("ccc", "ccc"); insert into t1 values ("ccc", "ccc");
insert into t1 values ("ddd", "ddd"); insert into t1 values ("ddd", "ddd");
set engine_condition_pushdown = 0; set optimizer_switch = "engine_condition_pushdown=off";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
set engine_condition_pushdown = 1; set optimizer_switch = "engine_condition_pushdown=on";
SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%');
# bug#29390 (scan filter is too large, discarded) # bug#29390 (scan filter is too large, discarded)
...@@ -1766,7 +1766,7 @@ insert into t1 values (30,3,300,0+0x3333); ...@@ -1766,7 +1766,7 @@ insert into t1 values (30,3,300,0+0x3333);
insert into t1 values (40,4,400,0+0x4444); insert into t1 values (40,4,400,0+0x4444);
insert into t1 values (50,5,500,0+0x5555); insert into t1 values (50,5,500,0+0x5555);
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
select a,b,d from t1 select a,b,d from t1
where b in (0,1,2,5) where b in (0,1,2,5)
...@@ -2050,5 +2050,5 @@ select a,b,d from t1 ...@@ -2050,5 +2050,5 @@ select a,b,d from t1
order by b; order by b;
--enable_query_log --enable_query_log
set engine_condition_pushdown = @old_ecpd; set optimizer_switch = @old_optimizer_switch;
DROP TABLE t1,t2,t3,t4,t5; DROP TABLE t1,t2,t3,t4,t5;
--source include/have_ndb.inc --source include/have_ndb.inc
SET storage_engine=ndbcluster; SET storage_engine=ndbcluster;
--source include/gis_generic.inc --source include/gis_generic.inc
set engine_condition_pushdown = on; set optimizer_switch = "engine_condition_pushdown=on";
--source include/gis_generic.inc --source include/gis_generic.inc
...@@ -112,11 +112,11 @@ insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NU ...@@ -112,11 +112,11 @@ insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NU
select * from t2 where c IS NULL order by a; select * from t2 where c IS NULL order by a;
select * from t2 where b = 3 AND c IS NULL order by a; select * from t2 where b = 3 AND c IS NULL order by a;
select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a; select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a;
set @old_ecpd = @@session.engine_condition_pushdown; set @old_optimizer_switch = @@session.optimizer_switch;
set engine_condition_pushdown = true; set optimizer_switch = "engine_condition_pushdown=on";
explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
set engine_condition_pushdown = @old_ecpd; set optimizer_switch = @old_optimizer_switch;
drop table t2; drop table t2;
......
SET @start_global_value = @@global.optimizer_switch; SET @start_global_value = @@global.optimizer_switch;
SELECT @start_global_value; SELECT @start_global_value;
@start_global_value @start_global_value
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
select @@global.optimizer_switch; select @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
select @@session.optimizer_switch; select @@session.optimizer_switch;
@@session.optimizer_switch @@session.optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
show global variables like 'optimizer_switch'; show global variables like 'optimizer_switch';
Variable_name Value Variable_name Value
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
show session variables like 'optimizer_switch'; show session variables like 'optimizer_switch';
Variable_name Value Variable_name Value
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
select * from information_schema.global_variables where variable_name='optimizer_switch'; select * from information_schema.global_variables where variable_name='optimizer_switch';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
select * from information_schema.session_variables where variable_name='optimizer_switch'; select * from information_schema.session_variables where variable_name='optimizer_switch';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
set global optimizer_switch=10; set global optimizer_switch=10;
select @@global.optimizer_switch; select @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,engine_condition_pushdown=off
set session optimizer_switch=5; set session optimizer_switch=5;
select @@session.optimizer_switch; select @@session.optimizer_switch;
@@session.optimizer_switch @@session.optimizer_switch
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,engine_condition_pushdown=off
set global optimizer_switch="index_merge_sort_union=on"; set global optimizer_switch="index_merge_sort_union=on";
select @@global.optimizer_switch; select @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=off
set session optimizer_switch="index_merge=off"; set session optimizer_switch="index_merge=off";
select @@session.optimizer_switch; select @@session.optimizer_switch;
@@session.optimizer_switch @@session.optimizer_switch
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,engine_condition_pushdown=off
set session optimizer_switch="default"; set session optimizer_switch="default";
select @@session.optimizer_switch; select @@session.optimizer_switch;
@@session.optimizer_switch @@session.optimizer_switch
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=off
set global optimizer_switch=1.1; set global optimizer_switch=1.1;
ERROR 42000: Incorrect argument type to variable 'optimizer_switch' ERROR 42000: Incorrect argument type to variable 'optimizer_switch'
set global optimizer_switch=1e1; set global optimizer_switch=1e1;
...@@ -51,4 +51,4 @@ ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'foobar' ...@@ -51,4 +51,4 @@ ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'foobar'
SET @@global.optimizer_switch = @start_global_value; SET @@global.optimizer_switch = @start_global_value;
SELECT @@global.optimizer_switch; SELECT @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
...@@ -40,6 +40,10 @@ SELECT @session_start_value; ...@@ -40,6 +40,10 @@ SELECT @session_start_value;
SET @global_start_value = @@global.engine_condition_pushdown; SET @global_start_value = @@global.engine_condition_pushdown;
SELECT @global_start_value; SELECT @global_start_value;
# same for optimizer_switch
select @old_session_opt_switch:=@@session.optimizer_switch,
@old_global_opt_switch:=@@global.optimizer_switch;
--echo '#--------------------FN_DYNVARS_028_01------------------------#' --echo '#--------------------FN_DYNVARS_028_01------------------------#'
######################################################################## ########################################################################
# Display the DEFAULT value of engine_condition_pushdown # # Display the DEFAULT value of engine_condition_pushdown #
...@@ -204,6 +208,44 @@ SELECT @@global.engine_condition_pushdown; ...@@ -204,6 +208,44 @@ SELECT @@global.engine_condition_pushdown;
SET @@global.engine_condition_pushdown = FALSE; SET @@global.engine_condition_pushdown = FALSE;
SELECT @@global.engine_condition_pushdown; SELECT @@global.engine_condition_pushdown;
--echo Check that @@engine_condition_pushdown influences
--echo @@optimizer_switch and vice-versa
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@session.engine_condition_pushdown = TRUE;
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@session.engine_condition_pushdown = FALSE;
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@global.engine_condition_pushdown = TRUE;
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@global.engine_condition_pushdown = FALSE;
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@session.optimizer_switch = "engine_condition_pushdown=on";
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@session.optimizer_switch = "engine_condition_pushdown=off";
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@global.optimizer_switch = "engine_condition_pushdown=on";
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
set @@global.optimizer_switch = "engine_condition_pushdown=off";
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
############################## ##############################
# Restore initial value # # Restore initial value #
############################## ##############################
...@@ -214,6 +256,12 @@ SELECT @@session.engine_condition_pushdown; ...@@ -214,6 +256,12 @@ SELECT @@session.engine_condition_pushdown;
SET @@global.engine_condition_pushdown = @global_start_value; SET @@global.engine_condition_pushdown = @global_start_value;
SELECT @@global.engine_condition_pushdown; SELECT @@global.engine_condition_pushdown;
set @session.optimizer_switch=@old_session_opt_switch,
@@global.optimizer_switch=@old_global_opt_switch;
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
############################################################### ###############################################################
# END OF engine_condition_pushdown TESTS # # END OF engine_condition_pushdown TESTS #
############################################################### ###############################################################
--optimizer-switch=engine_condition_pushdown=off --engine-condition-pushdown=1
# check how --engine-condition-pushdown and --optimizer-switch
# influence each other when used together (last wins).
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
--engine-condition-pushdown=1 --optimizer-switch=engine_condition_pushdown=off
# check how --engine-condition-pushdown and --optimizer-switch
# influence each other when used together (last wins).
select @@session.engine_condition_pushdown,
@@global.engine_condition_pushdown,
@@session.optimizer_switch, @@global.optimizer_switch;
...@@ -622,17 +622,19 @@ class Default_object_creation_ctx : public Object_creation_ctx ...@@ -622,17 +622,19 @@ class Default_object_creation_ctx : public Object_creation_ctx
#define MODE_PAD_CHAR_TO_FULL_LENGTH (ULL(1) << 31) #define MODE_PAD_CHAR_TO_FULL_LENGTH (ULL(1) << 31)
/* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */ /* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */
#define OPTIMIZER_SWITCH_INDEX_MERGE 1 #define OPTIMIZER_SWITCH_INDEX_MERGE (1ULL << 0)
#define OPTIMIZER_SWITCH_INDEX_MERGE_UNION 2 #define OPTIMIZER_SWITCH_INDEX_MERGE_UNION (1ULL << 1)
#define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION 4 #define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION (1ULL << 2)
#define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT 8 #define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT (1ULL << 3)
#define OPTIMIZER_SWITCH_LAST 16 #define OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN (1ULL << 4)
#define OPTIMIZER_SWITCH_LAST (1ULL << 5)
/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */ /* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \ #define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \ OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \ OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT) OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN)
/* /*
...@@ -2636,7 +2638,8 @@ enum options_mysqld ...@@ -2636,7 +2638,8 @@ enum options_mysqld
OPT_SSL_CIPHER, OPT_SSL_CIPHER,
OPT_SSL_KEY, OPT_SSL_KEY,
OPT_UPDATE_LOG, OPT_UPDATE_LOG,
OPT_WANT_CORE OPT_WANT_CORE,
OPT_ENGINE_CONDITION_PUSHDOWN
}; };
#endif /* MYSQL_SERVER */ #endif /* MYSQL_SERVER */
......
...@@ -6995,6 +6995,18 @@ mysqld_get_one_option(int optid, ...@@ -6995,6 +6995,18 @@ mysqld_get_one_option(int optid,
} }
break; break;
#endif /* defined(ENABLED_DEBUG_SYNC) */ #endif /* defined(ENABLED_DEBUG_SYNC) */
case OPT_ENGINE_CONDITION_PUSHDOWN:
/*
The last of --engine-condition-pushdown and --optimizer_switch on
command line wins (see get_options().
*/
if (global_system_variables.engine_condition_pushdown)
global_system_variables.optimizer_switch|=
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN;
else
global_system_variables.optimizer_switch&=
~OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN;
break;
} }
return 0; return 0;
} }
...@@ -7216,6 +7228,11 @@ static int get_options(int *argc,char **argv) ...@@ -7216,6 +7228,11 @@ static int get_options(int *argc,char **argv)
else else
pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */ pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */
#endif #endif
global_system_variables.engine_condition_pushdown=
test(global_system_variables.optimizer_switch &
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN);
return 0; return 0;
} }
......
...@@ -270,7 +270,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, ...@@ -270,7 +270,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
thd->variables.read_buff_size); thd->variables.read_buff_size);
} }
/* Condition pushdown to storage engine */ /* Condition pushdown to storage engine */
if (thd->variables.engine_condition_pushdown && if ((thd->variables.optimizer_switch &
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) &&
select && select->cond && select && select->cond &&
(select->cond->used_tables() & table->map) && (select->cond->used_tables() & table->map) &&
!table->file->pushed_cond) !table->file->pushed_cond)
......
...@@ -43,8 +43,8 @@ install-data-local: ...@@ -43,8 +43,8 @@ install-data-local:
$(DESTDIR)$(pkgdatadir)/$$lang/errmsg.sys; \ $(DESTDIR)$(pkgdatadir)/$$lang/errmsg.sys; \
done done
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/charsets $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/charsets
$(INSTALL_DATA) $(srcdir)/errmsg-utf8.txt \ $(INSTALL_DATA) $(srcdir)/errmsg-utf8.txt \
$(DESTDIR)$(pkgdatadir)/errmsg-utf8.txt; \ $(DESTDIR)$(pkgdatadir)/errmsg-utf8.txt; \
$(INSTALL_DATA) $(srcdir)/charsets/README $(DESTDIR)$(pkgdatadir)/charsets/README $(INSTALL_DATA) $(srcdir)/charsets/README $(DESTDIR)$(pkgdatadir)/charsets/README
$(INSTALL_DATA) $(srcdir)/charsets/*.xml $(DESTDIR)$(pkgdatadir)/charsets $(INSTALL_DATA) $(srcdir)/charsets/*.xml $(DESTDIR)$(pkgdatadir)/charsets
......
...@@ -6347,7 +6347,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) ...@@ -6347,7 +6347,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
/* Push condition to storage engine if this is enabled /* Push condition to storage engine if this is enabled
and the condition is not guarded */ and the condition is not guarded */
tab->table->file->pushed_cond= NULL; tab->table->file->pushed_cond= NULL;
if (thd->variables.engine_condition_pushdown) if (thd->variables.optimizer_switch &
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN)
{ {
COND *push_cond= COND *push_cond=
make_cond_for_table(tmp, current_map, current_map); make_cond_for_table(tmp, current_map, current_map);
...@@ -16630,7 +16631,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, ...@@ -16630,7 +16631,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
{ {
const COND *pushed_cond= tab->table->file->pushed_cond; const COND *pushed_cond= tab->table->file->pushed_cond;
if (thd->variables.engine_condition_pushdown && pushed_cond) if ((thd->variables.optimizer_switch &
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) && pushed_cond)
{ {
extra.append(STRING_WITH_LEN("; Using where with pushed " extra.append(STRING_WITH_LEN("; Using where with pushed "
"condition")); "condition"));
......
...@@ -1114,16 +1114,28 @@ static Sys_var_ulong Sys_optimizer_search_depth( ...@@ -1114,16 +1114,28 @@ static Sys_var_ulong Sys_optimizer_search_depth(
static const char *optimizer_switch_names[]= static const char *optimizer_switch_names[]=
{ {
"index_merge", "index_merge_union", "index_merge_sort_union", "index_merge", "index_merge_union", "index_merge_sort_union",
"index_merge_intersection", "index_merge_intersection", "engine_condition_pushdown",
"default", NullS "default", NullS
}; };
/** propagates changes to @@engine_condition_pushdown */
static bool fix_optimizer_switch(sys_var *self, THD *thd,
enum_var_type type)
{
SV *sv= (type == OPT_GLOBAL) ? &global_system_variables : &thd->variables;
sv->engine_condition_pushdown=
test(sv->optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN);
return false;
}
static Sys_var_flagset Sys_optimizer_switch( static Sys_var_flagset Sys_optimizer_switch(
"optimizer_switch", "optimizer_switch",
"optimizer_switch=option=val[,option=val...], where option is one of " "optimizer_switch=option=val[,option=val...], where option is one of "
"{index_merge, index_merge_union, index_merge_sort_union, " "{index_merge, index_merge_union, index_merge_sort_union, "
"index_merge_intersection} and val is one of {on, off, default}", "index_merge_intersection, engine_condition_pushdown}"
" and val is one of {on, off, default}",
SESSION_VAR(optimizer_switch), CMD_LINE(REQUIRED_ARG), SESSION_VAR(optimizer_switch), CMD_LINE(REQUIRED_ARG),
optimizer_switch_names, DEFAULT(OPTIMIZER_SWITCH_DEFAULT)); optimizer_switch_names, DEFAULT(OPTIMIZER_SWITCH_DEFAULT),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL),
ON_UPDATE(fix_optimizer_switch));
static Sys_var_charptr Sys_pid_file( static Sys_var_charptr Sys_pid_file(
"pid_file", "Pid file used by safe_mysqld", "pid_file", "Pid file used by safe_mysqld",
...@@ -1820,11 +1832,26 @@ static Sys_var_ulong Sys_net_wait_timeout( ...@@ -1820,11 +1832,26 @@ static Sys_var_ulong Sys_net_wait_timeout(
VALID_RANGE(1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)), VALID_RANGE(1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)),
DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1)); DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1));
/** propagates changes to the relevant flag of @@optimizer_switch */
static bool fix_engine_condition_pushdown(sys_var *self, THD *thd,
enum_var_type type)
{
SV *sv= (type == OPT_GLOBAL) ? &global_system_variables : &thd->variables;
if (sv->engine_condition_pushdown)
sv->optimizer_switch|= OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN;
else
sv->optimizer_switch&= ~OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN;
return false;
}
static Sys_var_mybool Sys_engine_condition_pushdown( static Sys_var_mybool Sys_engine_condition_pushdown(
"engine_condition_pushdown", "engine_condition_pushdown",
"Push supported query conditions to the storage engine", "Push supported query conditions to the storage engine."
SESSION_VAR(engine_condition_pushdown), CMD_LINE(OPT_ARG), " Deprecated, use --optimizer-switch instead.",
DEFAULT(TRUE)); SESSION_VAR(engine_condition_pushdown),
CMD_LINE(OPT_ARG, OPT_ENGINE_CONDITION_PUSHDOWN),
DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL),
ON_UPDATE(fix_engine_condition_pushdown),
DEPRECATED(70000, "'@@optimizer_switch'"));
static Sys_var_plugin Sys_default_storage_engine( static Sys_var_plugin Sys_default_storage_engine(
"default_storage_engine", "The default storage engine for new tables", "default_storage_engine", "The default storage engine for new tables",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment