
[Commits] a56def32ddd: MDEV-18632: wsrep_is_wsrep_xid: Conditional jump or move depends on uninitialised value
by jan 19 Feb '19
by jan 19 Feb '19
19 Feb '19
revision-id: a56def32ddd428f5adbee8ea4c0b081f0cfcdde0 (mariadb-10.3.6-142-ga56def32ddd)
parent(s): f2f0c2004408a38a428d6c6346a8f2d2d69cd599
author: Jan Lindström
committer: Jan Lindström
timestamp: 2019-02-19 16:11:06 +0200
message:
MDEV-18632: wsrep_is_wsrep_xid: Conditional jump or move depends on uninitialised value
Transaction XID is not initialized before transaction is started.
---
mysql-test/suite/innodb/r/innodb-rollback.result | 10 ++++++++++
mysql-test/suite/innodb/t/innodb-rollback.test | 17 +++++++++++++++++
storage/innobase/handler/ha_innodb.cc | 2 +-
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/mysql-test/suite/innodb/r/innodb-rollback.result b/mysql-test/suite/innodb/r/innodb-rollback.result
new file mode 100644
index 00000000000..5eca7ad6967
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-rollback.result
@@ -0,0 +1,10 @@
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+connect con1,localhost,root,,test;
+ALTER TABLE t1;
+connect con2,localhost,root,,test;
+SELECT f() FROM t1;
+ERROR 42000: FUNCTION test.f does not exist
+disconnect con2;
+disconnect con1;
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-rollback.test b/mysql-test/suite/innodb/t/innodb-rollback.test
new file mode 100644
index 00000000000..1d3e05b021f
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-rollback.test
@@ -0,0 +1,17 @@
+--source include/have_innodb.inc
+
+#
+# MDEV-18632: wsrep_is_wsrep_xid: Conditional jump or move depends on uninitialised value
+#
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+--connect (con1,localhost,root,,test)
+ALTER TABLE t1;
+--connect (con2,localhost,root,,test)
+--error ER_SP_DOES_NOT_EXIST
+SELECT f() FROM t1;
+
+# Cleanup
+--disconnect con2
+--disconnect con1
+--connection default
+DROP TABLE t1;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b0e58872ad8..5727934d23f 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4712,7 +4712,7 @@ innobase_rollback(
trx is being rolled back due to BF abort, clear XID in order
to avoid writing it to rollback segment out of order. The XID
will be reassigned when the transaction is replayed. */
- if (wsrep_is_wsrep_xid(trx->xid)) {
+ if (trx->state != TRX_STATE_NOT_STARTED && wsrep_is_wsrep_xid(trx->xid)) {
trx->xid->null();
}
#endif /* WITH_WSREP */
1
0

[Commits] cee6548379e: Don't build aws_key_management plugin by default
by Oleksandr Byelkin 19 Feb '19
by Oleksandr Byelkin 19 Feb '19
19 Feb '19
revision-id: cee6548379ec8a58f4a9e17224bcb6ae6b2a983a (mariadb-10.1.38-7-gcee6548379e)
parent(s): 346e46089621e6951e076c82ed5690aa23dcb5fe
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2019-02-19 12:38:51 +0100
message:
Don't build aws_key_management plugin by default
---
CMakeLists.txt | 2 +-
cmake/readline.cmake | 2 +-
configure.cmake | 2 +-
plugin/aws_key_management/CMakeLists.txt | 6 ++++++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ef8786aff12..358f73ccfdd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -500,5 +500,5 @@ ENDIF()
IF(NON_DISTRIBUTABLE_WARNING)
MESSAGE(WARNING "
-You have linked MariaDB with GPLv3 libraries! You may not distribute the resulting binary. If you do, you will put yourself into a legal problem with Free Software Foundation.")
+You have linked MariaDB with ${NON_DISTRIBUTABLE_WARNING} libraries! You may not distribute the resulting binary. If you do, you will put yourself into a legal problem with the Free Software Foundation.")
ENDIF()
diff --git a/cmake/readline.cmake b/cmake/readline.cmake
index d03fe503882..9cfbe4f0d55 100644
--- a/cmake/readline.cmake
+++ b/cmake/readline.cmake
@@ -157,7 +157,7 @@ MACRO (MYSQL_FIND_SYSTEM_READLINE)
SET(USE_NEW_READLINE_INTERFACE 1)
ELSE()
IF(NOT_FOR_DISTRIBUTION)
- SET(NON_DISTRIBUTABLE_WARNING 1)
+ SET(NON_DISTRIBUTABLE_WARNING "GPLv3")
SET(USE_NEW_READLINE_INTERFACE 1)
ELSE()
SET(USE_NEW_READLINE_INTERFACE 0)
diff --git a/configure.cmake b/configure.cmake
index d37dccbea4a..38165e5b444 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -258,7 +258,7 @@ SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DPACKAGE=test) # b
CHECK_INCLUDE_FILES (bfd.h BFD_H_EXISTS)
IF(BFD_H_EXISTS)
IF(NOT_FOR_DISTRIBUTION)
- SET(NON_DISTRIBUTABLE_WARNING 1)
+ SET(NON_DISTRIBUTABLE_WARNING "GPLv3")
SET(HAVE_BFD_H 1)
ENDIF()
ENDIF()
diff --git a/plugin/aws_key_management/CMakeLists.txt b/plugin/aws_key_management/CMakeLists.txt
index 9221b54ef7e..49f6b54a24c 100644
--- a/plugin/aws_key_management/CMakeLists.txt
+++ b/plugin/aws_key_management/CMakeLists.txt
@@ -22,11 +22,17 @@ MACRO(SKIP_AWS_PLUGIN msg)
ENDMACRO()
SET(CMAKE_CXX_STANDARD 11)
+IF(NOT NOT_FOR_DISTRIBUTION)
+ SKIP_AWS_PLUGIN("AWS SDK has Apache 2.0 License which is not complatible with GPLv2. Set -DNOT_FOR_DISTRIBUTION=ON if you need this plugin")
+ENDIF()
+
MYSQL_ADD_PLUGIN(aws_key_management aws_key_management_plugin.cc DISABLED
COMPONENT aws-key-management)
IF(NOT TARGET aws_key_management)
RETURN()
+ELSE()
+ SET(NON_DISTRIBUTABLE_WARNING "Apache 2.0" PARENT_SCOPE)
ENDIF()
# This plugin needs recent C++ compilers (AWS C++ SDK header files are using C++11 features)
1
0
revision-id: 2e73c5612071274bf2b8893a59c12c030b3b5c8b (mariadb-10.3.6-130-g2e73c56)
parent(s): 8283d7d2c029cb520214ae7d33af8851acc80892 764429271dc94e5af08706dd0ac6fb962c15726d
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-19 03:18:17 -0800
message:
Merge branch '10.4' into bb-10.4-mdev7486
mysql-test/main/analyze_format_json.result | 10 +-
mysql-test/main/analyze_stmt_orderby.result | 6 +-
mysql-test/main/cte_recursive.result | 12 +-
mysql-test/main/derived_cond_pushdown.result | 140 +++++++++---------
mysql-test/main/except.result | 12 +-
mysql-test/main/explain_json.result | 16 +--
mysql-test/main/in_subq_cond_pushdown.result | 4 +-
mysql-test/main/intersect.result | 6 +-
mysql-test/main/myisam_mrr,64bit.rdiff | 13 ++
mysql-test/main/myisam_mrr.test | 1 +
mysql-test/main/mysqld--help.result | 9 +-
mysql-test/main/range.result | 20 +++
mysql-test/main/range.test | 23 +++
mysql-test/main/range_mrr_icp.result | 20 +++
mysql-test/main/range_vs_index_merge.result | 98 ++++++-------
mysql-test/main/range_vs_index_merge_innodb.result | 60 ++++----
mysql-test/main/statistics.result | 107 ++++++++++++++
mysql-test/main/statistics.test | 91 ++++++++++++
.../suite/sys_vars/r/optimizer_switch_basic.result | 16 +--
.../sys_vars/r/sysvars_server_embedded.result | 26 +++-
.../sys_vars/r/sysvars_server_notembedded.result | 26 +++-
sql/CMakeLists.txt | 6 -
sql/mysql_install_db.cc | 26 +++-
sql/sql_class.h | 1 +
sql/sql_priv.h | 5 +-
sql/sql_statistics.cc | 157 ++++++++++++++++-----
sql/sys_vars.cc | 11 +-
.../mysql-test/tokudb/r/ext_key_1_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_1_tokudb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_tokudb.result | 2 +-
31 files changed, 672 insertions(+), 258 deletions(-)
diff --cc mysql-test/main/mysqld--help.result
index e611c9b,65fda40..bff1696
--- a/mysql-test/main/mysqld--help.result
+++ b/mysql-test/main/mysqld--help.result
@@@ -1572,7 -1576,7 +1577,7 @@@ old-style-user-limits FALS
optimizer-prune-level 1
optimizer-search-depth 62
optimizer-selectivity-sampling-limit 100
- optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
optimizer-trace
optimizer-trace-max-mem-size 1048576
optimizer-use-condition-selectivity 4
diff --cc mysql-test/suite/sys_vars/r/optimizer_switch_basic.result
index c6b782e,7243860..74f4fd1
--- a/mysql-test/suite/sys_vars/r/optimizer_switch_basic.result
+++ b/mysql-test/suite/sys_vars/r/optimizer_switch_basic.result
@@@ -1,25 -1,25 +1,25 @@@
SET @start_global_value = @@global.optimizer_switch;
SELECT @start_global_value;
@start_global_value
- index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
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,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
select @@session.optimizer_switch;
@@session.optimizer_switch
- index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
show global variables like 'optimizer_switch';
Variable_name Value
- optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
show session variables like 'optimizer_switch';
Variable_name Value
- optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
select * from information_schema.global_variables where variable_name='optimizer_switch';
VARIABLE_NAME VARIABLE_VALUE
- OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
select * from information_schema.session_variables where variable_name='optimizer_switch';
VARIABLE_NAME VARIABLE_VALUE
- OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
set global optimizer_switch=10;
set session optimizer_switch=5;
select @@global.optimizer_switch;
@@@ -69,4 -69,4 +69,4 @@@ ERROR 42000: Variable 'optimizer_switch
SET @@global.optimizer_switch = @start_global_value;
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,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
diff --cc mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
index 6428c4b,67cab18..816adba
--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
@@@ -2743,10 -2757,10 +2757,10 @@@ ENUM_VALUE_LIST NUL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_SWITCH
- SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
- GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
-GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
++GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
GLOBAL_VALUE_ORIGIN COMPILE-TIME
- DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
VARIABLE_SCOPE SESSION
VARIABLE_TYPE FLAGSET
VARIABLE_COMMENT Fine-tune the optimizer behavior
diff --cc mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index f9bc7d3,35ce738..ea0f569
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@@ -2967,10 -2981,10 +2981,10 @@@ ENUM_VALUE_LIST NUL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_SWITCH
- SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
- GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
-GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
++GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
GLOBAL_VALUE_ORIGIN COMPILE-TIME
- DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
VARIABLE_SCOPE SESSION
VARIABLE_TYPE FLAGSET
VARIABLE_COMMENT Fine-tune the optimizer behavior
diff --cc sql/sql_priv.h
index 0f28f5b,13ecbe9..3744dfc
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@@ -262,9 -262,9 +262,10 @@@
OPTIMIZER_SWITCH_ORDERBY_EQ_PROP | \
OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_DERIVED | \
OPTIMIZER_SWITCH_SPLIT_MATERIALIZED | \
-- OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_SUBQUERY |\
- OPTIMIZER_SWITCH_USE_ROWID_FILTER |\
++ OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_SUBQUERY | \
+ OPTIMIZER_SWITCH_USE_ROWID_FILTER | \
- OPTIMIZER_SWITCH_COND_PUSHDOWN_FROM_HAVING)
++ OPTIMIZER_SWITCH_COND_PUSHDOWN_FROM_HAVING | \
+ OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE)
/*
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
diff --cc storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
index b156f66,17270ac..b24c2fa
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
@@@ -1,7 -1,7 +1,7 @@@
drop table if exists t;
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,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --cc storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
index 0c0f8db,0ea5a45..8b7f4d8
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
@@@ -1,7 -1,7 +1,7 @@@
drop table if exists t;
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,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=tokudb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --cc storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
index 1193a27,58bc4bc..8e95644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
@@@ -1,7 -1,7 +1,7 @@@
drop table if exists t;
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,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=innodb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
diff --cc storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
index 21284ed,dbcbe39..740e78f
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
@@@ -1,7 -1,7 +1,7 @@@
drop table if exists t;
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,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
++index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,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=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=tokudb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
1
0

19 Feb '19
revision-id: 5e6a3a090998496e15ef8c46294b4e702a29684d (mariadb-10.3.6-128-g5e6a3a0)
parent(s): 4de3fd4ea29be8ed9f9b6ad83de523c21ff8c9d7
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-19 02:44:27 -0800
message:
MDEV-7486: Condition pushdown from HAVING into WHERE
Optimized the code that removed multiple equalities pushed from HAVING
into WHERE. Now this removal is postponed until all multiple equalities
are eliminated in substitute_for_best_equal_field().
---
mysql-test/main/having.result | 2 +-
mysql-test/main/having_cond_pushdown.result | 2 +-
mysql-test/main/union.result | 2 +-
sql/item.cc | 4 --
sql/item.h | 5 +-
sql/item_cmpfunc.cc | 4 --
sql/item_cmpfunc.h | 19 +------
sql/opt_subselect.cc | 84 -----------------------------
sql/sql_lex.cc | 54 +++++++------------
sql/sql_select.cc | 23 ++++----
10 files changed, 36 insertions(+), 163 deletions(-)
diff --git a/mysql-test/main/having.result b/mysql-test/main/having.result
index 18066c9..b1cd776 100644
--- a/mysql-test/main/having.result
+++ b/mysql-test/main/having.result
@@ -483,7 +483,7 @@ HAVING (table2.f2 = 8);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where 0 group by `test`.`table1`.`f1`,7 having 1
+Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where 0 group by `test`.`table1`.`f1`,7 having multiple equal(8, 7)
DROP TABLE t1;
#
# Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355
diff --git a/mysql-test/main/having_cond_pushdown.result b/mysql-test/main/having_cond_pushdown.result
index 1555638..9d2fbce 100644
--- a/mysql-test/main/having_cond_pushdown.result
+++ b/mysql-test/main/having_cond_pushdown.result
@@ -1596,7 +1596,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 5,
"filtered": 100,
- "attached_condition": "t1.c = t1.a and t1.a > 1 or t1.a < 3"
+ "attached_condition": "t1.a > 1 and t1.c = t1.a or t1.a < 3"
}
}
}
diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result
index a7688a1..e975e0f 100644
--- a/mysql-test/main/union.result
+++ b/mysql-test/main/union.result
@@ -2332,7 +2332,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
2 UNION NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 /* select#1 */ select 1 AS `1`,2 AS `2` union all /* select#2 */ select 1 AS `i`,count(0) AS `COUNT(*)` from `test`.`t2` where 0 group by 1 having 1
+Note 1003 /* select#1 */ select 1 AS `1`,2 AS `2` union all /* select#2 */ select 1 AS `i`,count(0) AS `COUNT(*)` from `test`.`t2` where 0 group by 1 having multiple equal(10, `i`)
DROP TABLE t1,t2;
#
# Start of 10.3 tests
diff --git a/sql/item.cc b/sql/item.cc
index e5b833b..a6b4402 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -7309,7 +7309,6 @@ Item *Item::build_pushable_cond(THD *thd,
{
List<Item> equalities;
Item *new_cond= NULL;
- Item_equal *item_equal= (Item_equal *)this;
if (((Item_equal *)this)->create_pushable_equalities(thd, &equalities,
checker, arg) ||
(equalities.elements == 0))
@@ -7325,9 +7324,6 @@ Item *Item::build_pushable_cond(THD *thd,
equalities,
&cond_value,
false);
- if (equalities.elements ==
- (item_equal->elements_count()-1) && item_equal->upper_levels)
- item_equal->upper_levels->work_references--;
return new_cond;
}
diff --git a/sql/item.h b/sql/item.h
index 4feaebf..2691a69 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -151,8 +151,9 @@ bool mark_unsupported_function(const char *w1, const char *w2,
#define NO_EXTRACTION_FL (1 << 6)
#define FULL_EXTRACTION_FL (1 << 7)
-#define SUBSTITUTION_FL (1 << 8)
-#define EXTRACTION_MASK (NO_EXTRACTION_FL | FULL_EXTRACTION_FL)
+#define DELETION_FL (1 << 8)
+#define SUBSTITUTION_FL (1 << 9)
+#define EXTRACTION_MASK (NO_EXTRACTION_FL | FULL_EXTRACTION_FL | DELETION_FL)
extern const char *item_empty_name;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index b4ff4ab..55a0625 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -6509,8 +6509,6 @@ Item_equal::Item_equal(THD *thd, Item_equal *item_equal):
with_const= item_equal->with_const;
cond_false= item_equal->cond_false;
upper_levels= item_equal->upper_levels;
- if (item_equal->upper_levels)
- item_equal->upper_levels->increase_references();
}
@@ -7353,8 +7351,6 @@ Item_equal::excl_dep_on_group_fields_for_having_pushdown(st_select_lex *sel)
{
if (item->excl_dep_on_group_fields_for_having_pushdown(sel))
{
- if (upper_levels)
- upper_levels->references--;
set_extraction_flag(FULL_EXTRACTION_FL);
return true;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index e85c8fe..ed9dc5f 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -3223,17 +3223,12 @@ class COND_EQUAL: public Sql_alloc
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
List<Item_equal> current_level; /* list of multiple equalities of
the current and level */
- uint references; /* number of conditions that have
- reference on this COND_EQUAL */
- uint work_references; /* same as references */
COND_EQUAL()
{
upper_levels= 0;
- references= 0;
- work_references= 0;
}
COND_EQUAL(Item_equal *item, MEM_ROOT *mem_root)
- :upper_levels(0), references(0), work_references(0)
+ :upper_levels(0)
{
current_level.push_back(item, mem_root);
}
@@ -3241,8 +3236,6 @@ class COND_EQUAL: public Sql_alloc
{
max_members= cond_equal.max_members;
upper_levels= cond_equal.upper_levels;
- references= cond_equal.references;
- work_references= cond_equal.work_references;
if (cond_equal.current_level.is_empty())
current_level.empty();
else
@@ -3252,16 +3245,6 @@ class COND_EQUAL: public Sql_alloc
{
return (current_level.elements == 0);
}
- void increase_references()
- {
- references++;
- work_references++;
- }
- void clean_references()
- {
- references= 0;
- work_references= 0;
- }
};
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 4f45d77..1db1fbc 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -5554,82 +5554,6 @@ int select_value_catcher::send_data(List<Item> &items)
/**
@brief
- Set missing links on multiply equalities
-
- @param thd the thread handle
- @param cond the condition to set links for
- @param inherited path to all inherited multiple equality items
- @param build_cond_equal flag to control if COND_EQUAL for AND-condition
- should be built
-
- @details
- The method traverses cond and set links for the upper COND_EQUAL levels
- where needed.
- If build_cond_equal is set to true it builds for each AND-level except the
- external one COND_EQUAL.
-*/
-
-static
-void set_cond_equal_links(THD *thd, Item *cond, COND_EQUAL *inherited,
- bool build_cond_equal)
-{
- if (cond->type() == Item::FUNC_ITEM &&
- ((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)
- {
- ((Item_equal *)cond)->upper_levels= inherited;
- if (inherited)
- inherited->increase_references();
- }
-
- if (cond->type() != Item::COND_ITEM)
- return;
-
- List_iterator<Item> it(*((Item_cond *)cond)->argument_list());
- Item *item;
- while ((item=it++))
- {
- if (item->type() != Item::COND_ITEM ||
- ((Item_cond*) item)->functype() != Item_func::COND_AND_FUNC)
- {
- set_cond_equal_links(thd, item, inherited, build_cond_equal);
- continue;
- }
- Item_cond_and *and_item= (Item_cond_and *)item;
- if (build_cond_equal)
- {
- COND_EQUAL new_cond_equal;
- List_iterator<Item> li(*and_item->argument_list());
- Item *elem;
-
- while ((elem=li++))
- {
- if (elem->type() == Item::FUNC_ITEM &&
- ((Item_func*) elem)->functype() == Item_func::MULT_EQUAL_FUNC)
- {
- if (new_cond_equal.current_level.push_back((Item_equal *)elem,
- thd->mem_root))
- return;
- li.remove();
- }
- }
- List<Item> *equal_list=
- (List<Item> *)&and_item->m_cond_equal.current_level;
- and_item->m_cond_equal.copy(new_cond_equal);
- and_item->argument_list()->append(equal_list);
- }
- and_item->m_cond_equal.upper_levels= inherited;
- and_item->m_cond_equal.clean_references();
- if (inherited)
- inherited->increase_references();
-
- set_cond_equal_links(thd, item, &and_item->m_cond_equal,
- build_cond_equal);
- }
-}
-
-
-/**
- @brief
Conjunct conditions after optimize_cond() call
@param thd the thread handle
@@ -5658,7 +5582,6 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
bool build_cond_equal)
{
COND_EQUAL new_cond_equal;
- COND_EQUAL *inherited= 0;
Item *item;
Item_equal *equality;
bool is_simplified_cond= false;
@@ -5731,7 +5654,6 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
and_args->append((List<Item> *) cond_equalities);
*cond_eq= &((Item_cond_and *) cond)->m_cond_equal;
- inherited= &((Item_cond_and *)cond)->m_cond_equal;
propagate_new_equalities(thd, cond, cond_equalities,
cond_equal->upper_levels,
@@ -5815,7 +5737,6 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
and_cond->m_cond_equal.copy(new_cond_equal);
cond= (Item *)and_cond;
*cond_eq= &((Item_cond_and *)cond)->m_cond_equal;
- inherited= &((Item_cond_and *)cond)->m_cond_equal;
}
else
{
@@ -5840,11 +5761,6 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
if (is_simplified_cond)
cond= cond->remove_eq_conds(thd, cond_value, true);
- if (cond)
- {
- set_cond_equal_links(thd, cond, inherited, build_cond_equal);
- }
-
return cond;
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index c71754b..c4c1419 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -7759,8 +7759,8 @@ void binlog_unsafe_map_init()
@param thd The thread handle
@details
- This method looks through the fields that are used in the GROUP BY of this
- st_select_lex and saves onfo on these fields.
+ This method looks through the fields that are used in the GROUP BY of this
+ st_select_lex and saves info on these fields.
*/
void st_select_lex::collect_grouping_fields_for_derived(THD *thd,
@@ -7874,9 +7874,6 @@ st_select_lex::check_cond_extraction_for_grouping_fields(THD *thd, Item *cond,
cond->set_extraction_flag(NO_EXTRACTION_FL);
if (count_full == arg_list->elements)
{
- if (and_cond != 0 && !and_cond->m_cond_equal.is_empty() &&
- and_cond->m_cond_equal.upper_levels)
- and_cond->m_cond_equal.upper_levels->work_references--;
cond->set_extraction_flag(FULL_EXTRACTION_FL);
}
if (cond->get_extraction_flag() != 0)
@@ -9969,9 +9966,12 @@ bool cleanup_condition_pushed_from_having(THD *thd, Item *cond)
As in the pushdown from HAVING into WHERE conditions are not just cloned
so they can be later pushed down as it is for pushdown into materialized
derived tables/views or IN subqueries, but also should be removed from
- the HAVING clause there comes a problem with multiple equalities removal.
- It is solved with the removal from multiple equalities list 'm_cond_equal'
- of 'cond' conditions that are marked with the FULL_EXTRACTION_FLAG flag.
+ the HAVING clause.
+ The multiple equalities of the HAVING clause are not removed in this
+ function, but rather marked as to be removed later. Their removal is
+ done in substitute_for_best_equal_field() called for HAVING at the moment
+ when all multiple equalities referencing the top level multiple equalities
+ have been already eliminated.
@retval
condition without removed subformulas
@@ -9983,6 +9983,12 @@ Item *remove_pushed_top_conjuncts_for_having(THD *thd, Item *cond)
if (cond->get_extraction_flag() == FULL_EXTRACTION_FL)
{
cond->clear_extraction_flag();
+ if (cond->type() == Item::FUNC_ITEM &&
+ ((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)
+ {
+ cond->set_extraction_flag(DELETION_FL);
+ return cond;
+ }
return 0;
}
if (cond->type() != Item::COND_ITEM)
@@ -9991,32 +9997,6 @@ Item *remove_pushed_top_conjuncts_for_having(THD *thd, Item *cond)
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
List<Item> *cond_arg_list= ((Item_cond_and *)cond)->argument_list();
- List<Item_equal> *cond_equalities=
- &((Item_cond_and*) cond)->m_cond_equal.current_level;
- cond_arg_list->disjoin((List<Item> *) cond_equalities);
- List_iterator<Item_equal> it(*cond_equalities);
- Item_equal *eq_item;
-
- if (((Item_cond_and*) cond)->m_cond_equal.work_references == 0)
- {
- while ((eq_item= it++))
- {
- if (eq_item->get_extraction_flag() == FULL_EXTRACTION_FL)
- {
- eq_item->clear_extraction_flag();
- it.remove();
- }
- }
- ((Item_cond_and*) cond)->m_cond_equal.clean_references();
- }
- else
- {
- while ((eq_item= it++))
- eq_item->clear_extraction_flag();
- ((Item_cond_and*) cond)->m_cond_equal.work_references=
- ((Item_cond_and*) cond)->m_cond_equal.references;
- }
- cond_arg_list->append((List<Item> *) cond_equalities);
List_iterator<Item> li(*cond_arg_list);
Item *item;
while ((item= li++))
@@ -10024,7 +10004,11 @@ Item *remove_pushed_top_conjuncts_for_having(THD *thd, Item *cond)
if (item->get_extraction_flag() == FULL_EXTRACTION_FL)
{
item->clear_extraction_flag();
- li.remove();
+ if (item->type() == Item::FUNC_ITEM &&
+ ((Item_func*) item)->functype() == Item_func::MULT_EQUAL_FUNC)
+ item->set_extraction_flag(DELETION_FL);
+ else
+ li.remove();
}
}
switch (cond_arg_list->elements)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c598532..94968cc 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2290,7 +2290,8 @@ int JOIN::optimize_stage2()
DBUG_PRINT("error",("Error from substitute_for_best_equal"));
DBUG_RETURN(1);
}
- having->update_used_tables();
+ if (having)
+ having->update_used_tables();
DBUG_EXECUTE("having",
print_where(having,
"after substitute_best_equal",
@@ -5210,11 +5211,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
{
if (*s->on_expr_ref && s->cond_equal &&
s->cond_equal->upper_levels == orig_cond_equal)
- {
s->cond_equal->upper_levels= join->cond_equal;
- if (s->cond_equal->upper_levels)
- s->cond_equal->upper_levels->references++;
- }
}
}
}
@@ -14775,8 +14772,6 @@ COND *Item_func_eq::build_equal_items(THD *thd,
set_if_bigger(thd->lex->current_select->max_equal_elems,
item_equal->n_field_items());
item_equal->upper_levels= inherited;
- if (inherited)
- inherited->increase_references();
if (cond_equal_ref)
*cond_equal_ref= new (thd->mem_root) COND_EQUAL(item_equal,
thd->mem_root);
@@ -14811,8 +14806,6 @@ COND *Item_func_eq::build_equal_items(THD *thd,
and_cond->update_used_tables();
if (cond_equal_ref)
*cond_equal_ref= &and_cond->m_cond_equal;
- if (inherited)
- inherited->increase_references();
return and_cond;
}
}
@@ -14938,8 +14931,6 @@ static COND *build_equal_items(JOIN *join, COND *cond,
if (*cond_equal_ref)
{
(*cond_equal_ref)->upper_levels= inherited;
- if (inherited)
- inherited->increase_references();
inherited= *cond_equal_ref;
}
}
@@ -15175,7 +15166,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
((Item_func *) cond)->functype() == Item_func::EQ_FUNC) ||
(cond->type() == Item::COND_ITEM &&
((Item_func *) cond)->functype() == Item_func::COND_AND_FUNC));
-
+
/*
Pick the "head" item: the constant one or the first in the join order
(if the first in the join order happends to be inside an SJM nest, that's
@@ -15442,8 +15433,12 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,
COND *eq_cond= 0;
List_iterator_fast<Item_equal> it(cond_equal->current_level);
bool false_eq_cond= FALSE;
+ bool all_deleted= true;
while ((item_equal= it++))
{
+ if (item_equal->get_extraction_flag() == DELETION_FL)
+ continue;
+ all_deleted= false;
eq_cond= eliminate_item_equal(thd, eq_cond, cond_equal->upper_levels,
item_equal);
if (!eq_cond)
@@ -15482,7 +15477,7 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,
}
}
}
- if (!eq_cond)
+ if (!eq_cond && !all_deleted)
{
/*
We are out of memory doing the transformation.
@@ -15501,6 +15496,8 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,
cond_equal= item_equal->upper_levels;
if (cond_equal && cond_equal->current_level.head() == item_equal)
cond_equal= cond_equal->upper_levels;
+ if (item_equal->get_extraction_flag() == DELETION_FL)
+ return 0;
cond= eliminate_item_equal(thd, 0, cond_equal, item_equal);
return cond ? cond : org_cond;
}
1
0

[Commits] 531645545cf: MDEV-18601: Can't create table with ENCRYPTED=DEFAULT when innodb_default_encryption_key_id!=1
by jan 19 Feb '19
by jan 19 Feb '19
19 Feb '19
revision-id: 531645545cf295c6564238fbc84a463b7919d844 (mariadb-10.1.37-82-g531645545cf)
parent(s): 698df0a1ae0f72199afb71dc560552ce00c4dc35
author: Jan Lindström
committer: Jan Lindström
timestamp: 2019-02-19 10:28:13 +0200
message:
MDEV-18601: Can't create table with ENCRYPTED=DEFAULT when innodb_default_encryption_key_id!=1
Allow creating and altering table even when used key_id or default key_id
is not system default 1.
ha_innobase::check_table_options
Ignore key_id table option when user has
explicitly requested no encryption or if default encryption
is used and encryption is disabled. Issue only a warning
as used key_id value is not stored InnoDB data dictionary
and encryption metadata is not created on page 0 of the table.
---
.../encryption/r/innodb-encryption-alter.result | 51 +++++++++-------------
.../encryption/t/innodb-encryption-alter.test | 23 +++++-----
storage/innobase/handler/ha_innodb.cc | 31 +++++--------
storage/xtradb/handler/ha_innodb.cc | 31 +++++--------
4 files changed, 55 insertions(+), 81 deletions(-)
diff --git a/mysql-test/suite/encryption/r/innodb-encryption-alter.result b/mysql-test/suite/encryption/r/innodb-encryption-alter.result
index 5245d1da7d0..8765a0f65cf 100644
--- a/mysql-test/suite/encryption/r/innodb-encryption-alter.result
+++ b/mysql-test/suite/encryption/r/innodb-encryption-alter.result
@@ -4,7 +4,7 @@ SET GLOBAL innodb_encrypt_tables = ON;
SET GLOBAL innodb_encryption_threads = 4;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4;
Warnings:
-Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 4 when encryption is disabled
+Warning 140 InnoDB: ENCRYPTION_KEY_ID=4 ignored when ENCRYPTED=NO
DROP TABLE t1;
set innodb_default_encryption_key_id = 99;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
@@ -41,7 +41,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4
CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
Warnings:
-Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 1 when encryption is disabled
+Warning 140 InnoDB: ENCRYPTION_KEY_ID=1 ignored when ENCRYPTED=NO
ALTER TABLE t1 ENCRYPTION_KEY_ID=99;
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
SHOW WARNINGS;
@@ -50,40 +50,29 @@ Warning 140 InnoDB: ENCRYPTION_KEY_ID 99 not available
Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
set innodb_default_encryption_key_id = 1;
drop table t1,t2;
+set innodb_default_encryption_key_id = 10;
SET GLOBAL innodb_encrypt_tables=OFF;
CREATE TABLE t1 (a int not null primary key) engine=innodb;
ALTER TABLE t1 ENCRYPTION_KEY_ID=4;
-ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
-SHOW WARNINGS;
-Level Code Message
-Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
-Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
-SHOW CREATE TABLE t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` int(11) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
+Warnings:
+Warning 140 InnoDB: ENCRYPTION_KEY_ID=4 ignored when innodb_encrypt_tables=OFF
+ALTER TABLE t1 ENCRYPTION_KEY_ID=8, ALGORITHM=COPY;
+Warnings:
+Warning 140 InnoDB: ENCRYPTION_KEY_ID=8 ignored when innodb_encrypt_tables=OFF
DROP TABLE t1;
-CREATE TABLE t2 (a int not null primary key) engine=innodb;
-ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
-ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
+CREATE TABLE t1 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
+Warnings:
+Warning 140 InnoDB: ENCRYPTION_KEY_ID=4 ignored when innodb_encrypt_tables=OFF
SHOW WARNINGS;
Level Code Message
-Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
-Error 1005 Can't create table `test`.`#sql-temporary` (errno: 140 "Wrong create options")
-Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
-SHOW CREATE TABLE t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` int(11) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-DROP TABLE t2;
-CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
-ERROR HY000: Can't create table `test`.`t3` (errno: 140 "Wrong create options")
+Warning 140 InnoDB: ENCRYPTION_KEY_ID=4 ignored when innodb_encrypt_tables=OFF
+ALTER TABLE t1 ENCRYPTION_KEY_ID=10;
+DROP TABLE t1;
+CREATE TABLE t1 (a int not null primary key) engine=innodb ENCRYPTED=NO ENCRYPTION_KEY_ID=10;
SHOW WARNINGS;
Level Code Message
-Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
-Error 1005 Can't create table `test`.`t3` (errno: 140 "Wrong create options")
-Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
+ALTER TABLE t1 ENCRYPTION_KEY_ID=1;
+Warnings:
+Warning 140 InnoDB: ENCRYPTION_KEY_ID=1 ignored when ENCRYPTED=NO
+DROP TABLE t1;
+set innodb_default_encryption_key_id = 1;
diff --git a/mysql-test/suite/encryption/t/innodb-encryption-alter.test b/mysql-test/suite/encryption/t/innodb-encryption-alter.test
index 9465226dd96..d1bcafa8767 100644
--- a/mysql-test/suite/encryption/t/innodb-encryption-alter.test
+++ b/mysql-test/suite/encryption/t/innodb-encryption-alter.test
@@ -89,27 +89,26 @@ drop table t1,t2;
#
# MDEV-17230: encryption_key_id from alter is ignored by encryption threads
+# MDEV-18601: Can't create table with ENCRYPTED=DEFAULT when innodb_default_encryption_key_id!=1
#
+set innodb_default_encryption_key_id = 10;
SET GLOBAL innodb_encrypt_tables=OFF;
CREATE TABLE t1 (a int not null primary key) engine=innodb;
---error ER_ILLEGAL_HA_CREATE_OPTION
ALTER TABLE t1 ENCRYPTION_KEY_ID=4;
-SHOW WARNINGS;
-SHOW CREATE TABLE t1;
+ALTER TABLE t1 ENCRYPTION_KEY_ID=8, ALGORITHM=COPY;
DROP TABLE t1;
-CREATE TABLE t2 (a int not null primary key) engine=innodb;
---replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/
---error ER_CANT_CREATE_TABLE
-ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
---replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/
+CREATE TABLE t1 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
SHOW WARNINGS;
-SHOW CREATE TABLE t2;
-DROP TABLE t2;
+ALTER TABLE t1 ENCRYPTION_KEY_ID=10;
+DROP TABLE t1;
---error ER_CANT_CREATE_TABLE
-CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
+CREATE TABLE t1 (a int not null primary key) engine=innodb ENCRYPTED=NO ENCRYPTION_KEY_ID=10;
SHOW WARNINGS;
+ALTER TABLE t1 ENCRYPTION_KEY_ID=1;
+DROP TABLE t1;
+
+set innodb_default_encryption_key_id = 1;
# reset system
--disable_query_log
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index fc97b1dc104..ec6d7b7c5b9 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -11882,30 +11882,23 @@ ha_innobase::check_table_options(
}
}
- /* Ignore nondefault key_id if encryption is set off */
- if (encrypt == FIL_ENCRYPTION_OFF &&
- options->encryption_key_id != THDVAR(thd, default_encryption_key_id)) {
+ /* We should ignore key_id table option when user has
+ explicitly requested no encryption or if default encryption
+ is used and encryption is disabled. */
+ const uint key_id = THDVAR(thd, default_encryption_key_id);
+ if ((encrypt == FIL_ENCRYPTION_OFF
+ || (encrypt == FIL_ENCRYPTION_DEFAULT && !srv_encrypt_tables))
+ && options->encryption_key_id != key_id) {
push_warning_printf(
thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
- "InnoDB: Ignored ENCRYPTION_KEY_ID %u when encryption is disabled",
- (uint)options->encryption_key_id
+ "InnoDB: ENCRYPTION_KEY_ID=%u ignored when %s",
+ (uint)options->encryption_key_id,
+ encrypt == FIL_ENCRYPTION_OFF ? "ENCRYPTED=NO"
+ : "innodb_encrypt_tables=OFF"
);
- options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY;
- }
- /* If default encryption is used and encryption is disabled, you may
- not use nondefault encryption_key_id as it is not stored anywhere. */
- if (encrypt == FIL_ENCRYPTION_DEFAULT
- && !srv_encrypt_tables
- && options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) {
- compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1);
- push_warning_printf(
- thd, Sql_condition::WARN_LEVEL_WARN,
- HA_WRONG_CREATE_OPTION,
- "InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1"
- );
- return "ENCRYPTION_KEY_ID";
+ options->encryption_key_id = key_id;
}
/* Check atomic writes requirements */
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index f4e0420519e..02a5a8901ad 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -12451,30 +12451,23 @@ ha_innobase::check_table_options(
}
}
- /* Ignore nondefault key_id if encryption is set off */
- if (encrypt == FIL_ENCRYPTION_OFF &&
- options->encryption_key_id != THDVAR(thd, default_encryption_key_id)) {
+ /* We should ignore key_id table option when user has
+ explicitly requested no encryption or if default encryption
+ is used and encryption is disabled. */
+ const uint key_id = THDVAR(thd, default_encryption_key_id);
+ if ((encrypt == FIL_ENCRYPTION_OFF
+ || (encrypt == FIL_ENCRYPTION_DEFAULT && !srv_encrypt_tables))
+ && options->encryption_key_id != key_id) {
push_warning_printf(
thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
- "InnoDB: Ignored ENCRYPTION_KEY_ID %u when encryption is disabled",
- (uint)options->encryption_key_id
+ "InnoDB: ENCRYPTION_KEY_ID=%u ignored when %s",
+ (uint)options->encryption_key_id,
+ encrypt == FIL_ENCRYPTION_OFF ? "ENCRYPTED=NO"
+ : "innodb_encrypt_tables=OFF"
);
- options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY;
- }
- /* If default encryption is used and encryption is disabled, you may
- not use nondefault encryption_key_id as it is not stored anywhere. */
- if (encrypt == FIL_ENCRYPTION_DEFAULT
- && !srv_encrypt_tables
- && options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) {
- compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1);
- push_warning_printf(
- thd, Sql_condition::WARN_LEVEL_WARN,
- HA_WRONG_CREATE_OPTION,
- "InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1"
- );
- return "ENCRYPTION_KEY_ID";
+ options->encryption_key_id = key_id;
}
/* Check atomic writes requirements */
1
0
revision-id: 4de3fd4ea29be8ed9f9b6ad83de523c21ff8c9d7 (mariadb-10.3.6-127-g4de3fd4)
parent(s): 97419304900c5ef4ee228c1c41efe0c38f26882c
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-18 22:11:25 -0800
message:
MDEV-7486: Cosmetic changes
- Removed dead code
- Renamed a function
- Removed a parameter that not needed.
- Corrected comments
---
sql/sql_lex.cc | 104 +++++++++++++++++++--------------------------------------
sql/sql_lex.h | 3 +-
2 files changed, 36 insertions(+), 71 deletions(-)
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 4893ba0..c71754b 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -7754,13 +7754,13 @@ void binlog_unsafe_map_init()
/**
@brief
- Finding fiels that are used in the GROUP BY of this st_select_lex
+ Collect fiels that are used in the GROUP BY of this st_select_lex
@param thd The thread handle
@details
- This method looks through the fields which are used in the GROUP BY of this
- st_select_lex and saves this fields.
+ This method looks through the fields that are used in the GROUP BY of this
+ st_select_lex and saves onfo on these fields.
*/
void st_select_lex::collect_grouping_fields_for_derived(THD *thd,
@@ -7826,7 +7826,7 @@ bool st_select_lex::collect_grouping_fields(THD *thd)
This method traverses the AND-OR condition cond and for each subformula of
the condition it checks whether it can be usable for the extraction of a
condition over the grouping fields of this select. The method uses
- the call-back parameter checker to ckeck whether a primary formula
+ the call-back parameter checker to check whether a primary formula
depends only on grouping fields.
The subformulas that are not usable are marked with the flag NO_EXTRACTION_FL.
The subformulas that can be entierly extracted are marked with the flag
@@ -7870,7 +7870,7 @@ st_select_lex::check_cond_extraction_for_grouping_fields(THD *thd, Item *cond,
else if (!and_cond)
break;
}
- if (item)
+ if ((and_cond && count == 0) || item)
cond->set_extraction_flag(NO_EXTRACTION_FL);
if (count_full == arg_list->elements)
{
@@ -9723,7 +9723,7 @@ void st_select_lex::mark_or_conds_to_avoid_pushdown(Item *cond)
@details
The method finds out what conditions can be extracted from cond depended
only on the grouping fields of this SELECT or fields equal to them.
- If the condition that can be pushed is AND-condition it is splitted out
+ If the condition that can be pushed is AND-condition it is splitted up
and for each its element it is checked if it can be pushed.
Pushable elements are attached to the attach_to_conds list.
If the condition isn't AND-condition it is entirely pushed into
@@ -9745,9 +9745,11 @@ void st_select_lex::mark_or_conds_to_avoid_pushdown(Item *cond)
bool
st_select_lex::build_pushable_cond_for_having_pushdown(THD *thd,
- Item *cond,
- Pushdown_checker checker)
+ Item *cond)
{
+ Pushdown_checker checker=
+ &Item::pushable_equality_checker_for_having_pushdown;
+
bool is_multiple_equality= cond->type() == Item::FUNC_ITEM &&
((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC;
@@ -9862,33 +9864,15 @@ Field_pair *get_corresponding_field_pair(Item *item,
/**
@brief
- Find fields in WHERE clause multiple equalities that can be used in pushdown
+ Collect fields in multiple equalities usable for pushdown from having
@param thd The thread handle
@details
This method looks through the multiple equalities of the WHERE clause
- trying to find any of them which fields are used in the GROUP BY of the
- SELECT. If such multiple equality exists conditions in the HAVING
- clause that use fields of this multiple equality can be pushed down
- into the WHERE clause as well as the conditions depended on the fields
- from the GROUP BY or fields equal to them that are taken from the HAVING
- clause multiple equalities.
-
- Example:
-
- SELECT a,MAX(b),c
- FROM t1
- WHERE (t1.a=t1.c)
- GROUP BY t1.a
- HAVING (t1.c>1)
-
- =>
-
- SELECT a,MAX(b),c
- FROM t1
- WHERE (t1.a=t1.c) AND (t1.c>1)
- GROUP BY t1.a
+ trying to find any of them whose fields are used in the GROUP BY of the
+ SELECT. Any field from these multiple equality is included into the
+ the list of fields against which any candidate for pushing is checked.
@retval
true - if an error occurs
@@ -9909,22 +9893,16 @@ bool st_select_lex::collect_fields_equal_to_grouping(THD *thd)
Item *item;
while ((item= it++))
{
- if (item->type() != Item::FIELD_ITEM &&
- item->type() != Item::REF_ITEM)
- continue;
-
if (get_corresponding_field_pair(item, grouping_tmp_fields))
break;
}
if (!item)
break;
- it.rewind();
+ it.rewind();
while ((item= it++))
{
- if ((item->type() != Item::FIELD_ITEM &&
- item->type() != Item::REF_ITEM) ||
- get_corresponding_field_pair(item, grouping_tmp_fields))
+ if (get_corresponding_field_pair(item, grouping_tmp_fields))
continue;
Field_pair *grouping_tmp_field=
new Field_pair(((Item_field *)item->real_item())->field, item);
@@ -9937,7 +9915,7 @@ bool st_select_lex::collect_fields_equal_to_grouping(THD *thd)
/**
@brief
- Cleanup and fix for the condition that is ready to be pushed down
+ Cleanup and fix of the condition that is ready to be pushed down
@param thd The thread handle
@param cond The condition to be processed
@@ -9954,7 +9932,7 @@ bool st_select_lex::collect_fields_equal_to_grouping(THD *thd)
*/
static
-bool cleanup_inequalities_for_having_pushdown(THD *thd, Item *cond)
+bool cleanup_condition_pushed_from_having(THD *thd, Item *cond)
{
if (cond->type() == Item::FUNC_ITEM &&
((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)
@@ -9966,7 +9944,7 @@ bool cleanup_inequalities_for_having_pushdown(THD *thd, Item *cond)
Item *item;
while ((item=it++))
- cleanup_inequalities_for_having_pushdown(thd, item);
+ cleanup_condition_pushed_from_having(thd, item);
}
else
{
@@ -10075,7 +10053,7 @@ Item *remove_pushed_top_conjuncts_for_having(THD *thd, Item *cond)
This function builds the most restrictive condition depending only on
the fields used in the GROUP BY of this select (directly or indirectly
through equality) that can be extracted from the HAVING clause of this
- select having and pushes it into the WHERE clause of this select.
+ select and pushes it into the WHERE clause of this select.
Example of the transformation:
@@ -10095,11 +10073,11 @@ Item *remove_pushed_top_conjuncts_for_having(THD *thd, Item *cond)
In details:
1. Collect fields used in the GROUP BY grouping_fields of this SELECT
2. Collect fields equal to grouping_fields from the WHERE clause
- of this SELECT and attach them to the grouping_fields list.
- 3. Search for the conditions in the HAVING clause of this select
- that depends only on grouping_fields. Store them in the
- attach_to_conds list.
- 4. Remove pushable conditions from the HAVING clause having.
+ of this SELECT and add them to the grouping_fields list.
+ 3. Extract the most restrictive condition from the HAVING clause of this
+ select that depends only on the grouping fields (directly or indirectly
+ through equality). Store it in the attach_to_conds list.
+ 4. Remove pushable conditions from the HAVING clause if it's possible.
@note
This method is similar to st_select_lex::pushdown_cond_into_where_clause().
@@ -10119,37 +10097,25 @@ Item *st_select_lex::pushdown_from_having_into_where(THD *thd, Item *having)
thd->lex->current_select= this;
/*
- 1. Collect fields used in the GROUP BY grouping_fields of this SELECT
+ 1. Collect fields used in the GROUP BY grouping fields of this SELECT
2. Collect fields equal to grouping_fields from the WHERE clause
- of this SELECT and attach them to the grouping_fields list.
+ of this SELECT and add them to the grouping fields list.
*/
- if (have_window_funcs())
- {
- if (group_list.first || join->implicit_grouping)
- return having;
- ORDER *common_partition_fields=
- find_common_window_func_partition_fields(thd);
- if (!common_partition_fields ||
- collect_grouping_fields(thd) ||
- collect_fields_equal_to_grouping(thd))
- return having;
- }
- else if (collect_grouping_fields(thd) ||
- collect_fields_equal_to_grouping(thd))
+ if (collect_grouping_fields(thd) ||
+ collect_fields_equal_to_grouping(thd))
return having;
/*
- 3. Search for the conditions in the HAVING clause of this select
- that depends only on grouping_fields. Store them in the
- attach_to_conds list.
+ 3. Extract the most restrictive condition from the HAVING clause of this
+ select that depends only on the grouping fields (directly or indirectly
+ through equality). Store it in the attach_to_conds list.
*/
thd->having_pushdown= true;
List_iterator_fast<Item> it(attach_to_conds);
Item *item;
check_cond_extraction_for_grouping_fields(thd, having,
&Item::dep_on_grouping_fields_checker_for_having_pushdown);
- if (build_pushable_cond_for_having_pushdown(thd, having,
- &Item::pushable_equality_checker_for_having_pushdown))
+ if (build_pushable_cond_for_having_pushdown(thd, having))
{
attach_to_conds.empty();
goto exit;
@@ -10157,14 +10123,14 @@ Item *st_select_lex::pushdown_from_having_into_where(THD *thd, Item *having)
if (attach_to_conds.elements != 0)
{
/*
- 4. Remove pushable conditions from the HAVING clause having.
+ 4. Remove pushable conditions from the HAVING clause if it's possible.
*/
having= remove_pushed_top_conjuncts_for_having(thd, having);
it.rewind();
while ((item=it++))
{
- if (cleanup_inequalities_for_having_pushdown(thd, item))
+ if (cleanup_condition_pushed_from_having(thd, item))
{
attach_to_conds.empty();
goto exit;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 93aa714..ee4baba 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1504,8 +1504,7 @@ class st_select_lex: public st_select_lex_node
{ return !olap && !explicit_limit && !tvc; }
bool build_pushable_cond_for_having_pushdown(THD *thd,
- Item *cond,
- Pushdown_checker checker);
+ Item *cond);
void pushdown_cond_into_where_clause(THD *thd, Item *extracted_cond,
Item **remaining_cond,
Item_transformer transformer,
1
0
revision-id: 75bb5e457c268baf8f8956595669fcea4ed04fe2 (mariadb-10.3.12-57-g75bb5e457c2)
parent(s): 5b43dbb33e86cdd073274daf2f67439d00b0ceaa
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2019-02-18 23:51:56 +0100
message:
fix of windows compiler warnings
---
sql/sql_binlog.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index 8801e9a806f..60de2923a8f 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -241,7 +241,7 @@ void mysql_client_binlog_statement(THD* thd)
goto end;
}
- decoded_len= my_base64_needed_decoded_length(coded_len);
+ decoded_len= my_base64_needed_decoded_length((int)coded_len);
if (!(buf= (char *) my_malloc(decoded_len, MYF(MY_WME))))
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 1);
1
0
revision-id: 2c33e6d29d7d9807641f9e3aec74c7a9b188905d (mariadb-10.3.6-138-g2c33e6d29d7)
parent(s): 97e7676834c9a31c4ea10f7a10a69fa43b7d1a57
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2019-02-18 23:40:30 +0100
message:
c
---
sql/group_by_handler.cc | 5 +++-
sql/opt_subselect.cc | 3 ---
sql/sql_class.cc | 13 ----------
sql/sql_class.h | 8 ++++++
sql/sql_delete.cc | 1 +
sql/sql_error.cc | 2 +-
sql/sql_insert.cc | 2 --
sql/sql_lex.h | 27 ++++++--------------
sql/sql_profile.cc | 2 +-
sql/sql_repl.cc | 2 +-
sql/sql_select.cc | 67 ++++++++++++++++++++++++++-----------------------
sql/sql_union.cc | 3 ---
12 files changed, 59 insertions(+), 76 deletions(-)
diff --git a/sql/group_by_handler.cc b/sql/group_by_handler.cc
index f5ed24370b1..70a8d2a88cf 100644
--- a/sql/group_by_handler.cc
+++ b/sql/group_by_handler.cc
@@ -97,7 +97,10 @@ int Pushdown_query::execute(JOIN *join)
{
int error;
/* result < 0 if row was not accepted and should not be counted */
- if (unlikely((error= join->result->send_data(*join->fields))))
+ if (unlikely((error=
+ join->result->send_data_with_check(*join->fields,
+ join->unit,
+ join->send_records))))
{
handler->end_scan();
DBUG_RETURN(error < 0 ? 0 : -1);
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 5362af5cdde..910c9485d56 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -5581,9 +5581,6 @@ int select_value_catcher::send_data(List<Item> &items)
DBUG_ASSERT(!assigned);
DBUG_ASSERT(items.elements == n_elements);
- if (unit->lim.check_and_move_offset())
- DBUG_RETURN(0); // Using limit offset,count
-
Item *val_item;
List_iterator_fast<Item> li(items);
for (uint i= 0; (val_item= li++); i++)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 9166fd203b8..524b58fd9f3 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2977,9 +2977,6 @@ int select_send::send_data(List<Item> &items)
Protocol *protocol= thd->protocol;
DBUG_ENTER("select_send::send_data");
- /* unit is not set when using 'delete ... returning' */
- if (unit && unit->lim.check_and_move_offset())
- DBUG_RETURN(FALSE); // using limit offset,count
if (thd->killed == ABORT_QUERY)
DBUG_RETURN(FALSE);
@@ -3244,8 +3241,6 @@ int select_export::send_data(List<Item> &items)
String tmp(buff,sizeof(buff),&my_charset_bin),*res;
tmp.length(0);
- if (unit->lim.check_and_move_offset())
- DBUG_RETURN(0); // using limit offset,count
if (thd->killed == ABORT_QUERY)
DBUG_RETURN(0);
row_count++;
@@ -3501,8 +3496,6 @@ int select_dump::send_data(List<Item> &items)
Item *item;
DBUG_ENTER("select_dump::send_data");
- if (unit->lim.check_and_move_offset())
- DBUG_RETURN(0); // using limit offset,count
if (thd->killed == ABORT_QUERY)
DBUG_RETURN(0);
@@ -3541,8 +3534,6 @@ int select_singlerow_subselect::send_data(List<Item> &items)
MYF(current_thd->lex->ignore ? ME_WARNING : 0));
DBUG_RETURN(1);
}
- if (unit->lim.check_and_move_offset())
- DBUG_RETURN(0); // Using limit offset,count
if (thd->killed == ABORT_QUERY)
DBUG_RETURN(0);
List_iterator_fast<Item> li(items);
@@ -3679,8 +3670,6 @@ int select_exists_subselect::send_data(List<Item> &items)
{
DBUG_ENTER("select_exists_subselect::send_data");
Item_exists_subselect *it= (Item_exists_subselect *)item;
- if (unit->lim.check_and_move_offset())
- DBUG_RETURN(0); // Using limit offset,count
if (thd->killed == ABORT_QUERY)
DBUG_RETURN(0);
it->value= 1;
@@ -4085,8 +4074,6 @@ int select_dumpvar::send_data(List<Item> &items)
{
DBUG_ENTER("select_dumpvar::send_data");
- if (unit->lim.check_and_move_offset())
- DBUG_RETURN(0); // using limit offset,count
if (row_count++)
{
my_message(ER_TOO_MANY_ROWS, ER_THD(thd, ER_TOO_MANY_ROWS), MYF(0));
diff --git a/sql/sql_class.h b/sql/sql_class.h
index fc8ac86c9e0..befc7a1229b 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5114,6 +5114,14 @@ class select_result_sink: public Sql_alloc
public:
THD *thd;
select_result_sink(THD *thd_arg): thd(thd_arg) {}
+ inline int send_data_with_check(List<Item> &items,
+ SELECT_LEX_UNIT *u,
+ ha_rows sent)
+ {
+ if (u->lim.check_offset(sent))
+ return 0;
+ return send_data(items);
+ }
/*
send_data returns 0 on ok, 1 on error and -1 if data was ignored, for
example for a duplicate row entry written to a temp table.
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 1630d335559..c55d3ee9143 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -742,6 +742,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
break;
}
+ // no LIMIT / OFFSET
if (with_select && result->send_data(select_lex->item_list) < 0)
{
error=1;
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 6bb36dbb089..e20b7422630 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -813,7 +813,7 @@ bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
/* Skip levels that the user is not interested in */
if (!(levels_to_show & ((ulong) 1 << err->get_level())))
continue;
- if (unit->lim.check_and_move_offset())
+ if (unit->lim.check_offset(idx))
continue; // using limit offset,count
if (idx > unit->lim.get_select_limit())
break;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index cd010ebc462..979f4ad6896 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -3838,8 +3838,6 @@ int select_insert::send_data(List<Item> &values)
DBUG_ENTER("select_insert::send_data");
bool error=0;
- if (unit->lim.check_and_move_offset())
- DBUG_RETURN(0); // using limit offset,count
if (unlikely(thd->killed == ABORT_QUERY))
DBUG_RETURN(0);
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index c251972b8ea..e49ff16c06b 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -826,51 +826,38 @@ bool print_explain_for_slow_log(LEX *lex, THD *thd, String *str);
class Select_limit_counters
{
- ha_rows offset_limit_cnt_start,
- select_limit_cnt, offset_limit_cnt;
+ ha_rows select_limit_cnt, offset_limit_cnt;
public:
Select_limit_counters():
- offset_limit_cnt_start(0),
select_limit_cnt(0), offset_limit_cnt(0)
{};
void set_limit(ha_rows limit, ha_rows offset)
{
- offset_limit_cnt_start= offset;
+ offset_limit_cnt= offset;
select_limit_cnt= limit;
- if (select_limit_cnt + offset_limit_cnt_start >=
+ if (select_limit_cnt + offset_limit_cnt >=
select_limit_cnt)
- select_limit_cnt+= offset_limit_cnt_start;
+ select_limit_cnt+= offset_limit_cnt;
else
select_limit_cnt= HA_POS_ERROR;
- reset();
}
void set_single_row()
{
- offset_limit_cnt= offset_limit_cnt_start= 0;
+ offset_limit_cnt= 0;
select_limit_cnt= 1;
}
- void reset()
- {
- offset_limit_cnt= offset_limit_cnt_start;
- }
-
bool is_unlimited()
{ return select_limit_cnt == HA_POS_ERROR; }
void set_unlimited()
{ select_limit_cnt= HA_POS_ERROR; offset_limit_cnt= 0; }
- bool check_and_move_offset()
+ bool check_offset(ha_rows sent)
{
- if (offset_limit_cnt)
- {
- offset_limit_cnt--;
- return TRUE;
- }
- return FALSE;
+ return sent < offset_limit_cnt;
}
void remove_offset() { offset_limit_cnt= 0; }
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index e2b7b18faac..0e937aba6ff 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -438,7 +438,7 @@ bool PROFILING::show_profiles()
double query_time_usecs= prof->m_end_time_usecs - prof->m_start_time_usecs;
- if (unit->lim.check_and_move_offset())
+ if (unit->lim.check_offset(idx))
continue;
if (idx > unit->lim.get_select_limit())
break;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 26ff0e4ece3..64d3f845901 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -4011,7 +4011,7 @@ bool mysql_show_binlog_events(THD* thd)
description_event,
opt_master_verify_checksum)); )
{
- if (!unit->lim.check_and_move_offset() &&
+ if (!unit->lim.check_offset(event_count) &&
ev->net_send(protocol, linfo.log_file_name, pos))
{
errmsg = "Net error";
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2b9f82f7a85..d96b00e0443 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3877,8 +3877,6 @@ JOIN::reinit()
{
DBUG_ENTER("JOIN::reinit");
- unit->lim.reset();
-
first_record= false;
group_sent= false;
cleaned= false;
@@ -4149,7 +4147,8 @@ void JOIN::exec_inner()
{
if (do_send_rows &&
(procedure ? (procedure->send_row(procedure_fields_list) ||
- procedure->end_of_records()) : result->send_data(fields_list)> 0))
+ procedure->end_of_records()):
+ result->send_data_with_check(fields_list, unit, 0)> 0))
error= 1;
else
send_records= ((select_options & OPTION_FOUND_ROWS) ? 1 :
@@ -13974,7 +13973,7 @@ return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables,
{
bool send_error= FALSE;
if (send_row)
- send_error= result->send_data(fields) > 0;
+ send_error= result->send_data_with_check(fields, join->unit, 0) > 0;
if (likely(!send_error))
result->send_eof(); // Should be safe
}
@@ -19403,33 +19402,34 @@ do_select(JOIN *join, Procedure *procedure)
HAVING will be checked after processing aggregate functions,
But WHERE should checked here (we alredy have read tables).
Notice that make_join_select() splits all conditions in this case
- into two groups exec_const_cond and outer_ref_cond.
- If join->table_count == join->const_tables then it is
- sufficient to check only the condition pseudo_bits_cond.
- */
- DBUG_ASSERT(join->outer_ref_cond == NULL);
- if (!join->pseudo_bits_cond || join->pseudo_bits_cond->val_int())
- {
- // HAVING will be checked by end_select
- error= (*end_select)(join, 0, 0);
- if (error >= NESTED_LOOP_OK)
- error= (*end_select)(join, 0, 1);
-
- /*
- If we don't go through evaluate_join_record(), do the counting
- here. join->send_records is increased on success in end_send(),
- so we don't touch it here.
+ into two groups exec_const_cond and outer_ref_cond.
+ If join->table_count == join->const_tables then it is
+ sufficient to check only the condition pseudo_bits_cond.
*/
- join->join_examined_rows++;
- DBUG_ASSERT(join->join_examined_rows <= 1);
- }
- else if (join->send_row_on_empty_set())
- {
- if (!join->having || join->having->val_int())
+ DBUG_ASSERT(join->outer_ref_cond == NULL);
+ if (!join->pseudo_bits_cond || join->pseudo_bits_cond->val_int())
{
- List<Item> *columns_list= (procedure ? &join->procedure_fields_list :
+ // HAVING will be checked by end_select
+ error= (*end_select)(join, 0, 0);
+ if (error >= NESTED_LOOP_OK)
+ error= (*end_select)(join, 0, 1);
+
+ /*
+ If we don't go through evaluate_join_record(), do the counting
+ here. join->send_records is increased on success in end_send(),
+ so we don't touch it here.
+ */
+ join->join_examined_rows++;
+ DBUG_ASSERT(join->join_examined_rows <= 1);
+ }
+ else if (join->send_row_on_empty_set())
+ {
+ if (!join->having || join->having->val_int())
+ {
+ List<Item> *columns_list= (procedure ? &join->procedure_fields_list :
join->fields);
- rc= join->result->send_data(*columns_list) > 0;
+ rc= join->result->send_data_with_check(*columns_list,
+ join->unit, 0) > 0;
}
}
/*
@@ -21104,7 +21104,9 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{
int error;
/* result < 0 if row was not accepted and should not be counted */
- if (unlikely((error= join->result->send_data(*fields))))
+ if (unlikely((error= join->result->send_data_with_check(*fields,
+ join->unit,
+ 0))))
{
if (error > 0)
DBUG_RETURN(NESTED_LOOP_ERROR);
@@ -21252,7 +21254,9 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{
if (join->do_send_rows)
{
- error=join->result->send_data(*fields);
+ error= join->result->send_data_with_check(*fields,
+ join->unit,
+ join->send_records);
if (unlikely(error < 0))
{
/* Duplicate row, don't count */
@@ -25401,7 +25405,8 @@ int JOIN::rollup_send_data(uint idx)
if ((!having || having->val_int()))
{
if (send_records < unit->lim.get_select_limit() && do_send_rows &&
- (res= result->send_data(rollup.fields[i])) > 0)
+ (res= result->send_data_with_check(rollup.fields[i],
+ unit, send_records)) > 0)
return 1;
if (!res)
send_records++;
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index d563301a339..6a841f178e1 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -110,8 +110,6 @@ int select_unit::send_data(List<Item> &values)
{
int rc;
int not_reported_error= 0;
- if (unit->lim.check_and_move_offset())
- return 0; // using limit offset,count
if (thd->killed == ABORT_QUERY)
return 0;
if (table->no_rows_with_nulls)
@@ -1474,7 +1472,6 @@ bool st_select_lex_unit::exec()
}
if (!sl->tvc)
saved_error= sl->join->error;
- lim.reset();
if (likely(!saved_error))
{
examined_rows+= thd->get_examined_row_count();
1
0

[Commits] 97419304900: MDEV-18636 The test case for bug mdev-16765 crashes the server
by Galina 18 Feb '19
by Galina 18 Feb '19
18 Feb '19
revision-id: 97419304900c5ef4ee228c1c41efe0c38f26882c (mariadb-10.3.6-126-g97419304900)
parent(s): d25af33116edfc9ea91324e816ea783013127bba
author: Galina Shalygina
committer: Galina Shalygina
timestamp: 2019-02-19 01:05:56 +0300
message:
MDEV-18636 The test case for bug mdev-16765 crashes the server
in the tree bb-10.4-mdev7486
The crash was caused because of the similar problem as in mdev-16765:
Item_cond::excl_dep_on_group_fields_for_having_pushdown() was missing.
---
mysql-test/main/derived_cond_pushdown.result | 196 +++++++++++++++++++++++++++
mysql-test/main/derived_cond_pushdown.test | 16 +--
sql/item_cmpfunc.cc | 16 +++
sql/item_cmpfunc.h | 1 +
4 files changed, 221 insertions(+), 8 deletions(-)
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 75b5a50ffa7..3eb246b39c0 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -10040,6 +10040,202 @@ DROP TABLE t1,t2,t3;
#
CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 VALUES (1,2), (3,4), (2,3);
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR (tab2.max_a=2))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 2
+1 3
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR (tab2.max_a=2))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.max_a = 1 or tab2.max_a = 2) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "case when (max_a = 1 or max_a = 2) then 1 else 0 end = 1",
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR ((tab2.max_a>2) AND (tab2.max_a<4)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 2
+1 4
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR ((tab2.max_a>2) AND (tab2.max_a<4)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.max_a = 1 or tab2.max_a > 2 and tab2.max_a < 4) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "case when (max_a = 1 or max_a > 2 and max_a < 4) then 1 else 0 end = 1",
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a>1) AND ((tab2.max_a=2) OR (tab2.max_a>2)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 3
+1 4
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a>1) AND ((tab2.max_a=2) OR (tab2.max_a>2)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.max_a > 1 and (tab2.max_a = 2 or tab2.max_a > 2)) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "case when (max_a > 1 and (max_a = 2 or max_a > 2)) then 1 else 0 end = 1",
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.b=2) OR (tab2.b=4))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 2
+1 4
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.b=2) OR (tab2.b=4))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.b = 2 or tab2.b = 4) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (t1.b = 2 or t1.b = 4) then 1 else 0 end = 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
DROP TABLE t1;
#
# MDEV-16803: pushdown condition with IN predicate in the derived table
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index 4c9481748c5..076d39c1abd 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -1981,8 +1981,8 @@ FROM
FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
) AS tab1
WHERE (tab1.max_a=1);
-# EVAL $query;
-# EVAL EXPLAIN FORMAT=JSON $query;
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
LET $query=
SELECT *
@@ -1993,8 +1993,8 @@ FROM
FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
) AS tab1
WHERE (tab1.max_a=1);
-# EVAL $query;
-# EVAL EXPLAIN FORMAT=JSON $query;
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
LET $query=
SELECT *
@@ -2005,8 +2005,8 @@ FROM
FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
) AS tab1
WHERE (tab1.max_a=1);
-# EVAL $query;
-# EVAL EXPLAIN FORMAT=JSON $query;
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
LET $query=
SELECT *
@@ -2017,8 +2017,8 @@ FROM
FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
) AS tab1
WHERE (tab1.max_a=1);
-# EVAL $query;
-# EVAL EXPLAIN FORMAT=JSON $query;
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
DROP TABLE t1;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 743da0d37dd..b4ff4ab3fe0 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -5222,6 +5222,22 @@ bool Item_cond::excl_dep_on_grouping_fields(st_select_lex *sel)
}
+bool
+Item_cond::excl_dep_on_group_fields_for_having_pushdown(st_select_lex *sel)
+{
+ if (has_rand_bit())
+ return false;
+ List_iterator_fast<Item> li(list);
+ Item *item;
+ while ((item= li++))
+ {
+ if (!item->excl_dep_on_group_fields_for_having_pushdown(sel))
+ return false;
+ }
+ return true;
+}
+
+
void Item_cond_and::mark_as_condition_AND_part(TABLE_LIST *embedding)
{
List_iterator<Item> li(list);
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index fc0cb4bf8d0..e85c8feb4d6 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -3011,6 +3011,7 @@ class Item_cond :public Item_bool_func
bool eval_not_null_tables(void *opt_arg);
Item *build_clone(THD *thd);
bool excl_dep_on_grouping_fields(st_select_lex *sel);
+ bool excl_dep_on_group_fields_for_having_pushdown(st_select_lex *sel);
};
template <template<class> class LI, class T> class Item_equal_iterator;
1
0

[Commits] d25af33116e: MDEV-18635 The test case for bug mdev-16727 crashes the server
by Galina 18 Feb '19
by Galina 18 Feb '19
18 Feb '19
revision-id: d25af33116edfc9ea91324e816ea783013127bba (mariadb-10.3.6-125-gd25af33116e)
parent(s): e4f1094c5074e4931cca82fc45a82c1fe1ac8963
author: Galina Shalygina
committer: Galina Shalygina
timestamp: 2019-02-18 23:27:11 +0300
message:
MDEV-18635 The test case for bug mdev-16727 crashes the server
in the tree bb-10.4-mdev7486
The crash was caused because after merge of bb-10.4-mdev7486 and
10.4 branches changes for mdev-16727 were missing.
---
mysql-test/main/in_subq_cond_pushdown.result | 13 ++++++++++++-
mysql-test/main/in_subq_cond_pushdown.test | 20 ++++++++++----------
sql/opt_subselect.cc | 2 +-
3 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result
index 05feaa8c774..2dd66547e79 100644
--- a/mysql-test/main/in_subq_cond_pushdown.result
+++ b/mysql-test/main/in_subq_cond_pushdown.result
@@ -3836,13 +3836,24 @@ DROP TABLE t1;
# of multiple equalities
#
CREATE TABLE t1 (a varchar(1));
-INSERT INTO `t1` VALUES ('x'), ('y'), ('z');
+INSERT INTO t1 VALUES ('x'), ('y'), ('z');
CREATE TABLE t2 (b varchar(1));
INSERT INTO t2 VALUES ('x');
CREATE TABLE t3 (c varchar(1));
INSERT INTO t3 VALUES ('y');
CREATE TABLE t4 (d varchar(1));
INSERT INTO t4 VALUES ('x'), ('z');
+SELECT * FROM t1
+JOIN t2 ON (t1.a=t2.b)
+LEFT JOIN t3 ON (t1.a=t3.c)
+WHERE (t1.a) IN
+(
+SELECT t4.d
+FROM t4
+ORDER BY t4.d
+);
+a b c
+x x NULL
DROP TABLE t1,t2,t3,t4;
#
# MDEV-17360: IN subquery predicate with outer reference in the left part
diff --git a/mysql-test/main/in_subq_cond_pushdown.test b/mysql-test/main/in_subq_cond_pushdown.test
index eee32c05a4b..7763201cda1 100644
--- a/mysql-test/main/in_subq_cond_pushdown.test
+++ b/mysql-test/main/in_subq_cond_pushdown.test
@@ -799,7 +799,7 @@ DROP TABLE t1;
--echo #
CREATE TABLE t1 (a varchar(1));
-INSERT INTO `t1` VALUES ('x'), ('y'), ('z');
+INSERT INTO t1 VALUES ('x'), ('y'), ('z');
CREATE TABLE t2 (b varchar(1));
INSERT INTO t2 VALUES ('x');
@@ -810,15 +810,15 @@ INSERT INTO t3 VALUES ('y');
CREATE TABLE t4 (d varchar(1));
INSERT INTO t4 VALUES ('x'), ('z');
-# SELECT * FROM t1
-# JOIN t2 ON (t1.a=t2.b)
-# LEFT JOIN t3 ON (t1.a=t3.c)
-# WHERE (t1.a) IN
-# (
-# SELECT t4.d
-# FROM t4
-# ORDER BY t4.d
-# );
+SELECT * FROM t1
+JOIN t2 ON (t1.a=t2.b)
+LEFT JOIN t3 ON (t1.a=t3.c)
+WHERE (t1.a) IN
+(
+ SELECT t4.d
+ FROM t4
+ ORDER BY t4.d
+);
DROP TABLE t1,t2,t3,t4;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 2e339f03540..4f45d77a717 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -5803,7 +5803,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond,
if (equality->fix_fields(thd, NULL))
return NULL;
}
- *cond_eq= &new_cond_equal;
+ (*cond_eq)->copy(new_cond_equal);
}
new_conds_list.append((List<Item> *)&new_cond_equal.current_level);
1
0