Commit d294aae6 authored by Sergey Petrunya's avatar Sergey Petrunya

MWL#17: Table elimination: last fixes

- Add an @@optimizer_switch flag for table_elimination for debug build
- Better comments 

mysql-test/t/index_merge_myisam.test:
  MWL#17: Table elimination: last fixes
  - Add an @@optimizer_switch flag for table_elimination for debug build
sql/mysql_priv.h:
  MWL#17: Table elimination: last fixes
  - Add an @@optimizer_switch flag for table_elimination for debug build
sql/mysqld.cc:
  MWL#17: Table elimination: last fixes
  - Add an @@optimizer_switch flag for table_elimination for debug build
parent 21d25739
...@@ -25,15 +25,19 @@ let $merge_table_support= 1; ...@@ -25,15 +25,19 @@ let $merge_table_support= 1;
--echo # we get another @@optimizer_switch user) --echo # we get another @@optimizer_switch user)
--echo # --echo #
--replace_regex /,table_elimination=on//
select @@optimizer_switch; select @@optimizer_switch;
set optimizer_switch='index_merge=off,index_merge_union=off'; set optimizer_switch='index_merge=off,index_merge_union=off';
--replace_regex /,table_elimination=on//
select @@optimizer_switch; select @@optimizer_switch;
set optimizer_switch='index_merge_union=on'; set optimizer_switch='index_merge_union=on';
--replace_regex /,table_elimination=on//
select @@optimizer_switch; select @@optimizer_switch;
set optimizer_switch='default,index_merge_sort_union=off'; set optimizer_switch='default,index_merge_sort_union=off';
--replace_regex /,table_elimination=on//
select @@optimizer_switch; select @@optimizer_switch;
--error ER_WRONG_VALUE_FOR_VAR --error ER_WRONG_VALUE_FOR_VAR
...@@ -71,17 +75,21 @@ set optimizer_switch='default,index_merge=on,index_merge=off,default'; ...@@ -71,17 +75,21 @@ set optimizer_switch='default,index_merge=on,index_merge=off,default';
set optimizer_switch=default; 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';
--replace_regex /,table_elimination=on//
select @@optimizer_switch; select @@optimizer_switch;
set optimizer_switch=default; set optimizer_switch=default;
# Check setting defaults for global vars # Check setting defaults for global vars
--replace_regex /,table_elimination=on//
select @@global.optimizer_switch; select @@global.optimizer_switch;
set @@global.optimizer_switch=default; set @@global.optimizer_switch=default;
--replace_regex /,table_elimination=on//
select @@global.optimizer_switch; select @@global.optimizer_switch;
--echo # --echo #
--echo # Check index_merge's @@optimizer_switch flags --echo # Check index_merge's @@optimizer_switch flags
--echo # --echo #
--replace_regex /,table_elimination.on//
select @@optimizer_switch; select @@optimizer_switch;
create table t0 (a int); create table t0 (a int);
...@@ -182,6 +190,7 @@ set optimizer_switch='default,index_merge_union=off'; ...@@ -182,6 +190,7 @@ set optimizer_switch='default,index_merge_union=off';
explain select * from t1 where a=10 and b=10 or c=10; explain select * from t1 where a=10 and b=10 or c=10;
set optimizer_switch=default; set optimizer_switch=default;
--replace_regex /,table_elimination.on//
show variables like 'optimizer_switch'; show variables like 'optimizer_switch';
drop table t0, t1; drop table t0, t1;
......
...@@ -528,14 +528,27 @@ protected: ...@@ -528,14 +528,27 @@ protected:
#define OPTIMIZER_SWITCH_INDEX_MERGE_UNION 2 #define OPTIMIZER_SWITCH_INDEX_MERGE_UNION 2
#define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION 4 #define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION 4
#define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT 8 #define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT 8
#define OPTIMIZER_SWITCH_LAST 16
/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */ #ifdef DBUG_OFF
#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \ # define OPTIMIZER_SWITCH_LAST 16
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \ #else
OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \ # define OPTIMIZER_SWITCH_TABLE_ELIMINATION 16
OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT) # define OPTIMIZER_SWITCH_LAST 32
#endif
#ifdef DBUG_OFF
/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
# define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT)
#else
# define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \
OPTIMIZER_SWITCH_TABLE_ELIMINATION)
#endif
/* /*
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
......
...@@ -297,9 +297,14 @@ TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"", ...@@ -297,9 +297,14 @@ TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"",
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", "default", NullS "index_merge_intersection",
#ifndef DBUG_OFF
"table_elimination",
#endif
"default", NullS
}; };
/* Corresponding defines are named OPTIMIZER_SWITCH_XXX */ /* Corresponding defines are named OPTIMIZER_SWITCH_XXX */
static const unsigned int optimizer_switch_names_len[]= static const unsigned int optimizer_switch_names_len[]=
{ {
...@@ -307,6 +312,9 @@ static const unsigned int optimizer_switch_names_len[]= ...@@ -307,6 +312,9 @@ static const unsigned int optimizer_switch_names_len[]=
sizeof("index_merge_union") - 1, sizeof("index_merge_union") - 1,
sizeof("index_merge_sort_union") - 1, sizeof("index_merge_sort_union") - 1,
sizeof("index_merge_intersection") - 1, sizeof("index_merge_intersection") - 1,
#ifndef DBUG_OFF
sizeof("table_elimination") - 1,
#endif
sizeof("default") - 1 sizeof("default") - 1
}; };
TYPELIB optimizer_switch_typelib= { array_elements(optimizer_switch_names)-1,"", TYPELIB optimizer_switch_typelib= { array_elements(optimizer_switch_names)-1,"",
...@@ -382,7 +390,10 @@ static const char *sql_mode_str= "OFF"; ...@@ -382,7 +390,10 @@ static const char *sql_mode_str= "OFF";
/* Text representation for OPTIMIZER_SWITCH_DEFAULT */ /* Text representation for OPTIMIZER_SWITCH_DEFAULT */
static const char *optimizer_switch_str="index_merge=on,index_merge_union=on," static const char *optimizer_switch_str="index_merge=on,index_merge_union=on,"
"index_merge_sort_union=on," "index_merge_sort_union=on,"
"index_merge_intersection=on"; "index_merge_intersection=on"
#ifndef DBUG_OFF
",table_elimination=on";
#endif
static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr; static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr;
static char *opt_init_slave, *language_ptr, *opt_init_connect; static char *opt_init_slave, *language_ptr, *opt_init_connect;
static char *default_character_set_name; static char *default_character_set_name;
...@@ -6929,8 +6940,11 @@ The minimum value for this variable is 4096.", ...@@ -6929,8 +6940,11 @@ The minimum value for this variable is 4096.",
0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0}, 0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
{"optimizer_switch", OPT_OPTIMIZER_SWITCH, {"optimizer_switch", OPT_OPTIMIZER_SWITCH,
"optimizer_switch=option=val[,option=val...], where option={index_merge, " "optimizer_switch=option=val[,option=val...], where option={index_merge, "
"index_merge_union, index_merge_sort_union, index_merge_intersection} and " "index_merge_union, index_merge_sort_union, index_merge_intersection"
"val={on, off, default}.", #ifndef DBUG_OFF
", table_elimination"
#endif
"} and val={on, off, default}.",
(uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG, (uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG,
/*OPTIMIZER_SWITCH_DEFAULT*/0, /*OPTIMIZER_SWITCH_DEFAULT*/0,
0, 0, 0, 0, 0}, 0, 0, 0, 0, 0},
......
This diff is collapsed.
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