summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/dtrace.cmake5
-rw-r--r--cmake/install_layout.cmake10
-rw-r--r--cmake/install_macros.cmake87
-rw-r--r--cmake/os/WindowsCache.cmake1
-rw-r--r--cmake/plugin.cmake1
-rw-r--r--cmake/ssl.cmake1
-rw-r--r--config.h.cmake1
-rw-r--r--configure.cmake1
-rwxr-xr-xdebian/autobake-deb.sh1
-rw-r--r--debian/control1
-rw-r--r--debian/libmariadb-dev-compat.links3
-rw-r--r--debian/libmariadb-dev.install2
-rw-r--r--debian/libmariadb3.install1
-rw-r--r--debian/mariadb-server-10.5.install2
-rwxr-xr-xdebian/rules3
-rw-r--r--extra/mariabackup/xtrabackup.cc4
-rw-r--r--include/my_sys.h7
-rw-r--r--mysql-test/include/partition_mrr.inc92
-rw-r--r--mysql-test/main/alter_user.result2
-rw-r--r--mysql-test/main/alter_user.test2
-rw-r--r--mysql-test/main/backup_interaction.result24
-rw-r--r--mysql-test/main/backup_interaction.test27
-rw-r--r--mysql-test/main/disabled.def2
-rw-r--r--mysql-test/main/endspace.result2
-rw-r--r--mysql-test/main/events_restart.result29
-rw-r--r--mysql-test/main/events_restart.test31
-rw-r--r--mysql-test/main/func_str.result15
-rw-r--r--mysql-test/main/func_str.test11
-rw-r--r--mysql-test/main/grant.result2
-rw-r--r--mysql-test/main/lock_user.result2
-rw-r--r--mysql-test/main/lock_user.test2
-rw-r--r--mysql-test/main/mdev375.test2
-rw-r--r--mysql-test/main/mysql_client_test.test2
-rw-r--r--mysql-test/main/mysqld--defaults-file.result10
-rw-r--r--mysql-test/main/mysqld--defaults-file.test16
-rw-r--r--mysql-test/main/parser.result36
-rw-r--r--mysql-test/main/parser.test33
-rw-r--r--mysql-test/main/partition_innodb.result12
-rw-r--r--mysql-test/main/partition_innodb.test24
-rw-r--r--mysql-test/main/partition_mrr_aria.result161
-rw-r--r--mysql-test/main/partition_mrr_innodb.result161
-rw-r--r--mysql-test/main/partition_mrr_myisam.result220
-rw-r--r--mysql-test/main/partition_mrr_myisam.test59
-rw-r--r--mysql-test/main/rowid_filter_innodb.result336
-rw-r--r--mysql-test/main/rowid_filter_innodb.test153
-rw-r--r--mysql-test/suite/galera/disabled.def5
-rw-r--r--mysql-test/suite/galera/r/galera_as_master_gtid.result29
-rw-r--r--mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result31
-rw-r--r--mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result3
-rw-r--r--mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result168
-rw-r--r--mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result321
-rw-r--r--mysql-test/suite/galera/r/galera_rsu_add_pk.result24
-rw-r--r--mysql-test/suite/galera/r/galera_slave_replay.result101
-rw-r--r--mysql-test/suite/galera/r/galera_var_notify_cmd.result16
-rw-r--r--mysql-test/suite/galera/r/galera_wsrep_new_cluster.result2
-rw-r--r--mysql-test/suite/galera/r/lp1376747-4.result9
-rw-r--r--mysql-test/suite/galera/t/galera_as_master_gtid.cnf15
-rw-r--r--mysql-test/suite/galera/t/galera_as_master_gtid.test65
-rw-r--r--mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf6
-rw-r--r--mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test67
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test1
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf17
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test161
-rw-r--r--mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test159
-rw-r--r--mysql-test/suite/galera/t/galera_rsu_add_pk.test14
-rw-r--r--mysql-test/suite/galera/t/galera_slave_replay.test203
-rw-r--r--mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt1
-rw-r--r--mysql-test/suite/galera/t/galera_var_notify_cmd.cnf13
-rw-r--r--mysql-test/suite/galera/t/galera_var_notify_cmd.test14
-rw-r--r--mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt1
-rw-r--r--mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf10
-rw-r--r--mysql-test/suite/galera/t/galera_wsrep_new_cluster.test26
-rw-r--r--mysql-test/suite/galera/t/lp1376747-4.test27
-rw-r--r--mysql-test/suite/heap/heap_btree.result16
-rw-r--r--mysql-test/suite/heap/heap_hash.result8
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_charset.result11
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_index_rename.result17
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_charset.test15
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_index_rename.test15
-rw-r--r--mysql-test/suite/innodb_fts/r/misc_debug2.result3
-rw-r--r--mysql-test/suite/innodb_fts/t/misc_debug2.test3
-rw-r--r--mysql-test/suite/parts/r/partition_special_innodb.result8
-rw-r--r--mysql-test/suite/parts/t/partition_special_innodb.test10
-rw-r--r--mysys/CMakeLists.txt5
-rw-r--r--mysys/my_addr_resolve.c12
-rw-r--r--mysys/my_default.c10
-rw-r--r--mysys/my_getncpus.c43
-rw-r--r--mysys/my_windac.c202
-rw-r--r--plugin/auth_pam/CMakeLists.txt14
-rw-r--r--plugin/auth_pam/mapper/pam_user_map.c30
-rw-r--r--plugin/win_auth_client/CMakeLists.txt3
-rw-r--r--sql/events.cc8
-rw-r--r--sql/ha_partition.cc40
-rw-r--r--sql/ha_partition.h426
-rw-r--r--sql/handler.cc20
-rw-r--r--sql/handler.h14
-rw-r--r--sql/item_strfunc.h2
-rw-r--r--sql/log_event_server.cc10
-rw-r--r--sql/mdl.cc11
-rw-r--r--sql/multi_range_read.cc46
-rw-r--r--sql/multi_range_read.h16
-rw-r--r--sql/my_json_writer.cc121
-rw-r--r--sql/my_json_writer.h208
-rw-r--r--sql/opt_index_cond_pushdown.cc15
-rw-r--r--sql/opt_range.cc21
-rw-r--r--sql/opt_subselect.cc30
-rw-r--r--sql/opt_trace.cc113
-rw-r--r--sql/opt_trace.h2
-rw-r--r--sql/opt_trace_context.h54
-rw-r--r--sql/slave.cc31
-rw-r--r--sql/sql_class.cc6
-rw-r--r--sql/sql_class.h6
-rw-r--r--sql/sql_join_cache.cc2
-rw-r--r--sql/sql_reload.cc6
-rw-r--r--sql/sql_select.cc43
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_table.cc118
-rw-r--r--sql/sql_test.cc5
-rw-r--r--sql/sql_yacc.yy38
-rw-r--r--sql/table.cc2
-rw-r--r--sql/wsrep_thd.cc8
-rw-r--r--storage/heap/ha_heap.h5
-rw-r--r--storage/innobase/dict/dict0dict.cc1
-rw-r--r--storage/innobase/handler/ha_innodb.cc31
-rw-r--r--storage/innobase/handler/ha_innodb.h5
-rw-r--r--storage/innobase/log/log0recv.cc5
-rw-r--r--storage/innobase/page/page0zip.cc5
-rw-r--r--storage/rocksdb/ha_rocksdb.h1
-rw-r--r--support-files/CMakeLists.txt2
-rw-r--r--support-files/mariadb.pc.in2
-rw-r--r--support-files/mariadb.service.in2
-rw-r--r--support-files/mariadb@.service.in2
132 files changed, 2879 insertions, 2139 deletions
diff --git a/cmake/dtrace.cmake b/cmake/dtrace.cmake
index 4e0f7501045..1e29ba685e0 100644
--- a/cmake/dtrace.cmake
+++ b/cmake/dtrace.cmake
@@ -147,11 +147,10 @@ FUNCTION(DTRACE_INSTRUMENT target)
# Note: DTrace probes in static libraries are unusable currently
# (see explanation for DTRACE_INSTRUMENT_STATIC_LIBS below)
# but maybe one day this will be fixed.
- GET_TARGET_PROPERTY(target_location ${target} LOCATION)
ADD_CUSTOM_COMMAND(
TARGET ${target} POST_BUILD
- COMMAND ${CMAKE_AR} r ${target_location} ${outfile}
- COMMAND ${CMAKE_RANLIB} ${target_location}
+ COMMAND ${CMAKE_AR} r $<TARGET_FILE:${target}> ${outfile}
+ COMMAND ${CMAKE_RANLIB} $<TARGET_FILE:${target}>
)
# Used in DTRACE_INSTRUMENT_WITH_STATIC_LIBS
SET(TARGET_OBJECT_DIRECTORY_${target} ${objdir} CACHE INTERNAL "")
diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake
index 49dceccb9d2..2779e07e9dd 100644
--- a/cmake/install_layout.cmake
+++ b/cmake/install_layout.cmake
@@ -174,7 +174,7 @@ SET(INSTALL_SCRIPTDIR_DEB "bin")
SET(INSTALL_SYSCONFDIR_DEB "/etc")
SET(INSTALL_SYSCONF2DIR_DEB "/etc/mysql/conf.d")
#
-SET(INSTALL_LIBDIR_DEB "lib")
+SET(INSTALL_LIBDIR_DEB "lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}")
SET(INSTALL_PLUGINDIR_DEB "lib/mysql/plugin")
#
SET(INSTALL_INCLUDEDIR_DEB "include/mariadb")
@@ -186,7 +186,7 @@ SET(INSTALL_INFODIR_DEB "share/info")
#
SET(INSTALL_SHAREDIR_DEB "share")
SET(INSTALL_MYSQLSHAREDIR_DEB "share/mysql")
-SET(INSTALL_MYSQLTESTDIR_DEB "mysql-test")
+SET(INSTALL_MYSQLTESTDIR_DEB "share/mysql/mysql-test")
SET(INSTALL_SQLBENCHDIR_DEB ".")
SET(INSTALL_SUPPORTFILESDIR_DEB "share/mysql")
#
@@ -196,11 +196,7 @@ SET(INSTALL_UNIX_ADDRDIR_DEB "/var/run/mysqld/mysqld.sock")
SET(INSTALL_SYSTEMD_UNITDIR_DEB "/lib/systemd/system")
SET(INSTALL_SYSTEMD_SYSUSERSDIR_DEB "/usr/lib/sysusers.d")
SET(INSTALL_SYSTEMD_TMPFILESDIR_DEB "/usr/lib/tmpfiles.d")
-IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
- SET(INSTALL_PAMDIR_DEB "/lib/x86_64-linux-gnu/security")
-ELSE()
- SET(INSTALL_PAMDIR_DEB "/lib/i386-linux-gnu/security")
-ENDIF()
+SET(INSTALL_PAMDIR_DEB "/lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}/security")
#
# SVR4 layout
diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake
index f04ab691af1..2318e9d5dea 100644
--- a/cmake/install_macros.cmake
+++ b/cmake/install_macros.cmake
@@ -261,93 +261,6 @@ GET_FILENAME_COMPONENT(BINARY_PARENTDIR ${CMAKE_BINARY_DIR} PATH)
SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug build")
-FUNCTION(INSTALL_DEBUG_TARGET target)
- RETURN() # XXX unused?
- CMAKE_PARSE_ARGUMENTS(ARG
- ""
- "DESTINATION;RENAME;PDB_DESTINATION;COMPONENT"
- ""
- ${ARGN}
- )
- GET_TARGET_PROPERTY(target_type ${target} TYPE)
- IF(ARG_RENAME)
- SET(RENAME_PARAM RENAME ${ARG_RENAME}${CMAKE_${target_type}_SUFFIX})
- ELSE()
- SET(RENAME_PARAM)
- ENDIF()
- IF(NOT ARG_DESTINATION)
- MESSAGE(FATAL_ERROR "Need DESTINATION parameter for INSTALL_DEBUG_TARGET")
- ENDIF()
- GET_TARGET_PROPERTY(target_location ${target} LOCATION)
- IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
- STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}")
- ELSE()
- STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" )
- ENDIF()
- IF(NOT ARG_COMPONENT)
- SET(ARG_COMPONENT DebugBinaries)
- ENDIF()
-
- # Define permissions
- # For executable files
- SET(PERMISSIONS_EXECUTABLE
- PERMISSIONS
- OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE
- WORLD_READ WORLD_EXECUTE)
-
- # Permissions for shared library (honors CMAKE_INSTALL_NO_EXE which is
- # typically set on Debian)
- IF(CMAKE_INSTALL_SO_NO_EXE)
- SET(PERMISSIONS_SHARED_LIBRARY
- PERMISSIONS
- OWNER_READ OWNER_WRITE
- GROUP_READ
- WORLD_READ)
- ELSE()
- SET(PERMISSIONS_SHARED_LIBRARY ${PERMISSIONS_EXECUTABLE})
- ENDIF()
-
- # Shared modules get the same permissions as shared libraries
- SET(PERMISSIONS_MODULE_LIBRARY ${PERMISSIONS_SHARED_LIBRARY})
-
- # Define permissions for static library
- SET(PERMISSIONS_STATIC_LIBRARY
- PERMISSIONS
- OWNER_READ OWNER_WRITE
- GROUP_READ
- WORLD_READ)
-
- INSTALL(FILES ${debug_target_location}
- DESTINATION ${ARG_DESTINATION}
- ${RENAME_PARAM}
- ${PERMISSIONS_${target_type}}
- CONFIGURATIONS Release RelWithDebInfo
- COMPONENT ${ARG_COMPONENT}
- OPTIONAL)
-
- IF(MSVC)
- GET_FILENAME_COMPONENT(ext ${debug_target_location} EXT)
- STRING(REPLACE "${ext}" ".pdb" debug_pdb_target_location "${debug_target_location}" )
- IF (RENAME_PARAM)
- IF(NOT ARG_PDB_DESTINATION)
- STRING(REPLACE "${ext}" ".pdb" "${ARG_RENAME}" pdb_rename)
- SET(PDB_RENAME_PARAM RENAME "${pdb_rename}")
- ENDIF()
- ENDIF()
- IF(NOT ARG_PDB_DESTINATION)
- SET(ARG_PDB_DESTINATION "${ARG_DESTINATION}")
- ENDIF()
- INSTALL(FILES ${debug_pdb_target_location}
- DESTINATION ${ARG_PDB_DESTINATION}
- ${PDB_RENAME_PARAM}
- CONFIGURATIONS Release RelWithDebInfo
- COMPONENT ${ARG_COMPONENT}
- OPTIONAL)
- ENDIF()
-ENDFUNCTION()
-
-
FUNCTION(INSTALL_MYSQL_TEST from to)
IF(INSTALL_MYSQLTESTDIR)
INSTALL(
diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake
index 4ba36dc494d..a03a7bbf7e2 100644
--- a/cmake/os/WindowsCache.cmake
+++ b/cmake/os/WindowsCache.cmake
@@ -123,6 +123,7 @@ SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "")
SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "")
+SET(HAVE_PTHREAD_GETAFFINITY_NP CACHE INTERNAL "")
SET(HAVE_PTHREAD_INIT CACHE INTERNAL "")
SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "")
SET(HAVE_PTHREAD_RWLOCK_RDLOCK CACHE INTERNAL "")
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
index eec4fc6a33e..b77f1ed58cc 100644
--- a/cmake/plugin.cmake
+++ b/cmake/plugin.cmake
@@ -263,7 +263,6 @@ MACRO(MYSQL_ADD_PLUGIN)
SET(ARG_COMPONENT Server)
ENDIF()
MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT})
- #INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT ${ARG_COMPONENT})
ENDIF()
GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME)
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
index bcb4a512126..7143fce9e09 100644
--- a/cmake/ssl.cmake
+++ b/cmake/ssl.cmake
@@ -140,6 +140,7 @@ MACRO (MYSQL_CHECK_SSL)
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
SET(CMAKE_REQUIRED_LIBRARIES ${SSL_LIBRARIES})
+ SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
CHECK_SYMBOL_EXISTS(ERR_remove_thread_state "openssl/err.h"
HAVE_ERR_remove_thread_state)
CHECK_SYMBOL_EXISTS(EVP_aes_128_ctr "openssl/evp.h"
diff --git a/config.h.cmake b/config.h.cmake
index 2a270749661..9eb067b2362 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -196,6 +196,7 @@
#cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1
#cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
+#cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
#cmakedefine HAVE_PTHREAD_KILL 1
#cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1
diff --git a/configure.cmake b/configure.cmake
index 6b8bbed636e..43c32fda0ee 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -379,6 +379,7 @@ CHECK_FUNCTION_EXISTS (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE)
CHECK_FUNCTION_EXISTS (pthread_attr_getguardsize HAVE_PTHREAD_ATTR_GETGUARDSIZE)
CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
+CHECK_FUNCTION_EXISTS (pthread_getaffinity_np HAVE_PTHREAD_GETAFFINITY_NP)
CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)
diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh
index 26a00c541c1..671f9e4777e 100755
--- a/debian/autobake-deb.sh
+++ b/debian/autobake-deb.sh
@@ -77,7 +77,6 @@ fi
if ! apt-cache madison libzstd-dev | grep 'libzstd-dev' >/dev/null 2>&1
then
sed '/libzstd-dev/d' -i debian/control
- sed '/libzstd1/d' -i debian/control
fi
# If rocksdb-tools is not available (before Debian Buster and Ubuntu Disco)
diff --git a/debian/control b/debian/control
index 62476161363..847dd719840 100644
--- a/debian/control
+++ b/debian/control
@@ -7,6 +7,7 @@ Build-Depends: bison,
cmake (>= 2.7),
debhelper (>= 9),
dh-apparmor,
+ dh-exec,
dh-systemd,
gdb,
libaio-dev [linux-any],
diff --git a/debian/libmariadb-dev-compat.links b/debian/libmariadb-dev-compat.links
index 11e0dbce225..e02260c0129 100644
--- a/debian/libmariadb-dev-compat.links
+++ b/debian/libmariadb-dev-compat.links
@@ -1,3 +1,4 @@
+#!/usr/bin/dh-exec
usr/bin/mariadb_config usr/bin/mysql_config
usr/include/mariadb usr/include/mysql
-usr/share/pkgconfig/mariadb.pc usr/share/pkgconfig/mysqlclient.pc
+usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig/mariadb.pc usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig/mysqlclient.pc
diff --git a/debian/libmariadb-dev.install b/debian/libmariadb-dev.install
index 72798dec379..0625dec7a9e 100644
--- a/debian/libmariadb-dev.install
+++ b/debian/libmariadb-dev.install
@@ -4,6 +4,6 @@ usr/lib/*/libmariadb.so
usr/lib/*/libmariadbclient.a
usr/lib/*/libmariadbclient.so
usr/lib/*/libmysqlservices.a
+usr/lib/*/pkgconfig/mariadb.pc
usr/share/aclocal/mysql.m4
usr/share/man/man1/mysql_config.1
-usr/share/pkgconfig/mariadb.pc
diff --git a/debian/libmariadb3.install b/debian/libmariadb3.install
index 9783e7b0b01..8636166a493 100644
--- a/debian/libmariadb3.install
+++ b/debian/libmariadb3.install
@@ -3,4 +3,3 @@ usr/lib/mysql/plugin/client_ed25519.so
usr/lib/mysql/plugin/dialog.so
usr/lib/mysql/plugin/mysql_clear_password.so
usr/lib/mysql/plugin/sha256_password.so
-usr/lib/mysql/plugin/client_ed25519.so
diff --git a/debian/mariadb-server-10.5.install b/debian/mariadb-server-10.5.install
index 9b2fe0498dc..4a860ff57df 100644
--- a/debian/mariadb-server-10.5.install
+++ b/debian/mariadb-server-10.5.install
@@ -5,8 +5,8 @@ debian/additions/mysql.init usr/share/mysql
debian/additions/mysqld_safe_syslog.cnf etc/mysql/conf.d
etc/apparmor.d/usr.sbin.mysqld
etc/security/user_map.conf
-lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf
lib/*/security/pam_user_map.so
+lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf
usr/bin/aria_chk
usr/bin/aria_dump_log
usr/bin/aria_ftdump
diff --git a/debian/rules b/debian/rules
index 0370a753d2b..ab24e9f7638 100755
--- a/debian/rules
+++ b/debian/rules
@@ -86,9 +86,6 @@ endif
-DSYSTEM_TYPE="debian-$(DEB_HOST_GNU_SYSTEM)" \
-DCMAKE_SYSTEM_PROCESSOR=$(DEB_HOST_ARCH) \
-DBUILD_CONFIG=mysql_release \
- -DINSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
- -DINSTALL_PLUGINDIR=lib/mysql/plugin \
- -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test \
-DPLUGIN_AWS_KEY_MANAGEMENT=NO \
-DDEB=$(DEB_VENDOR) ..'
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index aac87c61742..0d1c97718c1 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -3092,13 +3092,13 @@ xb_load_single_table_tablespace(
}
}
- ut_free(name);
-
delete file;
if (err != DB_SUCCESS && xtrabackup_backup && !is_empty_file) {
die("Failed to not validate first page of the file %s, error %d",name, (int)err);
}
+
+ ut_free(name);
}
/** Scan the database directories under the MySQL datadir, looking for
diff --git a/include/my_sys.h b/include/my_sys.h
index 3d271c93a17..efb0cecbb5c 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -1084,13 +1084,6 @@ extern void thd_increment_net_big_packet_count(void *thd, size_t length);
#ifdef _WIN32
-/* implemented in my_windac.c */
-
-int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
- DWORD owner_rights, DWORD everybody_rights);
-
-void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
-
/* implemented in my_conio.c */
char* my_cgets(char *string, size_t clen, size_t* plen);
diff --git a/mysql-test/include/partition_mrr.inc b/mysql-test/include/partition_mrr.inc
index d6df1058ff8..188bc50147f 100644
--- a/mysql-test/include/partition_mrr.inc
+++ b/mysql-test/include/partition_mrr.inc
@@ -36,11 +36,103 @@ insert into t3 select
123456
from t1 A, t1 B;
+set @save_optimizer_switch=@@optimizer_switch;
+
set optimizer_switch='mrr=on';
--replace_column 9 #
explain
select * from t3 force index (key_col) where key_col < 3;
select * from t3 force index (key_col) where key_col < 3;
+set optimizer_switch=@save_optimizer_switch;
+
drop table t1,t3;
+--echo #
+--echo # MDEV-21544: partitioned table is joined with BKA+MRR
+--echo #
+
+set @save_join_cache_level=@@join_cache_level;
+set @save_optimizer_switch=@@optimizer_switch;
+
+create table t0 (
+ tp int, a int, b int not null, c varchar(12), index idx (a,b)
+);
+insert into t0 values
+(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'),
+(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'),
+(1,3,30,'yzzy'), (1,93,30,'zzzy'),
+(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'),
+(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'),
+(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'),
+(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'),
+(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'),
+(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'),
+(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'),
+(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'),
+(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'),
+(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'),
+(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'),
+(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'),
+(3,4,30,'zzzyy'), (3,94,30,'yyz');
+
+create table t1 (
+ tp int, a int, b int not null, c varchar(12), index idx (a,b)
+)
+partition by list (tp)
+( partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3));
+insert into t1 select * from t0;
+
+# tables t0 and t1 contain the same set of records.
+
+create table t2 (a int, index idx(a));
+insert into t2 values
+(1), (2), (3), (4), (5);
+insert into t2 select a+10 from t2;
+insert into t2 select a+20 from t2;
+
+analyze table t0,t1,t2;
+
+set join_cache_level=6;
+set optimizer_switch='mrr=on';
+
+let $q1=
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
+eval explain extended $q1;
+eval $q1;
+
+let $q2=
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
+eval explain extended $q2;
+eval $q2;
+
+let $q1=
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+eval explain extended $q1;
+eval $q1;
+
+let $q2=
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+eval explain extended $q2;
+eval $q2;
+
+insert into t2 values
+(3), (4), (5);
+analyze table t2;
+
+let $q1=
+select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
+eval explain extended $q1;
+eval $q1;
+
+let $q2=
+select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
+eval explain extended $q2;
+eval $q2;
+
+set join_cache_level=@save_join_cache_level;
+set optimizer_switch=@save_optimizer_switch;
+
+drop table t0,t1,t2;
diff --git a/mysql-test/main/alter_user.result b/mysql-test/main/alter_user.result
index a2ff642c073..233870084b7 100644
--- a/mysql-test/main/alter_user.result
+++ b/mysql-test/main/alter_user.result
@@ -48,7 +48,7 @@ SET GLOBAL read_only = @start_read_only;
alter user boo;
ERROR HY000: Operation ALTER USER failed for 'boo'
#--warning ER_CANNOT_USER
-alter if exists user boo;
+alter user if exists boo;
Warnings:
Error 1133 Can't find any matching row in the user table
Note 1396 Operation ALTER USER failed for 'boo'
diff --git a/mysql-test/main/alter_user.test b/mysql-test/main/alter_user.test
index a18076930b6..52970a4cfed 100644
--- a/mysql-test/main/alter_user.test
+++ b/mysql-test/main/alter_user.test
@@ -50,7 +50,7 @@ SET GLOBAL read_only = @start_read_only;
--error ER_CANNOT_USER
alter user boo;
--echo #--warning ER_CANNOT_USER
-alter if exists user boo;
+alter user if exists boo;
--echo #
diff --git a/mysql-test/main/backup_interaction.result b/mysql-test/main/backup_interaction.result
index 02ef0af070e..a6fe7cf448d 100644
--- a/mysql-test/main/backup_interaction.result
+++ b/mysql-test/main/backup_interaction.result
@@ -521,26 +521,8 @@ BACKUP STAGE END;
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, f INT);
BACKUP STAGE START;
FLUSH TABLE t1 FOR EXPORT;
-UNLOCK TABLES;
-BACKUP STAGE END;
-DROP TABLE t1;
-CREATE TABLE t1 (a INT);
-BACKUP STAGE START;
-FLUSH TABLE t1 FOR EXPORT;
-UNLOCK TABLES;
-connect con1,localhost,root,,test;
-BACKUP STAGE START;
-connection default;
-BACKUP STAGE END;
-connection con1;
-BACKUP STAGE END;
-disconnect con1;
-connection default;
-DROP TABLE t1;
-CREATE TABLE t1 (a INT);
-BACKUP STAGE START;
-FLUSH TABLES t1 WITH READ LOCK;
-UNLOCK TABLES;
-BACKUP STAGE BLOCK_COMMIT;
+ERROR HY000: Can't execute the command as you have a BACKUP STAGE active
+FLUSH TABLE t1 WITH READ LOCK;
+ERROR HY000: Can't execute the command as you have a BACKUP STAGE active
BACKUP STAGE END;
DROP TABLE t1;
diff --git a/mysql-test/main/backup_interaction.test b/mysql-test/main/backup_interaction.test
index 42b392f3125..a398a4a2d2d 100644
--- a/mysql-test/main/backup_interaction.test
+++ b/mysql-test/main/backup_interaction.test
@@ -509,30 +509,9 @@ BACKUP STAGE END;
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, f INT);
BACKUP STAGE START;
+--error ER_BACKUP_LOCK_IS_ACTIVE
FLUSH TABLE t1 FOR EXPORT;
-UNLOCK TABLES;
-BACKUP STAGE END;
-DROP TABLE t1;
-
-CREATE TABLE t1 (a INT);
-BACKUP STAGE START;
-FLUSH TABLE t1 FOR EXPORT;
-UNLOCK TABLES;
---connect (con1,localhost,root,,test)
---send BACKUP STAGE START
---connection default
-BACKUP STAGE END;
---connection con1
-reap;
-BACKUP STAGE END;
---disconnect con1
---connection default
-DROP TABLE t1;
-
-CREATE TABLE t1 (a INT);
-BACKUP STAGE START;
-FLUSH TABLES t1 WITH READ LOCK;
-UNLOCK TABLES;
-BACKUP STAGE BLOCK_COMMIT;
+--error ER_BACKUP_LOCK_IS_ACTIVE
+FLUSH TABLE t1 WITH READ LOCK;
BACKUP STAGE END;
DROP TABLE t1;
diff --git a/mysql-test/main/disabled.def b/mysql-test/main/disabled.def
index 93fff886791..8ba5b271c2b 100644
--- a/mysql-test/main/disabled.def
+++ b/mysql-test/main/disabled.def
@@ -14,8 +14,6 @@ events_time_zone : Test is not predictable as it depends on precise timi
read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists
mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 changes - eventum#41836
#show_explain : Psergey: random timeout in range-checked-for-each record query.
-innodb-wl5522-debug-zip : broken upstream
-innodb_bug12902967 : broken upstream
file_contents : MDEV-6526 these files are not installed anymore
max_statement_time : cannot possibly work, depends on timing
partition_open_files_limit : open_files_limit check broken by MDEV-18360
diff --git a/mysql-test/main/endspace.result b/mysql-test/main/endspace.result
index a0f53167148..f9619db7e64 100644
--- a/mysql-test/main/endspace.result
+++ b/mysql-test/main/endspace.result
@@ -145,8 +145,8 @@ teststring
teststring
select * from t1 where text1='teststring' or text1 >= 'teststring\t';
text1
-teststring
teststring
+teststring
select * from t1 order by text1;
text1
nothing
diff --git a/mysql-test/main/events_restart.result b/mysql-test/main/events_restart.result
index 68343fcf994..47092beed0e 100644
--- a/mysql-test/main/events_restart.result
+++ b/mysql-test/main/events_restart.result
@@ -113,3 +113,32 @@ Db Name Definer Time zone Type Execute at Interval value Interval field Starts E
test e1 root@localhost SYSTEM RECURRING # 1 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
DROP EVENT e1;
# end test for bug#11748899
+#
+# Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED
+#
+create event ev on schedule every 1 minute do set @a= 1;
+select name, originator, status from mysql.event;
+name originator status
+ev 1 ENABLED
+#
+# Restarting server with server_id=100
+#
+# restart: --server-id=100
+select @@global.server_id;
+@@global.server_id
+100
+select name, originator, status from mysql.event;
+name originator status
+ev 1 ENABLED
+set global server_id= 1;
+#
+# Restarting server with the original server_id=1
+#
+# restart
+select @@global.server_id;
+@@global.server_id
+1
+select name, originator, status from mysql.event;
+name originator status
+ev 1 ENABLED
+drop event ev;
diff --git a/mysql-test/main/events_restart.test b/mysql-test/main/events_restart.test
index ca674170e96..f56bd32b71d 100644
--- a/mysql-test/main/events_restart.test
+++ b/mysql-test/main/events_restart.test
@@ -141,3 +141,34 @@ SHOW EVENTS;
DROP EVENT e1;
--echo # end test for bug#11748899
+
+--echo #
+--echo # Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED
+--echo #
+
+create event ev on schedule every 1 minute do set @a= 1;
+select name, originator, status from mysql.event;
+
+--let $server_id= `SELECT @@global.server_id`
+
+--echo #
+--echo # Restarting server with server_id=100
+--echo #
+--let $restart_parameters= --server-id=100
+--source include/restart_mysqld.inc
+
+select @@global.server_id;
+select name, originator, status from mysql.event;
+--eval set global server_id= $server_id
+
+--echo #
+--echo # Restarting server with the original server_id=$server_id
+--echo #
+--let $restart_parameters=
+--source include/restart_mysqld.inc
+
+select @@global.server_id;
+select name, originator, status from mysql.event;
+
+# Cleanup
+drop event ev;
diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result
index 18ae4d0aee0..6fc61dc0f5f 100644
--- a/mysql-test/main/func_str.result
+++ b/mysql-test/main/func_str.result
@@ -5159,6 +5159,21 @@ DROP TABLE t1, t2;
# Start of 10.4 tests
#
#
+# MDEV-21841 CONV() function truncates the result type to 21 symbol.
+#
+CREATE TABLE t1(i BIGINT);
+INSERT INTO t1 VALUES (-1);
+CREATE TABLE t2 AS SELECT conv(i,16,2) from t1;
+SELECT * FROM t2;
+conv(i,16,2)
+1111111111111111111111111111111111111111111111111111111111111111
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `conv(i,16,2)` varchar(64) CHARACTER SET utf8 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1,t2;
+#
# MDEV-18205 Assertion `str_length < len' failed in Binary_string::realloc_raw
#
SELECT GROUP_CONCAT( UpdateXML( '<a>new year</a>', '/a', '2019-01-01 00:00:00' ), ENCODE('text','pass') ) AS f;
diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test
index a01b3942209..ba5b671ca4f 100644
--- a/mysql-test/main/func_str.test
+++ b/mysql-test/main/func_str.test
@@ -2100,6 +2100,17 @@ DROP TABLE t1, t2;
--echo #
--echo #
+--echo # MDEV-21841 CONV() function truncates the result type to 21 symbol.
+--echo #
+
+CREATE TABLE t1(i BIGINT);
+INSERT INTO t1 VALUES (-1);
+CREATE TABLE t2 AS SELECT conv(i,16,2) from t1;
+SELECT * FROM t2;
+SHOW CREATE TABLE t2;
+DROP TABLE t1,t2;
+
+--echo #
--echo # MDEV-18205 Assertion `str_length < len' failed in Binary_string::realloc_raw
--echo #
diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result
index 8ce99075e6d..e8efb8c9ef4 100644
--- a/mysql-test/main/grant.result
+++ b/mysql-test/main/grant.result
@@ -608,7 +608,7 @@ Create temporary tables Databases To use CREATE TEMPORARY TABLE
Create view Tables To create new views
Create user Server Admin To create new users
Delete Tables To delete existing rows
-Delete versioning rows Tables To delete versioning table historical rows
+Delete history Tables To delete versioning table historical rows
Drop Databases,Tables To drop databases, tables, and views
Event Server Admin To create, alter, drop and execute events
Execute Functions,Procedures To execute stored routines
diff --git a/mysql-test/main/lock_user.result b/mysql-test/main/lock_user.result
index bc32ee986b3..5048c5a9bee 100644
--- a/mysql-test/main/lock_user.result
+++ b/mysql-test/main/lock_user.result
@@ -31,7 +31,7 @@ alter user user1@localhost account unlock;
#
alter user inexistentUser@localhost account lock;
ERROR HY000: Operation ALTER USER failed for 'inexistentUser'@'localhost'
-alter if exists user inexistentUser@localhost account lock;
+alter user if exists inexistentUser@localhost account lock;
Warnings:
Error 1133 Can't find any matching row in the user table
Note 1396 Operation ALTER USER failed for 'inexistentUser'@'localhost'
diff --git a/mysql-test/main/lock_user.test b/mysql-test/main/lock_user.test
index 366c34ecea8..17ce1cc79da 100644
--- a/mysql-test/main/lock_user.test
+++ b/mysql-test/main/lock_user.test
@@ -44,7 +44,7 @@ alter user user1@localhost account unlock;
--error ER_CANNOT_USER
alter user inexistentUser@localhost account lock;
-alter if exists user inexistentUser@localhost account lock;
+alter user if exists inexistentUser@localhost account lock;
--echo #
--echo # Passing an existing user to CREATE should not be allowed
diff --git a/mysql-test/main/mdev375.test b/mysql-test/main/mdev375.test
index 9e35190b927..6fdb35016ca 100644
--- a/mysql-test/main/mdev375.test
+++ b/mysql-test/main/mdev375.test
@@ -27,6 +27,8 @@ SELECT 2;
--connection default
SELECT 0;
+let $count_sessions=11;
+--source include/wait_until_count_sessions.inc
show status like "Threads_connected";
SET GLOBAL log_warnings=@save_log_warnings;
diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test
index 7efb4dadd72..7885dc5c0d7 100644
--- a/mysql-test/main/mysql_client_test.test
+++ b/mysql-test/main/mysql_client_test.test
@@ -2,8 +2,6 @@
-- source include/not_embedded.inc
# need to have the dynamic loading turned on for the client plugin tests
--source include/have_plugin_auth.inc
-# This test is slow on buildbot.
---source include/big_test.inc
# Run test with default character set
--source include/default_charset.inc
diff --git a/mysql-test/main/mysqld--defaults-file.result b/mysql-test/main/mysqld--defaults-file.result
index 5fd5ca8d95a..ccad1d119fc 100644
--- a/mysql-test/main/mysqld--defaults-file.result
+++ b/mysql-test/main/mysqld--defaults-file.result
@@ -10,3 +10,13 @@ Could not open required defaults file: MYSQL_TEST_DIR/with.ext
Fatal error in defaults handling. Program aborted
Could not open required defaults file: MYSQL_TEST_DIR/no_extension
Fatal error in defaults handling. Program aborted
+#
+# MDEV-21374: When "--help --verbose" prints out configuration file paths,
+# the --defaults-file option is not considered
+#
+# Test on `defaults-file`
+Default options are read from the following files in the given order:
+MYSQLTEST_VARDIR/my.cnf
+# Test on `defaults-extra-file`
+Default options are read from the following files in the given order:
+<first-defaults> MYSQLTEST_VARDIR/my_test.cnf ~/.my.cnf
diff --git a/mysql-test/main/mysqld--defaults-file.test b/mysql-test/main/mysqld--defaults-file.test
index 26a92cbee53..f3168f97eaf 100644
--- a/mysql-test/main/mysqld--defaults-file.test
+++ b/mysql-test/main/mysqld--defaults-file.test
@@ -31,3 +31,19 @@ exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1;
--error 1
exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1;
+--echo #
+--echo # MDEV-21374: When "--help --verbose" prints out configuration file paths,
+--echo # the --defaults-file option is not considered
+--echo #
+
+--echo # Test on `defaults-file`
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --help --verbose | grep -A 1 'Default options are read';
+
+--echo # Test on `defaults-extra-file`
+# <first-defaults> = `/etc/my.cnf /etc/mysql/my.cnf`
+# Using sysconfdir configuration, we don't always have `/etc/mysql/my.cnf`, so replace them with a regex as well.
+copy_file $MYSQLTEST_VARDIR/my.cnf $MYSQLTEST_VARDIR/my_test.cnf;
+--replace_regex /.*my_test.cnf/<first-defaults> MYSQLTEST_VARDIR\/my_test.cnf/
+exec $MYSQLD --defaults-extra-file=$MYSQLTEST_VARDIR/my_test.cnf --help --verbose | grep -A 1 'Default options are read';
+remove_file $MYSQLTEST_VARDIR/my_test.cnf;
diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result
index 6c895f0b184..5cdb6b29fd9 100644
--- a/mysql-test/main/parser.result
+++ b/mysql-test/main/parser.result
@@ -1807,6 +1807,42 @@ Field Type Null Key Default Extra
a int(11) YES NULL
drop table t1;
SET STATEMENT max_statement_time=0 FOR do 1;
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+create table t1 (a int);
+SET STATEMENT max_statement_time=0 FOR desc t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+drop table t1;
+SET STATEMENT max_statement_time=0 FOR do 1;
+set SQL_MODE=@save_sql_mode;
+#
+# MDEV-21684: mysqld crash with signal 11 when renaming
+# table+max_statement_time
+#
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+ERROR 42S02: Table 'test.bleh' doesn't exist
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+Table Op Msg_type Msg_text
+test.t1_base preload_keys Error Table 'test.t1_base' doesn't exist
+test.t1_base preload_keys status Operation failed
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+ERROR 42S02: Table 'test.bleh' doesn't exist
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+Table Op Msg_type Msg_text
+test.t1_base preload_keys Error Table 'test.t1_base' doesn't exist
+test.t1_base preload_keys status Operation failed
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+set SQL_MODE=@save_sql_mode;
# End of 10.4 tests
#
# Start of 10.5 tests
diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test
index 7fe870722a2..aba83b146a0 100644
--- a/mysql-test/main/parser.test
+++ b/mysql-test/main/parser.test
@@ -1575,6 +1575,39 @@ SET STATEMENT max_statement_time=0 FOR desc t1;
drop table t1;
SET STATEMENT max_statement_time=0 FOR do 1;
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+create table t1 (a int);
+SET STATEMENT max_statement_time=0 FOR desc t1;
+drop table t1;
+SET STATEMENT max_statement_time=0 FOR do 1;
+set SQL_MODE=@save_sql_mode;
+
+
+--echo #
+--echo # MDEV-21684: mysqld crash with signal 11 when renaming
+--echo # table+max_statement_time
+--echo #
+
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+set SQL_MODE=@save_sql_mode;
+
--echo # End of 10.4 tests
diff --git a/mysql-test/main/partition_innodb.result b/mysql-test/main/partition_innodb.result
index 090e74b6079..554e7472a79 100644
--- a/mysql-test/main/partition_innodb.result
+++ b/mysql-test/main/partition_innodb.result
@@ -395,33 +395,33 @@ DROP TABLE t1;
create table t1 (a int) engine=innodb partition by hash(a) ;
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 InnoDB 10 Dynamic 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned 0 N
+t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 NULL # NULL NULL latin1_swedish_ci NULL partitioned 0 N
drop table t1;
create table t1 (a int)
engine = innodb
partition by key (a);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 InnoDB 10 Dynamic 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned 0 N
+t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 NULL Create_time NULL NULL latin1_swedish_ci NULL partitioned 0 N
insert into t1 values (0), (1), (2), (3);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 InnoDB 10 Dynamic 4 4096 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned 0 N
+t1 InnoDB 10 Dynamic 4 4096 16384 0 0 0 NULL Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N
drop table t1;
create table t1 (a int auto_increment primary key)
engine = innodb
partition by key (a);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 InnoDB 10 Dynamic 2 8192 16384 0 0 # 1 # NULL NULL latin1_swedish_ci NULL partitioned 0 N
+t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 1 Create_time NULL NULL latin1_swedish_ci NULL partitioned 0 N
insert into t1 values (NULL), (NULL), (NULL), (NULL);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 InnoDB 10 Dynamic 4 4096 16384 0 0 # 5 # NULL NULL latin1_swedish_ci NULL partitioned 0 N
+t1 InnoDB 10 Dynamic 4 4096 16384 0 0 0 5 Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N
insert into t1 values (NULL), (NULL), (NULL), (NULL);
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 InnoDB 10 Dynamic 8 2048 16384 0 0 # 9 # NULL NULL latin1_swedish_ci NULL partitioned 0 N
+t1 InnoDB 10 Dynamic 8 2048 16384 0 0 0 9 Create_time Update_time NULL latin1_swedish_ci NULL partitioned 0 N
drop table t1;
create table t1 (a int)
partition by key (a)
diff --git a/mysql-test/main/partition_innodb.test b/mysql-test/main/partition_innodb.test
index 1a05ce6e20d..16fd7ea60ef 100644
--- a/mysql-test/main/partition_innodb.test
+++ b/mysql-test/main/partition_innodb.test
@@ -411,9 +411,7 @@ DROP TABLE t1;
# Bug #14673: Wrong InnoDB default row format
#
create table t1 (a int) engine=innodb partition by hash(a) ;
-# Data_free for InnoDB tablespace varies depending on which
-# tests have been run before this one
---replace_column 10 # 12 #
+--replace_column 12 #
show table status like 't1';
drop table t1;
@@ -423,33 +421,23 @@ drop table t1;
create table t1 (a int)
engine = innodb
partition by key (a);
-# Data_free for InnoDB tablespace varies depending on which
-# tests have been run before this one
---replace_column 10 # 12 #
+--replace_column 12 Create_time
show table status;
insert into t1 values (0), (1), (2), (3);
-# Data_free for InnoDB tablespace varies depending on which
-# tests have been run before this one
---replace_column 10 # 12 #
+--replace_column 12 Create_time 13 Update_time
show table status;
drop table t1;
create table t1 (a int auto_increment primary key)
engine = innodb
partition by key (a);
-# Data_free for InnoDB tablespace varies depending on which
-# tests have been run before this one
---replace_column 10 # 12 #
+--replace_column 12 Create_time
show table status;
insert into t1 values (NULL), (NULL), (NULL), (NULL);
-# Data_free for InnoDB tablespace varies depending on which
-# tests have been run before this one
---replace_column 10 # 12 #
+--replace_column 12 Create_time 13 Update_time
show table status;
insert into t1 values (NULL), (NULL), (NULL), (NULL);
-# Data_free for InnoDB tablespace varies depending on which
-# tests have been run before this one
---replace_column 10 # 12 #
+--replace_column 12 Create_time 13 Update_time
show table status;
drop table t1;
diff --git a/mysql-test/main/partition_mrr_aria.result b/mysql-test/main/partition_mrr_aria.result
index 8e7f893e609..99fb17338c3 100644
--- a/mysql-test/main/partition_mrr_aria.result
+++ b/mysql-test/main/partition_mrr_aria.result
@@ -39,6 +39,7 @@ A.a,
B.a,
123456
from t1 A, t1 B;
+set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='mrr=on';
explain
select * from t3 force index (key_col) where key_col < 3;
@@ -76,4 +77,164 @@ ID part_id key_col col2
27 7 2 123456
28 8 2 123456
29 9 2 123456
+set optimizer_switch=@save_optimizer_switch;
drop table t1,t3;
+#
+# MDEV-21544: partitioned table is joined with BKA+MRR
+#
+set @save_join_cache_level=@@join_cache_level;
+set @save_optimizer_switch=@@optimizer_switch;
+create table t0 (
+tp int, a int, b int not null, c varchar(12), index idx (a,b)
+);
+insert into t0 values
+(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'),
+(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'),
+(1,3,30,'yzzy'), (1,93,30,'zzzy'),
+(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'),
+(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'),
+(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'),
+(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'),
+(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'),
+(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'),
+(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'),
+(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'),
+(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'),
+(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'),
+(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'),
+(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'),
+(3,4,30,'zzzyy'), (3,94,30,'yyz');
+create table t1 (
+tp int, a int, b int not null, c varchar(12), index idx (a,b)
+)
+partition by list (tp)
+( partition p1 values in (1),
+partition p2 values in (2),
+partition p3 values in (3));
+insert into t1 select * from t0;
+create table t2 (a int, index idx(a));
+insert into t2 values
+(1), (2), (3), (4), (5);
+insert into t2 select a+10 from t2;
+insert into t2 select a+20 from t2;
+analyze table t0,t1,t2;
+Table Op Msg_type Msg_text
+test.t0 analyze status Engine-independent statistics collected
+test.t0 analyze status OK
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+set join_cache_level=6;
+set optimizer_switch='mrr=on';
+explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
+tp a b c a
+3 4 30 yx 4
+3 4 30 yyxxx 4
+3 4 30 zzyy 4
+3 4 30 zxyy 4
+3 4 30 xxyy 4
+3 4 30 yyzx 4
+3 4 30 zyyy 4
+3 4 30 yzy 4
+3 4 30 zzzyy 4
+explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
+tp a b c a
+3 4 30 yx 4
+3 4 30 yyxxx 4
+3 4 30 zzyy 4
+3 4 30 zxyy 4
+3 4 30 xxyy 4
+3 4 30 yyzx 4
+3 4 30 zyyy 4
+3 4 30 yzy 4
+3 4 30 zzzyy 4
+explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+tp a b c a
+2 3 40 yxx 3
+2 4 40 xx 4
+2 3 40 yyx 3
+2 4 40 xxx 4
+2 3 40 xzzzz 3
+2 4 40 yyyxx 4
+2 3 40 xxx 3
+2 4 40 xx 4
+2 3 40 yyxzx 3
+2 4 40 xyx 4
+2 3 40 xxxzz 3
+2 4 40 xxz 4
+2 3 40 zzxxx 3
+2 4 40 zxx 4
+2 3 40 xyyxx 3
+2 4 40 xzzzx 4
+2 3 40 yzxxx 3
+2 4 40 xxzy 4
+explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+tp a b c a
+2 3 40 yxx 3
+2 4 40 xx 4
+2 3 40 yyx 3
+2 4 40 xxx 4
+2 3 40 xzzzz 3
+2 4 40 yyyxx 4
+2 3 40 xxx 3
+2 4 40 xx 4
+2 3 40 yyxzx 3
+2 4 40 xyx 4
+2 3 40 xxxzz 3
+2 4 40 xxz 4
+2 3 40 zzxxx 3
+2 4 40 zxx 4
+2 3 40 xyyxx 3
+2 4 40 xzzzx 4
+2 3 40 yzxxx 3
+2 4 40 xxzy 4
+insert into t2 values
+(3), (4), (5);
+analyze table t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null
+select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
+a tp a b c
+explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null
+select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
+a tp a b c
+set join_cache_level=@save_join_cache_level;
+set optimizer_switch=@save_optimizer_switch;
+drop table t0,t1,t2;
diff --git a/mysql-test/main/partition_mrr_innodb.result b/mysql-test/main/partition_mrr_innodb.result
index 10ecb0c878f..8e34914a6e3 100644
--- a/mysql-test/main/partition_mrr_innodb.result
+++ b/mysql-test/main/partition_mrr_innodb.result
@@ -39,6 +39,7 @@ A.a,
B.a,
123456
from t1 A, t1 B;
+set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='mrr=on';
explain
select * from t3 force index (key_col) where key_col < 3;
@@ -76,4 +77,164 @@ ID part_id key_col col2
27 7 2 123456
28 8 2 123456
29 9 2 123456
+set optimizer_switch=@save_optimizer_switch;
drop table t1,t3;
+#
+# MDEV-21544: partitioned table is joined with BKA+MRR
+#
+set @save_join_cache_level=@@join_cache_level;
+set @save_optimizer_switch=@@optimizer_switch;
+create table t0 (
+tp int, a int, b int not null, c varchar(12), index idx (a,b)
+);
+insert into t0 values
+(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'),
+(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'),
+(1,3,30,'yzzy'), (1,93,30,'zzzy'),
+(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'),
+(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'),
+(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'),
+(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'),
+(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'),
+(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'),
+(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'),
+(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'),
+(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'),
+(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'),
+(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'),
+(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'),
+(3,4,30,'zzzyy'), (3,94,30,'yyz');
+create table t1 (
+tp int, a int, b int not null, c varchar(12), index idx (a,b)
+)
+partition by list (tp)
+( partition p1 values in (1),
+partition p2 values in (2),
+partition p3 values in (3));
+insert into t1 select * from t0;
+create table t2 (a int, index idx(a));
+insert into t2 values
+(1), (2), (3), (4), (5);
+insert into t2 select a+10 from t2;
+insert into t2 select a+20 from t2;
+analyze table t0,t1,t2;
+Table Op Msg_type Msg_text
+test.t0 analyze status Engine-independent statistics collected
+test.t0 analyze status OK
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+set join_cache_level=6;
+set optimizer_switch='mrr=on';
+explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
+tp a b c a
+3 4 30 yx 4
+3 4 30 yyxxx 4
+3 4 30 zzyy 4
+3 4 30 zxyy 4
+3 4 30 xxyy 4
+3 4 30 yyzx 4
+3 4 30 zyyy 4
+3 4 30 yzy 4
+3 4 30 zzzyy 4
+explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
+tp a b c a
+3 4 30 yx 4
+3 4 30 yyxxx 4
+3 4 30 zzyy 4
+3 4 30 zxyy 4
+3 4 30 xxyy 4
+3 4 30 yyzx 4
+3 4 30 zyyy 4
+3 4 30 yzy 4
+3 4 30 zzzyy 4
+explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+tp a b c a
+2 3 40 yxx 3
+2 4 40 xx 4
+2 3 40 yyx 3
+2 4 40 xxx 4
+2 3 40 xzzzz 3
+2 4 40 yyyxx 4
+2 3 40 xxx 3
+2 4 40 xx 4
+2 3 40 yyxzx 3
+2 4 40 xyx 4
+2 3 40 xxxzz 3
+2 4 40 xxz 4
+2 3 40 zzxxx 3
+2 4 40 zxx 4
+2 3 40 xyyxx 3
+2 4 40 xzzzx 4
+2 3 40 yzxxx 3
+2 4 40 xxzy 4
+explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+tp a b c a
+2 3 40 yxx 3
+2 4 40 xx 4
+2 3 40 yyx 3
+2 4 40 xxx 4
+2 3 40 xzzzz 3
+2 4 40 yyyxx 4
+2 3 40 xxx 3
+2 4 40 xx 4
+2 3 40 yyxzx 3
+2 4 40 xyx 4
+2 3 40 xxxzz 3
+2 4 40 xxz 4
+2 3 40 zzxxx 3
+2 4 40 zxx 4
+2 3 40 xyyxx 3
+2 4 40 xzzzx 4
+2 3 40 yzxxx 3
+2 4 40 xxzy 4
+insert into t2 values
+(3), (4), (5);
+analyze table t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null
+select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
+a tp a b c
+explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null
+select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
+a tp a b c
+set join_cache_level=@save_join_cache_level;
+set optimizer_switch=@save_optimizer_switch;
+drop table t0,t1,t2;
diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result
index 2b172e6bd7b..395b64ffb11 100644
--- a/mysql-test/main/partition_mrr_myisam.result
+++ b/mysql-test/main/partition_mrr_myisam.result
@@ -39,6 +39,7 @@ A.a,
B.a,
123456
from t1 A, t1 B;
+set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='mrr=on';
explain
select * from t3 force index (key_col) where key_col < 3;
@@ -76,4 +77,223 @@ ID part_id key_col col2
27 7 2 123456
28 8 2 123456
29 9 2 123456
+set optimizer_switch=@save_optimizer_switch;
drop table t1,t3;
+#
+# MDEV-21544: partitioned table is joined with BKA+MRR
+#
+set @save_join_cache_level=@@join_cache_level;
+set @save_optimizer_switch=@@optimizer_switch;
+create table t0 (
+tp int, a int, b int not null, c varchar(12), index idx (a,b)
+);
+insert into t0 values
+(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'),
+(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'),
+(1,3,30,'yzzy'), (1,93,30,'zzzy'),
+(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'),
+(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'),
+(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'),
+(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'),
+(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'),
+(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'),
+(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'),
+(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'),
+(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'),
+(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'),
+(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'),
+(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'),
+(3,4,30,'zzzyy'), (3,94,30,'yyz');
+create table t1 (
+tp int, a int, b int not null, c varchar(12), index idx (a,b)
+)
+partition by list (tp)
+( partition p1 values in (1),
+partition p2 values in (2),
+partition p3 values in (3));
+insert into t1 select * from t0;
+create table t2 (a int, index idx(a));
+insert into t2 values
+(1), (2), (3), (4), (5);
+insert into t2 select a+10 from t2;
+insert into t2 select a+20 from t2;
+analyze table t0,t1,t2;
+Table Op Msg_type Msg_text
+test.t0 analyze status Engine-independent statistics collected
+test.t0 analyze status OK
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+set join_cache_level=6;
+set optimizer_switch='mrr=on';
+explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
+tp a b c a
+3 4 30 yx 4
+3 4 30 yyxxx 4
+3 4 30 zzyy 4
+3 4 30 zxyy 4
+3 4 30 xxyy 4
+3 4 30 yyzx 4
+3 4 30 zyyy 4
+3 4 30 yzy 4
+3 4 30 zzzyy 4
+explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
+tp a b c a
+3 4 30 yx 4
+3 4 30 yyxxx 4
+3 4 30 zzyy 4
+3 4 30 zxyy 4
+3 4 30 xxyy 4
+3 4 30 yyzx 4
+3 4 30 zyyy 4
+3 4 30 yzy 4
+3 4 30 zzzyy 4
+explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+tp a b c a
+2 3 40 yxx 3
+2 4 40 xx 4
+2 3 40 yyx 3
+2 4 40 xxx 4
+2 3 40 xzzzz 3
+2 4 40 yyyxx 4
+2 3 40 xxx 3
+2 4 40 xx 4
+2 3 40 yyxzx 3
+2 4 40 xyx 4
+2 3 40 xxxzz 3
+2 4 40 xxz 4
+2 3 40 zzxxx 3
+2 4 40 zxx 4
+2 3 40 xyyxx 3
+2 4 40 xzzzx 4
+2 3 40 yzxxx 3
+2 4 40 xxzy 4
+explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+tp a b c a
+2 3 40 yxx 3
+2 4 40 xx 4
+2 3 40 yyx 3
+2 4 40 xxx 4
+2 3 40 xzzzz 3
+2 4 40 yyyxx 4
+2 3 40 xxx 3
+2 4 40 xx 4
+2 3 40 yyxzx 3
+2 4 40 xyx 4
+2 3 40 xxxzz 3
+2 4 40 xxz 4
+2 3 40 zzxxx 3
+2 4 40 zxx 4
+2 3 40 xyyxx 3
+2 4 40 xzzzx 4
+2 3 40 yzxxx 3
+2 4 40 xxzy 4
+insert into t2 values
+(3), (4), (5);
+analyze table t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null
+select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
+a tp a b c
+explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null
+select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
+a tp a b c
+set join_cache_level=@save_join_cache_level;
+set optimizer_switch=@save_optimizer_switch;
+drop table t0,t1,t2;
+#
+# MDEV-21628: Index condition pushdown for a simple condition over
+# index fields is not used for ref access of partitioned tables when employing BKA
+#
+create table t0 (
+tp int, a int, b int, c varchar(12), index idx (a,b)
+);
+insert into t0 values
+(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'),
+(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'),
+(1,3,30,'yzzy'), (1,93,30,'zzzy'),
+(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'),
+(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'),
+(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'),
+(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'),
+(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'),
+(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'),
+(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'),
+(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'),
+(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'),
+(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'),
+(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'),
+(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'),
+(3,4,30,'zzzyy'), (3,94,30,'yyz');
+create table t1 (
+tp int, a int, b int, c varchar(12), index idx (a,b)
+) engine=myisam
+partition by list (tp)
+( partition p1 values in (1),
+partition p2 values in (2),
+partition p3 values in (3));
+insert into t1 select * from t0;
+create table t2 (a int, index idx(a)) engine=myisam;
+insert into t2 values (1), (2), (3), (4), (5);
+insert into t2 select a+10 from t2;
+insert into t2 select a+20 from t2;
+analyze table t0,t1,t2;
+Table Op Msg_type Msg_text
+test.t0 analyze status Engine-independent statistics collected
+test.t0 analyze status OK
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+set @tmp1=@@join_cache_level, @tmp2=@@optimizer_switch;
+set join_cache_level=6, optimizer_switch='mrr=on';
+explain
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index
+1 SIMPLE t0 ref idx idx 5 test.t2.a 12 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
+# This will use "Using index condition(BKA)"
+explain
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index
+1 SIMPLE t1 ref idx idx 5 test.t2.a 12 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
+set join_cache_level=@tmp1, optimizer_switch=@tmp2;
+drop table t0,t1,t2;
diff --git a/mysql-test/main/partition_mrr_myisam.test b/mysql-test/main/partition_mrr_myisam.test
index d67a37ab3d2..eb30319d81f 100644
--- a/mysql-test/main/partition_mrr_myisam.test
+++ b/mysql-test/main/partition_mrr_myisam.test
@@ -1,3 +1,62 @@
let $engine_type= myisam;
--source include/partition_mrr.inc
+
+--echo #
+--echo # MDEV-21628: Index condition pushdown for a simple condition over
+--echo # index fields is not used for ref access of partitioned tables when employing BKA
+--echo #
+
+create table t0 (
+tp int, a int, b int, c varchar(12), index idx (a,b)
+);
+
+insert into t0 values
+(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'),
+(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'),
+(1,3,30,'yzzy'), (1,93,30,'zzzy'),
+(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'),
+(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'),
+(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'),
+(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'),
+(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'),
+(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'),
+(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'),
+(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'),
+(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'),
+(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'),
+(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'),
+(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'),
+(3,4,30,'zzzyy'), (3,94,30,'yyz');
+
+create table t1 (
+tp int, a int, b int, c varchar(12), index idx (a,b)
+) engine=myisam
+partition by list (tp)
+( partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3));
+insert into t1 select * from t0;
+
+create table t2 (a int, index idx(a)) engine=myisam;
+insert into t2 values (1), (2), (3), (4), (5);
+insert into t2 select a+10 from t2;
+insert into t2 select a+20 from t2;
+
+analyze table t0,t1,t2;
+
+set @tmp1=@@join_cache_level, @tmp2=@@optimizer_switch;
+set join_cache_level=6, optimizer_switch='mrr=on';
+
+explain
+select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
+
+--echo # This will use "Using index condition(BKA)"
+explain
+select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
+
+set join_cache_level=@tmp1, optimizer_switch=@tmp2;
+
+drop table t0,t1,t2;
+
+
diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result
index bc7b220d92d..f0fa6736daa 100644
--- a/mysql-test/main/rowid_filter_innodb.result
+++ b/mysql-test/main/rowid_filter_innodb.result
@@ -2548,3 +2548,339 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 index a,b PRIMARY 4 NULL 3008 3008.00 1.36 0.00 Using where
DROP TABLE t1;
SET global innodb_stats_persistent= @stats.save;
+#
+# MDEV-21610: Using rowid filter with BKA+MRR
+#
+set @stats.save= @@innodb_stats_persistent;
+set global innodb_stats_persistent=on;
+CREATE TABLE acli (
+id bigint(20) NOT NULL,
+rid varchar(255) NOT NULL,
+tp smallint(6) NOT NULL DEFAULT 0,
+PRIMARY KEY (id),
+KEY acli_rid (rid),
+KEY acli_tp (tp)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+insert into acli(id,rid,tp) values
+(184929059698905997,'ABABABABABABABABAB',103),
+(184929059698905998,'ABABABABABABABABAB',121),
+(283586039035985921,'00000000000000000000000000000000',103),
+(2216474704108064678,'020BED6D07B741CE9B10AB2200FEF1DF',103),
+(2216474704108064679,'020BED6D07B741CE9B10AB2200FEF1DF',121),
+(3080602882609775593,'B5FCC8C7111E4E3CBC21AAF5012F59C2',103),
+(3080602882609775594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121),
+(3080602882609776594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121),
+(3080602882609777595,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121),
+(4269412446747236214,'SCSCSCSCSCSCSCSC',103),
+(4269412446747236215,'SCSCSCSCSCSCSCSC',121),
+(6341490487802728356,'6072D47E513F4A4794BBAB2200FDB67D',103),
+(6341490487802728357,'6072D47E513F4A4794BBAB2200FDB67D',121);
+CREATE TABLE acei (
+id bigint(20) NOT NULL,
+aclid bigint(20) NOT NULL DEFAULT 0,
+atp smallint(6) NOT NULL DEFAULT 0,
+clus smallint(6) NOT NULL DEFAULT 0,
+PRIMARY KEY (id),
+KEY acei_aclid (aclid),
+KEY acei_clus (clus)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+insert into acei(id,aclid,atp,clus) values
+(184929059698905999,184929059698905997,0,1),
+(184929059698906000,184929059698905997,0,1),
+(184929059698906001,184929059698905997,1,1),
+(184929059698906002,184929059698905998,1,1),
+(283586039035985922,283586039035985921,1,1),
+(2216474704108064684,2216474704108064678,0,1),
+(2216474704108064685,2216474704108064678,0,1),
+(2216474704108064686,2216474704108064678,1,1),
+(2216474704108064687,2216474704108064679,1,1),
+(3080602882609775595,3080602882609775593,0,1),
+(3080602882609775596,3080602882609775593,0,1),
+(3080602882609775597,3080602882609775593,1,1),
+(3080602882609775598,3080602882609775594,1,1),
+(3080602882609776595,3080602882609776594,1,1),
+(3080602882609777596,3080602882609777595,1,1),
+(4269412446747236216,4269412446747236214,0,1),
+(4269412446747236217,4269412446747236214,0,1),
+(4269412446747236218,4269412446747236214,1,1),
+(4269412446747236219,4269412446747236215,1,1),
+(6341490487802728358,6341490487802728356,0,1),
+(6341490487802728359,6341490487802728356,0,1),
+(6341490487802728360,6341490487802728356,1,1),
+(6341490487802728361,6341490487802728357,1,1);
+CREATE TABLE filt (
+id bigint(20) NOT NULL,
+aceid bigint(20) NOT NULL DEFAULT 0,
+clid smallint(6) NOT NULL DEFAULT 0,
+fh bigint(20) NOT NULL DEFAULT 0,
+PRIMARY KEY (id),
+KEY filt_aceid (aceid),
+KEY filt_clid (clid),
+KEY filt_fh (fh)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+insert into filt(id,aceid,clid,fh) values
+(184929059698905999,184929059698905999,1,8948400944397203540),
+(184929059698906000,184929059698906000,1,-3516039679025944536),
+(184929059698906001,184929059698906001,1,-3516039679025944536),
+(184929059698906002,184929059698906001,1,2965370193075218252),
+(184929059698906003,184929059698906001,1,8948400944397203540),
+(184929059698906004,184929059698906002,1,2478709353550777738),
+(283586039035985922,283586039035985922,1,5902600816362013271),
+(2216474704108064686,2216474704108064684,1,8948400944397203540),
+(2216474704108064687,2216474704108064685,1,-7244708939311117030),
+(2216474704108064688,2216474704108064686,1,-7244708939311117030),
+(2216474704108064689,2216474704108064686,1,7489060986210282479),
+(2216474704108064690,2216474704108064686,1,8948400944397203540),
+(2216474704108064691,2216474704108064687,1,-3575268945274980038),
+(3080602882609775595,3080602882609775595,1,8948400944397203540),
+(3080602882609775596,3080602882609775596,1,-5420422472375069774),
+(3080602882609775597,3080602882609775597,1,-5420422472375069774),
+(3080602882609775598,3080602882609775597,1,8518228073041491534),
+(3080602882609775599,3080602882609775597,1,8948400944397203540),
+(3080602882609775600,3080602882609775598,1,6311439873746261694),
+(3080602882609775601,3080602882609775598,1,6311439873746261694),
+(3080602882609776595,3080602882609776595,1,-661101805245999843),
+(3080602882609777596,3080602882609777596,1,-661101805245999843),
+(3080602882609777597,3080602882609777596,1,2216865386202464067),
+(4269412446747236216,4269412446747236216,1,8948400944397203540),
+(4269412446747236217,4269412446747236217,1,-1143096194892676000),
+(4269412446747236218,4269412446747236218,1,-1143096194892676000),
+(4269412446747236219,4269412446747236218,1,5313391811364818290),
+(4269412446747236220,4269412446747236218,1,8948400944397203540),
+(4269412446747236221,4269412446747236219,1,7624499822621753835),
+(6341490487802728358,6341490487802728358,1,8948400944397203540),
+(6341490487802728359,6341490487802728359,1,8141092449587136068),
+(6341490487802728360,6341490487802728360,1,8141092449587136068),
+(6341490487802728361,6341490487802728360,1,1291319099896431785),
+(6341490487802728362,6341490487802728360,1,8948400944397203540),
+(6341490487802728363,6341490487802728361,1,6701841652906431497);
+analyze table filt, acei, acli;
+Table Op Msg_type Msg_text
+test.filt analyze status Engine-independent statistics collected
+test.filt analyze status OK
+test.acei analyze status Engine-independent statistics collected
+test.acei analyze status OK
+test.acli analyze status Engine-independent statistics collected
+test.acli analyze status OK
+set @save_optimizer_switch=@@optimizer_switch;
+set @save_join_cache_level=@@join_cache_level;
+set optimizer_switch='mrr=off';
+set join_cache_level=2;
+set statement optimizer_switch='rowid_filter=off' for explain extended select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index
+1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where
+1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 17.14 Using where
+Warnings:
+Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)
+set statement optimizer_switch='rowid_filter=off' for select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id id aceid clid fh
+3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694
+3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694
+set statement optimizer_switch='rowid_filter=on' for explain extended select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index
+1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where
+1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 1 (17%) 17.14 Using where; Using rowid filter
+Warnings:
+Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)
+set statement optimizer_switch='rowid_filter=on' for select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id id aceid clid fh
+3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694
+3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694
+set optimizer_switch='mrr=on';
+set join_cache_level=6;
+set statement optimizer_switch='rowid_filter=off' for explain extended select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index
+1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where; Using join buffer (flat, BKA join); Rowid-ordered scan
+1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 17.14 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan
+Warnings:
+Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)
+set statement optimizer_switch='rowid_filter=off' for select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id id aceid clid fh
+3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694
+3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694
+set statement optimizer_switch='rowid_filter=on' for explain extended select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index
+1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where; Using join buffer (flat, BKA join); Rowid-ordered scan
+1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 1 (17%) 17.14 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan; Using rowid filter
+Warnings:
+Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)
+set statement optimizer_switch='rowid_filter=on' for select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+id id aceid clid fh
+3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694
+3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694
+set statement optimizer_switch='rowid_filter=on' for analyze format=json select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+inner join filt fi on a.id = fi.aceid
+where
+t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+t.tp = 121 and
+a.atp = 1 and
+fi.fh in (6311439873746261694,-397087483897438286,
+8518228073041491534,-5420422472375069774);
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "t",
+ "access_type": "index_merge",
+ "possible_keys": ["PRIMARY", "acli_rid", "acli_tp"],
+ "key_length": "2,767",
+ "index_merge": {
+ "intersect": {
+ "range": {
+ "key": "acli_tp",
+ "used_key_parts": ["tp"]
+ },
+ "range": {
+ "key": "acli_rid",
+ "used_key_parts": ["rid"]
+ }
+ }
+ },
+ "r_loops": 1,
+ "rows": 2,
+ "r_rows": 3,
+ "r_table_time_ms": "REPLACED",
+ "r_other_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 100,
+ "attached_condition": "t.tp = 121 and t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2'",
+ "using_index": true
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "a",
+ "access_type": "ref",
+ "possible_keys": ["PRIMARY", "acei_aclid"],
+ "key": "acei_aclid",
+ "key_length": "8",
+ "used_key_parts": ["aclid"],
+ "ref": ["test.t.id"],
+ "r_loops": 1,
+ "rows": 1,
+ "r_rows": 3,
+ "r_table_time_ms": "REPLACED",
+ "r_other_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 100
+ },
+ "buffer_type": "flat",
+ "buffer_size": "8Kb",
+ "join_type": "BKA",
+ "mrr_type": "Rowid-ordered scan",
+ "attached_condition": "a.atp = 1",
+ "r_filtered": 100
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "fi",
+ "access_type": "ref",
+ "possible_keys": ["filt_aceid", "filt_fh"],
+ "key": "filt_aceid",
+ "key_length": "8",
+ "used_key_parts": ["aceid"],
+ "ref": ["test.a.id"],
+ "rowid_filter": {
+ "range": {
+ "key": "filt_fh",
+ "used_key_parts": ["fh"]
+ },
+ "rows": 6,
+ "selectivity_pct": 17.143,
+ "r_rows": 5,
+ "r_selectivity_pct": 40,
+ "r_buffer_size": "REPLACED",
+ "r_filling_time_ms": "REPLACED"
+ },
+ "r_loops": 1,
+ "rows": 1,
+ "r_rows": 2,
+ "r_table_time_ms": "REPLACED",
+ "r_other_time_ms": "REPLACED",
+ "filtered": 17.143,
+ "r_filtered": 100
+ },
+ "buffer_type": "incremental",
+ "buffer_size": "603",
+ "join_type": "BKA",
+ "mrr_type": "Rowid-ordered scan",
+ "attached_condition": "fi.fh in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)",
+ "r_filtered": 100
+ }
+ }
+}
+set optimizer_switch=@save_optimizer_switch;
+set join_cache_level=@save_join_cache_level;
+drop table filt, acei, acli;
+set global innodb_stats_persistent= @stats.save;
diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test
index cd64972e100..ab65a40e89e 100644
--- a/mysql-test/main/rowid_filter_innodb.test
+++ b/mysql-test/main/rowid_filter_innodb.test
@@ -381,3 +381,156 @@ ORDER BY pk LIMIT 1;
DROP TABLE t1;
SET global innodb_stats_persistent= @stats.save;
+
+--echo #
+--echo # MDEV-21610: Using rowid filter with BKA+MRR
+--echo #
+
+set @stats.save= @@innodb_stats_persistent;
+set global innodb_stats_persistent=on;
+
+CREATE TABLE acli (
+ id bigint(20) NOT NULL,
+ rid varchar(255) NOT NULL,
+ tp smallint(6) NOT NULL DEFAULT 0,
+ PRIMARY KEY (id),
+ KEY acli_rid (rid),
+ KEY acli_tp (tp)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+insert into acli(id,rid,tp) values
+(184929059698905997,'ABABABABABABABABAB',103),
+(184929059698905998,'ABABABABABABABABAB',121),
+(283586039035985921,'00000000000000000000000000000000',103),
+(2216474704108064678,'020BED6D07B741CE9B10AB2200FEF1DF',103),
+(2216474704108064679,'020BED6D07B741CE9B10AB2200FEF1DF',121),
+(3080602882609775593,'B5FCC8C7111E4E3CBC21AAF5012F59C2',103),
+(3080602882609775594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121),
+(3080602882609776594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121),
+(3080602882609777595,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121),
+(4269412446747236214,'SCSCSCSCSCSCSCSC',103),
+(4269412446747236215,'SCSCSCSCSCSCSCSC',121),
+(6341490487802728356,'6072D47E513F4A4794BBAB2200FDB67D',103),
+(6341490487802728357,'6072D47E513F4A4794BBAB2200FDB67D',121);
+
+CREATE TABLE acei (
+ id bigint(20) NOT NULL,
+ aclid bigint(20) NOT NULL DEFAULT 0,
+ atp smallint(6) NOT NULL DEFAULT 0,
+ clus smallint(6) NOT NULL DEFAULT 0,
+ PRIMARY KEY (id),
+ KEY acei_aclid (aclid),
+ KEY acei_clus (clus)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+insert into acei(id,aclid,atp,clus) values
+(184929059698905999,184929059698905997,0,1),
+(184929059698906000,184929059698905997,0,1),
+(184929059698906001,184929059698905997,1,1),
+(184929059698906002,184929059698905998,1,1),
+(283586039035985922,283586039035985921,1,1),
+(2216474704108064684,2216474704108064678,0,1),
+(2216474704108064685,2216474704108064678,0,1),
+(2216474704108064686,2216474704108064678,1,1),
+(2216474704108064687,2216474704108064679,1,1),
+(3080602882609775595,3080602882609775593,0,1),
+(3080602882609775596,3080602882609775593,0,1),
+(3080602882609775597,3080602882609775593,1,1),
+(3080602882609775598,3080602882609775594,1,1),
+(3080602882609776595,3080602882609776594,1,1),
+(3080602882609777596,3080602882609777595,1,1),
+(4269412446747236216,4269412446747236214,0,1),
+(4269412446747236217,4269412446747236214,0,1),
+(4269412446747236218,4269412446747236214,1,1),
+(4269412446747236219,4269412446747236215,1,1),
+(6341490487802728358,6341490487802728356,0,1),
+(6341490487802728359,6341490487802728356,0,1),
+(6341490487802728360,6341490487802728356,1,1),
+(6341490487802728361,6341490487802728357,1,1);
+
+CREATE TABLE filt (
+ id bigint(20) NOT NULL,
+ aceid bigint(20) NOT NULL DEFAULT 0,
+ clid smallint(6) NOT NULL DEFAULT 0,
+ fh bigint(20) NOT NULL DEFAULT 0,
+ PRIMARY KEY (id),
+ KEY filt_aceid (aceid),
+ KEY filt_clid (clid),
+ KEY filt_fh (fh)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+insert into filt(id,aceid,clid,fh) values
+(184929059698905999,184929059698905999,1,8948400944397203540),
+(184929059698906000,184929059698906000,1,-3516039679025944536),
+(184929059698906001,184929059698906001,1,-3516039679025944536),
+(184929059698906002,184929059698906001,1,2965370193075218252),
+(184929059698906003,184929059698906001,1,8948400944397203540),
+(184929059698906004,184929059698906002,1,2478709353550777738),
+(283586039035985922,283586039035985922,1,5902600816362013271),
+(2216474704108064686,2216474704108064684,1,8948400944397203540),
+(2216474704108064687,2216474704108064685,1,-7244708939311117030),
+(2216474704108064688,2216474704108064686,1,-7244708939311117030),
+(2216474704108064689,2216474704108064686,1,7489060986210282479),
+(2216474704108064690,2216474704108064686,1,8948400944397203540),
+(2216474704108064691,2216474704108064687,1,-3575268945274980038),
+(3080602882609775595,3080602882609775595,1,8948400944397203540),
+(3080602882609775596,3080602882609775596,1,-5420422472375069774),
+(3080602882609775597,3080602882609775597,1,-5420422472375069774),
+(3080602882609775598,3080602882609775597,1,8518228073041491534),
+(3080602882609775599,3080602882609775597,1,8948400944397203540),
+(3080602882609775600,3080602882609775598,1,6311439873746261694),
+(3080602882609775601,3080602882609775598,1,6311439873746261694),
+(3080602882609776595,3080602882609776595,1,-661101805245999843),
+(3080602882609777596,3080602882609777596,1,-661101805245999843),
+(3080602882609777597,3080602882609777596,1,2216865386202464067),
+(4269412446747236216,4269412446747236216,1,8948400944397203540),
+(4269412446747236217,4269412446747236217,1,-1143096194892676000),
+(4269412446747236218,4269412446747236218,1,-1143096194892676000),
+(4269412446747236219,4269412446747236218,1,5313391811364818290),
+(4269412446747236220,4269412446747236218,1,8948400944397203540),
+(4269412446747236221,4269412446747236219,1,7624499822621753835),
+(6341490487802728358,6341490487802728358,1,8948400944397203540),
+(6341490487802728359,6341490487802728359,1,8141092449587136068),
+(6341490487802728360,6341490487802728360,1,8141092449587136068),
+(6341490487802728361,6341490487802728360,1,1291319099896431785),
+(6341490487802728362,6341490487802728360,1,8948400944397203540),
+(6341490487802728363,6341490487802728361,1,6701841652906431497);
+
+analyze table filt, acei, acli;
+
+let $q=
+select t.id, fi.*
+from (acli t inner join acei a on a.aclid = t.id)
+ inner join filt fi on a.id = fi.aceid
+ where
+ t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and
+ t.tp = 121 and
+ a.atp = 1 and
+ fi.fh in (6311439873746261694,-397087483897438286,
+ 8518228073041491534,-5420422472375069774);
+
+set @save_optimizer_switch=@@optimizer_switch;
+set @save_join_cache_level=@@join_cache_level;
+
+set optimizer_switch='mrr=off';
+set join_cache_level=2;
+eval $without_filter explain extended $q;
+eval $without_filter $q;
+eval $with_filter explain extended $q;
+eval $with_filter $q;
+
+set optimizer_switch='mrr=on';
+set join_cache_level=6;
+eval $without_filter explain extended $q;
+eval $without_filter $q;
+eval $with_filter explain extended $q;
+eval $with_filter $q;
+--source include/analyze-format.inc
+eval $with_filter analyze format=json $q;
+
+set optimizer_switch=@save_optimizer_switch;
+set join_cache_level=@save_join_cache_level;
+
+drop table filt, acei, acli;
+
+set global innodb_stats_persistent= @stats.save;
diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def
index 24a75386511..5b3a040c293 100644
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@ -19,7 +19,6 @@ MW-328A : MDEV-21483 galera.MW-328A galera.MW-328B
MW-328B : MDEV-21483 galera.MW-328A galera.MW-328B
MW-329 : MDEV-19962 Galera test failure on MW-329
galera.galera_defaults : MDEV-21494 Galera test sporadic failure on galera.galera_defaults
-galera_as_slave_gtid_replicate_do_db_cc : MDEV-21796 Crash on galera.galera_as_slave_gtid_replicate_do_db_cc
galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event()
galera_autoinc_sst_mariabackup : Known issue, may require porting MDEV-17458 from later versions
galera_bf_abort_group_commit : MDEV-18282 Galera test failure on galera.galera_bf_abort_group_commit
@@ -27,7 +26,6 @@ galera_binlog_stmt_autoinc : MDEV-19959 Galera test failure on galera_binlog_stm
galera_encrypt_tmp_files : Get error failed to enable encryption of temporary files
galera_ftwrl : MDEV-21525 galera.galera_ftwrl
galera_gcache_recover_manytrx : MDEV-18834 Galera test failure
-galera_ist_mariabackup : MDEV-18829 test leaves port open
galera_ist_progress : MDEV-15236 fails when trying to read transfer status
galera_kill_largechanges : MDEV-18179 Galera test failure on galera.galera_kill_largechanges
galera_kill_nochanges : MDEV-18280 Galera test failure on galera_split_brain and galera_kill_nochanges
@@ -45,12 +43,13 @@ galera_sst_mariabackup_table_options: MDEV-19741 Galera test failure on galera.g
galera_toi_ddl_nonconflicting : MDEV-21518 galera.galera_toi_ddl_nonconflicting
galera_var_innodb_disallow_writes : MDEV-20928 galera.galera_var_innodb_disallow_writes
galera_var_node_address : MDEV-20485 Galera test failure
-galera_var_notify_cmd : MDEV-21488,MDEV-20600
+galera_var_notify_cmd : MDEV-21905 Galera test galera_var_notify_cmd causes hang
galera_var_reject_queries : assertion in inline_mysql_socket_send
galera_var_retry_autocommit: MDEV-18181 Galera test failure on galera.galera_var_retry_autocommit
galera_wan : MDEV-17259 Test failure on galera.galera_wan
galera_wsrep_new_cluster : MDEV-21515 galera.galera_wsrep_new_cluster
mysql-wsrep#198 : MDEV-18935 Galera test mysql-wsrep#198 sporaric assertion transaction.cpp:362: int wsrep::transaction::before_commit(): Assertion `state() == s_executing || state() == s_committing || state() == s_must_abort || state() == s_replaying' failed.
+lp1376747-4 : MDEV-21911 Galera test failure on lp1376747-4
partition : MDEV-19958 Galera test failure on galera.partition
query_cache: MDEV-15805 Test failure on galera.query_cache
sql_log_bin : MDEV-21491 galera.sql_log_bin
diff --git a/mysql-test/suite/galera/r/galera_as_master_gtid.result b/mysql-test/suite/galera/r/galera_as_master_gtid.result
deleted file mode 100644
index 51337321712..00000000000
--- a/mysql-test/suite/galera/r/galera_as_master_gtid.result
+++ /dev/null
@@ -1,29 +0,0 @@
-connection node_2;
-connection node_1;
-connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
-START SLAVE;
-connection node_1;
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(1);
-SELECT @@global.gtid_binlog_pos;
-@@global.gtid_binlog_pos
-100-1-2
-connection node_2;
-INSERT INTO t1 VALUES(2);
-gtid_do_not_match
-1
-connection node_3;
-gtid_do_not_match
-1
-connection node_1;
-DROP TABLE t1;
-connection node_3;
-connection node_1;
-connection node_2;
-gtid_executed_equal
-1
-connection node_3;
-gtid_executed_equal
-1
-STOP SLAVE;
-RESET SLAVE ALL;
diff --git a/mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result b/mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result
deleted file mode 100644
index 38040fbe9d7..00000000000
--- a/mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result
+++ /dev/null
@@ -1,31 +0,0 @@
-connection node_2;
-connection node_1;
-connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
-START SLAVE;
-connection node_1;
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(1);
-connection node_2;
-INSERT INTO t1 VALUES(2);
-connection node_3;
-STOP SLAVE;
-START SLAVE;
-connection node_1;
-INSERT INTO t1 VALUES(3);
-connection node_2;
-INSERT INTO t1 VALUES(4);
-connection node_3;
-connection node_1;
-DROP TABLE t1;
-connection node_3;
-STOP SLAVE;
-RESET SLAVE ALL;
-RESET MASTER;
-connection node_2;
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
-connection node_1;
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result
index 6d808ce801e..e2fb5a05e9c 100644
--- a/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result
+++ b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result
@@ -1,5 +1,8 @@
connection node_2;
connection node_1;
+SELECT @@WSREP_ON;
+@@WSREP_ON
+1
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
SELECT @@wsrep_on;
@@wsrep_on
diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result
deleted file mode 100644
index afe30250811..00000000000
--- a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result
+++ /dev/null
@@ -1,168 +0,0 @@
-connection node_2;
-connection node_1;
-connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
-connection node_1;
-SET global wsrep_on=OFF;
-RESET MASTER;
-SET global wsrep_on=ON;
-connection node_3;
-RESET MASTER;
-connection node_2;
-SET global wsrep_on=OFF;
-RESET MASTER;
-SET global wsrep_on=ON;
-START SLAVE;
-connection node_3;
-CREATE SCHEMA test1;
-CREATE SCHEMA test2;
-USE test1;
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB;
-USE test2;
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB;
-INSERT INTO test1.t1 (f1) VALUES (1);
-INSERT INTO test2.t1 (f1) VALUES (1);
-INSERT INTO test1.t1 (f1) VALUES (2);
-INSERT INTO test2.t1 (f1) VALUES (2);
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-UPDATE test2.t1 SET test2.t1.f2 = 'cde';
-UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz';
-DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3;
-SET AUTOCOMMIT=OFF;
-START TRANSACTION;
-INSERT INTO test2.t1 (f1) VALUES (999);
-INSERT INTO test2.t1 (f1) VALUES (9999);
-COMMIT;
-START TRANSACTION;
-INSERT INTO test1.t1 (f1) VALUES (111);
-INSERT INTO test1.t1 (f1) VALUES (222);
-COMMIT;
-START TRANSACTION;
-INSERT INTO test1.t1 (f1) VALUES (333);
-INSERT INTO test2.t1 (f1) VALUES (99999);
-COMMIT;
-connection node_2;
-SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 256 Gtid_list 2 285 []
-master-bin.000001 285 Binlog_checkpoint 2 329 master-bin.000001
-master-bin.000001 329 Gtid 3 371 GTID 0-3-1
-master-bin.000001 371 Query 3 458 CREATE SCHEMA test1
-master-bin.000001 458 Gtid 3 500 GTID 0-3-3
-master-bin.000001 500 Query 3 647 use `test1`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB
-master-bin.000001 647 Gtid 3 689 BEGIN GTID 0-3-5
-master-bin.000001 689 Annotate_rows 3 748 INSERT INTO test1.t1 (f1) VALUES (1)
-master-bin.000001 748 Table_map 3 797 table_id: ### (test1.t1)
-master-bin.000001 797 Write_rows_v1 3 839 table_id: ### flags: STMT_END_F
-master-bin.000001 839 Xid 3 870 COMMIT /* xid=### */
-master-bin.000001 870 Gtid 3 912 BEGIN GTID 0-3-7
-master-bin.000001 912 Annotate_rows 3 971 INSERT INTO test1.t1 (f1) VALUES (2)
-master-bin.000001 971 Table_map 3 1020 table_id: ### (test1.t1)
-master-bin.000001 1020 Write_rows_v1 3 1062 table_id: ### flags: STMT_END_F
-master-bin.000001 1062 Xid 3 1093 COMMIT /* xid=### */
-master-bin.000001 1093 Gtid 3 1135 BEGIN GTID 0-3-9
-master-bin.000001 1135 Annotate_rows 3 1194 INSERT INTO test1.t1 (f1) VALUES (3)
-master-bin.000001 1194 Table_map 3 1243 table_id: ### (test1.t1)
-master-bin.000001 1243 Write_rows_v1 3 1285 table_id: ### flags: STMT_END_F
-master-bin.000001 1285 Xid 3 1316 COMMIT /* xid=### */
-master-bin.000001 1316 Gtid 3 1358 BEGIN GTID 0-3-12
-master-bin.000001 1358 Annotate_rows 3 1451 UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz'
-master-bin.000001 1451 Table_map 3 1500 table_id: ### (test1.t1)
-master-bin.000001 1500 Update_rows_v1 3 1588 table_id: ### flags: STMT_END_F
-master-bin.000001 1588 Xid 3 1619 COMMIT /* xid=### */
-master-bin.000001 1619 Gtid 3 1661 BEGIN GTID 0-3-13
-master-bin.000001 1661 Annotate_rows 3 1795 DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3
-master-bin.000001 1795 Table_map 3 1844 table_id: ### (test1.t1)
-master-bin.000001 1844 Delete_rows_v1 3 1886 table_id: ### flags: STMT_END_F
-master-bin.000001 1886 Xid 3 1917 COMMIT /* xid=### */
-master-bin.000001 1917 Gtid 3 1959 BEGIN GTID 0-3-15
-master-bin.000001 1959 Annotate_rows 3 2020 INSERT INTO test1.t1 (f1) VALUES (111)
-master-bin.000001 2020 Table_map 3 2069 table_id: ### (test1.t1)
-master-bin.000001 2069 Write_rows_v1 3 2111 table_id: ### flags: STMT_END_F
-master-bin.000001 2111 Annotate_rows 3 2172 INSERT INTO test1.t1 (f1) VALUES (222)
-master-bin.000001 2172 Table_map 3 2221 table_id: ### (test1.t1)
-master-bin.000001 2221 Write_rows_v1 3 2263 table_id: ### flags: STMT_END_F
-master-bin.000001 2263 Xid 3 2294 COMMIT /* xid=### */
-master-bin.000001 2294 Gtid 3 2336 BEGIN GTID <effective_uuid>
-master-bin.000001 2336 Annotate_rows 3 2397 INSERT INTO test1.t1 (f1) VALUES (333)
-master-bin.000001 2397 Table_map 3 2446 table_id: ### (test1.t1)
-master-bin.000001 2446 Write_rows_v1 3 2488 table_id: ### flags: STMT_END_F
-master-bin.000001 2488 Xid 3 2519 COMMIT /* xid=### */
-connection node_1;
-gtid_executed_equal
-0
-SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 256 Gtid_list 1 285 []
-master-bin.000001 285 Binlog_checkpoint 1 329 master-bin.000001
-master-bin.000001 329 Gtid 3 371 GTID 0-3-1
-master-bin.000001 371 Query 3 458 CREATE SCHEMA test1
-master-bin.000001 458 Gtid 3 500 GTID 0-3-3
-master-bin.000001 500 Query 3 647 use `test1`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB
-master-bin.000001 647 Gtid 3 689 BEGIN GTID 0-3-5
-master-bin.000001 689 Annotate_rows 3 748 INSERT INTO test1.t1 (f1) VALUES (1)
-master-bin.000001 748 Table_map 3 797 table_id: ### (test1.t1)
-master-bin.000001 797 Write_rows_v1 3 839 table_id: ### flags: STMT_END_F
-master-bin.000001 839 Xid 3 870 COMMIT /* xid=### */
-master-bin.000001 870 Gtid 3 912 BEGIN GTID 0-3-7
-master-bin.000001 912 Annotate_rows 3 971 INSERT INTO test1.t1 (f1) VALUES (2)
-master-bin.000001 971 Table_map 3 1020 table_id: ### (test1.t1)
-master-bin.000001 1020 Write_rows_v1 3 1062 table_id: ### flags: STMT_END_F
-master-bin.000001 1062 Xid 3 1093 COMMIT /* xid=### */
-master-bin.000001 1093 Gtid 3 1135 BEGIN GTID 0-3-9
-master-bin.000001 1135 Annotate_rows 3 1194 INSERT INTO test1.t1 (f1) VALUES (3)
-master-bin.000001 1194 Table_map 3 1243 table_id: ### (test1.t1)
-master-bin.000001 1243 Write_rows_v1 3 1285 table_id: ### flags: STMT_END_F
-master-bin.000001 1285 Xid 3 1316 COMMIT /* xid=### */
-master-bin.000001 1316 Gtid 3 1358 BEGIN GTID 0-3-12
-master-bin.000001 1358 Annotate_rows 3 1451 UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz'
-master-bin.000001 1451 Table_map 3 1500 table_id: ### (test1.t1)
-master-bin.000001 1500 Update_rows_v1 3 1588 table_id: ### flags: STMT_END_F
-master-bin.000001 1588 Xid 3 1619 COMMIT /* xid=### */
-master-bin.000001 1619 Gtid 3 1661 BEGIN GTID 0-3-13
-master-bin.000001 1661 Annotate_rows 3 1795 DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3
-master-bin.000001 1795 Table_map 3 1844 table_id: ### (test1.t1)
-master-bin.000001 1844 Delete_rows_v1 3 1886 table_id: ### flags: STMT_END_F
-master-bin.000001 1886 Xid 3 1917 COMMIT /* xid=### */
-master-bin.000001 1917 Gtid 3 1959 BEGIN GTID 0-3-15
-master-bin.000001 1959 Annotate_rows 3 2020 INSERT INTO test1.t1 (f1) VALUES (111)
-master-bin.000001 2020 Table_map 3 2069 table_id: ### (test1.t1)
-master-bin.000001 2069 Write_rows_v1 3 2111 table_id: ### flags: STMT_END_F
-master-bin.000001 2111 Annotate_rows 3 2172 INSERT INTO test1.t1 (f1) VALUES (222)
-master-bin.000001 2172 Table_map 3 2221 table_id: ### (test1.t1)
-master-bin.000001 2221 Write_rows_v1 3 2263 table_id: ### flags: STMT_END_F
-master-bin.000001 2263 Xid 3 2294 COMMIT /* xid=### */
-master-bin.000001 2294 Gtid 3 2336 BEGIN GTID <effective_uuid>
-master-bin.000001 2336 Annotate_rows 3 2397 INSERT INTO test1.t1 (f1) VALUES (333)
-master-bin.000001 2397 Table_map 3 2446 table_id: ### (test1.t1)
-master-bin.000001 2446 Write_rows_v1 3 2488 table_id: ### flags: STMT_END_F
-master-bin.000001 2488 Xid 3 2519 COMMIT /* xid=### */
-include/diff_servers.inc [servers=1 2]
-connection node_1;
-SELECT COUNT(*) = 2 FROM test1.t1 WHERE f1 IN (1,2);
-COUNT(*) = 2
-1
-SELECT COUNT(*) = 3 FROM test1.t1 WHERE f1 IN (111,222,333);
-COUNT(*) = 3
-1
-SELECT COUNT(*) = 2 FROM test1.t1 WHERE f2 = 'klm';
-COUNT(*) = 2
-1
-USE test2;
-ERROR 42000: Unknown database 'test2'
-connection node_3;
-DROP SCHEMA test1;
-DROP SCHEMA test2;
-connection node_1;
-connection node_2;
-STOP SLAVE;
-RESET SLAVE ALL;
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
-connection node_1;
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
-connection node_3;
-RESET MASTER;
diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result
deleted file mode 100644
index aba5a098b69..00000000000
--- a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result
+++ /dev/null
@@ -1,321 +0,0 @@
-connection node_2;
-connection node_1;
-connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
-connection node_1;
-SET global wsrep_on=OFF;
-RESET MASTER;
-SET global wsrep_on=ON;
-connection node_3;
-RESET MASTER;
-connection node_2;
-SET global wsrep_on=OFF;
-RESET MASTER;
-SET global wsrep_on=ON;
-START SLAVE USER='root';
-Warnings:
-Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
-CREATE SCHEMA test1;
-CREATE SCHEMA test2;
-USE test1;
-CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
-USE test2;
-CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
-INSERT INTO test1.t1 (f1) VALUES (1);
-INSERT INTO test2.t1 (f1) VALUES (1);
-INSERT INTO test1.t1 (f1) VALUES (2);
-INSERT INTO test2.t1 (f1) VALUES (2);
-SET GLOBAL wsrep_provider_options='gmcast.isolate=1';
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-SET SESSION wsrep_on=OFF;
-include/wait_for_slave_sql_error.inc [errno=1047]
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-SET GLOBAL wsrep_provider_options='gmcast.isolate=0';
-INSERT INTO test1.t1 (f1) VALUES (5);
-INSERT INTO test2.t1 (f1) VALUES (5);
-SET SESSION wsrep_on=ON;
-INSERT INTO test1.t1 (f1) VALUES (6);
-INSERT INTO test2.t1 (f1) VALUES (6);
-START SLAVE;
-SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120;
-Log_name Pos Event_type Server_id End_log_pos Info
-mysqld-bin.000001 120 Previous_gtids 2 151
-mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:1'
-mysqld-bin.000001 199 Query 1 294 CREATE SCHEMA test1
-mysqld-bin.000001 294 Gtid 1 342 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:2'
-mysqld-bin.000001 342 Query 1 415 BEGIN
-mysqld-bin.000001 415 Query 1 489 COMMIT
-mysqld-bin.000001 489 Gtid 1 537 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:3'
-mysqld-bin.000001 537 Query 1 655 use `test1`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB
-mysqld-bin.000001 655 Gtid 1 703 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:4'
-mysqld-bin.000001 703 Query 1 776 BEGIN
-mysqld-bin.000001 776 Query 1 850 COMMIT
-mysqld-bin.000001 850 Gtid 1 898 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:5'
-mysqld-bin.000001 898 Query 1 961 BEGIN
-mysqld-bin.000001 961 Table_map 1 1007 table_id: ### (test1.t1)
-mysqld-bin.000001 1007 Write_rows 1 1047 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 1047 Xid 1 1078 COMMIT /* xid=### */
-mysqld-bin.000001 1078 Gtid 1 1126 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:6'
-mysqld-bin.000001 1126 Query 1 1189 BEGIN
-mysqld-bin.000001 1189 Query 1 1253 COMMIT
-mysqld-bin.000001 1253 Gtid 1 1301 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:7'
-mysqld-bin.000001 1301 Query 1 1364 BEGIN
-mysqld-bin.000001 1364 Table_map 1 1410 table_id: ### (test1.t1)
-mysqld-bin.000001 1410 Write_rows 1 1450 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 1450 Xid 1 1481 COMMIT /* xid=### */
-mysqld-bin.000001 1481 Gtid 1 1529 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:8'
-mysqld-bin.000001 1529 Query 1 1592 BEGIN
-mysqld-bin.000001 1592 Query 1 1656 COMMIT
-mysqld-bin.000001 1656 Gtid 2 1704 SET @@SESSION.GTID_NEXT= '<effective_uuid_2>:12'
-mysqld-bin.000001 1704 Query 2 1772 BEGIN
-mysqld-bin.000001 1772 Ignorable 2 1795 # Unrecognized ignorable event
-mysqld-bin.000001 1795 Query 2 1864 COMMIT
-mysqld-bin.000001 1864 Gtid 2 1912 SET @@SESSION.GTID_NEXT= '<effective_uuid_2>:13'
-mysqld-bin.000001 1912 Query 2 1980 BEGIN
-mysqld-bin.000001 1980 Ignorable 2 2003 # Unrecognized ignorable event
-mysqld-bin.000001 2003 Query 2 2072 COMMIT
-mysqld-bin.000001 2072 Gtid 1 2120 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:9'
-mysqld-bin.000001 2120 Query 1 2183 BEGIN
-mysqld-bin.000001 2183 Table_map 1 2229 table_id: ### (test1.t1)
-mysqld-bin.000001 2229 Write_rows 1 2269 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 2269 Xid 1 2300 COMMIT /* xid=### */
-mysqld-bin.000001 2300 Gtid 1 2348 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:10'
-mysqld-bin.000001 2348 Query 1 2411 BEGIN
-mysqld-bin.000001 2411 Query 1 2475 COMMIT
-mysqld-bin.000001 2475 Gtid 1 2523 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:11'
-mysqld-bin.000001 2523 Query 1 2586 BEGIN
-mysqld-bin.000001 2586 Table_map 1 2632 table_id: ### (test1.t1)
-mysqld-bin.000001 2632 Write_rows 1 2672 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 2672 Xid 1 2703 COMMIT /* xid=### */
-mysqld-bin.000001 2703 Gtid 1 2751 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:12'
-mysqld-bin.000001 2751 Query 1 2814 BEGIN
-mysqld-bin.000001 2814 Query 1 2878 COMMIT
-mysqld-bin.000001 2878 Gtid 1 2926 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:13'
-mysqld-bin.000001 2926 Query 1 2989 BEGIN
-mysqld-bin.000001 2989 Table_map 1 3035 table_id: ### (test1.t1)
-mysqld-bin.000001 3035 Write_rows 1 3075 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 3075 Xid 1 3106 COMMIT /* xid=### */
-mysqld-bin.000001 3106 Gtid 1 3154 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:14'
-mysqld-bin.000001 3154 Query 1 3217 BEGIN
-mysqld-bin.000001 3217 Query 1 3281 COMMIT
-mysqld-bin.000001 3281 Gtid 1 3329 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:15'
-mysqld-bin.000001 3329 Query 1 3392 BEGIN
-mysqld-bin.000001 3392 Table_map 1 3438 table_id: ### (test1.t1)
-mysqld-bin.000001 3438 Write_rows 1 3478 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 3478 Xid 1 3509 COMMIT /* xid=### */
-mysqld-bin.000001 3509 Gtid 1 3557 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:16'
-mysqld-bin.000001 3557 Query 1 3620 BEGIN
-mysqld-bin.000001 3620 Query 1 3684 COMMIT
-mysqld-bin.000001 3684 Gtid 1 3732 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:17'
-mysqld-bin.000001 3732 Query 1 3795 BEGIN
-mysqld-bin.000001 3795 Table_map 1 3841 table_id: ### (test1.t1)
-mysqld-bin.000001 3841 Write_rows 1 3881 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 3881 Xid 1 3912 COMMIT /* xid=### */
-mysqld-bin.000001 3912 Gtid 1 3960 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:18'
-mysqld-bin.000001 3960 Query 1 4023 BEGIN
-mysqld-bin.000001 4023 Query 1 4087 COMMIT
-mysqld-bin.000001 4087 Gtid 1 4135 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:19'
-mysqld-bin.000001 4135 Query 1 4198 BEGIN
-mysqld-bin.000001 4198 Table_map 1 4244 table_id: ### (test1.t1)
-mysqld-bin.000001 4244 Write_rows 1 4284 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 4284 Xid 1 4315 COMMIT /* xid=### */
-mysqld-bin.000001 4315 Gtid 1 4363 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:20'
-mysqld-bin.000001 4363 Query 1 4426 BEGIN
-mysqld-bin.000001 4426 Query 1 4490 COMMIT
-mysqld-bin.000001 4490 Gtid 1 4538 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:21'
-mysqld-bin.000001 4538 Query 1 4601 BEGIN
-mysqld-bin.000001 4601 Table_map 1 4647 table_id: ### (test1.t1)
-mysqld-bin.000001 4647 Write_rows 1 4687 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 4687 Xid 1 4718 COMMIT /* xid=### */
-mysqld-bin.000001 4718 Gtid 1 4766 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:22'
-mysqld-bin.000001 4766 Query 1 4829 BEGIN
-mysqld-bin.000001 4829 Query 1 4893 COMMIT
-mysqld-bin.000001 4893 Gtid 1 4941 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:23'
-mysqld-bin.000001 4941 Query 1 5004 BEGIN
-mysqld-bin.000001 5004 Table_map 1 5050 table_id: ### (test1.t1)
-mysqld-bin.000001 5050 Write_rows 1 5090 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 5090 Xid 1 5121 COMMIT /* xid=### */
-mysqld-bin.000001 5121 Gtid 1 5169 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:24'
-mysqld-bin.000001 5169 Query 1 5232 BEGIN
-mysqld-bin.000001 5232 Query 1 5296 COMMIT
-mysqld-bin.000001 5296 Gtid 1 5344 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:25'
-mysqld-bin.000001 5344 Query 1 5407 BEGIN
-mysqld-bin.000001 5407 Table_map 1 5453 table_id: ### (test1.t1)
-mysqld-bin.000001 5453 Write_rows 1 5493 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 5493 Xid 1 5524 COMMIT /* xid=### */
-mysqld-bin.000001 5524 Gtid 1 5572 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:26'
-mysqld-bin.000001 5572 Query 1 5635 BEGIN
-mysqld-bin.000001 5635 Query 1 5699 COMMIT
-mysqld-bin.000001 5699 Gtid 1 5747 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:27'
-mysqld-bin.000001 5747 Query 1 5810 BEGIN
-mysqld-bin.000001 5810 Table_map 1 5856 table_id: ### (test1.t1)
-mysqld-bin.000001 5856 Write_rows 1 5896 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 5896 Xid 1 5927 COMMIT /* xid=### */
-mysqld-bin.000001 5927 Gtid 1 5975 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:28'
-mysqld-bin.000001 5975 Query 1 6038 BEGIN
-mysqld-bin.000001 6038 Query 1 6102 COMMIT
-mysqld-bin.000001 6102 Gtid 1 6150 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:29'
-mysqld-bin.000001 6150 Query 1 6213 BEGIN
-mysqld-bin.000001 6213 Table_map 1 6259 table_id: ### (test1.t1)
-mysqld-bin.000001 6259 Write_rows 1 6299 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 6299 Xid 1 6330 COMMIT /* xid=### */
-mysqld-bin.000001 6330 Gtid 1 6378 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:30'
-mysqld-bin.000001 6378 Query 1 6441 BEGIN
-mysqld-bin.000001 6441 Query 1 6505 COMMIT
-USE test2;
-ERROR 42000: Unknown database 'test2'
-gtid_executed_equal
-1
-USE test2;
-ERROR 42000: Unknown database 'test2'
-SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120;
-Log_name Pos Event_type Server_id End_log_pos Info
-mysqld-bin.000001 120 Previous_gtids 4 151
-mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:1'
-mysqld-bin.000001 199 Query 1 294 CREATE SCHEMA test1
-mysqld-bin.000001 294 Gtid 1 342 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:2'
-mysqld-bin.000001 342 Query 1 415 BEGIN
-mysqld-bin.000001 415 Query 1 489 COMMIT
-mysqld-bin.000001 489 Gtid 1 537 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:3'
-mysqld-bin.000001 537 Query 1 655 use `test1`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB
-mysqld-bin.000001 655 Gtid 1 703 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:4'
-mysqld-bin.000001 703 Query 1 776 BEGIN
-mysqld-bin.000001 776 Query 1 850 COMMIT
-mysqld-bin.000001 850 Gtid 1 898 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:5'
-mysqld-bin.000001 898 Query 1 961 BEGIN
-mysqld-bin.000001 961 Table_map 1 1007 table_id: ### (test1.t1)
-mysqld-bin.000001 1007 Write_rows 1 1047 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 1047 Xid 1 1078 COMMIT /* xid=### */
-mysqld-bin.000001 1078 Gtid 1 1126 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:6'
-mysqld-bin.000001 1126 Query 1 1189 BEGIN
-mysqld-bin.000001 1189 Query 1 1253 COMMIT
-mysqld-bin.000001 1253 Gtid 1 1301 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:7'
-mysqld-bin.000001 1301 Query 1 1364 BEGIN
-mysqld-bin.000001 1364 Table_map 1 1410 table_id: ### (test1.t1)
-mysqld-bin.000001 1410 Write_rows 1 1450 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 1450 Xid 1 1481 COMMIT /* xid=### */
-mysqld-bin.000001 1481 Gtid 1 1529 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:8'
-mysqld-bin.000001 1529 Query 1 1592 BEGIN
-mysqld-bin.000001 1592 Query 1 1656 COMMIT
-mysqld-bin.000001 1656 Gtid 4 1704 SET @@SESSION.GTID_NEXT= '<effective_uuid_2>:12'
-mysqld-bin.000001 1704 Query 4 1772 BEGIN
-mysqld-bin.000001 1772 Ignorable 4 1795 # Unrecognized ignorable event
-mysqld-bin.000001 1795 Query 4 1864 COMMIT
-mysqld-bin.000001 1864 Gtid 4 1912 SET @@SESSION.GTID_NEXT= '<effective_uuid_2>:13'
-mysqld-bin.000001 1912 Query 4 1980 BEGIN
-mysqld-bin.000001 1980 Ignorable 4 2003 # Unrecognized ignorable event
-mysqld-bin.000001 2003 Query 4 2072 COMMIT
-mysqld-bin.000001 2072 Gtid 1 2120 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:9'
-mysqld-bin.000001 2120 Query 1 2183 BEGIN
-mysqld-bin.000001 2183 Table_map 1 2229 table_id: ### (test1.t1)
-mysqld-bin.000001 2229 Write_rows 1 2269 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 2269 Xid 1 2300 COMMIT /* xid=### */
-mysqld-bin.000001 2300 Gtid 1 2348 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:10'
-mysqld-bin.000001 2348 Query 1 2411 BEGIN
-mysqld-bin.000001 2411 Query 1 2475 COMMIT
-mysqld-bin.000001 2475 Gtid 1 2523 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:11'
-mysqld-bin.000001 2523 Query 1 2586 BEGIN
-mysqld-bin.000001 2586 Table_map 1 2632 table_id: ### (test1.t1)
-mysqld-bin.000001 2632 Write_rows 1 2672 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 2672 Xid 1 2703 COMMIT /* xid=### */
-mysqld-bin.000001 2703 Gtid 1 2751 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:12'
-mysqld-bin.000001 2751 Query 1 2814 BEGIN
-mysqld-bin.000001 2814 Query 1 2878 COMMIT
-mysqld-bin.000001 2878 Gtid 1 2926 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:13'
-mysqld-bin.000001 2926 Query 1 2989 BEGIN
-mysqld-bin.000001 2989 Table_map 1 3035 table_id: ### (test1.t1)
-mysqld-bin.000001 3035 Write_rows 1 3075 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 3075 Xid 1 3106 COMMIT /* xid=### */
-mysqld-bin.000001 3106 Gtid 1 3154 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:14'
-mysqld-bin.000001 3154 Query 1 3217 BEGIN
-mysqld-bin.000001 3217 Query 1 3281 COMMIT
-mysqld-bin.000001 3281 Gtid 1 3329 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:15'
-mysqld-bin.000001 3329 Query 1 3392 BEGIN
-mysqld-bin.000001 3392 Table_map 1 3438 table_id: ### (test1.t1)
-mysqld-bin.000001 3438 Write_rows 1 3478 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 3478 Xid 1 3509 COMMIT /* xid=### */
-mysqld-bin.000001 3509 Gtid 1 3557 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:16'
-mysqld-bin.000001 3557 Query 1 3620 BEGIN
-mysqld-bin.000001 3620 Query 1 3684 COMMIT
-mysqld-bin.000001 3684 Gtid 1 3732 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:17'
-mysqld-bin.000001 3732 Query 1 3795 BEGIN
-mysqld-bin.000001 3795 Table_map 1 3841 table_id: ### (test1.t1)
-mysqld-bin.000001 3841 Write_rows 1 3881 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 3881 Xid 1 3912 COMMIT /* xid=### */
-mysqld-bin.000001 3912 Gtid 1 3960 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:18'
-mysqld-bin.000001 3960 Query 1 4023 BEGIN
-mysqld-bin.000001 4023 Query 1 4087 COMMIT
-mysqld-bin.000001 4087 Gtid 1 4135 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:19'
-mysqld-bin.000001 4135 Query 1 4198 BEGIN
-mysqld-bin.000001 4198 Table_map 1 4244 table_id: ### (test1.t1)
-mysqld-bin.000001 4244 Write_rows 1 4284 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 4284 Xid 1 4315 COMMIT /* xid=### */
-mysqld-bin.000001 4315 Gtid 1 4363 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:20'
-mysqld-bin.000001 4363 Query 1 4426 BEGIN
-mysqld-bin.000001 4426 Query 1 4490 COMMIT
-mysqld-bin.000001 4490 Gtid 1 4538 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:21'
-mysqld-bin.000001 4538 Query 1 4601 BEGIN
-mysqld-bin.000001 4601 Table_map 1 4647 table_id: ### (test1.t1)
-mysqld-bin.000001 4647 Write_rows 1 4687 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 4687 Xid 1 4718 COMMIT /* xid=### */
-mysqld-bin.000001 4718 Gtid 1 4766 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:22'
-mysqld-bin.000001 4766 Query 1 4829 BEGIN
-mysqld-bin.000001 4829 Query 1 4893 COMMIT
-mysqld-bin.000001 4893 Gtid 1 4941 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:23'
-mysqld-bin.000001 4941 Query 1 5004 BEGIN
-mysqld-bin.000001 5004 Table_map 1 5050 table_id: ### (test1.t1)
-mysqld-bin.000001 5050 Write_rows 1 5090 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 5090 Xid 1 5121 COMMIT /* xid=### */
-mysqld-bin.000001 5121 Gtid 1 5169 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:24'
-mysqld-bin.000001 5169 Query 1 5232 BEGIN
-mysqld-bin.000001 5232 Query 1 5296 COMMIT
-mysqld-bin.000001 5296 Gtid 1 5344 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:25'
-mysqld-bin.000001 5344 Query 1 5407 BEGIN
-mysqld-bin.000001 5407 Table_map 1 5453 table_id: ### (test1.t1)
-mysqld-bin.000001 5453 Write_rows 1 5493 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 5493 Xid 1 5524 COMMIT /* xid=### */
-mysqld-bin.000001 5524 Gtid 1 5572 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:26'
-mysqld-bin.000001 5572 Query 1 5635 BEGIN
-mysqld-bin.000001 5635 Query 1 5699 COMMIT
-mysqld-bin.000001 5699 Gtid 1 5747 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:27'
-mysqld-bin.000001 5747 Query 1 5810 BEGIN
-mysqld-bin.000001 5810 Table_map 1 5856 table_id: ### (test1.t1)
-mysqld-bin.000001 5856 Write_rows 1 5896 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 5896 Xid 1 5927 COMMIT /* xid=### */
-mysqld-bin.000001 5927 Gtid 1 5975 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:28'
-mysqld-bin.000001 5975 Query 1 6038 BEGIN
-mysqld-bin.000001 6038 Query 1 6102 COMMIT
-mysqld-bin.000001 6102 Gtid 1 6150 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:29'
-mysqld-bin.000001 6150 Query 1 6213 BEGIN
-mysqld-bin.000001 6213 Table_map 1 6259 table_id: ### (test1.t1)
-mysqld-bin.000001 6259 Write_rows 1 6299 table_id: ### flags: STMT_END_F
-mysqld-bin.000001 6299 Xid 1 6330 COMMIT /* xid=### */
-mysqld-bin.000001 6330 Gtid 1 6378 SET @@SESSION.GTID_NEXT= '<effective_uuid_1>:30'
-mysqld-bin.000001 6378 Query 1 6441 BEGIN
-mysqld-bin.000001 6441 Query 1 6505 COMMIT
-DROP SCHEMA test1;
-DROP SCHEMA test2;
-STOP SLAVE;
-RESET SLAVE ALL;
-CALL mtr.add_suppression("GTID replication failed");
-CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed");
-CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047");
-CALL mtr.add_suppression("TO isolation failed for");
-CALL mtr.add_suppression("Slave SQL: Error 'Deadlock found when trying to get lock; try restarting transaction' on query");
-CALL mtr.add_suppression("Slave SQL: Error 'WSREP has not yet prepared node for application use' on query");
-CALL mtr.add_suppression("Slave: WSREP has not yet prepared node for application use Error_code: 1047");
diff --git a/mysql-test/suite/galera/r/galera_rsu_add_pk.result b/mysql-test/suite/galera/r/galera_rsu_add_pk.result
index 9b068ba30d1..a38f3ff30cb 100644
--- a/mysql-test/suite/galera/r/galera_rsu_add_pk.result
+++ b/mysql-test/suite/galera/r/galera_rsu_add_pk.result
@@ -11,19 +11,19 @@ SET SESSION wsrep_OSU_method = "RSU";
ALTER TABLE t1 ADD PRIMARY KEY (f1);
SET SESSION wsrep_OSU_method = "TOI";
INSERT INTO t1 (f1) SELECT 200000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
-SELECT COUNT(*) = 300000 FROM t1;
-COUNT(*) = 300000
-1
-SELECT MAX(f1) = 299999 FROM t1;
-MAX(f1) = 299999
-1
+SELECT COUNT(*) AS EXPECT_300000 FROM t1;
+EXPECT_300000
+300000
+SELECT MAX(f1) AS EXPECT_299999 FROM t1;
+EXPECT_299999
+299999
connection node_1;
-SELECT COUNT(*) = 300000 FROM t1;
-COUNT(*) = 300000
-1
-SELECT MAX(f1) = 299999 FROM t1;
-MAX(f1) = 299999
-1
+SELECT COUNT(*) AS EXPECT_300000 FROM t1;
+EXPECT_300000
+300000
+SELECT MAX(f1) AS EXPECT_299999 FROM t1;
+EXPECT_299999
+299999
SET SESSION wsrep_OSU_method = "RSU";
ALTER TABLE t1 ADD PRIMARY KEY (f1);
SET SESSION wsrep_OSU_method = "TOI";
diff --git a/mysql-test/suite/galera/r/galera_slave_replay.result b/mysql-test/suite/galera/r/galera_slave_replay.result
new file mode 100644
index 00000000000..e8dd6ae87b1
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_slave_replay.result
@@ -0,0 +1,101 @@
+connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
+connection node_2a;
+connection node_2;
+connection node_1;
+connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
+connection node_3;
+SET GLOBAL wsrep_on=OFF;
+RESET MASTER;
+SET GLOBAL wsrep_on=ON;
+connection node_2a;
+START SLAVE;
+connection node_3;
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb;
+INSERT INTO t1 VALUES (1, 'a');
+INSERT INTO t1 VALUES (3, 'a');
+set binlog_format=STATEMENT;
+SET AUTOCOMMIT=ON;
+START TRANSACTION;
+SELECT * FROM t1 FOR UPDATE;
+f1 f2
+1 a
+3 a
+UPDATE t1 SET f2 = 'c' WHERE f1 > 1;
+connection node_2a;
+SET SESSION wsrep_sync_wait = 0;
+connection node_1;
+SET SESSION wsrep_sync_wait = 0;
+connection node_2a;
+SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_master_enter_sync';
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
+connection node_1;
+INSERT INTO test.t1 VALUES (2, 'b');
+connection node_3;
+COMMIT;
+connection node_2a;
+SET SESSION wsrep_on = 0;
+SET SESSION wsrep_on = 1;
+SET GLOBAL debug_dbug = "";
+SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
+connection node_2a;
+SET GLOBAL wsrep_provider_options = 'dbug=';
+SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_master_enter_sync';
+connection node_3;
+SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a';
+COUNT(*) = 1
+1
+SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
+COUNT(*) = 1
+1
+SELECT * FROM t1;
+f1 f2
+1 a
+3 c
+connection node_2a;
+set session wsrep_sync_wait=15;
+set session wsrep_sync_wait=0;
+wsrep_local_replays
+1
+SELECT * FROM t1;
+f1 f2
+1 a
+2 b
+3 c
+SET DEBUG_SYNC = "RESET";
+#
+# test phase with real abort
+#
+connection node_3;
+set binlog_format=ROW;
+insert into t1 values (4, 'd');
+SET AUTOCOMMIT=ON;
+START TRANSACTION;
+UPDATE t1 SET f2 = 'd' WHERE f1 = 3;
+connection node_2a;
+SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_master_enter_sync';
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
+connection node_3;
+UPDATE test.t1 SET f2 = 'e' WHERE f1 = 3;
+connection node_3;
+COMMIT;
+connection node_2a;
+SET GLOBAL debug_dbug = "";
+SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
+connection node_2a;
+SET GLOBAL wsrep_provider_options = 'dbug=';
+SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_master_enter_sync';
+SET DEBUG_SYNC = "RESET";
+connection node_2a;
+set session wsrep_sync_wait=15;
+SELECT COUNT(*) = 1 FROM test.t1 WHERE f2 = 'e';
+COUNT(*) = 1
+1
+set session wsrep_sync_wait=0;
+STOP SLAVE;
+RESET SLAVE;
+DROP TABLE t1;
+connection node_3;
+DROP TABLE t1;
+SET GLOBAL wsrep_on=OFF;
+RESET MASTER;
+SET GLOBAL wsrep_on=ON;
diff --git a/mysql-test/suite/galera/r/galera_var_notify_cmd.result b/mysql-test/suite/galera/r/galera_var_notify_cmd.result
index 2b390d0db8d..823407fbba7 100644
--- a/mysql-test/suite/galera/r/galera_var_notify_cmd.result
+++ b/mysql-test/suite/galera/r/galera_var_notify_cmd.result
@@ -1,11 +1,11 @@
connection node_1;
-SET SESSION wsrep_sync_wait=15;
-SELECT COUNT(DISTINCT uuid) FROM mtr_wsrep_notify.membership;
-COUNT(DISTINCT uuid)
+SELECT COUNT(DISTINCT uuid) AS EXPECT_2 FROM mtr_wsrep_notify.membership;
+EXPECT_2
2
-SELECT MAX(size) FROM mtr_wsrep_notify.status;
-MAX(size)
+SELECT MAX(size) AS EXPECT_2 FROM mtr_wsrep_notify.status;
+EXPECT_2
2
-SELECT COUNT(DISTINCT idx) FROM mtr_wsrep_notify.status;
-COUNT(DISTINCT idx)
-1
+SELECT COUNT(DISTINCT idx) AS EXPECT_2 FROM mtr_wsrep_notify.status;
+EXPECT_2
+2
+DROP SCHEMA mtr_wsrep_notify;
diff --git a/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result b/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result
index 2aac6d8851c..8edf1a02e9d 100644
--- a/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result
+++ b/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result
@@ -27,7 +27,7 @@ VARIABLE_VALUE = 'ON'
1
SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index';
VARIABLE_VALUE = 0
-0
+1
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
VARIABLE_VALUE = 'ON'
1
diff --git a/mysql-test/suite/galera/r/lp1376747-4.result b/mysql-test/suite/galera/r/lp1376747-4.result
index d6884cc3746..6bbc24309ad 100644
--- a/mysql-test/suite/galera/r/lp1376747-4.result
+++ b/mysql-test/suite/galera/r/lp1376747-4.result
@@ -5,18 +5,13 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connection node_2;
SET session wsrep_sync_wait=0;
-SET session wsrep_causal_reads=OFF;
-Warnings:
-Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead
FLUSH TABLE WITH READ LOCK;
connection node_1;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
INSERT INTO t1 VALUES (2,3);
connection node_2a;
SET session wsrep_sync_wait=0;
-SET session wsrep_causal_reads=OFF;
-Warnings:
-Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead
+# node_1 DDL should not yet be applied
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -26,6 +21,7 @@ t1 CREATE TABLE `t1` (
FLUSH TABLES t1 WITH READ LOCK;;
connection node_2;
UNLOCK TABLES;
+# node_1 DDL should not yet be applied 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -34,6 +30,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
connection node_2a;
UNLOCK TABLES;
+# node_1 DDL should be applied 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid.cnf b/mysql-test/suite/galera/t/galera_as_master_gtid.cnf
deleted file mode 100644
index 53d8b5e59dd..00000000000
--- a/mysql-test/suite/galera/t/galera_as_master_gtid.cnf
+++ /dev/null
@@ -1,15 +0,0 @@
-!include ../galera_2nodes_as_master.cnf
-
-[mysqld]
-log-bin=mysqld-bin
-log-slave-updates
-binlog-format=ROW
-[mysqld.1]
-gtid-domain-id=1
-wsrep_gtid_mode=1
-wsrep_gtid_domain_id=100
-[mysqld.2]
-gtid-domain-id=1
-wsrep_gtid_mode=1
-[mysqld.3]
-gtid-domain-id=2 \ No newline at end of file
diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid.test b/mysql-test/suite/galera/t/galera_as_master_gtid.test
deleted file mode 100644
index 3ddccf94da1..00000000000
--- a/mysql-test/suite/galera/t/galera_as_master_gtid.test
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Test Galera as a master to a MySQL slave with GTID
-#
-# The galera/galera_2node_master.cnf describes the setup of the nodes
-#
-# We check that all transactions originating from within Galera use a UUID that is
-# different from the server_uuid of either node
-#
-#
-
---source include/have_innodb.inc
---source include/have_log_bin.inc
---source include/galera_cluster.inc
-
---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
---disable_query_log
---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1;
---enable_query_log
-START SLAVE;
-
---connection node_1
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(1);
-
-SELECT @@global.gtid_binlog_pos;
---let $effective_gtid = @@global.gtid_binlog_pos
-
---connection node_2
-INSERT INTO t1 VALUES(2);
-
---disable_query_log
---eval SELECT '$effective_gtid' != @@global.gtid_binlog_pos AS gtid_do_not_match;
---enable_query_log
-
---connection node_3
---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
---let $wait_condition = SELECT COUNT(*) = 2 FROM t1;
---source include/wait_condition.inc
-
---disable_query_log
---eval SELECT '$effective_gtid' != @@global.gtid_binlog_pos AS gtid_do_not_match;
---enable_query_log
-
---connection node_1
-DROP TABLE t1;
-
---connection node_3
---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
---connection node_1
---let $gtid_executed_node1 = `SELECT @@global.gtid_binlog_pos;`
---connection node_2
---disable_query_log
---eval SELECT '$gtid_executed_node1' = @@global.gtid_binlog_pos AS gtid_executed_equal
---enable_query_log
---connection node_3
---disable_query_log
---eval SELECT '$gtid_executed_node1' = @@global.gtid_binlog_pos AS gtid_executed_equal
---enable_query_log
-
-STOP SLAVE;
-RESET SLAVE ALL;
diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf
deleted file mode 100644
index 75caba5420a..00000000000
--- a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf
+++ /dev/null
@@ -1,6 +0,0 @@
-!include ../galera_2nodes_as_master.cnf
-
-[mysqld]
-log-bin=mysqld-bin
-log-slave-updates
-binlog-format=ROW
diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test
deleted file mode 100644
index e67456dddaf..00000000000
--- a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# Test that a MySQL slave can use CHANGE MASTER MASTER_AUTO_POSITION to begin replicating
-# from another Galera node
-#
-# The galera/galera_2node_master.cnf describes the setup of the nodes
-#
-#
-
---source include/have_innodb.inc
---source include/have_log_bin.inc
---source include/galera_cluster.inc
-
---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
---disable_query_log
---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1;
---enable_query_log
-START SLAVE;
-
---connection node_1
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(1);
-
---connection node_2
-INSERT INTO t1 VALUES(2);
-
---connection node_3
---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-STOP SLAVE;
---disable_query_log
---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_2, MASTER_USER='root';
---enable_query_log
-START SLAVE;
-
---connection node_1
-INSERT INTO t1 VALUES(3);
-
---connection node_2
-INSERT INTO t1 VALUES(4);
-
---connection node_3
---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
---let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
---source include/wait_condition.inc
-
---connection node_1
-DROP TABLE t1;
-
---connection node_3
---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
-STOP SLAVE;
-RESET SLAVE ALL;
-RESET MASTER;
-
---connection node_2
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
-
---connection node_1
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test
index 40f8bd7ad49..6df605079e8 100644
--- a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test
+++ b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test
@@ -14,6 +14,7 @@
--source include/have_innodb.inc
--source include/have_log_bin.inc
--source include/galera_cluster.inc
+SELECT @@WSREP_ON;
# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it
# we open the node_3 connection here
diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf
deleted file mode 100644
index e0852c50c44..00000000000
--- a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf
+++ /dev/null
@@ -1,17 +0,0 @@
-!include ../galera_2nodes_as_slave.cnf
-
-[mysqld]
-#gtid-mode=ON
-log-bin=master-bin
-log-bin-index=master-bin
-log-slave-updates
-#enforce-gtid-consistency
-binlog-format=ROW
-
-[mysqld.2]
-replicate-do-db=test1
-replicate-wild-do-table=test1.%
-
-[mysqld.3]
-replicate-do-db=test1
-replicate-wild-do-table=test1.%
diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test
deleted file mode 100644
index 10886c41fde..00000000000
--- a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test
+++ /dev/null
@@ -1,161 +0,0 @@
-#
-# Test Galera as a slave to a MySQL master using GTIDs
-#
-
---source include/have_innodb.inc
---source include/galera_cluster.inc
---source include/have_log_bin.inc
-
-# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it
-# we open the node_3 connection here
---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
-
---connection node_1
-SET global wsrep_on=OFF;
-RESET MASTER;
-SET global wsrep_on=ON;
-
---connection node_3
-RESET MASTER;
-
---connection node_2
-SET global wsrep_on=OFF;
-RESET MASTER;
-SET global wsrep_on=ON;
---disable_query_log
---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_3, MASTER_USER='root';
---enable_query_log
-START SLAVE;
-
---connection node_3
-CREATE SCHEMA test1;
-CREATE SCHEMA test2;
-USE test1;
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB;
-USE test2;
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB;
-
-#
-# First , some autocommit stuff
-#
-
-# Simple inserts
-
-INSERT INTO test1.t1 (f1) VALUES (1);
-INSERT INTO test2.t1 (f1) VALUES (1);
-
-INSERT INTO test1.t1 (f1) VALUES (2);
-INSERT INTO test2.t1 (f1) VALUES (2);
-
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-
-# Update that only covers test2.t1
-
-UPDATE test2.t1 SET test2.t1.f2 = 'cde';
-
-# Multi-table UPDATE
-
-UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz';
-
-# Multi-table DELETE
-
-DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3;
-
-#
-# Multi-statement transactions
-#
-
-# Transaction which is not replicated at all
-
-SET AUTOCOMMIT=OFF;
-START TRANSACTION;
-INSERT INTO test2.t1 (f1) VALUES (999);
-INSERT INTO test2.t1 (f1) VALUES (9999);
-COMMIT;
-
-# Transaction that is completely replicated
-START TRANSACTION;
-INSERT INTO test1.t1 (f1) VALUES (111);
-INSERT INTO test1.t1 (f1) VALUES (222);
-COMMIT;
-
-# Transaction that is partially replicated
-
-START TRANSACTION;
-INSERT INTO test1.t1 (f1) VALUES (333);
-INSERT INTO test2.t1 (f1) VALUES (99999);
-COMMIT;
-
-#
-# Make sure binary logs and gtid_executed strings are equal
-#
-
---sleep 2
---connection node_2
---let $effective_uuid = `SELECT LEFT(@@global.gtid_current_pos, 36)`
---let $gtid_executed_node2 = `SELECT @@global.gtid_current_pos;`
-
---replace_result $effective_uuid <effective_uuid>
---replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/
-SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256;
-
---connection node_1
-
---disable_query_log
---eval SELECT '$gtid_executed_node2' = @@global.gtid_current_pos AS gtid_executed_equal;
---enable_query_log
-
---replace_result $effective_uuid <effective_uuid>
---replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/
-SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256;
-
-#
-# Final consistency checks
-#
-
---let $diff_servers = 1 2
---source include/diff_servers.inc
-
---connection node_1
---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
-SELECT COUNT(*) = 2 FROM test1.t1 WHERE f1 IN (1,2);
-SELECT COUNT(*) = 3 FROM test1.t1 WHERE f1 IN (111,222,333);
-SELECT COUNT(*) = 2 FROM test1.t1 WHERE f2 = 'klm';
-
---error 1049
-USE test2;
-
-#
-# Cleanup
-#
-
---connection node_3
-DROP SCHEMA test1;
-DROP SCHEMA test2;
-
---sleep 1
-
---connection node_1
---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
---connection node_2
---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
-STOP SLAVE;
-RESET SLAVE ALL;
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
-
---connection node_1
-SET GLOBAL wsrep_on=OFF;
-RESET MASTER;
-SET GLOBAL wsrep_on=ON;
-
---connection node_3
-RESET MASTER;
diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test
deleted file mode 100644
index c539617428e..00000000000
--- a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test
+++ /dev/null
@@ -1,159 +0,0 @@
-#
-# Test the case where a Galera slave to async replication goes non-prim while
-# a stream of replication events including filtered events is arriving
-#
-
---source include/have_innodb.inc
---source include/have_log_bin.inc
---source include/big_test.inc
---source include/galera_cluster.inc
-
-# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it
-# we open the node_3 connection here
---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
-SELECT @@wsrep_on;
-RESET MASTER;
-
---connection node_1
-# make sure gtid_slave_pos is of innodb engine, mtr does not currently provide that
-ALTER TABLE mysql.gtid_slave_pos engine = InnoDB;
-
---connection node_1
---disable_query_log
---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3;
---enable_query_log
-START SLAVE;
-
---connection node_3
-CREATE SCHEMA test1;
-CREATE SCHEMA test2;
-USE test1;
-CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
-USE test2;
-CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
-
-INSERT INTO test1.t1 (f1) VALUES (1);
-INSERT INTO test2.t1 (f1) VALUES (1);
-
-INSERT INTO test1.t1 (f1) VALUES (2);
-INSERT INTO test2.t1 (f1) VALUES (2);
-
---connection node_1
---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
---let $wait_condition = SELECT COUNT(*) = 2 FROM test1.t1;
---source include/wait_condition.inc
-
-SET GLOBAL wsrep_provider_options='gmcast.isolate=1';
-
---connection node_3
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-INSERT INTO test1.t1 (f1) VALUES (3);
-INSERT INTO test2.t1 (f1) VALUES (3);
-
---connection node_1
-SET SESSION wsrep_on=OFF;
---let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status';
---source include/wait_condition.inc
-
---let $slave_sql_errno = 1047
---source include/wait_for_slave_sql_error.inc
-
---connection node_3
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-INSERT INTO test1.t1 (f1) VALUES (4);
-INSERT INTO test2.t1 (f1) VALUES (4);
-
---connection node_1
-SET GLOBAL wsrep_provider_options='gmcast.isolate=0';
-
---connection node_3
-INSERT INTO test1.t1 (f1) VALUES (5);
-INSERT INTO test2.t1 (f1) VALUES (5);
-
---connection node_1
---let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status';
---source include/wait_condition.inc
-SET SESSION wsrep_on=ON;
---let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_ready';
---source include/wait_condition.inc
-
---connection node_3
-INSERT INTO test1.t1 (f1) VALUES (6);
-INSERT INTO test2.t1 (f1) VALUES (6);
-
---connection node_1
-START SLAVE;
-
-#
-# Consistency checks
-#
-
---connection node_1
---let $wait_condition = SELECT COUNT(DISTINCT f1) = 6 FROM test1.t1;
---source include/wait_condition.inc
-
---connection node_2
---let $wait_condition = SELECT COUNT(DISTINCT f1) = 6 FROM test1.t1;
---source include/wait_condition.inc
-
---connection node_1
-SELECT LENGTH(@@global.gtid_binlog_state) > 1;
-SELECT @@global.gtid_binlog_state;
---let $gtid_binlog_state_node1 = `SELECT @@global.gtid_binlog_state;`
-
---error 1049
-USE test2;
-
---connection node_3
-SELECT @@global.gtid_binlog_state;
---disable_query_log
---eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal;
---enable_query_log
-
---error 1049
-USE test2;
-
---replace_result $effective_uuid_1 <effective_uuid_1> $effective_uuid_2 <effective_uuid_2>
---replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/
-SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120;
-
-#
-# Cleanup
-#
-
---connection node_3
-DROP SCHEMA test1;
-DROP SCHEMA test2;
-
---connection node_1
---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
---connection node_2
---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
---source include/wait_condition.inc
-
---connection node_1
-STOP SLAVE;
-RESET SLAVE ALL;
-CALL mtr.add_suppression("GTID replication failed");
-CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed");
-CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047");
-CALL mtr.add_suppression("TO isolation failed for");
-CALL mtr.add_suppression("Slave SQL: Error 'Deadlock found when trying to get lock; try restarting transaction' on query");
-CALL mtr.add_suppression("Slave SQL: Error 'WSREP has not yet prepared node for application use' on query");
-CALL mtr.add_suppression("Slave: WSREP has not yet prepared node for application use Error_code: 1047");
diff --git a/mysql-test/suite/galera/t/galera_rsu_add_pk.test b/mysql-test/suite/galera/t/galera_rsu_add_pk.test
index 7db990d7be1..094048f6caa 100644
--- a/mysql-test/suite/galera/t/galera_rsu_add_pk.test
+++ b/mysql-test/suite/galera/t/galera_rsu_add_pk.test
@@ -26,14 +26,20 @@ SET SESSION wsrep_OSU_method = "TOI";
# Insert values after the ALTER
INSERT INTO t1 (f1) SELECT 200000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
+--let $wait_condition = SELECT COUNT(*) = 300000 FROM t1;
+--source include/wait_condition.inc
-SELECT COUNT(*) = 300000 FROM t1;
-SELECT MAX(f1) = 299999 FROM t1;
+SELECT COUNT(*) AS EXPECT_300000 FROM t1;
+SELECT MAX(f1) AS EXPECT_299999 FROM t1;
--connection node_1
--reap
-SELECT COUNT(*) = 300000 FROM t1;
-SELECT MAX(f1) = 299999 FROM t1;
+
+--let $wait_condition = SELECT COUNT(*) = 300000 FROM t1;
+--source include/wait_condition.inc
+
+SELECT COUNT(*) AS EXPECT_300000 FROM t1;
+SELECT MAX(f1) AS EXPECT_299999 FROM t1;
SET SESSION wsrep_OSU_method = "RSU";
ALTER TABLE t1 ADD PRIMARY KEY (f1);
diff --git a/mysql-test/suite/galera/t/galera_slave_replay.test b/mysql-test/suite/galera/t/galera_slave_replay.test
new file mode 100644
index 00000000000..6cdcc8d15b3
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_slave_replay.test
@@ -0,0 +1,203 @@
+#
+# This test tests the operation of transaction replay for async replication slave.
+# If a potentially conflicting galera transaction arrives at
+# just the right time during the commit and has lock conflict with async replication transaction
+# applied by slave SQL thread, then the async replication transaction should either abort
+# or rollback and replay (depending on the nature of lock conflict).
+#
+
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
+
+--connection node_2a
+--source include/galera_cluster.inc
+--source include/galera_have_debug_sync.inc
+
+#
+# node 3 is native MariaDB server operating as async replication master
+#
+--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
+--connection node_3
+SET GLOBAL wsrep_on=OFF;
+RESET MASTER;
+SET GLOBAL wsrep_on=ON;
+
+--connection node_2a
+#
+# count the number of wsrep replay's done in the node
+#
+--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
+
+
+#
+# nodes 1 and 2 form a galera cluster, node 2 operates as slave for native MariaDB naster in node 3
+#
+--disable_query_log
+--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3;
+--enable_query_log
+START SLAVE;
+
+--connection node_3
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb;
+INSERT INTO t1 VALUES (1, 'a');
+INSERT INTO t1 VALUES (3, 'a');
+
+#
+# use statement format replication to cause a false positive conflict with async replication transaction
+# and galera replication. The conflict will be on GAP lock, and slave SQL thread should rollback
+# and replay
+#
+set binlog_format=STATEMENT;
+
+SET AUTOCOMMIT=ON;
+START TRANSACTION;
+
+SELECT * FROM t1 FOR UPDATE;
+UPDATE t1 SET f2 = 'c' WHERE f1 > 1;
+
+--connection node_2a
+# wait for create table and inserts to be replicated from master
+SET SESSION wsrep_sync_wait = 0;
+--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1;
+--source include/wait_condition.inc
+
+# wait for create table and inserts to be replicated in cluster
+--connection node_1
+SET SESSION wsrep_sync_wait = 0;
+--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1;
+--source include/wait_condition.inc
+
+--connection node_2a
+# Block the future commit of async replication
+--let $galera_sync_point = commit_monitor_master_enter_sync
+--source include/galera_set_sync_point.inc
+
+# block also the applier before applying begins
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
+
+#
+# now inject a conflicting insert from node 1, it will replicate with
+# earlier seqno (than async transaction) and pause before applying in node 2
+#
+--connection node_1
+INSERT INTO test.t1 VALUES (2, 'b');
+
+#
+# send the update from master, this will succeed here, beceuase of async replication.
+# async replication will apply this in node 2 and pause before commit phase,
+--connection node_3
+--error 0
+COMMIT;
+
+# Wait until async slave commit is blocked in node_2
+--connection node_2a
+--source include/galera_wait_sync_point.inc
+
+#
+# release the applier
+# note: have to clear wsrep_apply_cb sync point first, as async replication will go for replay
+# and as this sync point, after BF applier is released to progress
+#
+SET GLOBAL debug_dbug = "";
+SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
+
+# Unblock the async slave commit
+--connection node_2a
+--source include/galera_clear_sync_point.inc
+--source include/galera_signal_sync_point.inc
+
+--connection node_3
+
+SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a';
+SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
+SELECT * FROM t1;
+
+--connection node_2a
+
+# wsrep_local_replays has increased by 1
+set session wsrep_sync_wait=15;
+--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
+set session wsrep_sync_wait=0;
+
+--disable_query_log
+--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays;
+--enable_query_log
+
+#
+# replaying of async transaction should be effective, and row 3 having 'c' in f2
+#
+SELECT * FROM t1;
+SET DEBUG_SYNC = "RESET";
+
+#********************************************************************************
+# test phase 2
+#********************************************************************************
+
+--echo #
+--echo # test phase with real abort
+--echo #
+
+--connection node_3
+
+set binlog_format=ROW;
+
+insert into t1 values (4, 'd');
+
+SET AUTOCOMMIT=ON;
+START TRANSACTION;
+
+UPDATE t1 SET f2 = 'd' WHERE f1 = 3;
+
+--connection node_2a
+# wait for the last insert to be replicated from master
+--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1;
+--source include/wait_condition.inc
+
+# Block the commit
+--let $galera_sync_point = commit_monitor_master_enter_sync
+--source include/galera_set_sync_point.inc
+
+# block applier
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
+
+# Inject a conflicting update from node 3
+--connection node_3
+UPDATE test.t1 SET f2 = 'e' WHERE f1 = 3;
+
+# send the update from master
+--connection node_3
+--error 0
+COMMIT;
+
+--connection node_2a
+
+# release the applier
+SET GLOBAL debug_dbug = "";
+SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
+
+
+# Unblock the async slave commit
+--connection node_2a
+--source include/galera_clear_sync_point.inc
+--source include/galera_signal_sync_point.inc
+SET DEBUG_SYNC = "RESET";
+
+--connection node_2a
+
+set session wsrep_sync_wait=15;
+SELECT COUNT(*) = 1 FROM test.t1 WHERE f2 = 'e';
+set session wsrep_sync_wait=0;
+
+STOP SLAVE;
+RESET SLAVE;
+
+DROP TABLE t1;
+
+--connection node_3
+DROP TABLE t1;
+SET GLOBAL wsrep_on=OFF;
+RESET MASTER;
+SET GLOBAL wsrep_on=ON;
diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt b/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt
new file mode 100644
index 00000000000..70dfc98736b
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt
@@ -0,0 +1 @@
+--wsrep_notify_cmd=$MYSQL_TEST_DIR/std_data/wsrep_notify.sh --wsrep-sync-wait=0
diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd.cnf b/mysql-test/suite/galera/t/galera_var_notify_cmd.cnf
deleted file mode 100644
index 69df4f0e7e0..00000000000
--- a/mysql-test/suite/galera/t/galera_var_notify_cmd.cnf
+++ /dev/null
@@ -1,13 +0,0 @@
-!include ../galera_2nodes.cnf
-
-[mysqld.1]
-wsrep_notify_cmd=$MYSQL_TEST_DIR/std_data/wsrep_notify.sh
-wsrep-sync-wait=0
-
-[mysqld.2]
-
-
-
-
-
-
diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd.test b/mysql-test/suite/galera/t/galera_var_notify_cmd.test
index 2b0852b4870..fda61bf2914 100644
--- a/mysql-test/suite/galera/t/galera_var_notify_cmd.test
+++ b/mysql-test/suite/galera/t/galera_var_notify_cmd.test
@@ -4,9 +4,15 @@
#
--source include/galera_cluster.inc
+--source include/force_restart.inc
--connection node_1
-SET SESSION wsrep_sync_wait=15;
-SELECT COUNT(DISTINCT uuid) FROM mtr_wsrep_notify.membership;
-SELECT MAX(size) FROM mtr_wsrep_notify.status;
-SELECT COUNT(DISTINCT idx) FROM mtr_wsrep_notify.status;
+--let $wait_condition = SELECT COUNT(DISTINCT uuid) = 2 FROM mtr_wsrep_notify.membership;
+--source include/wait_condition.inc
+
+SELECT COUNT(DISTINCT uuid) AS EXPECT_2 FROM mtr_wsrep_notify.membership;
+SELECT MAX(size) AS EXPECT_2 FROM mtr_wsrep_notify.status;
+SELECT COUNT(DISTINCT idx) AS EXPECT_2 FROM mtr_wsrep_notify.status;
+
+# CLEANUP
+DROP SCHEMA mtr_wsrep_notify;
diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt b/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt
new file mode 100644
index 00000000000..c31150c46af
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt
@@ -0,0 +1 @@
+--wsrep-new-cluster
diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf
deleted file mode 100644
index 0acbcfb7843..00000000000
--- a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf
+++ /dev/null
@@ -1,10 +0,0 @@
-!include ../galera_2nodes.cnf
-
-[mysqld.1]
-wsrep-new-cluster
-
-[mysqld.2]
-
-
-
-
diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test
index 28025363019..0df9f0f88df 100644
--- a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test
+++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test
@@ -6,6 +6,19 @@
--source include/galera_cluster.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'on' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+--source include/wait_condition.inc
+
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index';
@@ -15,6 +28,19 @@ SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VAR
--connection node_2
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'on' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state';
+--source include/wait_condition.inc
+--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
+--source include/wait_condition.inc
+
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index';
diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test
index 0c707d6d681..7cf922b97e5 100644
--- a/mysql-test/suite/galera/t/lp1376747-4.test
+++ b/mysql-test/suite/galera/t/lp1376747-4.test
@@ -17,7 +17,6 @@ INSERT INTO t1 VALUES (1);
--connection node_2
SET session wsrep_sync_wait=0;
-SET session wsrep_causal_reads=OFF;
FLUSH TABLE WITH READ LOCK;
--connection node_1
@@ -26,26 +25,32 @@ INSERT INTO t1 VALUES (2,3);
--connection node_2a
SET session wsrep_sync_wait=0;
-SET session wsrep_causal_reads=OFF;
+
+--echo # node_1 DDL should not yet be applied
SHOW CREATE TABLE t1;
---sleep 1
+
--send FLUSH TABLES t1 WITH READ LOCK;
--connection node_2
-# let the flush table wait in pause state before we unlock
-# table otherwise there is window where-in flush table is
-# yet to wait in pause and unlock allows alter table to proceed.
-# this is because send in asynchronous.
---sleep 3
-# this will release existing lock but will not resume
-# the cluster as there is new FTRL that is still pausing it.
+--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%committed%';
+--source include/wait_condition.inc
+
UNLOCK TABLES;
+
+--echo # node_1 DDL should not yet be applied 2
SHOW CREATE TABLE t1;
--connection node_2a
--reap
UNLOCK TABLES;
---sleep 2
+
+--let $wait_condition = SELECT COUNT(*) = 2 FROM t1;
+--source include/wait_condition.inc
+
+--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 't1';
+--source include/wait_condition.inc
+
+--echo # node_1 DDL should be applied 2
SHOW CREATE TABLE t1;
SELECT * from t1;
diff --git a/mysql-test/suite/heap/heap_btree.result b/mysql-test/suite/heap/heap_btree.result
index 5985350a213..8c1c8217b6a 100644
--- a/mysql-test/suite/heap/heap_btree.result
+++ b/mysql-test/suite/heap/heap_btree.result
@@ -59,10 +59,10 @@ a
869751
select * from t1 where a in (869751,736494,226312,802616);
a
-869751
-736494
226312
+736494
802616
+869751
alter table t1 engine=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
@@ -178,7 +178,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
explain select * from t1 where btn like "h%";
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL btn NULL NULL NULL # Using where
+1 SIMPLE t1 range btn btn 10 NULL # Using where
explain select * from t1 where btn like "a%";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
@@ -350,11 +350,11 @@ insert into t1 values (869751),(736494),(226312),(802616),(728912);
alter table t1 add unique uniq_id using BTREE (a);
select 0+a from t1 where a > 736494;
0+a
-869751
802616
+869751
explain select 0+a from t1 where a > 736494;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
+1 SIMPLE t1 range uniq_id uniq_id 8 NULL 3 Using where
select 0+a from t1 where a = 736494;
0+a
736494
@@ -370,13 +370,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
select 0+a from t1 where a in (869751,736494,226312,802616);
0+a
-869751
-736494
226312
+736494
802616
+869751
explain select 0+a from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
+1 SIMPLE t1 range uniq_id uniq_id 8 NULL 4 Using where
drop table t1;
End of 5.3 tests
create table t1 (id int, a varchar(300) not null, key using btree(a)) engine=heap;
diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result
index 1fbfa99c61f..df1acdae506 100644
--- a/mysql-test/suite/heap/heap_hash.result
+++ b/mysql-test/suite/heap/heap_hash.result
@@ -428,14 +428,14 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
select 0+a from t1 where a in (869751,736494,226312,802616,728912);
0+a
-869751
-736494
226312
-802616
728912
+736494
+802616
+869751
explain select 0+a from t1 where a in (869751,736494,226312,802616,728912);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
+1 SIMPLE t1 range uniq_id uniq_id 8 NULL 5 Using where
drop table t1;
End of 5.3 tests
#
diff --git a/mysql-test/suite/innodb/r/instant_alter_charset.result b/mysql-test/suite/innodb/r/instant_alter_charset.result
index f8c21978327..cbb49819bfe 100644
--- a/mysql-test/suite/innodb/r/instant_alter_charset.result
+++ b/mysql-test/suite/innodb/r/instant_alter_charset.result
@@ -1918,3 +1918,14 @@ check table t;
Table Op Msg_type Msg_text
test.t check status OK
drop table t;
+#
+# MDEV-20726: InnoDB: Assertion failure in file data0type.cc line 67
+#
+CREATE TABLE t (
+id int(10) unsigned NOT NULL PRIMARY KEY,
+a text CHARSET utf8mb3,
+KEY a_idx(a(1))
+) ENGINE=InnoDB;
+INSERT INTO t VALUES (1, 'something in the air');
+ALTER TABLE t MODIFY a text CHARSET utf8mb4;
+DROP TABLE t;
diff --git a/mysql-test/suite/innodb/r/instant_alter_index_rename.result b/mysql-test/suite/innodb/r/instant_alter_index_rename.result
index 52051eff0bd..69f7cc8df4c 100644
--- a/mysql-test/suite/innodb/r/instant_alter_index_rename.result
+++ b/mysql-test/suite/innodb/r/instant_alter_index_rename.result
@@ -74,7 +74,6 @@ select @a_key_returns_id = get_index_id(@table_id, 'a_key_returns'),
@a_key_returns_id = get_index_id(@table_id, 'a_key_returns') @b_key_id = get_index_id(@table_id, 'b_key') @c_key_id = get_index_id(@table_id, 'c_key2') @primary_id = get_index_id(@table_id, 'primary')
1 1 1 1
drop table t;
-drop function get_index_id;
create table errors (
a int,
unique key a_key (a),
@@ -183,3 +182,19 @@ CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2);
ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1);
DROP TABLE t1;
+#
+# MDEV-21669 InnoDB: Table ... contains <n> indexes inside InnoDB, which is different from the number of indexes <n> defined in the MariaDB
+#
+CREATE TABLE t1 (col_int INTEGER, col_char CHAR(20), col_varchar VARCHAR(500)) ENGINE=InnoDB;
+SET @table_id = (SELECT table_id FROM information_schema.innodb_sys_tables WHERE name='test/t1');
+ALTER TABLE t1 ADD KEY idx3 (col_varchar(9)), ADD KEY idX2 (col_char(9));
+SET @idx3_key_id = get_index_id(@table_id, 'iDx3');
+ALTER TABLE t1 DROP KEY iDx3, ADD KEY Idx3 (col_varchar(9));
+SELECT @idx3_key_id = get_index_id(@table_id, 'Idx3');
+@idx3_key_id = get_index_id(@table_id, 'Idx3')
+1
+CHECK TABLE t1 EXTENDED ;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
+DROP FUNCTION get_index_id;
diff --git a/mysql-test/suite/innodb/t/instant_alter_charset.test b/mysql-test/suite/innodb/t/instant_alter_charset.test
index 82ae1040f57..270db2d6462 100644
--- a/mysql-test/suite/innodb/t/instant_alter_charset.test
+++ b/mysql-test/suite/innodb/t/instant_alter_charset.test
@@ -715,3 +715,18 @@ alter table t modify c varchar(10) collate latin1_general_cs, algorithm=instant;
check table t;
drop table t;
+
+--echo #
+--echo # MDEV-20726: InnoDB: Assertion failure in file data0type.cc line 67
+--echo #
+
+CREATE TABLE t (
+ id int(10) unsigned NOT NULL PRIMARY KEY,
+ a text CHARSET utf8mb3,
+ KEY a_idx(a(1))
+) ENGINE=InnoDB;
+
+INSERT INTO t VALUES (1, 'something in the air');
+ALTER TABLE t MODIFY a text CHARSET utf8mb4;
+
+DROP TABLE t;
diff --git a/mysql-test/suite/innodb/t/instant_alter_index_rename.test b/mysql-test/suite/innodb/t/instant_alter_index_rename.test
index 3a608a00837..dd6cee7c860 100644
--- a/mysql-test/suite/innodb/t/instant_alter_index_rename.test
+++ b/mysql-test/suite/innodb/t/instant_alter_index_rename.test
@@ -73,7 +73,6 @@ select @a_key_returns_id = get_index_id(@table_id, 'a_key_returns'),
@primary_id = get_index_id(@table_id, 'primary');
drop table t;
-drop function get_index_id;
create table errors (
a int,
@@ -194,3 +193,17 @@ CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2);
ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1);
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-21669 InnoDB: Table ... contains <n> indexes inside InnoDB, which is different from the number of indexes <n> defined in the MariaDB
+--echo #
+CREATE TABLE t1 (col_int INTEGER, col_char CHAR(20), col_varchar VARCHAR(500)) ENGINE=InnoDB;
+SET @table_id = (SELECT table_id FROM information_schema.innodb_sys_tables WHERE name='test/t1');
+ALTER TABLE t1 ADD KEY idx3 (col_varchar(9)), ADD KEY idX2 (col_char(9));
+SET @idx3_key_id = get_index_id(@table_id, 'iDx3');
+ALTER TABLE t1 DROP KEY iDx3, ADD KEY Idx3 (col_varchar(9));
+SELECT @idx3_key_id = get_index_id(@table_id, 'Idx3');
+CHECK TABLE t1 EXTENDED ;
+DROP TABLE t1;
+
+DROP FUNCTION get_index_id;
diff --git a/mysql-test/suite/innodb_fts/r/misc_debug2.result b/mysql-test/suite/innodb_fts/r/misc_debug2.result
index 2c8281579b9..ed7e6b9b7e1 100644
--- a/mysql-test/suite/innodb_fts/r/misc_debug2.result
+++ b/mysql-test/suite/innodb_fts/r/misc_debug2.result
@@ -1,4 +1,5 @@
-call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded");
+call mtr.add_suppression("InnoDB: Table '.*' tablespace is set as discarded.");
+call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded.");
CREATE TABLE mdev21563(f1 VARCHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB;
set debug_dbug="+d,fts_instrument_sync_request";
INSERT INTO mdev21563 VALUES('This is a test');
diff --git a/mysql-test/suite/innodb_fts/t/misc_debug2.test b/mysql-test/suite/innodb_fts/t/misc_debug2.test
index 5b0184e5cca..0a9e137dd80 100644
--- a/mysql-test/suite/innodb_fts/t/misc_debug2.test
+++ b/mysql-test/suite/innodb_fts/t/misc_debug2.test
@@ -1,7 +1,8 @@
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/not_embedded.inc
-call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded");
+call mtr.add_suppression("InnoDB: Table '.*' tablespace is set as discarded.");
+call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded.");
CREATE TABLE mdev21563(f1 VARCHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB;
set debug_dbug="+d,fts_instrument_sync_request";
diff --git a/mysql-test/suite/parts/r/partition_special_innodb.result b/mysql-test/suite/parts/r/partition_special_innodb.result
index c375c2d2232..01c6e1f9e64 100644
--- a/mysql-test/suite/parts/r/partition_special_innodb.result
+++ b/mysql-test/suite/parts/r/partition_special_innodb.result
@@ -327,3 +327,11 @@ disconnect con3;
disconnect con2;
disconnect con1;
connection default;
+CREATE TABLE t1(
+f1 INT, f2 VARCHAR(10) CHARSET ascii,
+f3 CHAR(150) CHARSET ascii,
+f4 TEXT CHARSET ascii)ENGINE=InnoDB
+PARTITION BY RANGE(f1) (PARTITION p1 VALUES LESS THAN(10),
+PARTITION p2 VALUES LESS THAN (100));
+ALTER TABLE t1 convert to charset ascii collate ascii_bin, ALGORITHM=INSTANT;
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/t/partition_special_innodb.test b/mysql-test/suite/parts/t/partition_special_innodb.test
index 1fc9ac7fafc..ef7cf4bd4cf 100644
--- a/mysql-test/suite/parts/t/partition_special_innodb.test
+++ b/mysql-test/suite/parts/t/partition_special_innodb.test
@@ -205,3 +205,13 @@ DROP TABLE t4;
--disconnect con1
--connection default
# End of Test #3
+
+# MDEV-21693 ALGORITHM=INSTANT does not work for partitioned tables
+CREATE TABLE t1(
+ f1 INT, f2 VARCHAR(10) CHARSET ascii,
+ f3 CHAR(150) CHARSET ascii,
+ f4 TEXT CHARSET ascii)ENGINE=InnoDB
+ PARTITION BY RANGE(f1) (PARTITION p1 VALUES LESS THAN(10),
+ PARTITION p2 VALUES LESS THAN (100));
+ALTER TABLE t1 convert to charset ascii collate ascii_bin, ALGORITHM=INSTANT;
+DROP TABLE t1;
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index a8be235f5e2..f4a6a6d55b3 100644
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -53,7 +53,6 @@ IF (WIN32)
my_wincond.c
my_winerr.c
my_winfile.c
- my_windac.c
my_conio.c
my_win_popen.cc)
ENDIF()
@@ -103,7 +102,3 @@ SET_TARGET_PROPERTIES(thr_timer PROPERTIES COMPILE_FLAGS "-DMAIN")
ADD_EXECUTABLE(test_hash hash.c)
TARGET_LINK_LIBRARIES(test_hash mysys)
SET_TARGET_PROPERTIES(test_hash PROPERTIES COMPILE_FLAGS "-DMAIN")
-
-IF(MSVC)
- INSTALL_DEBUG_TARGET(mysys DESTINATION ${INSTALL_LIBDIR}/debug)
-ENDIF()
diff --git a/mysys/my_addr_resolve.c b/mysys/my_addr_resolve.c
index ff15558ddd4..b217d4b043c 100644
--- a/mysys/my_addr_resolve.c
+++ b/mysys/my_addr_resolve.c
@@ -56,6 +56,18 @@ static ElfW(Addr) offset= 0;
#define offset 0
#endif
+#ifndef bfd_get_section_flags
+#define bfd_get_section_flags(H, S) bfd_section_flags(S)
+#endif /* bfd_get_section_flags */
+
+#ifndef bfd_get_section_size
+#define bfd_get_section_size(S) bfd_section_size(S)
+#endif /* bfd_get_section_size */
+
+#ifndef bfd_get_section_vma
+#define bfd_get_section_vma(H, S) bfd_section_vma(S)
+#endif /* bfd_get_section_vma */
+
/**
finds a file name, a line number, and a function name corresponding to addr.
diff --git a/mysys/my_default.c b/mysys/my_default.c
index b78de1d9f61..7eefa7aa044 100644
--- a/mysys/my_default.c
+++ b/mysys/my_default.c
@@ -873,6 +873,11 @@ void my_print_default_files(const char *conf_file)
char name[FN_REFLEN], **ext;
puts("\nDefault options are read from the following files in the given order:");
+ if (my_defaults_file)
+ {
+ puts(my_defaults_file);
+ return;
+ }
if (dirname_length(conf_file))
fputs(conf_file,stdout);
@@ -897,7 +902,12 @@ void my_print_default_files(const char *conf_file)
if (**dirs)
pos= *dirs;
else if (my_defaults_extra_file)
+ {
pos= my_defaults_extra_file;
+ fputs(pos, stdout);
+ fputs(" ", stdout);
+ continue;
+ }
else
continue;
end= convert_dirname(name, pos, NullS);
diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c
index 38585161c22..6890de4f827 100644
--- a/mysys/my_getncpus.c
+++ b/mysys/my_getncpus.c
@@ -21,30 +21,61 @@
#include <unistd.h>
#endif
+#if defined(__FreeBSD__) && defined(HAVE_PTHREAD_GETAFFINITY_NP)
+#include <pthread_np.h>
+#include <sys/cpuset.h>
+#endif
+
static int ncpus=0;
-int my_getncpus()
+int my_getncpus(void)
{
if (!ncpus)
{
+ /*
+ First attempt to get the total number of available cores. sysconf is
+ the fallback, but it can return a larger number. It will return the
+ total number of cores, not the ones available to the process - as
+ configured via core affinity.
+ */
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(HAVE_PTHREAD_GETAFFINITY_NP)
+ cpu_set_t set;
+ if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0)
+ {
+#ifdef CPU_COUNT
+ /* CPU_COUNT was introduced with glibc 2.6. */
+ ncpus= CPU_COUNT(&set);
+#else
+ /* Implementation for platforms with glibc < 2.6 */
+ size_t i;
+
+ for (i= 0; i < CPU_SETSIZE; i++)
+ if (CPU_ISSET(i, &set))
+ ncpus++;
+#endif
+ return ncpus;
+ }
+#endif /* (__linux__ || __FreeBSD__) && HAVE_PTHREAD_GETAFFINITY_NP */
+
#ifdef _SC_NPROCESSORS_ONLN
ncpus= sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(__WIN__)
SYSTEM_INFO sysinfo;
/*
- * We are not calling GetNativeSystemInfo here because (1) we
- * don't believe that they return different values for number
- * of processors and (2) if WOW64 limits processors for Win32
- * then we don't want to try to override that.
+ We are not calling GetNativeSystemInfo here because (1) we
+ don't believe that they return different values for number
+ of processors and (2) if WOW64 limits processors for Win32
+ then we don't want to try to override that.
*/
GetSystemInfo(&sysinfo);
ncpus= sysinfo.dwNumberOfProcessors;
#else
- /* unknown so play safe: assume SMP and forbid uniprocessor build */
+ /* Unknown so play safe: assume SMP and forbid uniprocessor build */
ncpus= 2;
#endif
}
+
return ncpus;
}
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
deleted file mode 100644
index d53f34f20e7..00000000000
--- a/mysys/my_windac.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-
-#include "mysys_priv.h"
-#include "m_string.h"
-#ifdef __WIN__
-
-/*
- Auxiliary structure to store pointers to the data which we need to keep
- around while SECURITY_ATTRIBUTES is in use.
-*/
-
-typedef struct st_my_security_attr
-{
- PSID everyone_sid;
- PACL dacl;
-} My_security_attr;
-
-
-/*
- Allocate and initialize SECURITY_ATTRIBUTES setting up access
- rights for the owner and group `Everybody'.
-
- SYNOPSIS
- my_security_attr_create()
- psa [OUT] pointer to store the pointer to SA in
- perror [OUT] pointer to store error message if there was an
- error
- owner_rights [IN] access rights for the owner
- everyone_rights [IN] access rights for group Everybody
-
- DESCRIPTION
- Set up the security attributes to provide clients with sufficient
- access rights to a kernel object. We need this function
- because if we simply grant all access to everybody (by installing
- a NULL DACL) a mailicious user can attempt a denial of service
- attack by taking ownership over the kernel object. Upon successful
- return `psa' contains a pointer to SECUIRITY_ATTRIBUTES that can be used
- to create kernel objects with proper access rights.
-
- RETURN
- 0 success, psa is 0 or points to a valid SA structure,
- perror is left intact
- !0 error, SA is set to 0, error message is stored in perror
-*/
-
-int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
- DWORD owner_rights, DWORD everyone_rights)
-{
- /* Top-level SID authority */
- SID_IDENTIFIER_AUTHORITY world_auth= SECURITY_WORLD_SID_AUTHORITY;
- PSID everyone_sid= 0;
- HANDLE htoken= 0;
- SECURITY_ATTRIBUTES *sa= 0;
- PACL dacl= 0;
- DWORD owner_token_length, dacl_length;
- SECURITY_DESCRIPTOR *sd;
- PTOKEN_USER owner_token;
- PSID owner_sid;
- My_security_attr *attr;
-
- /*
- Get SID of Everyone group. Easier to retrieve all SIDs each time
- this function is called than worry about thread safety.
- */
- if (! AllocateAndInitializeSid(&world_auth, 1, SECURITY_WORLD_RID,
- 0, 0, 0, 0, 0, 0, 0, &everyone_sid))
- {
- *perror= "Failed to retrieve the SID of Everyone group";
- goto error;
- }
-
- /*
- Get SID of the owner. Using GetSecurityInfo this task can be done
- in just one call instead of five, but GetSecurityInfo declared in
- aclapi.h, so I hesitate to use it.
- SIC: OpenThreadToken works only if there is an active impersonation
- token, hence OpenProcessToken is used.
- */
- if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &htoken))
- {
- *perror= "Failed to retrieve thread access token";
- goto error;
- }
- GetTokenInformation(htoken, TokenUser, 0, 0, &owner_token_length);
-
- if (! my_multi_malloc(MYF(MY_WME), PSI_INSTRUMENT_ME,
- &sa, ALIGN_SIZE(sizeof(SECURITY_ATTRIBUTES)) +
- sizeof(My_security_attr),
- &sd, sizeof(SECURITY_DESCRIPTOR),
- &owner_token, owner_token_length,
- 0))
- {
- *perror= "Failed to allocate memory for SECURITY_ATTRIBUTES";
- goto error;
- }
- bzero(owner_token, owner_token_length);
- if (! GetTokenInformation(htoken, TokenUser, owner_token,
- owner_token_length, &owner_token_length))
- {
- *perror= "GetTokenInformation failed";
- goto error;
- }
- owner_sid= owner_token->User.Sid;
-
- if (! IsValidSid(owner_sid))
- {
- *perror= "IsValidSid failed";
- goto error;
- }
-
- /* Calculate the amount of memory that must be allocated for the DACL */
- dacl_length= sizeof(ACL) + (sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD)) * 2 +
- GetLengthSid(everyone_sid) + GetLengthSid(owner_sid);
-
- /* Create an ACL */
- if (! (dacl= (PACL) my_malloc(PSI_INSTRUMENT_ME, dacl_length, MYF(MY_ZEROFILL|MY_WME))))
- {
- *perror= "Failed to allocate memory for DACL";
- goto error;
- }
- if (! InitializeAcl(dacl, dacl_length, ACL_REVISION))
- {
- *perror= "Failed to initialize DACL";
- goto error;
- }
- if (! AddAccessAllowedAce(dacl, ACL_REVISION, everyone_rights, everyone_sid))
- {
- *perror= "Failed to set up DACL";
- goto error;
- }
- if (! AddAccessAllowedAce(dacl, ACL_REVISION, owner_rights, owner_sid))
- {
- *perror= "Failed to set up DACL";
- goto error;
- }
- if (! InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
- {
- *perror= "Could not initialize security descriptor";
- goto error;
- }
- if (! SetSecurityDescriptorDacl(sd, TRUE, dacl, FALSE))
- {
- *perror= "Failed to install DACL";
- goto error;
- }
-
- sa->nLength= sizeof(*sa);
- sa->bInheritHandle= TRUE;
- sa->lpSecurityDescriptor= sd;
- /* Save pointers to everyone_sid and dacl to be able to clean them up */
- attr= (My_security_attr*) (((char*) sa) + ALIGN_SIZE(sizeof(*sa)));
- attr->everyone_sid= everyone_sid;
- attr->dacl= dacl;
- *psa= sa;
-
- CloseHandle(htoken);
- return 0;
-error:
- if (everyone_sid)
- FreeSid(everyone_sid);
- if (htoken)
- CloseHandle(htoken);
- my_free(sa);
- my_free(dacl);
- *psa= 0;
- return 1;
-}
-
-/*
- Cleanup security attributes freeing used memory.
-
- SYNOPSIS
- my_security_attr_free()
- sa security attributes
-*/
-
-void my_security_attr_free(SECURITY_ATTRIBUTES *sa)
-{
- if (sa)
- {
- My_security_attr *attr= (My_security_attr*)
- (((char*)sa) + ALIGN_SIZE(sizeof(*sa)));
- FreeSid(attr->everyone_sid);
- my_free(attr->dacl);
- my_free(sa);
- }
-}
-
-#endif /* __WIN__ */
diff --git a/plugin/auth_pam/CMakeLists.txt b/plugin/auth_pam/CMakeLists.txt
index a556b870719..89d5cc6a8af 100644
--- a/plugin/auth_pam/CMakeLists.txt
+++ b/plugin/auth_pam/CMakeLists.txt
@@ -1,10 +1,24 @@
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckFunctionExists)
+CHECK_INCLUDE_FILES (security/pam_ext.h HAVE_PAM_EXT_H)
CHECK_INCLUDE_FILES (security/pam_appl.h HAVE_PAM_APPL_H)
CHECK_FUNCTION_EXISTS (strndup HAVE_STRNDUP)
+SET(CMAKE_REQUIRED_LIBRARIES pam)
+CHECK_FUNCTION_EXISTS(pam_syslog HAVE_PAM_SYSLOG)
+SET(CMAKE_REQUIRED_LIBRARIES)
+
+IF(HAVE_PAM_SYSLOG)
+ ADD_DEFINITIONS(-DHAVE_PAM_SYSLOG)
+ENDIF()
+
+IF(HAVE_PAM_EXT_H)
+ ADD_DEFINITIONS(-DHAVE_PAM_EXT_H)
+ENDIF()
+
IF(HAVE_PAM_APPL_H)
+ ADD_DEFINITIONS(-DHAVE_PAM_APPL_H)
IF(HAVE_STRNDUP)
ADD_DEFINITIONS(-DHAVE_STRNDUP)
ENDIF(HAVE_STRNDUP)
diff --git a/plugin/auth_pam/mapper/pam_user_map.c b/plugin/auth_pam/mapper/pam_user_map.c
index e1d11acabb9..9d7ed53f8b1 100644
--- a/plugin/auth_pam/mapper/pam_user_map.c
+++ b/plugin/auth_pam/mapper/pam_user_map.c
@@ -2,7 +2,7 @@
Pam module to change user names arbitrarily in the pam stack.
Compile as
-
+
gcc pam_user_map.c -shared -lpam -fPIC -o pam_user_map.so
Install as appropriate (for example, in /lib/security/).
@@ -39,14 +39,36 @@ and usually end up in /var/log/secure file.
#include <grp.h>
#include <pwd.h>
+#ifdef HAVE_PAM_EXT_H
#include <security/pam_ext.h>
+#endif
+
+#ifdef HAVE_PAM_APPL_H
+#include <unistd.h>
+#include <security/pam_appl.h>
+#endif
+
#include <security/pam_modules.h>
+#ifndef HAVE_PAM_SYSLOG
+#include <stdarg.h>
+static void
+pam_syslog (const pam_handle_t *pamh, int priority,
+ const char *fmt, ...)
+{
+ va_list args;
+ va_start (args, fmt);
+ vsyslog (priority, fmt, args);
+ va_end (args);
+}
+#endif
+
#define FILENAME "/etc/security/user_map.conf"
#define skip(what) while (*s && (what)) s++
+#define SYSLOG_DEBUG if (mode_debug) pam_syslog
#define GROUP_BUFFER_SIZE 100
-
+static const char debug_keyword[]= "debug";
static int populate_user_groups(const char *user, gid_t **groups)
{
@@ -128,10 +150,6 @@ static void print_groups(pam_handle_t *pamh, const gid_t *user_groups, int ng)
ng, (ng == 1) ? "group" : "groups", buf+1);
}
-
-static const char debug_keyword[]= "debug";
-#define SYSLOG_DEBUG if (mode_debug) pam_syslog
-
int pam_sm_authenticate(pam_handle_t *pamh, int flags,
int argc, const char *argv[])
{
diff --git a/plugin/win_auth_client/CMakeLists.txt b/plugin/win_auth_client/CMakeLists.txt
index 435c5b8966a..8c7696347aa 100644
--- a/plugin/win_auth_client/CMakeLists.txt
+++ b/plugin/win_auth_client/CMakeLists.txt
@@ -31,7 +31,4 @@ IF(WIN32)
LINK_LIBRARIES Secur32
MODULE_ONLY COMPONENT ClientPlugins)
- #IF(MSVC)
- # INSTALL_DEBUG_TARGET(auth_win_client DESTINATION ${INSTALL_LIBDIR}/debug)
- #ENDIF()
ENDIF(WIN32)
diff --git a/sql/events.cc b/sql/events.cc
index 3bed25e20c3..91adc0c23ba 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1218,9 +1218,9 @@ Events::load_events_from_db(THD *thd)
#ifdef WITH_WSREP
/**
- IF SST is done from a galera node that is also acting as MASTER
- newly synced node in galera eco-system will also copy-over the event state
- enabling duplicate event in galera eco-system.
+ If SST is done from a galera node that is also acting as MASTER
+ newly synced node in galera eco-system will also copy-over the
+ event state enabling duplicate event in galera eco-system.
DISABLE such events if the current node is not event orginator.
(Also, make sure you skip disabling it if is already disabled to avoid
creation of redundant action)
@@ -1230,7 +1230,7 @@ Events::load_events_from_db(THD *thd)
Infact, based on galera use-case it seems like it recommends to have each
node with different server-id.
*/
- if (et->originator != thd->variables.server_id)
+ if (WSREP(thd) && et->originator != thd->variables.server_id)
{
if (et->status == Event_parse_data::SLAVESIDE_DISABLED)
continue;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index f30ef6a9688..2e5355580c7 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -6317,9 +6317,10 @@ static bool partition_multi_range_key_skip_record(range_seq_t seq,
{
PARTITION_PART_KEY_MULTI_RANGE_HLD *hld=
(PARTITION_PART_KEY_MULTI_RANGE_HLD *)seq;
+ PARTITION_KEY_MULTI_RANGE *pkmr= (PARTITION_KEY_MULTI_RANGE *)range_info;
DBUG_ENTER("partition_multi_range_key_skip_record");
DBUG_RETURN(hld->partition->m_seq_if->skip_record(hld->partition->m_seq,
- range_info, rowid));
+ pkmr->ptr, rowid));
}
@@ -6328,9 +6329,10 @@ static bool partition_multi_range_key_skip_index_tuple(range_seq_t seq,
{
PARTITION_PART_KEY_MULTI_RANGE_HLD *hld=
(PARTITION_PART_KEY_MULTI_RANGE_HLD *)seq;
+ PARTITION_KEY_MULTI_RANGE *pkmr= (PARTITION_KEY_MULTI_RANGE *)range_info;
DBUG_ENTER("partition_multi_range_key_skip_index_tuple");
DBUG_RETURN(hld->partition->m_seq_if->skip_index_tuple(hld->partition->m_seq,
- range_info));
+ pkmr->ptr));
}
ha_rows ha_partition::multi_range_read_info_const(uint keyno,
@@ -11802,6 +11804,40 @@ void ha_partition::clear_top_table_fields()
DBUG_VOID_RETURN;
}
+bool
+ha_partition::can_convert_string(const Field_string* field,
+ const Column_definition& new_type) const
+{
+ for (uint index= 0; index < m_tot_parts; index++)
+ {
+ if (!m_file[index]->can_convert_string(field, new_type))
+ return false;
+ }
+ return true;
+}
+
+bool
+ha_partition::can_convert_varstring(const Field_varstring* field,
+ const Column_definition& new_type) const{
+ for (uint index= 0; index < m_tot_parts; index++)
+ {
+ if (!m_file[index]->can_convert_varstring(field, new_type))
+ return false;
+ }
+ return true;
+}
+
+bool
+ha_partition::can_convert_blob(const Field_blob* field,
+ const Column_definition& new_type) const
+{
+ for (uint index= 0; index < m_tot_parts; index++)
+ {
+ if (!m_file[index]->can_convert_blob(field, new_type))
+ return false;
+ }
+ return true;
+}
struct st_mysql_storage_engine partition_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index ff3093098a4..e50ed2aeef7 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -3,7 +3,7 @@
/*
Copyright (c) 2005, 2012, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013, Monty Program Ab & SkySQL Ab.
+ Copyright (c) 2009, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -224,7 +224,7 @@ typedef struct st_partition_key_multi_range
/*
- List of ranges to be scanned in a certain [sub]partition.
+ List of ranges to be scanned in a certain [sub]partition
The idea is that there's a list of ranges to be scanned in the table
(formed by PARTITION_KEY_MULTI_RANGE structures),
@@ -260,10 +260,10 @@ typedef struct st_partition_part_key_multi_range_hld
/* Owner object */
ha_partition *partition;
- // id of the the partition this structure is for
+ /* id of the the partition this structure is for */
uint32 part_id;
- // Current range we're iterating through.
+ /* Current range we're iterating through */
PARTITION_PART_KEY_MULTI_RANGE *partition_part_key_multi_range;
} PARTITION_PART_KEY_MULTI_RANGE_HLD;
@@ -431,18 +431,18 @@ private:
/** Stores shared auto_increment etc. */
Partition_share *part_share;
/** Fix spurious -Werror=overloaded-virtual in GCC 9 */
- virtual void restore_auto_increment(ulonglong prev_insert_id)
+ virtual void restore_auto_increment(ulonglong prev_insert_id) override
{
handler::restore_auto_increment(prev_insert_id);
}
/** Store and restore next_auto_inc_val over duplicate key errors. */
- virtual void store_auto_increment()
+ void store_auto_increment() override
{
DBUG_ASSERT(part_share);
part_share->prev_auto_inc_val= part_share->next_auto_inc_val;
handler::store_auto_increment();
}
- virtual void restore_auto_increment()
+ void restore_auto_increment() override
{
DBUG_ASSERT(part_share);
part_share->next_auto_inc_val= part_share->prev_auto_inc_val;
@@ -450,7 +450,7 @@ private:
}
void sum_copy_info(handler *file);
void sum_copy_infos();
- void reset_copy_info();
+ void reset_copy_info() override;
/** Temporary storage for new partitions Handler_shares during ALTER */
List<Parts_share_refs> m_new_partitions_share_refs;
/** Sorted array of partition ids in descending order of number of rows. */
@@ -483,16 +483,16 @@ public:
return NO_CURRENT_PART_ID;
}
Partition_share *get_part_share() { return part_share; }
- handler *clone(const char *name, MEM_ROOT *mem_root);
- virtual void set_part_info(partition_info *part_info)
+ handler *clone(const char *name, MEM_ROOT *mem_root) override;
+ virtual void set_part_info(partition_info *part_info) override
{
m_part_info= part_info;
m_is_sub_partitioned= part_info->is_sub_partitioned();
}
- virtual void return_record_by_parent();
+ void return_record_by_parent() override;
- virtual bool vers_can_native(THD *thd)
+ bool vers_can_native(THD *thd) override
{
if (thd->lex->part_info)
{
@@ -551,31 +551,30 @@ public:
object needed in opening the object in openfrm
-------------------------------------------------------------------------
*/
- virtual int delete_table(const char *from);
- virtual int rename_table(const char *from, const char *to);
- virtual int create(const char *name, TABLE *form,
- HA_CREATE_INFO *create_info);
- virtual int create_partitioning_metadata(const char *name,
- const char *old_name, int action_flag);
- virtual void update_create_info(HA_CREATE_INFO *create_info);
- virtual char *update_table_comment(const char *comment);
- virtual int change_partitions(HA_CREATE_INFO *create_info,
- const char *path,
- ulonglong * const copied,
- ulonglong * const deleted,
- const uchar *pack_frm_data,
- size_t pack_frm_len);
- virtual int drop_partitions(const char *path);
- virtual int rename_partitions(const char *path);
- bool get_no_parts(const char *name, uint *num_parts)
+ int delete_table(const char *from) override;
+ int rename_table(const char *from, const char *to) override;
+ int create(const char *name, TABLE *form,
+ HA_CREATE_INFO *create_info) override;
+ int create_partitioning_metadata(const char *name,
+ const char *old_name, int action_flag)
+ override;
+ void update_create_info(HA_CREATE_INFO *create_info) override;
+ char *update_table_comment(const char *comment) override;
+ int change_partitions(HA_CREATE_INFO *create_info, const char *path,
+ ulonglong * const copied, ulonglong * const deleted,
+ const uchar *pack_frm_data, size_t pack_frm_len)
+ override;
+ int drop_partitions(const char *path) override;
+ int rename_partitions(const char *path) override;
+ bool get_no_parts(const char *, uint *num_parts) override
{
DBUG_ENTER("ha_partition::get_no_parts");
*num_parts= m_tot_parts;
DBUG_RETURN(0);
}
- virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
- virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
- uint table_changes);
+ void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) override;
+ bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
+ uint table_changes) override;
void update_part_create_info(HA_CREATE_INFO *create_info, uint part_id)
{
m_file[part_id]->update_create_info(create_info);
@@ -614,7 +613,7 @@ private:
bool is_subpart);
bool populate_partition_name_hash();
Partition_share *get_share();
- bool set_ha_share_ref(Handler_share **ha_share);
+ bool set_ha_share_ref(Handler_share **ha_share) override;
void fix_data_dir(char* path);
bool init_partition_bitmaps();
void free_partition_bitmaps();
@@ -634,8 +633,8 @@ public:
being used for normal queries (not before meta-data changes always.
If the object was opened it will also be closed before being deleted.
*/
- virtual int open(const char *name, int mode, uint test_if_locked);
- virtual int close(void);
+ int open(const char *name, int mode, uint test_if_locked) override;
+ int close() override;
/*
-------------------------------------------------------------------------
@@ -650,31 +649,31 @@ public:
and these go directly to the handlers supporting transactions
-------------------------------------------------------------------------
*/
- virtual THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
- enum thr_lock_type lock_type);
- virtual int external_lock(THD * thd, int lock_type);
- LEX_CSTRING *engine_name() { return hton_name(partition_ht()); }
+ THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
+ enum thr_lock_type lock_type) override;
+ int external_lock(THD * thd, int lock_type) override;
+ LEX_CSTRING *engine_name() override { return hton_name(partition_ht()); }
/*
When table is locked a statement is started by calling start_stmt
instead of external_lock
*/
- virtual int start_stmt(THD * thd, thr_lock_type lock_type);
+ int start_stmt(THD * thd, thr_lock_type lock_type) override;
/*
Lock count is number of locked underlying handlers (I assume)
*/
- virtual uint lock_count(void) const;
+ uint lock_count() const override;
/*
Call to unlock rows not to be updated in transaction
*/
- virtual void unlock_row();
+ void unlock_row() override;
/*
Check if semi consistent read
*/
- virtual bool was_semi_consistent_read();
+ bool was_semi_consistent_read() override;
/*
Call to hint about semi consistent read
*/
- virtual void try_semi_consistent_read(bool);
+ void try_semi_consistent_read(bool) override;
/*
NOTE: due to performance and resource issues with many partitions,
@@ -708,28 +707,28 @@ public:
start_bulk_insert and end_bulk_insert is called before and after a
number of calls to write_row.
*/
- virtual int write_row(const uchar * buf);
- virtual bool start_bulk_update();
- virtual int exec_bulk_update(ha_rows *dup_key_found);
- virtual int end_bulk_update();
- virtual int bulk_update_row(const uchar *old_data, const uchar *new_data,
- ha_rows *dup_key_found);
- virtual int update_row(const uchar * old_data, const uchar * new_data);
- virtual int direct_update_rows_init(List<Item> *update_fields);
- virtual int pre_direct_update_rows_init(List<Item> *update_fields);
- virtual int direct_update_rows(ha_rows *update_rows, ha_rows *found_rows);
- virtual int pre_direct_update_rows();
- virtual bool start_bulk_delete();
- virtual int end_bulk_delete();
- virtual int delete_row(const uchar * buf);
- virtual int direct_delete_rows_init();
- virtual int pre_direct_delete_rows_init();
- virtual int direct_delete_rows(ha_rows *delete_rows);
- virtual int pre_direct_delete_rows();
- virtual int delete_all_rows(void);
- virtual int truncate();
- virtual void start_bulk_insert(ha_rows rows, uint flags);
- virtual int end_bulk_insert();
+ int write_row(const uchar * buf) override;
+ bool start_bulk_update() override;
+ int exec_bulk_update(ha_rows *dup_key_found) override;
+ int end_bulk_update() override;
+ int bulk_update_row(const uchar *old_data, const uchar *new_data,
+ ha_rows *dup_key_found) override;
+ int update_row(const uchar * old_data, const uchar * new_data) override;
+ int direct_update_rows_init(List<Item> *update_fields) override;
+ int pre_direct_update_rows_init(List<Item> *update_fields) override;
+ int direct_update_rows(ha_rows *update_rows, ha_rows *found_rows) override;
+ int pre_direct_update_rows() override;
+ bool start_bulk_delete() override;
+ int end_bulk_delete() override;
+ int delete_row(const uchar * buf) override;
+ int direct_delete_rows_init() override;
+ int pre_direct_delete_rows_init() override;
+ int direct_delete_rows(ha_rows *delete_rows) override;
+ int pre_direct_delete_rows() override;
+ int delete_all_rows() override;
+ int truncate() override;
+ void start_bulk_insert(ha_rows rows, uint flags) override;
+ int end_bulk_insert() override;
private:
ha_rows guess_bulk_insert_rows();
void start_part_bulk_insert(THD *thd, uint part_id);
@@ -745,7 +744,7 @@ public:
*/
int truncate_partition(Alter_info *, bool *binlog_stmt);
- virtual bool is_fatal_error(int error, uint flags)
+ bool is_fatal_error(int error, uint flags) override
{
if (!handler::is_fatal_error(error, flags) ||
error == HA_ERR_NO_PARTITION_FOUND ||
@@ -780,12 +779,12 @@ public:
position it to the start of the table, no need to deallocate
and allocate it again
*/
- virtual int rnd_init(bool scan);
- virtual int rnd_end();
- virtual int rnd_next(uchar * buf);
- virtual int rnd_pos(uchar * buf, uchar * pos);
- virtual int rnd_pos_by_record(uchar *record);
- virtual void position(const uchar * record);
+ int rnd_init(bool scan) override;
+ int rnd_end() override;
+ int rnd_next(uchar * buf) override;
+ int rnd_pos(uchar * buf, uchar * pos) override;
+ int rnd_pos_by_record(uchar *record) override;
+ void position(const uchar * record) override;
/*
-------------------------------------------------------------------------
@@ -819,11 +818,11 @@ public:
index_init initializes an index before using it and index_end does
any end processing needed.
*/
- virtual int index_read_map(uchar * buf, const uchar * key,
- key_part_map keypart_map,
- enum ha_rkey_function find_flag);
- virtual int index_init(uint idx, bool sorted);
- virtual int index_end();
+ int index_read_map(uchar * buf, const uchar * key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag) override;
+ int index_init(uint idx, bool sorted) override;
+ int index_end() override;
/**
@breif
@@ -831,36 +830,36 @@ public:
row if available. If the key value is null, begin at first key of the
index.
*/
- virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key,
- key_part_map keypart_map,
- enum ha_rkey_function find_flag);
+ int index_read_idx_map(uchar *buf, uint index, const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag) override;
/*
These methods are used to jump to next or previous entry in the index
scan. There are also methods to jump to first and last entry.
*/
- virtual int index_next(uchar * buf);
- virtual int index_prev(uchar * buf);
- virtual int index_first(uchar * buf);
- virtual int index_last(uchar * buf);
- virtual int index_next_same(uchar * buf, const uchar * key, uint keylen);
+ int index_next(uchar * buf) override;
+ int index_prev(uchar * buf) override;
+ int index_first(uchar * buf) override;
+ int index_last(uchar * buf) override;
+ int index_next_same(uchar * buf, const uchar * key, uint keylen) override;
int index_read_last_map(uchar *buf,
const uchar *key,
- key_part_map keypart_map);
+ key_part_map keypart_map) override;
/*
read_first_row is virtual method but is only implemented by
handler.cc, no storage engine has implemented it so neither
will the partition handler.
- virtual int read_first_row(uchar *buf, uint primary_key);
+ int read_first_row(uchar *buf, uint primary_key) override;
*/
- virtual int read_range_first(const key_range * start_key,
- const key_range * end_key,
- bool eq_range, bool sorted);
- virtual int read_range_next();
+ int read_range_first(const key_range * start_key,
+ const key_range * end_key,
+ bool eq_range, bool sorted) override;
+ int read_range_next() override;
HANDLER_BUFFER *m_mrr_buffer;
@@ -870,28 +869,31 @@ public:
uint m_mrr_new_full_buffer_size;
MY_BITMAP m_mrr_used_partitions;
uint *m_stock_range_seq;
- // not used: uint m_current_range_seq;
+ /* not used: uint m_current_range_seq; */
- // Value of mrr_mode passed to ha_partition::multi_range_read_init
+ /* Value of mrr_mode passed to ha_partition::multi_range_read_init */
uint m_mrr_mode;
- // Value of n_ranges passed to ha_partition::multi_range_read_init
+ /* Value of n_ranges passed to ha_partition::multi_range_read_init */
uint m_mrr_n_ranges;
/*
Ordered MRR mode: m_range_info[N] has the range_id of the last record that
- we've got from partition N.
+ we've got from partition N
*/
range_id_t *m_range_info;
- // TRUE <=> This ha_partition::multi_range_read_next() call is the first one
+ /*
+ TRUE <=> This ha_partition::multi_range_read_next() call is the first one
+ */
bool m_multi_range_read_first;
- // not used: uint m_mrr_range_init_flags;
+
+ /* not used: uint m_mrr_range_init_flags; */
/* Number of elements in the list pointed by m_mrr_range_first. Not used */
uint m_mrr_range_length;
- // Linked list of ranges to scan
+ /* Linked list of ranges to scan */
PARTITION_KEY_MULTI_RANGE *m_mrr_range_first;
PARTITION_KEY_MULTI_RANGE *m_mrr_range_current;
@@ -900,41 +902,39 @@ public:
*/
uint *m_part_mrr_range_length;
- /*
- For each partition: List of ranges to scan in this partition.
- */
+ /* For each partition: List of ranges to scan in this partition */
PARTITION_PART_KEY_MULTI_RANGE **m_part_mrr_range_first;
PARTITION_PART_KEY_MULTI_RANGE **m_part_mrr_range_current;
PARTITION_PART_KEY_MULTI_RANGE_HLD *m_partition_part_key_multi_range_hld;
/*
- Sequence of ranges to be scanned (TODO: why not stores this in
+ Sequence of ranges to be scanned (TODO: why not store this in
handler::mrr_{iter,funcs}?)
*/
range_seq_t m_seq;
RANGE_SEQ_IF *m_seq_if;
- // Range iterator structure to be supplied to partitions
+ /* Range iterator structure to be supplied to partitions */
RANGE_SEQ_IF m_part_seq_if;
virtual int multi_range_key_create_key(
RANGE_SEQ_IF *seq,
range_seq_t seq_it
);
- virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
- void *seq_init_param,
- uint n_ranges, uint *bufsz,
- uint *mrr_mode,
- Cost_estimate *cost);
- virtual ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
- uint key_parts, uint *bufsz,
- uint *mrr_mode, Cost_estimate *cost);
- virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
- uint n_ranges, uint mrr_mode,
- HANDLER_BUFFER *buf);
- virtual int multi_range_read_next(range_id_t *range_info);
- virtual int multi_range_read_explain_info(uint mrr_mode, char *str,
- size_t size);
+ ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
+ void *seq_init_param,
+ uint n_ranges, uint *bufsz,
+ uint *mrr_mode,
+ Cost_estimate *cost) override;
+ ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
+ uint key_parts, uint *bufsz,
+ uint *mrr_mode, Cost_estimate *cost) override;
+ int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
+ uint n_ranges, uint mrr_mode,
+ HANDLER_BUFFER *buf) override;
+ int multi_range_read_next(range_id_t *range_info) override;
+ int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size)
+ override;
uint last_part() { return m_last_part; }
private:
@@ -962,21 +962,20 @@ public:
purposes.
-------------------------------------------------------------------------
*/
- virtual int info(uint);
- void get_dynamic_partition_info(PARTITION_STATS *stat_info,
- uint part_id);
- void set_partitions_to_open(List<String> *partition_names);
- int change_partitions_to_open(List<String> *partition_names);
+ int info(uint) override;
+ void get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id)
+ override;
+ void set_partitions_to_open(List<String> *partition_names) override;
+ int change_partitions_to_open(List<String> *partition_names) override;
int open_read_partitions(char *name_buff, size_t name_buff_size);
- virtual int extra(enum ha_extra_function operation);
- virtual int extra_opt(enum ha_extra_function operation, ulong arg);
- virtual int reset(void);
- virtual uint count_query_cache_dependant_tables(uint8 *tables_type);
- virtual my_bool
- register_query_cache_dependant_tables(THD *thd,
- Query_cache *cache,
- Query_cache_block_table **block,
- uint *n);
+ int extra(enum ha_extra_function operation) override;
+ int extra_opt(enum ha_extra_function operation, ulong arg) override;
+ int reset() override;
+ uint count_query_cache_dependant_tables(uint8 *tables_type) override;
+ my_bool register_query_cache_dependant_tables(THD *thd,
+ Query_cache *cache,
+ Query_cache_block_table **block,
+ uint *n) override;
private:
typedef int handler_callback(handler *, void *);
@@ -1031,40 +1030,40 @@ public:
index-only scanning when performing an ORDER BY query.
Only called from one place in sql_select.cc
*/
- virtual const key_map *keys_to_use_for_scanning();
+ const key_map *keys_to_use_for_scanning() override;
/*
Called in test_quick_select to determine if indexes should be used.
*/
- virtual double scan_time();
+ double scan_time() override;
- virtual double key_scan_time(uint inx);
+ double key_scan_time(uint inx) override;
- virtual double keyread_time(uint inx, uint ranges, ha_rows rows);
+ double keyread_time(uint inx, uint ranges, ha_rows rows) override;
/*
The next method will never be called if you do not implement indexes.
*/
- virtual double read_time(uint index, uint ranges, ha_rows rows);
+ double read_time(uint index, uint ranges, ha_rows rows) override;
/*
For the given range how many records are estimated to be in this range.
Used by optimiser to calculate cost of using a particular index.
*/
- virtual ha_rows records_in_range(uint inx, key_range * min_key,
- key_range * max_key);
+ ha_rows records_in_range(uint inx, key_range * min_key, key_range * max_key)
+ override;
/*
Upper bound of number records returned in scan is sum of all
underlying handlers.
*/
- virtual ha_rows estimate_rows_upper_bound();
+ ha_rows estimate_rows_upper_bound() override;
/*
table_cache_type is implemented by the underlying handler but all
underlying handlers must have the same implementation for it to work.
*/
- virtual uint8 table_cache_type();
- virtual ha_rows records();
+ uint8 table_cache_type() override;
+ ha_rows records() override;
/* Calculate hash value for PARTITION BY KEY tables. */
static uint32 calculate_key_hash_value(Field **field_array);
@@ -1082,19 +1081,19 @@ public:
Here we must ensure that all handlers use the same index type
for each index created.
*/
- virtual const char *index_type(uint inx);
+ const char *index_type(uint inx) override;
/* The name of the table type that will be used for display purposes */
- virtual const char *table_type() const;
+ const char *table_type() const;
/* The name of the row type used for the underlying tables. */
- virtual enum row_type get_row_type() const;
+ enum row_type get_row_type() const override;
/*
Handler specific error messages
*/
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String * buf);
+ void print_error(int error, myf errflag) override;
+ bool get_error_message(int error, String * buf) override;
/*
-------------------------------------------------------------------------
MODULE handler characteristics
@@ -1248,7 +1247,7 @@ public:
HA_CAN_INSERT_DELAYED, HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is disabled
until further investigated.
*/
- virtual Table_flags table_flags() const;
+ Table_flags table_flags() const override;
/*
This is a bitmap of flags that says how the storage engine
@@ -1306,7 +1305,7 @@ public:
must be updated in the row.
(InnoDB, MyISAM)
*/
- virtual ulong index_flags(uint inx, uint part, bool all_parts) const
+ ulong index_flags(uint inx, uint part, bool all_parts) const override
{
/*
The following code is not safe if you are using different
@@ -1319,7 +1318,8 @@ public:
wrapper function for handlerton alter_table_flags, since
the ha_partition_hton cannot know all its capabilities
*/
- virtual alter_table_operations alter_table_flags(alter_table_operations flags);
+ alter_table_operations alter_table_flags(alter_table_operations flags)
+ override;
/*
unireg.cc will call the following to make sure that the storage engine
can handle the data it is about to send.
@@ -1327,19 +1327,18 @@ public:
The maximum supported values is the minimum of all handlers in the table
*/
uint min_of_the_max_uint(uint (handler::*operator_func)(void) const) const;
- virtual uint max_supported_record_length() const;
- virtual uint max_supported_keys() const;
- virtual uint max_supported_key_parts() const;
- virtual uint max_supported_key_length() const;
- virtual uint max_supported_key_part_length() const;
- virtual uint min_record_length(uint options) const;
+ uint max_supported_record_length() const override;
+ uint max_supported_keys() const override;
+ uint max_supported_key_parts() const override;
+ uint max_supported_key_length() const override;
+ uint max_supported_key_part_length() const override;
+ uint min_record_length(uint options) const override;
/*
Primary key is clustered can only be true if all underlying handlers have
this feature.
*/
- virtual bool primary_key_is_clustered()
- { return m_pkey_is_clustered; }
+ bool primary_key_is_clustered() override { return m_pkey_is_clustered; }
/*
-------------------------------------------------------------------------
@@ -1357,7 +1356,7 @@ public:
to check whether the rest of the reference part is also the same.
-------------------------------------------------------------------------
*/
- virtual int cmp_ref(const uchar * ref1, const uchar * ref2);
+ int cmp_ref(const uchar * ref1, const uchar * ref2) override;
/*
-------------------------------------------------------------------------
MODULE auto increment
@@ -1371,15 +1370,15 @@ public:
auto_increment_column_changed
-------------------------------------------------------------------------
*/
- virtual bool need_info_for_auto_inc();
- virtual bool can_use_for_auto_inc_init();
- virtual void get_auto_increment(ulonglong offset, ulonglong increment,
- ulonglong nb_desired_values,
- ulonglong *first_value,
- ulonglong *nb_reserved_values);
- virtual void release_auto_increment();
+ bool need_info_for_auto_inc() override;
+ bool can_use_for_auto_inc_init() override;
+ void get_auto_increment(ulonglong offset, ulonglong increment,
+ ulonglong nb_desired_values,
+ ulonglong *first_value,
+ ulonglong *nb_reserved_values) override;
+ void release_auto_increment() override;
private:
- virtual int reset_auto_increment(ulonglong value);
+ int reset_auto_increment(ulonglong value) override;
void update_next_auto_inc_val();
virtual void lock_auto_increment()
{
@@ -1441,7 +1440,7 @@ public:
This method is a special InnoDB method called before a HANDLER query.
-------------------------------------------------------------------------
*/
- virtual void init_table_handle_for_HANDLER();
+ void init_table_handle_for_HANDLER() override;
/*
The remainder of this file defines the handler methods not implemented
@@ -1469,20 +1468,20 @@ public:
List<FOREIGN_KEY_INFO> *f_key_list)
virtual uint referenced_by_foreign_key()
*/
- virtual bool can_switch_engines();
+ bool can_switch_engines() override;
/*
-------------------------------------------------------------------------
MODULE fulltext index
-------------------------------------------------------------------------
*/
void ft_close_search(FT_INFO *handler);
- virtual int ft_init();
- virtual int pre_ft_init();
- virtual void ft_end();
- virtual int pre_ft_end();
- virtual FT_INFO *ft_init_ext(uint flags, uint inx, String *key);
- virtual int ft_read(uchar *buf);
- virtual int pre_ft_read(bool use_parallel);
+ int ft_init() override;
+ int pre_ft_init() override;
+ void ft_end() override;
+ int pre_ft_end() override;
+ FT_INFO *ft_init_ext(uint flags, uint inx, String *key) override;
+ int ft_read(uchar *buf) override;
+ int pre_ft_read(bool use_parallel) override;
/*
-------------------------------------------------------------------------
@@ -1490,7 +1489,7 @@ public:
-------------------------------------------------------------------------
The following method is only used by MyISAM when used as
temporary tables in a join.
- virtual int restart_rnd_next(uchar *buf, uchar *pos);
+ int restart_rnd_next(uchar *buf, uchar *pos) override;
*/
/*
@@ -1501,16 +1500,18 @@ public:
They are used for in-place alter table:
-------------------------------------------------------------------------
*/
- virtual enum_alter_inplace_result
+ enum_alter_inplace_result
check_if_supported_inplace_alter(TABLE *altered_table,
- Alter_inplace_info *ha_alter_info);
- virtual bool prepare_inplace_alter_table(TABLE *altered_table,
- Alter_inplace_info *ha_alter_info);
- virtual bool inplace_alter_table(TABLE *altered_table,
- Alter_inplace_info *ha_alter_info);
- virtual bool commit_inplace_alter_table(TABLE *altered_table,
- Alter_inplace_info *ha_alter_info,
- bool commit);
+ Alter_inplace_info *ha_alter_info)
+ override;
+ bool prepare_inplace_alter_table(TABLE *altered_table,
+ Alter_inplace_info *ha_alter_info)
+ override;
+ bool inplace_alter_table(TABLE *altered_table,
+ Alter_inplace_info *ha_alter_info) override;
+ bool commit_inplace_alter_table(TABLE *altered_table,
+ Alter_inplace_info *ha_alter_info,
+ bool commit) override;
/*
-------------------------------------------------------------------------
MODULE tablespace support
@@ -1533,24 +1534,24 @@ public:
all partitions.
-------------------------------------------------------------------------
*/
- virtual int optimize(THD* thd, HA_CHECK_OPT *check_opt);
- virtual int analyze(THD* thd, HA_CHECK_OPT *check_opt);
- virtual int check(THD* thd, HA_CHECK_OPT *check_opt);
- virtual int repair(THD* thd, HA_CHECK_OPT *check_opt);
- virtual bool check_and_repair(THD *thd);
- virtual bool auto_repair(int error) const;
- virtual bool is_crashed() const;
- virtual int check_for_upgrade(HA_CHECK_OPT *check_opt);
+ int optimize(THD* thd, HA_CHECK_OPT *check_opt) override;
+ int analyze(THD* thd, HA_CHECK_OPT *check_opt) override;
+ int check(THD* thd, HA_CHECK_OPT *check_opt) override;
+ int repair(THD* thd, HA_CHECK_OPT *check_opt) override;
+ bool check_and_repair(THD *thd) override;
+ bool auto_repair(int error) const override;
+ bool is_crashed() const override;
+ int check_for_upgrade(HA_CHECK_OPT *check_opt) override;
/*
-------------------------------------------------------------------------
MODULE condition pushdown
-------------------------------------------------------------------------
*/
- virtual const COND *cond_push(const COND *cond);
- virtual void cond_pop();
- virtual void clear_top_table_fields();
- virtual int info_push(uint info_type, void *info);
+ const COND *cond_push(const COND *cond) override;
+ void cond_pop() override;
+ void clear_top_table_fields() override;
+ int info_push(uint info_type, void *info) override;
private:
int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags);
@@ -1564,13 +1565,13 @@ public:
void append_row_to_str(String &str);
public:
- virtual int pre_calculate_checksum();
- virtual int calculate_checksum();
+ int pre_calculate_checksum() override;
+ int calculate_checksum() override;
/* Enabled keycache for performance reasons, WL#4571 */
- virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt);
- virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
- virtual TABLE_LIST *get_next_global_for_child();
+ int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) override;
+ int preload_keys(THD* thd, HA_CHECK_OPT* check_opt) override;
+ TABLE_LIST *get_next_global_for_child() override;
/*
-------------------------------------------------------------------------
@@ -1579,9 +1580,9 @@ public:
Enable/Disable Indexes are only supported by HEAP and MyISAM.
-------------------------------------------------------------------------
*/
- virtual int disable_indexes(uint mode);
- virtual int enable_indexes(uint mode);
- virtual int indexes_are_disabled(void);
+ int disable_indexes(uint mode) override;
+ int enable_indexes(uint mode) override;
+ int indexes_are_disabled() override;
/*
-------------------------------------------------------------------------
@@ -1609,7 +1610,7 @@ public:
this can also be done before partition will support a mix of engines,
but preferably together with other incompatible API changes.
*/
- virtual handlerton *partition_ht() const
+ handlerton *partition_ht() const override
{
handlerton *h= m_file[0]->ht;
for (uint i=1; i < m_tot_parts; i++)
@@ -1638,5 +1639,16 @@ public:
friend int cmp_key_rowid_part_id(void *ptr, uchar *ref1, uchar *ref2);
friend int cmp_key_part_id(void *key_p, uchar *ref1, uchar *ref2);
+ bool can_convert_string(
+ const Field_string* field,
+ const Column_definition& new_field) const override;
+
+ bool can_convert_varstring(
+ const Field_varstring* field,
+ const Column_definition& new_field) const override;
+
+ bool can_convert_blob(
+ const Field_blob* field,
+ const Column_definition& new_field) const override;
};
#endif /* HA_PARTITION_INCLUDED */
diff --git a/sql/handler.cc b/sql/handler.cc
index 4dd915d8b91..c3fee4c78c9 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2748,11 +2748,13 @@ double handler::keyread_time(uint index, uint ranges, ha_rows rows)
size_t len= table->key_info[index].key_length + ref_length;
if (index == table->s->primary_key && table->file->primary_key_is_clustered())
len= table->s->stored_rec_length;
- uint keys_per_block= (uint) (stats.block_size/2.0/len+1);
- ulonglong blocks= !rows ? 0 : (rows-1) / keys_per_block + 1;
double cost= (double)rows*len/(stats.block_size+1)*IDX_BLOCK_COPY_COST;
if (ranges)
+ {
+ uint keys_per_block= (uint) (stats.block_size/2.0/len+1);
+ ulonglong blocks= !rows ? 0 : (rows-1) / keys_per_block + 1;
cost+= blocks;
+ }
return cost;
}
@@ -7042,6 +7044,20 @@ void handler::set_lock_type(enum thr_lock_type lock)
table->reginfo.lock_type= lock;
}
+Compare_keys handler::compare_key_parts(const Field &old_field,
+ const Column_definition &new_field,
+ const KEY_PART_INFO &old_part,
+ const KEY_PART_INFO &new_part) const
+{
+ if (!old_field.is_equal(new_field))
+ return Compare_keys::NotEqual;
+
+ if (old_part.length != new_part.length)
+ return Compare_keys::NotEqual;
+
+ return Compare_keys::Equal;
+}
+
#ifdef WITH_WSREP
/**
@details
diff --git a/sql/handler.h b/sql/handler.h
index f17c303571f..9ed6858874a 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2940,6 +2940,13 @@ public:
virtual ~Handler_share() {}
};
+enum class Compare_keys : uint32_t
+{
+ Equal= 0,
+ EqualButKeyPartLength,
+ EqualButComment,
+ NotEqual
+};
/**
The handler class is the interface for dynamically loadable
@@ -4911,6 +4918,13 @@ public:
return false;
}
+ /* Used for ALTER TABLE.
+ Some engines can handle some differences in indexes by themself. */
+ virtual Compare_keys compare_key_parts(const Field &old_field,
+ const Column_definition &new_field,
+ const KEY_PART_INFO &old_part,
+ const KEY_PART_INFO &new_part) const;
+
protected:
Handler_share *get_ha_share_ptr();
void set_ha_share_ptr(Handler_share *arg_ha_share);
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index d96e361d05d..186efdf7fb9 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -1203,7 +1203,7 @@ public:
bool fix_length_and_dec()
{
collation.set(default_charset());
- max_length=64;
+ fix_char_length(64);
maybe_null= 1;
return FALSE;
}
diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc
index 2267f91f0f9..ba904a254e9 100644
--- a/sql/log_event_server.cc
+++ b/sql/log_event_server.cc
@@ -3859,10 +3859,16 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi)
thd->variables.option_bits&= ~OPTION_GTID_BEGIN;
res= trans_commit(thd); /* Automatically rolls back on error. */
thd->mdl_context.release_transactional_locks();
-
+#ifdef WITH_WSREP
+ if (WSREP(thd)) mysql_mutex_lock(&thd->LOCK_thd_data);
+ if ((!res || (WSREP(thd) && thd->wsrep_trx().state() == wsrep::transaction::s_must_replay )) && sub_id)
+#else
if (likely(!res) && sub_id)
+#endif /* WITH_WSREP */
rpl_global_gtid_slave_state->update_state_hash(sub_id, &gtid, hton, rgi);
-
+#ifdef WITH_WSREP
+ if (WSREP(thd)) mysql_mutex_unlock(&thd->LOCK_thd_data);
+#endif /* WITH_WSREP */
/*
Increment the global status commit count variable
*/
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 5f229f73b2f..98a9d8f0d01 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -3227,19 +3227,14 @@ void MDL_context::set_transaction_duration_for_all_locks()
DBUG_ASSERT(m_tickets[MDL_STATEMENT].is_empty());
- /* Don't swap locks if this thread is running backup stages */
- if (current_thd->current_backup_stage == BACKUP_FINISHED)
- m_tickets[MDL_TRANSACTION].swap(m_tickets[MDL_EXPLICIT]);
+ m_tickets[MDL_TRANSACTION].swap(m_tickets[MDL_EXPLICIT]);
Ticket_iterator it_ticket(m_tickets[MDL_EXPLICIT]);
while ((ticket= it_ticket++))
{
- if (ticket->get_key()->mdl_namespace() != MDL_key::BACKUP)
- {
- m_tickets[MDL_EXPLICIT].remove(ticket);
- m_tickets[MDL_TRANSACTION].push_front(ticket);
- }
+ m_tickets[MDL_EXPLICIT].remove(ticket);
+ m_tickets[MDL_TRANSACTION].push_front(ticket);
}
#ifndef DBUG_OFF
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 7e4c2ed1f53..c000187626f 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -702,7 +702,8 @@ static int rowid_cmp_reverse(void *file, uchar *a, uchar *b)
int Mrr_ordered_rndpos_reader::init(handler *h_arg,
Mrr_index_reader *index_reader_arg,
uint mode,
- Lifo_buffer *buf)
+ Lifo_buffer *buf,
+ Rowid_filter *filter)
{
file= h_arg;
index_reader= index_reader_arg;
@@ -710,19 +711,7 @@ int Mrr_ordered_rndpos_reader::init(handler *h_arg,
is_mrr_assoc= !MY_TEST(mode & HA_MRR_NO_ASSOCIATION);
index_reader_exhausted= FALSE;
index_reader_needs_refill= TRUE;
-
- /*
- Currently usage of a rowid filter within InnoDB engine is not supported
- if the table is accessed by the primary key.
- With optimizer switches ''mrr' and 'mrr_sort_keys' are both enabled
- any access by a secondary index is converted to the rndpos access. In
- InnoDB the rndpos access is always uses the primary key.
- Do not use pushed rowid filter if the table is accessed actually by the
- primary key. Use the rowid filter outside the engine code (see
- Mrr_ordered_rndpos_reader::refill_from_index_reader).
- */
- if (file->pushed_rowid_filter && file->primary_key_is_clustered())
- file->cancel_pushed_rowid_filter();
+ rowid_filter= filter;
return 0;
}
@@ -817,10 +806,8 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader()
index_reader->position();
/*
- If the built rowid filter cannot be used at the engine level use it here.
+ If the built rowid filter cannot be used at the engine level, use it here.
*/
- Rowid_filter *rowid_filter=
- file->get_table()->reginfo.join_tab->rowid_filter;
if (rowid_filter && !file->pushed_rowid_filter &&
!rowid_filter->check((char *)index_rowid))
continue;
@@ -960,7 +947,8 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
void *seq_init_param, uint n_ranges, uint mode,
HANDLER_BUFFER *buf)
{
- THD *thd= h_arg->get_table()->in_use;
+ TABLE *table= h_arg->get_table();
+ THD *thd= table->in_use;
int res;
Key_parameters keypar;
uint UNINIT_VAR(key_buff_elem_size); /* set/used when do_sort_keys==TRUE */
@@ -1015,6 +1003,21 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
if (!(keyno == table->s->primary_key && h_idx->primary_key_is_clustered()))
{
strategy= disk_strategy= &reader_factory.ordered_rndpos_reader;
+ if (h_arg->pushed_rowid_filter)
+ {
+ /*
+ Currently usage of a rowid filter within InnoDB engine is not supported
+ if the table is accessed by the primary key.
+ With optimizer switches ''mrr' and 'mrr_sort_keys' are both enabled
+ any access by a secondary index is converted to the rndpos access. In
+ InnoDB the rndpos access is always uses the primary key.
+ Do not use pushed rowid filter if the table is accessed actually by the
+ primary key. Use the rowid filter outside the engine code (see
+ Mrr_ordered_rndpos_reader::refill_from_index_reader).
+ */
+ rowid_filter= h_arg->pushed_rowid_filter;
+ h_arg->cancel_pushed_rowid_filter();
+ }
}
full_buf= buf->buffer;
@@ -1094,14 +1097,18 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
goto use_default_impl;
}
+ // setup_two_handlers() will call dsmrr_close() will clears the filter.
+ // Save its value and restore afterwards.
+ Rowid_filter *tmp = rowid_filter;
if ((res= setup_two_handlers()))
goto error;
+ rowid_filter= tmp;
if ((res= index_strategy->init(secondary_file, seq_funcs, seq_init_param,
n_ranges, mode, &keypar, key_buffer,
&buf_manager)) ||
(res= disk_strategy->init(primary_file, index_strategy, mode,
- &rowid_buffer)))
+ &rowid_buffer, rowid_filter)))
{
goto error;
}
@@ -1283,6 +1290,7 @@ void DsMrr_impl::close_second_handler()
void DsMrr_impl::dsmrr_close()
{
DBUG_ENTER("DsMrr_impl::dsmrr_close");
+ rowid_filter= NULL;
close_second_handler();
strategy= NULL;
DBUG_VOID_RETURN;
diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h
index 0473fef04ae..37a00e3086f 100644
--- a/sql/multi_range_read.h
+++ b/sql/multi_range_read.h
@@ -364,7 +364,7 @@ class Mrr_ordered_rndpos_reader : public Mrr_reader
{
public:
int init(handler *file, Mrr_index_reader *index_reader, uint mode,
- Lifo_buffer *buf);
+ Lifo_buffer *buf, Rowid_filter *filter);
int get_next(range_id_t *range_info);
int refill_buffer(bool initial);
private:
@@ -399,6 +399,9 @@ private:
/* Buffer to store (rowid, range_id) pairs */
Lifo_buffer *rowid_buffer;
+ /* Rowid filter to be checked against (if any) */
+ Rowid_filter *rowid_filter;
+
int refill_from_index_reader();
};
@@ -554,7 +557,8 @@ public:
typedef void (handler::*range_check_toggle_func_t)(bool on);
DsMrr_impl()
- : secondary_file(NULL) {};
+ : secondary_file(NULL),
+ rowid_filter(NULL) {};
void init(handler *h_arg, TABLE *table_arg)
{
@@ -591,7 +595,13 @@ private:
to run both index scan and rnd_pos() scan at the same time)
*/
handler *secondary_file;
-
+
+ /*
+ The rowid filter that DS-MRR has "unpushed" from the storage engine.
+ If it's present, DS-MRR will use it.
+ */
+ Rowid_filter *rowid_filter;
+
uint keyno; /* index we're running the scan on */
/* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */
bool is_mrr_assoc;
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc
index 4200769b1dc..f4cf8204d61 100644
--- a/sql/my_json_writer.cc
+++ b/sql/my_json_writer.cc
@@ -79,7 +79,8 @@ void Json_writer::end_array()
Json_writer& Json_writer::add_member(const char *name)
{
- if (fmt_helper.on_add_member(name))
+ size_t len= strlen(name);
+ if (fmt_helper.on_add_member(name, len))
return *this; // handled
// assert that we are in an object
@@ -87,7 +88,22 @@ Json_writer& Json_writer::add_member(const char *name)
start_element();
output.append('"');
- output.append(name);
+ output.append(name, len);
+ output.append("\": ", 3);
+ return *this;
+}
+
+Json_writer& Json_writer::add_member(const char *name, size_t len)
+{
+ if (fmt_helper.on_add_member(name, len))
+ return *this; // handled
+
+ // assert that we are in an object
+ DBUG_ASSERT(!element_started);
+ start_element();
+
+ output.append('"');
+ output.append(name, len);
output.append("\": ");
return *this;
}
@@ -141,28 +157,31 @@ void Json_writer::add_ull(ulonglong val)
void Json_writer::add_size(longlong val)
{
char buf[64];
+ size_t len;
if (val < 1024)
- my_snprintf(buf, sizeof(buf), "%lld", val);
+ len= my_snprintf(buf, sizeof(buf), "%lld", val);
else if (val < 1024*1024*16)
{
/* Values less than 16MB are specified in KB for precision */
- size_t len= my_snprintf(buf, sizeof(buf), "%lld", val/1024);
+ len= my_snprintf(buf, sizeof(buf), "%lld", val/1024);
strcpy(buf + len, "Kb");
+ len+= 2;
}
else
{
- size_t len= my_snprintf(buf, sizeof(buf), "%lld", val/(1024*1024));
+ len= my_snprintf(buf, sizeof(buf), "%lld", val/(1024*1024));
strcpy(buf + len, "Mb");
+ len+= 2;
}
- add_str(buf);
+ add_str(buf, len);
}
void Json_writer::add_double(double val)
{
char buf[64];
- my_snprintf(buf, sizeof(buf), "%lg", val);
- add_unquoted_str(buf);
+ size_t len= my_snprintf(buf, sizeof(buf), "%lg", val);
+ add_unquoted_str(buf, len);
}
@@ -174,32 +193,46 @@ void Json_writer::add_bool(bool val)
void Json_writer::add_null()
{
- add_unquoted_str("null");
+ add_unquoted_str("null", (size_t) 4);
}
void Json_writer::add_unquoted_str(const char* str)
{
- if (fmt_helper.on_add_str(str, 0))
+ size_t len= strlen(str);
+ if (fmt_helper.on_add_str(str, len))
return;
if (!element_started)
start_element();
- output.append(str);
+ output.append(str, len);
+ element_started= false;
+}
+
+void Json_writer::add_unquoted_str(const char* str, size_t len)
+{
+ if (fmt_helper.on_add_str(str, len))
+ return;
+
+ if (!element_started)
+ start_element();
+
+ output.append(str, len);
element_started= false;
}
void Json_writer::add_str(const char *str)
{
- if (fmt_helper.on_add_str(str, 0))
+ size_t len= strlen(str);
+ if (fmt_helper.on_add_str(str, len))
return;
if (!element_started)
start_element();
output.append('"');
- output.append(str);
+ output.append(str, len);
output.append('"');
element_started= false;
}
@@ -227,50 +260,6 @@ void Json_writer::add_str(const String &str)
add_str(str.ptr(), str.length());
}
-Json_writer_object::Json_writer_object(THD *thd) :
- Json_writer_struct(thd)
-{
- if (my_writer)
- my_writer->start_object();
-}
-
-Json_writer_object::Json_writer_object(THD* thd, const char *str) :
- Json_writer_struct(thd)
-{
- if (my_writer)
- my_writer->add_member(str).start_object();
-}
-
-Json_writer_object::~Json_writer_object()
-{
- if (!closed && my_writer)
- my_writer->end_object();
- closed= TRUE;
-}
-
-Json_writer_array::Json_writer_array(THD *thd) :
- Json_writer_struct(thd)
-{
- if (my_writer)
- my_writer->start_array();
-}
-
-Json_writer_array::Json_writer_array(THD *thd, const char *str) :
- Json_writer_struct(thd)
-{
- if (my_writer)
- my_writer->add_member(str).start_array();
-
-}
-Json_writer_array::~Json_writer_array()
-{
- if (!closed && my_writer)
- {
- my_writer->end_array();
- closed= TRUE;
- }
-}
-
Json_writer_temp_disable::Json_writer_temp_disable(THD *thd_arg)
{
thd= thd_arg;
@@ -281,7 +270,8 @@ Json_writer_temp_disable::~Json_writer_temp_disable()
thd->opt_trace.enable_tracing_if_required();
}
-bool Single_line_formatting_helper::on_add_member(const char *name)
+bool Single_line_formatting_helper::on_add_member(const char *name,
+ size_t len)
{
DBUG_ASSERT(state== INACTIVE || state == DISABLED);
if (state != DISABLED)
@@ -290,7 +280,6 @@ bool Single_line_formatting_helper::on_add_member(const char *name)
buf_ptr= buffer;
//append member name to the array
- size_t len= strlen(name);
if (len < MAX_LINE_LEN)
{
memcpy(buf_ptr, name, len);
@@ -344,12 +333,10 @@ void Single_line_formatting_helper::on_start_object()
bool Single_line_formatting_helper::on_add_str(const char *str,
- size_t num_bytes)
+ size_t len)
{
if (state == IN_ARRAY)
{
- size_t len= num_bytes ? num_bytes : strlen(str);
-
// New length will be:
// "$string",
// quote + quote + comma + space = 4
@@ -425,9 +412,11 @@ void Single_line_formatting_helper::disable_and_flush()
while (ptr < buf_ptr)
{
char *str= ptr;
+ size_t len= strlen(str);
+
if (nr == 0)
{
- owner->add_member(str);
+ owner->add_member(str, len);
if (start_array)
owner->start_array();
}
@@ -435,13 +424,11 @@ void Single_line_formatting_helper::disable_and_flush()
{
//if (nr == 1)
// owner->start_array();
- owner->add_str(str);
+ owner->add_str(str, len);
}
nr++;
- while (*ptr!=0)
- ptr++;
- ptr++;
+ ptr+= len+1;
}
buf_ptr= buffer;
state= INACTIVE;
diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h
index f1f1be70bb0..bc8002de529 100644
--- a/sql/my_json_writer.h
+++ b/sql/my_json_writer.h
@@ -86,7 +86,7 @@ public:
void init(Json_writer *owner_arg) { owner= owner_arg; }
- bool on_add_member(const char *name);
+ bool on_add_member(const char *name, size_t len);
bool on_start_array();
bool on_end_array();
@@ -184,6 +184,7 @@ class Json_writer
public:
/* Add a member. We must be in an object. */
Json_writer& add_member(const char *name);
+ Json_writer& add_member(const char *name, size_t len);
/* Add atomic values */
void add_str(const char* val);
@@ -202,6 +203,7 @@ public:
private:
void add_unquoted_str(const char* val);
+ void add_unquoted_str(const char* val, size_t len);
public:
/* Start a child object */
void start_object();
@@ -254,63 +256,51 @@ public:
void init(Json_writer *my_writer) { writer= my_writer; }
void add_str(const char* val)
{
- if (writer)
writer->add_str(val);
}
void add_str(const char* val, size_t length)
{
- if (writer)
writer->add_str(val, length);
}
void add_str(const String &str)
{
- if (writer)
- writer->add_str(str);
+ writer->add_str(str.ptr(), str.length());
}
- void add_str(LEX_CSTRING str)
+ void add_str(const LEX_CSTRING &str)
{
- if (writer)
- writer->add_str(str.str);
+ writer->add_str(str.str, str.length);
}
void add_str(Item *item)
{
- if (writer)
writer->add_str(item);
}
void add_ll(longlong val)
{
- if (writer)
writer->add_ll(val);
}
void add_size(longlong val)
{
- if (writer)
writer->add_size(val);
}
void add_double(double val)
{
- if (writer)
writer->add_double(val);
}
void add_bool(bool val)
{
- if (writer)
writer->add_bool(val);
}
void add_null()
{
- if (writer)
writer->add_null();
}
void add_table_name(const JOIN_TAB *tab)
{
- if (writer)
writer->add_table_name(tab);
}
void add_table_name(const TABLE* table)
{
- if (writer)
writer->add_table_name(table);
}
};
@@ -333,6 +323,10 @@ public:
context.init(my_writer);
closed= false;
}
+ bool trace_started()
+ {
+ return my_writer != 0;
+ }
};
@@ -349,55 +343,90 @@ class Json_writer_object : public Json_writer_struct
private:
void add_member(const char *name)
{
- if (my_writer)
- my_writer->add_member(name);
+ my_writer->add_member(name);
}
public:
- explicit Json_writer_object(THD *thd);
- explicit Json_writer_object(THD *thd, const char *str);
+ explicit Json_writer_object(THD *thd)
+ : Json_writer_struct(thd)
+ {
+ if (unlikely(my_writer))
+ my_writer->start_object();
+ }
+
+ explicit Json_writer_object(THD* thd, const char *str)
+ : Json_writer_struct(thd)
+ {
+ if (unlikely(my_writer))
+ my_writer->add_member(str).start_object();
+ }
+
+ ~Json_writer_object()
+ {
+ if (my_writer && !closed)
+ my_writer->end_object();
+ closed= TRUE;
+ }
Json_writer_object& add(const char *name, bool value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_bool(value);
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_bool(value);
+ }
return *this;
}
Json_writer_object& add(const char *name, ulonglong value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_ll(static_cast<longlong>(value));
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_ll(static_cast<longlong>(value));
+ }
return *this;
}
Json_writer_object& add(const char *name, longlong value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_ll(value);
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_ll(value);
+ }
return *this;
}
Json_writer_object& add(const char *name, double value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_double(value);
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_double(value);
+ }
return *this;
}
#ifndef _WIN64
Json_writer_object& add(const char *name, size_t value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_ll(static_cast<longlong>(value));
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_ll(static_cast<longlong>(value));
+ }
return *this;
}
#endif
Json_writer_object& add(const char *name, const char *value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_str(value);
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_str(value);
+ }
return *this;
}
Json_writer_object& add(const char *name, const char *value, size_t num_bytes)
@@ -406,59 +435,76 @@ public:
context.add_str(value, num_bytes);
return *this;
}
- Json_writer_object& add(const char *name, LEX_CSTRING value)
+ Json_writer_object& add(const char *name, const LEX_CSTRING &value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_str(value.str);
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_str(value.str, value.length);
+ }
return *this;
}
Json_writer_object& add(const char *name, Item *value)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_str(value);
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_str(value);
+ }
return *this;
}
Json_writer_object& add_null(const char*name)
{
DBUG_ASSERT(!closed);
- add_member(name);
- context.add_null();
+ if (my_writer)
+ {
+ add_member(name);
+ context.add_null();
+ }
return *this;
}
Json_writer_object& add_table_name(const JOIN_TAB *tab)
{
DBUG_ASSERT(!closed);
- add_member("table");
- context.add_table_name(tab);
+ if (my_writer)
+ {
+ add_member("table");
+ context.add_table_name(tab);
+ }
return *this;
}
Json_writer_object& add_table_name(const TABLE *table)
{
DBUG_ASSERT(!closed);
- add_member("table");
- context.add_table_name(table);
+ if (my_writer)
+ {
+ add_member("table");
+ context.add_table_name(table);
+ }
return *this;
}
Json_writer_object& add_select_number(uint select_number)
{
DBUG_ASSERT(!closed);
- add_member("select_id");
- if (unlikely(select_number >= INT_MAX))
- context.add_str("fake");
- else
- context.add_ll(static_cast<longlong>(select_number));
+ if (my_writer)
+ {
+ add_member("select_id");
+ if (unlikely(select_number >= INT_MAX))
+ context.add_str("fake");
+ else
+ context.add_ll(static_cast<longlong>(select_number));
+ }
return *this;
}
void end()
{
DBUG_ASSERT(!closed);
- if (my_writer)
+ if (unlikely(my_writer))
my_writer->end_object();
closed= TRUE;
}
- ~Json_writer_object();
};
@@ -473,12 +519,29 @@ public:
class Json_writer_array : public Json_writer_struct
{
public:
- Json_writer_array(THD *thd);
- Json_writer_array(THD *thd, const char *str);
+ Json_writer_array(THD *thd): Json_writer_struct(thd)
+ {
+ if (unlikely(my_writer))
+ my_writer->start_array();
+ }
+
+ Json_writer_array(THD *thd, const char *str) : Json_writer_struct(thd)
+ {
+ if (unlikely(my_writer))
+ my_writer->add_member(str).start_array();
+ }
+ ~Json_writer_array()
+ {
+ if (unlikely(my_writer && !closed))
+ {
+ my_writer->end_array();
+ closed= TRUE;
+ }
+ }
void end()
{
DBUG_ASSERT(!closed);
- if (my_writer)
+ if (unlikely(my_writer))
my_writer->end_array();
closed= TRUE;
}
@@ -486,78 +549,89 @@ public:
Json_writer_array& add(bool value)
{
DBUG_ASSERT(!closed);
- context.add_bool(value);
+ if (my_writer)
+ context.add_bool(value);
return *this;
}
Json_writer_array& add(ulonglong value)
{
DBUG_ASSERT(!closed);
- context.add_ll(static_cast<longlong>(value));
+ if (my_writer)
+ context.add_ll(static_cast<longlong>(value));
return *this;
}
Json_writer_array& add(longlong value)
{
DBUG_ASSERT(!closed);
- context.add_ll(value);
+ if (my_writer)
+ context.add_ll(value);
return *this;
}
Json_writer_array& add(double value)
{
DBUG_ASSERT(!closed);
- context.add_double(value);
+ if (my_writer)
+ context.add_double(value);
return *this;
}
#ifndef _WIN64
Json_writer_array& add(size_t value)
{
DBUG_ASSERT(!closed);
- context.add_ll(static_cast<longlong>(value));
+ if (my_writer)
+ context.add_ll(static_cast<longlong>(value));
return *this;
}
#endif
Json_writer_array& add(const char *value)
{
DBUG_ASSERT(!closed);
- context.add_str(value);
+ if (my_writer)
+ context.add_str(value);
return *this;
}
Json_writer_array& add(const char *value, size_t num_bytes)
{
DBUG_ASSERT(!closed);
- context.add_str(value, num_bytes);
+ if (my_writer)
+ context.add_str(value, num_bytes);
return *this;
}
- Json_writer_array& add(LEX_CSTRING value)
+ Json_writer_array& add(const LEX_CSTRING &value)
{
DBUG_ASSERT(!closed);
- context.add_str(value.str);
+ if (my_writer)
+ context.add_str(value.str, value.length);
return *this;
}
Json_writer_array& add(Item *value)
{
DBUG_ASSERT(!closed);
- context.add_str(value);
+ if (my_writer)
+ context.add_str(value);
return *this;
}
Json_writer_array& add_null()
{
DBUG_ASSERT(!closed);
- context.add_null();
+ if (my_writer)
+ context.add_null();
return *this;
}
Json_writer_array& add_table_name(const JOIN_TAB *tab)
{
DBUG_ASSERT(!closed);
- context.add_table_name(tab);
+ if (my_writer)
+ context.add_table_name(tab);
return *this;
}
Json_writer_array& add_table_name(const TABLE *table)
{
DBUG_ASSERT(!closed);
- context.add_table_name(table);
+ if (my_writer)
+ context.add_table_name(table);
return *this;
}
- ~Json_writer_array();
};
/*
diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc
index a87d5664e29..f8d11da1d5e 100644
--- a/sql/opt_index_cond_pushdown.cc
+++ b/sql/opt_index_cond_pushdown.cc
@@ -390,8 +390,23 @@ void push_index_cond(JOIN_TAB *tab, uint keyno)
~(tab->table->map | tab->join->const_table_map)))
tab->cache_idx_cond= idx_cond;
else
+ {
idx_remainder_cond= tab->table->file->idx_cond_push(keyno, idx_cond);
+ /*
+ If (1) there is an index condition that we couldn't push using ICP,
+ (2) we are using Join Buffering
+ (3) and we are using BKA
+ then use BKA's Index Condition Pushdown mechanism to check it.
+ */
+ if (idx_remainder_cond && tab->use_join_cache && // (1) && (2)
+ tab->icp_other_tables_ok) // (3)
+ {
+ tab->cache_idx_cond= idx_remainder_cond;
+ idx_remainder_cond= NULL;
+ }
+ }
+
/*
Disable eq_ref's "lookup cache" if we've pushed down an index
condition.
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 5822aaa8250..d086257a446 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2254,6 +2254,7 @@ public:
void TRP_RANGE::trace_basic_info(PARAM *param,
Json_writer_object *trace_object) const
{
+ DBUG_ASSERT(trace_object->trace_started());
DBUG_ASSERT(param->using_real_indexes);
const uint keynr_in_table= param->real_keynr[key_idx];
@@ -2318,6 +2319,7 @@ void TRP_ROR_UNION::trace_basic_info(PARAM *param,
Json_writer_object *trace_object) const
{
THD *thd= param->thd;
+ DBUG_ASSERT(trace_object->trace_started());
trace_object->add("type", "index_roworder_union");
Json_writer_array smth_trace(thd, "union_of");
for (TABLE_READ_PLAN **current= first_ror; current != last_ror; current++)
@@ -2353,6 +2355,7 @@ void TRP_INDEX_INTERSECT::trace_basic_info(PARAM *param,
Json_writer_object *trace_object) const
{
THD *thd= param->thd;
+ DBUG_ASSERT(trace_object->trace_started());
trace_object->add("type", "index_sort_intersect");
Json_writer_array smth_trace(thd, "index_sort_intersect_of");
for (TRP_RANGE **current= range_scans; current != range_scans_end;
@@ -2386,6 +2389,7 @@ void TRP_INDEX_MERGE::trace_basic_info(PARAM *param,
Json_writer_object *trace_object) const
{
THD *thd= param->thd;
+ DBUG_ASSERT(trace_object->trace_started());
trace_object->add("type", "index_merge");
Json_writer_array smth_trace(thd, "index_merge_of");
for (TRP_RANGE **current= range_scans; current != range_scans_end; current++)
@@ -2454,6 +2458,8 @@ void TRP_GROUP_MIN_MAX::trace_basic_info(PARAM *param,
Json_writer_object *trace_object) const
{
THD *thd= param->thd;
+ DBUG_ASSERT(trace_object->trace_started());
+
trace_object->add("type", "index_group").add("index", index_info->name);
if (min_max_arg_part)
@@ -2837,7 +2843,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
{
{
Json_writer_array trace_range_summary(thd,
- "setup_range_conditions");
+ "setup_range_conditions");
if (cond)
tree= cond->get_mm_tree(&param, &cond);
if (notnull_cond_tree)
@@ -2909,7 +2915,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
remove_nonrange_trees(&param, tree);
/* Get best 'range' plan and prepare data for making other plans */
- if ((range_trp= get_key_scans_params(&param, tree, FALSE, TRUE,
+ if ((range_trp= get_key_scans_params(&param, tree,
+ only_single_index_range_scan, TRUE,
best_read_time)))
{
best_trp= range_trp;
@@ -4895,7 +4902,8 @@ double get_sweep_read_cost(const PARAM *param, ha_rows records)
{
double result;
DBUG_ENTER("get_sweep_read_cost");
- if (param->table->file->primary_key_is_clustered())
+ if (param->table->file->primary_key_is_clustered() ||
+ param->table->file->stats.block_size == 0 /* HEAP */)
{
/*
We are using the primary key to find the rows.
@@ -5600,6 +5608,8 @@ ha_rows get_table_cardinality_for_index_intersect(TABLE *table)
static
void print_keyparts(THD *thd, KEY *key, uint key_parts)
{
+ DBUG_ASSERT(thd->trace_started());
+
KEY_PART_INFO *part= key->key_part;
Json_writer_array keyparts= Json_writer_array(thd, "keyparts");
for(uint i= 0; i < key_parts; i++, part++)
@@ -6389,6 +6399,8 @@ void TRP_ROR_INTERSECT::trace_basic_info(PARAM *param,
Json_writer_object *trace_object) const
{
THD *thd= param->thd;
+ DBUG_ASSERT(trace_object->trace_started());
+
trace_object->add("type", "index_roworder_intersect");
trace_object->add("rows", records);
trace_object->add("cost", read_cost);
@@ -7428,10 +7440,12 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
{
trace_idx.add("chosen", false);
if (found_records == HA_POS_ERROR)
+ {
if (key->type == SEL_ARG::Type::MAYBE_KEY)
trace_idx.add("cause", "depends on unread values");
else
trace_idx.add("cause", "unknown");
+ }
else
trace_idx.add("cause", "cost");
}
@@ -15818,6 +15832,7 @@ static void trace_ranges(Json_writer_array *range_trace,
sel_arg_range_seq_next, 0, 0};
KEY *keyinfo= param->table->key_info + param->real_keynr[idx];
uint n_key_parts= param->table->actual_n_key_parts(keyinfo);
+ DBUG_ASSERT(range_trace->trace_started());
seq.keyno= idx;
seq.real_keyno= param->real_keynr[idx];
seq.param= param;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 6c491300d17..e855f56f832 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -3050,12 +3050,13 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
}
else
{
- Json_writer_object trace(join->thd);
- trace.add("strategy", "SJ-Materialization");
/* This is SJ-Materialization with lookups */
Cost_estimate prefix_cost;
signed int first_tab= (int)idx - mat_info->tables;
double prefix_rec_count;
+ Json_writer_object trace(join->thd);
+ trace.add("strategy", "SJ-Materialization");
+
if (first_tab < (int)join->const_tables)
{
prefix_cost.reset();
@@ -3084,7 +3085,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
*record_count= prefix_rec_count;
*handled_fanout= new_join_tab->emb_sj_nest->sj_inner_tables;
*strategy= SJ_OPT_MATERIALIZE;
- if (unlikely(join->thd->trace_started()))
+ if (unlikely(trace.trace_started()))
{
trace.add("records", *record_count);
trace.add("read_time", *read_time);
@@ -3166,7 +3167,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
*/
*record_count= prefix_rec_count;
*handled_fanout= mat_nest->sj_inner_tables;
- if (unlikely(join->thd->trace_started()))
+ if (unlikely(trace.trace_started()))
{
trace.add("records", *record_count);
trace.add("read_time", *read_time);
@@ -3266,7 +3267,7 @@ bool LooseScan_picker::check_qep(JOIN *join,
*/
*strategy= SJ_OPT_LOOSE_SCAN;
*handled_fanout= first->table->emb_sj_nest->sj_inner_tables;
- if (unlikely(join->thd->trace_started()))
+ if (unlikely(trace.trace_started()))
{
trace.add("records", *record_count);
trace.add("read_time", *read_time);
@@ -3384,7 +3385,7 @@ bool Firstmatch_picker::check_qep(JOIN *join,
*handled_fanout= firstmatch_need_tables;
/* *record_count and *read_time were set by the above call */
*strategy= SJ_OPT_FIRST_MATCH;
- if (unlikely(join->thd->trace_started()))
+ if (unlikely(trace.trace_started()))
{
trace.add("records", *record_count);
trace.add("read_time", *read_time);
@@ -3469,6 +3470,7 @@ bool Duplicate_weedout_picker::check_qep(JOIN *join,
uint temptable_rec_size;
Json_writer_object trace(join->thd);
trace.add("strategy", "DuplicateWeedout");
+
if (first_tab == join->const_tables)
{
prefix_rec_count= 1.0;
@@ -3529,7 +3531,7 @@ bool Duplicate_weedout_picker::check_qep(JOIN *join,
*record_count= prefix_rec_count * sj_outer_fanout;
*handled_fanout= dups_removed_fanout;
*strategy= SJ_OPT_DUPS_WEEDOUT;
- if (unlikely(join->thd->trace_started()))
+ if (unlikely(trace.trace_started()))
{
trace.add("records", *record_count);
trace.add("read_time", *read_time);
@@ -3727,18 +3729,20 @@ static void recalculate_prefix_record_count(JOIN *join, uint start, uint end)
void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
{
- uint table_count=join->table_count;
- uint tablenr;
- table_map remaining_tables= 0;
- table_map handled_tabs= 0;
join->sjm_lookup_tables= 0;
join->sjm_scan_tables= 0;
- THD *thd= join->thd;
if (!join->select_lex->sj_nests.elements)
return;
+
+ THD *thd= join->thd;
+ uint table_count=join->table_count;
+ uint tablenr;
+ table_map remaining_tables= 0;
+ table_map handled_tabs= 0;
Json_writer_object trace_wrapper(thd);
Json_writer_array trace_semijoin_strategies(thd,
- "fix_semijoin_strategies_for_picked_join_order");
+ "fix_semijoin_strategies_for_picked_join_order");
+
for (tablenr= table_count - 1 ; tablenr != join->const_tables - 1; tablenr--)
{
POSITION *pos= join->best_positions + tablenr;
diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc
index 057c6f3cc0a..a8676eec411 100644
--- a/sql/opt_trace.cc
+++ b/sql/opt_trace.cc
@@ -108,8 +108,8 @@ void opt_trace_print_expanded_query(THD *thd, SELECT_LEX *select_lex,
Json_writer_object *writer)
{
- if (!thd->trace_started())
- return;
+ DBUG_ASSERT(thd->trace_started());
+
StringBuffer<1024> str(system_charset_info);
ulonglong save_option_bits= thd->variables.option_bits;
thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE;
@@ -198,12 +198,11 @@ void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp)
{
if (likely(!(thd->variables.optimizer_trace &
Opt_trace_context::FLAG_ENABLED)) ||
- thd->system_thread)
+ thd->system_thread ||
+ !thd->trace_started())
return;
Opt_trace_context *const trace= &thd->opt_trace;
- if (!thd->trace_started())
- return;
bool full_access;
Security_context *const backup_thd_sctx= thd->security_context();
thd->set_security_context(&thd->main_security_ctx);
@@ -232,13 +231,12 @@ void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp)
void opt_trace_disable_if_no_tables_access(THD *thd, TABLE_LIST *tbl)
{
if (likely(!(thd->variables.optimizer_trace &
- Opt_trace_context::FLAG_ENABLED)) || thd->system_thread)
- return;
- Opt_trace_context *const trace= &thd->opt_trace;
-
- if (!thd->trace_started())
+ Opt_trace_context::FLAG_ENABLED)) ||
+ thd->system_thread ||
+ !thd->trace_started())
return;
+ Opt_trace_context *const trace= &thd->opt_trace;
Security_context *const backup_thd_sctx= thd->security_context();
thd->set_security_context(&thd->main_security_ctx);
const TABLE_LIST *const first_not_own_table= thd->lex->first_not_own_table();
@@ -293,12 +291,11 @@ void opt_trace_disable_if_no_view_access(THD *thd, TABLE_LIST *view,
if (likely(!(thd->variables.optimizer_trace &
Opt_trace_context::FLAG_ENABLED)) ||
- thd->system_thread)
- return;
- Opt_trace_context *const trace= &thd->opt_trace;
- if (!thd->trace_started())
+ thd->system_thread ||
+ !thd->trace_started())
return;
+ Opt_trace_context *const trace= &thd->opt_trace;
Security_context *const backup_table_sctx= view->security_ctx;
Security_context *const backup_thd_sctx= thd->security_context();
const GRANT_INFO backup_grant_info= view->grant;
@@ -334,64 +331,33 @@ void opt_trace_disable_if_no_view_access(THD *thd, TABLE_LIST *view,
The trace of one statement.
*/
-class Opt_trace_stmt {
- public:
- /**
- Constructor, starts a trace for information_schema and dbug.
- @param ctx_arg context
- */
- Opt_trace_stmt(Opt_trace_context *ctx_arg)
- {
- ctx= ctx_arg;
- current_json= new Json_writer();
- missing_priv= false;
- I_S_disabled= 0;
- }
- ~Opt_trace_stmt()
- {
- delete current_json;
- }
- void set_query(const char *query_ptr, size_t length, const CHARSET_INFO *charset);
- void open_struct(const char *key, char opening_bracket);
- void close_struct(const char *saved_key, char closing_bracket);
- void fill_info(Opt_trace_info* info);
- void add(const char *key, char *opening_bracket, size_t val_length);
- Json_writer* get_current_json() {return current_json;}
- void missing_privilege();
- void disable_tracing_for_children();
- void enable_tracing_for_children();
- bool is_enabled();
-
- void set_allowed_mem_size(size_t mem_size);
- size_t get_length() { return current_json->output.length(); }
- size_t get_truncated_bytes() { return current_json->get_truncated_bytes(); }
- bool get_missing_priv() { return missing_priv; }
-
-private:
- Opt_trace_context *ctx;
- String query; // store the query sent by the user
- Json_writer *current_json; // stores the trace
- bool missing_priv; ///< whether user lacks privilege to see this trace
- /*
- 0 <=> this trace should be in information_schema.
- !=0 tracing is disabled, this currently happens when we want to trace a
- sub-statement. For now traces are only collect for the top statement
- not for the sub-statments.
- */
- uint I_S_disabled;
-};
+Opt_trace_stmt::Opt_trace_stmt(Opt_trace_context *ctx_arg)
+{
+ ctx= ctx_arg;
+ current_json= new Json_writer();
+ missing_priv= false;
+ I_S_disabled= 0;
+}
-void Opt_trace_stmt::set_query(const char *query_ptr, size_t length,
- const CHARSET_INFO *charset)
+Opt_trace_stmt::~Opt_trace_stmt()
{
- query.append(query_ptr, length, charset);
+ delete current_json;
}
-Json_writer* Opt_trace_context::get_current_json()
+size_t Opt_trace_stmt::get_length()
{
- if (!is_started())
- return NULL;
- return current_trace->get_current_json();
+ return current_json->output.length();
+}
+
+size_t Opt_trace_stmt::get_truncated_bytes()
+{
+ return current_json->get_truncated_bytes();
+}
+
+void Opt_trace_stmt::set_query(const char *query_ptr, size_t length,
+ const CHARSET_INFO *charset)
+{
+ query.append(query_ptr, length, charset);
}
void Opt_trace_context::missing_privilege()
@@ -579,11 +545,6 @@ void Opt_trace_stmt::enable_tracing_for_children()
--I_S_disabled;
}
-bool Opt_trace_stmt::is_enabled()
-{
- return I_S_disabled == 0;
-}
-
void Opt_trace_stmt::set_allowed_mem_size(size_t mem_size)
{
current_json->set_size_limit(mem_size);
@@ -595,6 +556,7 @@ void Opt_trace_stmt::set_allowed_mem_size(size_t mem_size)
void Json_writer::add_table_name(const JOIN_TAB *tab)
{
+ DBUG_ASSERT(tab->join->thd->trace_started());
if (tab != NULL)
{
char table_name_buffer[SAFE_NAME_LEN];
@@ -633,6 +595,7 @@ void Json_writer::add_table_name(const TABLE *table)
void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab)
{
+ DBUG_ASSERT(thd->trace_started());
Json_writer_object table_records(thd);
table_records.add_table_name(tab);
Json_writer_object table_rec(thd, "table_scan");
@@ -658,6 +621,8 @@ void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab)
void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables)
{
THD *const thd= join->thd;
+ DBUG_ASSERT(thd->trace_started());
+
Json_writer_array plan_prefix(thd, "plan_prefix");
for (uint i= 0; i < idx; i++)
{
@@ -682,6 +647,8 @@ void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables)
void print_final_join_order(JOIN *join)
{
+ DBUG_ASSERT(join->thd->trace_started());
+
Json_writer_object join_order(join->thd);
Json_writer_array best_order(join->thd, "best_join_order");
JOIN_TAB *j;
@@ -695,6 +662,8 @@ void print_final_join_order(JOIN *join)
void print_best_access_for_table(THD *thd, POSITION *pos,
enum join_type type)
{
+ DBUG_ASSERT(thd->trace_started());
+
Json_writer_object trace_best_access(thd, "chosen_access_method");
trace_best_access.add("type", type == JT_ALL ? "scan" :
join_type_str[type]);
diff --git a/sql/opt_trace.h b/sql/opt_trace.h
index 46adbec2c3c..550f18c0797 100644
--- a/sql/opt_trace.h
+++ b/sql/opt_trace.h
@@ -21,8 +21,6 @@ class Item;
class THD;
struct TABLE_LIST;
-class Opt_trace_stmt;
-
/*
User-visible information about a trace.
*/
diff --git a/sql/opt_trace_context.h b/sql/opt_trace_context.h
index e5df16b1e3b..f578a0c67ec 100644
--- a/sql/opt_trace_context.h
+++ b/sql/opt_trace_context.h
@@ -3,7 +3,50 @@
#include "sql_array.h"
-class Opt_trace_stmt;
+class Opt_trace_context;
+struct Opt_trace_info;
+class Json_writer;
+
+class Opt_trace_stmt {
+ public:
+ /**
+ Constructor, starts a trace for information_schema and dbug.
+ @param ctx_arg context
+ */
+ Opt_trace_stmt(Opt_trace_context *ctx_arg);
+ ~Opt_trace_stmt();
+ void set_query(const char *query_ptr, size_t length, const CHARSET_INFO *charset);
+ void open_struct(const char *key, char opening_bracket);
+ void close_struct(const char *saved_key, char closing_bracket);
+ void fill_info(Opt_trace_info* info);
+ void add(const char *key, char *opening_bracket, size_t val_length);
+ Json_writer* get_current_json() {return current_json;}
+ void missing_privilege();
+ void disable_tracing_for_children();
+ void enable_tracing_for_children();
+ bool is_enabled()
+ {
+ return I_S_disabled == 0;
+ }
+ void set_allowed_mem_size(size_t mem_size);
+ size_t get_length();
+ size_t get_truncated_bytes();
+ bool get_missing_priv() { return missing_priv; }
+
+private:
+ Opt_trace_context *ctx;
+ String query; // store the query sent by the user
+ Json_writer *current_json; // stores the trace
+ bool missing_priv; ///< whether user lacks privilege to see this trace
+ /*
+ 0 <=> this trace should be in information_schema.
+ !=0 tracing is disabled, this currently happens when we want to trace a
+ sub-statement. For now traces are only collect for the top statement
+ not for the sub-statments.
+ */
+ uint I_S_disabled;
+};
+
class Opt_trace_context
{
@@ -48,7 +91,12 @@ public:
This returns the current trace, to which we are still writing and has not been finished
*/
- Json_writer* get_current_json();
+ Json_writer* get_current_json()
+ {
+ if (!is_started())
+ return NULL;
+ return current_trace->get_current_json();
+ }
bool empty()
{
@@ -57,7 +105,7 @@ public:
bool is_started()
{
- return current_trace && is_enabled();
+ return current_trace && current_trace->is_enabled();
}
bool disable_tracing_if_required();
diff --git a/sql/slave.cc b/sql/slave.cc
index aba10b8bd6e..436d5e0b5c5 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3997,19 +3997,26 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi,
exec_res= ev->apply_event(rgi);
#ifdef WITH_WSREP
- if (WSREP_ON)
- {
- mysql_mutex_lock(&thd->LOCK_thd_data);
- if (exec_res &&
- thd->wsrep_trx().state() != wsrep::transaction::s_executing)
- {
- WSREP_DEBUG("SQL apply failed, res %d conflict state: %s",
- exec_res, wsrep_thd_transaction_state_str(thd));
- rli->abort_slave= 1;
- rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(),
- "Node has dropped from cluster");
+ if (WSREP_ON) {
+ if (exec_res) {
+ mysql_mutex_lock(&thd->LOCK_thd_data);
+ switch(thd->wsrep_trx().state()) {
+ case wsrep::transaction::s_must_replay:
+ /* this transaction will be replayed,
+ so not raising slave error here */
+ WSREP_DEBUG("SQL apply failed for MUST_REPLAY, res %d", exec_res);
+ exec_res = 0;
+ break;
+ default:
+ WSREP_DEBUG("SQL apply failed, res %d conflict state: %s",
+ exec_res, wsrep_thd_transaction_state_str(thd));
+ rli->abort_slave= 1;
+ rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(),
+ "Node has dropped from cluster");
+ break;
+ }
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
- mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2143a9d4008..06b00e8799d 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2231,11 +2231,6 @@ void THD::reset_globals()
net.thd= 0;
}
-bool THD::trace_started()
-{
- return opt_trace.is_started();
-}
-
/*
Cleanup after query.
@@ -5690,6 +5685,7 @@ void THD::leave_locked_tables_mode()
{
if (locked_tables_mode == LTM_LOCK_TABLES)
{
+ DBUG_ASSERT(current_backup_stage == BACKUP_FINISHED);
/*
When leaving LOCK TABLES mode we have to change the duration of most
of the metadata locks being held, except for HANDLER and GRL locks,
diff --git a/sql/sql_class.h b/sql/sql_class.h
index acd304e24ea..19bdde022b0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3390,7 +3390,10 @@ public:
void reset_for_reuse();
bool store_globals();
void reset_globals();
- bool trace_started();
+ bool trace_started()
+ {
+ return opt_trace.is_started();
+ }
#ifdef SIGNAL_WITH_VIO_CLOSE
inline void set_active_vio(Vio* vio)
{
@@ -5137,6 +5140,7 @@ public:
Item *sp_fix_func_item(Item **it_addr);
Item *sp_prepare_func_item(Item **it_addr, uint cols= 1);
bool sp_eval_expr(Field *result_field, Item **expr_item_ptr);
+
};
/** A short cut for thd->get_stmt_da()->set_ok_status(). */
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index b3d0d985582..5a243cd0a6d 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -2254,6 +2254,8 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last)
if ((rc= join_tab_execution_startup(join_tab)) < 0)
goto finish2;
+ join_tab->build_range_rowid_filter_if_needed();
+
/* Prepare to retrieve all records of the joined table */
if (unlikely((error= join_tab_scan->open())))
{
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index 8eedffdf41a..63b233faea6 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -525,6 +525,12 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
goto error;
}
+ if (thd->current_backup_stage != BACKUP_FINISHED)
+ {
+ my_error(ER_BACKUP_LOCK_IS_ACTIVE, MYF(0));
+ return true;
+ }
+
if (thd->lex->type & REFRESH_READ_LOCK)
{
/*
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e8fd275c55b..40f6d5d9fa8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -360,8 +360,10 @@ bool dbug_user_var_equals_int(THD *thd, const char *name, int value)
static void trace_table_dependencies(THD *thd,
JOIN_TAB *join_tabs, uint table_count)
{
+ DBUG_ASSERT(thd->trace_started());
Json_writer_object trace_wrapper(thd);
Json_writer_array trace_dep(thd, "table_dependencies");
+
for (uint i= 0; i < table_count; i++)
{
TABLE_LIST *table_ref= join_tabs[i].tab_list;
@@ -1474,6 +1476,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
}
}
+ if (thd->trace_started())
{
Json_writer_object trace_wrapper(thd);
opt_trace_print_expanded_query(thd, select_lex, &trace_wrapper);
@@ -5350,6 +5353,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
{
Json_writer_object rows_estimation_wrapper(thd);
Json_writer_array rows_estimation(thd, "rows_estimation");
+
for (s=stat ; s < stat_end ; s++)
{
s->startup_cost= 0;
@@ -5494,10 +5498,16 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
if (select)
delete select;
else
- add_table_scan_values_to_trace(thd, s);
+ {
+ if (thd->trace_started())
+ add_table_scan_values_to_trace(thd, s);
+ }
}
else
- add_table_scan_values_to_trace(thd, s);
+ {
+ if (thd->trace_started())
+ add_table_scan_values_to_trace(thd, s);
+ }
}
}
@@ -7404,7 +7414,7 @@ best_access_path(JOIN *join,
Json_writer_object trace_access_idx(thd);
/*
- ft-keys require special treatment
+ full text keys require special treatment
*/
if (ft_key)
{
@@ -7416,7 +7426,7 @@ best_access_path(JOIN *join,
records= 1.0;
type= JT_FT;
trace_access_idx.add("access_type", join_type_str[type])
- .add("index", keyinfo->name);
+ .add("full-text index", keyinfo->name);
}
else
{
@@ -11870,18 +11880,21 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
i++;
}
- trace_attached_comp.end();
- Json_writer_array trace_attached_summary(thd,
- "attached_conditions_summary");
- for (tab= first_depth_first_tab(join); tab;
- tab= next_depth_first_tab(join, tab))
+ if (unlikely(thd->trace_started()))
{
- if (!tab->table)
- continue;
- Item *const cond = tab->select_cond;
- Json_writer_object trace_one_table(thd);
- trace_one_table.add_table_name(tab);
- trace_one_table.add("attached", cond);
+ trace_attached_comp.end();
+ Json_writer_array trace_attached_summary(thd,
+ "attached_conditions_summary");
+ for (tab= first_depth_first_tab(join); tab;
+ tab= next_depth_first_tab(join, tab))
+ {
+ if (!tab->table)
+ continue;
+ Item *const cond = tab->select_cond;
+ Json_writer_object trace_one_table(thd);
+ trace_one_table.add_table_name(tab);
+ trace_one_table.add("attached", cond);
+ }
}
}
DBUG_RETURN(0);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 02f6278140c..2b1be46b807 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -465,7 +465,7 @@ static struct show_privileges_st sys_privileges[]=
{"Create view", "Tables", "To create new views"},
{"Create user", "Server Admin", "To create new users"},
{"Delete", "Tables", "To delete existing rows"},
- {"Delete versioning rows", "Tables", "To delete versioning table historical rows"},
+ {"Delete history", "Tables", "To delete versioning table historical rows"},
{"Drop", "Databases,Tables", "To drop databases, tables, and views"},
#ifdef HAVE_EVENT_SCHEDULER
{"Event","Server Admin","To create, alter, drop and execute events"},
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a499f91397a..2d4ff71d0c1 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6599,38 +6599,68 @@ static int compare_uint(const uint *s, const uint *t)
return (*s < *t) ? -1 : ((*s > *t) ? 1 : 0);
}
-enum class Compare_keys : uint32_t
-{
- Equal= 0,
- EqualButKeyPartLength,
- EqualButComment,
- NotEqual
-};
+static Compare_keys merge(Compare_keys current, Compare_keys add) {
+ if (current == Compare_keys::Equal)
+ return add;
+
+ if (add == Compare_keys::Equal)
+ return current;
+
+ if (current == add)
+ return current;
+
+ if (current == Compare_keys::EqualButComment) {
+ return Compare_keys::NotEqual;
+ }
+
+ if (current == Compare_keys::EqualButKeyPartLength) {
+ if (add == Compare_keys::EqualButComment)
+ return Compare_keys::NotEqual;
+ DBUG_ASSERT(add == Compare_keys::NotEqual);
+ return Compare_keys::NotEqual;
+ }
+
+ DBUG_ASSERT(current == Compare_keys::NotEqual);
+ return current;
+}
Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key,
Alter_info *alter_info, const TABLE *table,
const KEY *const new_pk,
const KEY *const old_pk)
{
- Compare_keys result= Compare_keys::Equal;
+ if (table_key->algorithm != new_key->algorithm)
+ return Compare_keys::NotEqual;
+
+ if ((table_key->flags & HA_KEYFLAG_MASK) !=
+ (new_key->flags & HA_KEYFLAG_MASK))
+ return Compare_keys::NotEqual;
- if ((table_key->algorithm != new_key->algorithm) ||
- ((table_key->flags & HA_KEYFLAG_MASK) !=
- (new_key->flags & HA_KEYFLAG_MASK)) ||
- (table_key->user_defined_key_parts != new_key->user_defined_key_parts))
+ if (table_key->user_defined_key_parts != new_key->user_defined_key_parts)
return Compare_keys::NotEqual;
if (table_key->block_size != new_key->block_size)
return Compare_keys::NotEqual;
+ /*
+ Rebuild the index if following condition get satisfied:
+
+ (i) Old table doesn't have primary key, new table has it and vice-versa
+ (ii) Primary key changed to another existing index
+ */
+ if ((new_key == new_pk) != (table_key == old_pk))
+ return Compare_keys::NotEqual;
+
if (engine_options_differ(table_key->option_struct, new_key->option_struct,
table->file->ht->index_options))
return Compare_keys::NotEqual;
- const KEY_PART_INFO *end=
- table_key->key_part + table_key->user_defined_key_parts;
- for (const KEY_PART_INFO *key_part= table_key->key_part,
- *new_part= new_key->key_part;
+ Compare_keys result= Compare_keys::Equal;
+
+ for (const KEY_PART_INFO *
+ key_part= table_key->key_part,
+ *new_part= new_key->key_part,
+ *end= table_key->key_part + table_key->user_defined_key_parts;
key_part < end; key_part++, new_part++)
{
/*
@@ -6638,61 +6668,23 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key,
object with adjusted length. So below we have to check field
indexes instead of simply comparing pointers to Field objects.
*/
- Create_field *new_field= alter_info->create_list.elem(new_part->fieldnr);
- if (!new_field->field ||
- new_field->field->field_index != key_part->fieldnr - 1)
- return Compare_keys::NotEqual;
-
- /*
- If there is a change in index length due to column expansion
- like varchar(X) changed to varchar(X + N) and has a compatible
- packed data representation, we mark it for fast/INPLACE change
- in index definition. InnoDB supports INPLACE for this cases
-
- Key definition has changed if we are using a different field or
- if the user key part length is different.
- */
- const Field *old_field= table->field[key_part->fieldnr - 1];
+ const Create_field &new_field=
+ *alter_info->create_list.elem(new_part->fieldnr);
- bool is_equal= key_part->field->is_equal(*new_field);
- /* TODO: below is an InnoDB specific code which should be moved to InnoDB */
- if (!is_equal)
+ if (!new_field.field ||
+ new_field.field->field_index != key_part->fieldnr - 1)
{
- if (!key_part->field->can_be_converted_by_engine(*new_field))
- return Compare_keys::NotEqual;
-
- if (!Charset(old_field->charset())
- .eq_collation_specific_names(new_field->charset))
- return Compare_keys::NotEqual;
+ return Compare_keys::NotEqual;
}
- if (key_part->length != new_part->length)
- {
- if (key_part->length != old_field->field_length ||
- key_part->length >= new_part->length || is_equal)
- {
- return Compare_keys::NotEqual;
- }
- result= Compare_keys::EqualButKeyPartLength;
- }
+ auto compare= table->file->compare_key_parts(
+ *table->field[key_part->fieldnr - 1], new_field, *key_part, *new_part);
+ result= merge(result, compare);
}
- /*
- Rebuild the index if following condition get satisfied:
-
- (i) Old table doesn't have primary key, new table has it and vice-versa
- (ii) Primary key changed to another existing index
-*/
- if ((new_key == new_pk) != (table_key == old_pk))
- return Compare_keys::NotEqual;
-
/* Check that key comment is not changed. */
if (cmp(table_key->comment, new_key->comment) != 0)
- {
- if (result != Compare_keys::Equal)
- return Compare_keys::NotEqual;
- result= Compare_keys::EqualButComment;
- }
+ result= merge(result, Compare_keys::EqualButComment);
return result;
}
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index ffd42599527..e353c2a6b46 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -656,9 +656,12 @@ Memory allocated by threads: %s\n",
void print_keyuse_array_for_trace(THD *thd, DYNAMIC_ARRAY *keyuse_array)
{
+ DBUG_ASSERT(thd->trace_started());
+
Json_writer_object wrapper(thd);
Json_writer_array trace_key_uses(thd, "ref_optimizer_key_uses");
- for(uint i=0; i < keyuse_array->elements; i++)
+
+ for (uint i=0; i < keyuse_array->elements; i++)
{
KEYUSE *keyuse= (KEYUSE*)dynamic_array_ptr(keyuse_array, i);
Json_writer_object keyuse_elem(thd);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 3f0f7251d5c..e49a82dab80 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -7262,10 +7262,10 @@ alter:
lex->server_options.reset($3);
} OPTIONS_SYM '(' server_options_list ')' { }
/* ALTER USER foo is allowed for MySQL compatibility. */
- | ALTER opt_if_exists USER_SYM clear_privileges grant_list
+ | ALTER USER_SYM opt_if_exists clear_privileges grant_list
opt_require_clause opt_resource_options opt_account_locking opt_password_expiration
{
- Lex->create_info.set($2);
+ Lex->create_info.set($3);
Lex->sql_command= SQLCOM_ALTER_USER;
}
| ALTER SEQUENCE_SYM opt_if_exists
@@ -8300,9 +8300,13 @@ rename:
RENAME table_or_tables
{
Lex->sql_command= SQLCOM_RENAME_TABLE;
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
}
table_to_table_list
- {}
+ {
+ Lex->pop_select(); //main select
+ }
| RENAME USER_SYM clear_privileges rename_list
{
Lex->sql_command = SQLCOM_RENAME_USER;
@@ -8400,9 +8404,13 @@ preload:
LEX *lex=Lex;
lex->sql_command=SQLCOM_PRELOAD_KEYS;
lex->alter_info.reset();
+ if (lex->main_select_push())
+ MYSQL_YYABORT;
}
preload_list_or_parts
- {}
+ {
+ Lex->pop_select(); //main select
+ }
;
preload_list_or_parts:
@@ -12585,11 +12593,16 @@ drop:
}
table_list opt_lock_wait_timeout opt_restrict
{}
- | DROP INDEX_SYM opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout
+ | DROP INDEX_SYM
+ {
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
+ }
+ opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout
{
LEX *lex=Lex;
Alter_drop *ad= (new (thd->mem_root)
- Alter_drop(Alter_drop::KEY, $4.str, $3));
+ Alter_drop(Alter_drop::KEY, $5.str, $4));
if (unlikely(ad == NULL))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_DROP_INDEX;
@@ -12597,10 +12610,11 @@ drop:
lex->alter_info.flags= ALTER_DROP_INDEX;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
if (unlikely(!lex->current_select->
- add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING,
+ add_table_to_list(thd, $7, NULL, TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
MDL_SHARED_UPGRADABLE)))
MYSQL_YYABORT;
+ Lex->pop_select(); //main select
}
| DROP DATABASE opt_if_exists ident
{
@@ -14106,12 +14120,18 @@ backup_statements:
Lex->backup_stage= (backup_stages) (type-1);
break;
}
- | LOCK_SYM table_ident
+ | LOCK_SYM
{
- if (unlikely(!Select->add_table_to_list(thd, $2, NULL, 0,
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
+ }
+ table_ident
+ {
+ if (unlikely(!Select->add_table_to_list(thd, $3, NULL, 0,
TL_READ, MDL_SHARED_HIGH_PRIO)))
MYSQL_YYABORT;
Lex->sql_command= SQLCOM_BACKUP_LOCK;
+ Lex->pop_select(); //main select
}
| UNLOCK_SYM
{
diff --git a/sql/table.cc b/sql/table.cc
index 10c44013538..2b31cbef083 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -3904,7 +3904,7 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
*/
field= key_part->field=field->make_new_field(&outparam->mem_root,
outparam, 0);
- field->field_length= key_part->length;
+ const_cast<uint32_t&>(field->field_length)= key_part->length;
}
}
if (!share->use_ext_keys)
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 5ae583212f3..b605ff0496d 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -54,8 +54,9 @@ static void wsrep_replication_process(THD *thd,
Wsrep_applier_service applier_service(thd);
/* thd->system_thread_info.rpl_sql_info isn't initialized. */
- thd->system_thread_info.rpl_sql_info=
- new rpl_sql_thread_info(thd->wsrep_rgi->rli->mi->rpl_filter);
+ if (!thd->slave_thread)
+ thd->system_thread_info.rpl_sql_info=
+ new rpl_sql_thread_info(thd->wsrep_rgi->rli->mi->rpl_filter);
WSREP_INFO("Starting applier thread %llu", thd->thread_id);
enum wsrep::provider::status
@@ -67,7 +68,8 @@ static void wsrep_replication_process(THD *thd,
mysql_cond_broadcast(&COND_wsrep_slave_threads);
mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
- delete thd->system_thread_info.rpl_sql_info;
+ if (!thd->slave_thread)
+ delete thd->system_thread_info.rpl_sql_info;
delete thd->wsrep_rgi->rli->mi;
delete thd->wsrep_rgi->rli;
diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h
index 3440c8fd205..370906bd1f6 100644
--- a/storage/heap/ha_heap.h
+++ b/storage/heap/ha_heap.h
@@ -65,8 +65,9 @@ public:
double scan_time()
{ return (double) (stats.records+stats.deleted) / 20.0+10; }
double read_time(uint index, uint ranges, ha_rows rows)
- { return (double) rows / 20.0+1; }
-
+ { return (double) rows / 20.0+1; }
+ double keyread_time(uint index, uint ranges, ha_rows rows)
+ { return (double) rows / 20.0+1; }
int open(const char *name, int mode, uint test_if_locked);
int close(void);
void set_keys_for_scanning(void);
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index c1cc6ca1096..f533da30249 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -2029,6 +2029,7 @@ dict_index_add_to_cache(
> field->col->max_prefix) {
/* Set the max_prefix value based on the
prefix_len. */
+ ut_ad(field->prefix_len % field->col->mbmaxlen == 0);
field->col->max_prefix = field->prefix_len;
}
ut_ad(field->col->ord_part == 1);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index d054657ccb4..8f0a127b9f7 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -21192,6 +21192,37 @@ ha_innobase::can_convert_blob(const Field_blob* field,
return true;
}
+Compare_keys ha_innobase::compare_key_parts(
+ const Field &old_field, const Column_definition &new_field,
+ const KEY_PART_INFO &old_part, const KEY_PART_INFO &new_part) const
+{
+ const bool is_equal= old_field.is_equal(new_field);
+ const CHARSET_INFO *old_cs= old_field.charset();
+ const CHARSET_INFO *new_cs= new_field.charset;
+
+ if (!is_equal)
+ {
+ if (!old_field.can_be_converted_by_engine(new_field))
+ return Compare_keys::NotEqual;
+
+ if (!Charset(old_cs).eq_collation_specific_names(new_cs))
+ return Compare_keys::NotEqual;
+ }
+
+ if (old_part.length / old_cs->mbmaxlen != new_part.length / new_cs->mbmaxlen)
+ {
+ if (old_part.length != old_field.field_length)
+ return Compare_keys::NotEqual;
+
+ if (old_part.length >= new_part.length)
+ return Compare_keys::NotEqual;
+
+ return Compare_keys::EqualButKeyPartLength;
+ }
+
+ return Compare_keys::Equal;
+}
+
/******************************************************************//**
Use this when the args are passed to the format string from
errmsg-utf8.txt directly as is.
diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h
index a5098fcccee..5af8aebdebd 100644
--- a/storage/innobase/handler/ha_innodb.h
+++ b/storage/innobase/handler/ha_innodb.h
@@ -445,6 +445,11 @@ public:
/** @return whether innodb_strict_mode is active */
bool is_innodb_strict_mode()
{ return is_innodb_strict_mode(m_user_thd); }
+ Compare_keys
+ compare_key_parts(const Field& old_field,
+ const Column_definition& new_field,
+ const KEY_PART_INFO& old_part,
+ const KEY_PART_INFO& new_part) const override;
protected:
dberr_t innobase_get_autoinc(ulonglong* value);
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 9dd54c945b9..9839068ae99 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -549,8 +549,9 @@ struct file_name_t {
ulint size;
/** Constructor */
- file_name_t(std::string name_, bool deleted) :
- name(name_), space(NULL), status(deleted ? DELETED: NORMAL),
+ file_name_t(std::string name_, bool deleted)
+ : name(std::move(name_)), space(NULL),
+ status(deleted ? DELETED: NORMAL),
size(0) {}
};
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index 90a443c8b20..c0797271fef 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -3407,11 +3407,12 @@ page_zip_validate_low(
differed. Let us ignore it. */
page_zip_fail(("page_zip_validate:"
" min_rec_flag"
- " (%s%lu,%lu,0x%02lx)\n",
+ " (%s" ULINTPF "," ULINTPF
+ ",0x%02x)\n",
sloppy ? "ignored, " : "",
page_get_space_id(page),
page_get_page_no(page),
- (ulong) page[offset]));
+ page[offset]));
/* We don't check for spatial index, since
the "minimum record" could be deleted when
doing rtr_update_mbr_field.
diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h
index 1abdc345527..448900c5a91 100644
--- a/storage/rocksdb/ha_rocksdb.h
+++ b/storage/rocksdb/ha_rocksdb.h
@@ -739,6 +739,7 @@ public:
const TABLE *old_table_arg, const Rdb_tbl_def *old_tbl_def_arg) const
MY_ATTRIBUTE((__nonnull__));
+ using handler::compare_key_parts;
int compare_key_parts(const KEY *const old_key,
const KEY *const new_key) const
MY_ATTRIBUTE((__nonnull__, __warn_unused_result__));
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt
index a9f1bf64da8..80b6ca386df 100644
--- a/support-files/CMakeLists.txt
+++ b/support-files/CMakeLists.txt
@@ -91,7 +91,7 @@ IF(UNIX)
ENDIF()
CONFIGURE_FILE(mariadb.pc.in ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc @ONLY)
- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc DESTINATION ${INSTALL_SHAREDIR}/pkgconfig COMPONENT Development)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc DESTINATION ${INSTALL_LIBDIR}/pkgconfig COMPONENT Development)
INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)
diff --git a/support-files/mariadb.pc.in b/support-files/mariadb.pc.in
index bc84a5c5c4c..7d321f28491 100644
--- a/support-files/mariadb.pc.in
+++ b/support-files/mariadb.pc.in
@@ -20,4 +20,4 @@ Description: @CPACK_PACKAGE_DESCRIPTION_SUMMARY@
URL: @CPACK_PACKAGE_URL@
Version: @VERSION@
Libs: -L${libdir} @LIBS_FOR_CLIENTS@
-Cflags: -I${includedir} -I${includedir}/.. @CFLAGS_FOR_CLIENTS@
+Cflags: -I${includedir} @CFLAGS_FOR_CLIENTS@
diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in
index e7665ed1219..dca7a4c13a7 100644
--- a/support-files/mariadb.service.in
+++ b/support-files/mariadb.service.in
@@ -144,7 +144,7 @@ TimeoutStopSec=900
## isn't executed.
##
-# Number of files limit. previously [mysqld_safe] open-file-limit
+# Number of files limit. previously [mysqld_safe] open-files-limit
LimitNOFILE=16364
# Maximium core size. previously [mysqld_safe] core-file-size
diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in
index ffefc2f22d8..f12f44311f5 100644
--- a/support-files/mariadb@.service.in
+++ b/support-files/mariadb@.service.in
@@ -267,7 +267,7 @@ Group=mysql
## isn't executed.
##
-# Number of files limit. previously [mysqld_safe] open-file-limit
+# Number of files limit. previously [mysqld_safe] open-files-limit
LimitNOFILE=16364
# Maximium core size. previously [mysqld_safe] core-file-size