From 0c6a40f2d5c2c3791455b5ef761f8dd034851df0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 7 Nov 2013 13:22:19 +0100 Subject: [PATCH 01/19] increase the version --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index ed0c4b57704..26414adb678 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=33 -MYSQL_VERSION_EXTRA=a +MYSQL_VERSION_PATCH=34 +MYSQL_VERSION_EXTRA= From d1f2ba398585e46bc93203c04f684a59f9777f8a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 7 Nov 2013 13:22:27 +0100 Subject: [PATCH 02/19] MDEV-5250 doesn't install on fedora if mysql is installed when our package is to replace "mysql", it has both provide and obsolete it --- cmake/cpack_rpm.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index c21b863c71f..a8439fcab00 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -127,6 +127,8 @@ SET(CPACK_RPM_test_PACKAGE_PROVIDES "MySQL-test mysql-test") MACRO(ALTERNATIVE_NAME real alt) SET(p "CPACK_RPM_${real}_PACKAGE_PROVIDES") SET(${p} "${${p}} ${alt} ${alt}(x86-32) ${alt}(x86-64) config(${alt})") + SET(o "CPACK_RPM_${real}_PACKAGE_OBSOLETES") + SET(${o} "${${o}} ${alt}") ENDMACRO(ALTERNATIVE_NAME) IF(RPM MATCHES "(rhel|centos)5") From 3d57c343e517bc8fa4c2551ca93f08ef0e8ccd5f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:30:35 +0100 Subject: [PATCH 03/19] MDEV-5038 put tokudb into the server package --- CMakeLists.txt | 6 ++++++ debian/autobake-deb.sh | 2 +- debian/dist/Debian/control | 15 ++++----------- ...rver-5.5.files => mariadb-server-5.5.files.in} | 1 + debian/dist/Ubuntu/control | 15 ++++----------- ...rver-5.5.files => mariadb-server-5.5.files.in} | 1 + debian/mariadb-tokudb-engine-5.5.files | 5 ----- storage/tokudb/CMakeLists.txt | 8 +++++--- storage/tokudb/ft-index/CMakeLists.txt | 2 +- storage/tokudb/ft-index/ft/CMakeLists.txt | 2 +- 10 files changed, 24 insertions(+), 33 deletions(-) rename debian/dist/Debian/{mariadb-server-5.5.files => mariadb-server-5.5.files.in} (99%) rename debian/dist/Ubuntu/{mariadb-server-5.5.files => mariadb-server-5.5.files.in} (99%) delete mode 100644 debian/mariadb-tokudb-engine-5.5.files diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cbbd6c0571..ceaf7d17df9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,6 +350,12 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/info_macros.cmake.in ${CMAKE_BINARY_DIR}/info_macros.cmake @ONLY) +IF(DEB) + CONFIGURE_FILE( + ${CMAKE_SOURCE_DIR}/debian/mariadb-server-5.5.files.in + ${CMAKE_SOURCE_DIR}/debian/mariadb-server-5.5.files) +ENDIF(DEB) + # Handle the "INFO_*" files. INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake) # Source: This can be done during the cmake phase, all information is diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index ec725d419c2..3ee877af482 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -15,7 +15,7 @@ set -e # Buildbot, running the test suite from installed .debs on a clean VM. export DEB_BUILD_OPTIONS="nocheck" -export MARIADB_OPTIONAL_DEBS="tokudb-engine" +#export MARIADB_OPTIONAL_DEBS="tokudb-engine" # Find major.minor version. # diff --git a/debian/dist/Debian/control b/debian/dist/Debian/control index 38868478abd..2b4c419ea8e 100644 --- a/debian/dist/Debian/control +++ b/debian/dist/Debian/control @@ -190,12 +190,13 @@ Depends: mariadb-client-5.5 (>= ${source:Version}), libdbi-perl, perl (>= 5.6), Provides: mariadb-server, mysql-server, virtual-mysql-server Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3 + mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, + mariadb-tokudb-engine-5.5 Replaces: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, - libmariadbclient16 (<< 5.3.4), - libmariadbclient-dev (<< 5.5.0) + libmariadbclient16 (<< 5.3.4), libmariadbclient-dev (<< 5.5.0), + mariadb-tokudb-engine-5.5 Description: MariaDB database server binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -239,11 +240,3 @@ Description: MariaDB database regression test suite (metapackage depending on th mariadb-test (currently mariadb-test-5.5), as determined by the MariaDB maintainers. -Package: mariadb-tokudb-engine-5.5 -Section: database -Architecture: any -Depends: mariadb-server-5.5 -Description: TokuDB storage engine for MariaDB - TokuDB is a highly scalable, zero maintenance downtime, ACID and MVCC - compliant MariaDB Storage Engine that offers powerful indexing-based query - acceleration. http://www.tokutek.com/products/tokudb-for-mysql/ diff --git a/debian/dist/Debian/mariadb-server-5.5.files b/debian/dist/Debian/mariadb-server-5.5.files.in similarity index 99% rename from debian/dist/Debian/mariadb-server-5.5.files rename to debian/dist/Debian/mariadb-server-5.5.files.in index 15206865d4f..eb9ba7a9a2c 100644 --- a/debian/dist/Debian/mariadb-server-5.5.files +++ b/debian/dist/Debian/mariadb-server-5.5.files.in @@ -71,3 +71,4 @@ usr/share/mysql/mysql_system_tables_data.sql usr/share/mysql/mysql_system_tables.sql usr/share/mysql/mysql_performance_tables.sql usr/share/mysql/mysql_test_data_timezone.sql +@TOKUDB_DEB_FILES@ diff --git a/debian/dist/Ubuntu/control b/debian/dist/Ubuntu/control index de7b2405676..a4e25565944 100644 --- a/debian/dist/Ubuntu/control +++ b/debian/dist/Ubuntu/control @@ -184,12 +184,13 @@ Depends: mariadb-client-5.5 (>= ${source:Version}), libdbi-perl, perl (>= 5.6), Provides: mariadb-server, mysql-server, virtual-mysql-server Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, - mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3 + mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, + mariadb-tokudb-engine-5.5 Replaces: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, - libmariadbclient16 (<< 5.3.4), - libmariadbclient-dev (<< 5.5.0) + libmariadbclient16 (<< 5.3.4), libmariadbclient-dev (<< 5.5.0), + mariadb-tokudb-engine-5.5 Description: MariaDB database server binaries MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query @@ -233,11 +234,3 @@ Description: MariaDB database regression test suite (metapackage depending on th mariadb-test (currently mariadb-test-5.5), as determined by the MariaDB maintainers. -Package: mariadb-tokudb-engine-5.5 -Section: database -Architecture: any -Depends: mariadb-server-5.5 -Description: TokuDB storage engine for MariaDB - TokuDB is a highly scalable, zero maintenance downtime, ACID and MVCC - compliant MariaDB Storage Engine that offers powerful indexing-based query - acceleration. http://www.tokutek.com/products/tokudb-for-mysql/ diff --git a/debian/dist/Ubuntu/mariadb-server-5.5.files b/debian/dist/Ubuntu/mariadb-server-5.5.files.in similarity index 99% rename from debian/dist/Ubuntu/mariadb-server-5.5.files rename to debian/dist/Ubuntu/mariadb-server-5.5.files.in index c747d4d64db..4921d3fa267 100644 --- a/debian/dist/Ubuntu/mariadb-server-5.5.files +++ b/debian/dist/Ubuntu/mariadb-server-5.5.files.in @@ -73,3 +73,4 @@ usr/share/mysql/mysql_system_tables_data.sql usr/share/mysql/mysql_system_tables.sql usr/share/mysql/mysql_performance_tables.sql usr/share/mysql/mysql_test_data_timezone.sql +@TOKUDB_DEB_FILES@ diff --git a/debian/mariadb-tokudb-engine-5.5.files b/debian/mariadb-tokudb-engine-5.5.files deleted file mode 100644 index 2dc9f22d77a..00000000000 --- a/debian/mariadb-tokudb-engine-5.5.files +++ /dev/null @@ -1,5 +0,0 @@ -etc/mysql/conf.d/tokudb.cnf -usr/bin/tokuftdump -usr/lib/mysql/plugin/ha_tokudb.so -usr/share/doc/mariadb-tokudb-engine-5.5/README-TOKUDB -usr/share/doc/mariadb-tokudb-engine-5.5/README.md diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index 527d77996ff..26955370084 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -15,6 +15,7 @@ IF(NOT TOKUDB_OK) ENDIF() SET(ENV{TOKUDB_VERSION} "7.0.4") +SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump\nusr/share/doc/mariadb-server-5.5/README-TOKUDB\nusr/share/doc/mariadb-server-5.5/README.md" PARENT_SCOPE) SET(USE_BDB OFF CACHE BOOL "") SET(USE_VALGRIND OFF CACHE BOOL "") SET(BUILD_TESTING OFF CACHE BOOL "") @@ -45,12 +46,13 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/ft-index/toku_include) SET(TOKUDB_PLUGIN_DYNAMIC "ha_tokudb") SET(TOKUDB_SOURCES ha_tokudb.cc) MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY - COMPONENT "tokudb-engine" LINK_LIBRARIES tokufractaltree_static tokuportability_static ${ZLIB_LIBRARY} stdc++) SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -fuse-linker-plugin") +SET(CPACK_RPM_server_PACKAGE_OBSOLETES + "${CPACK_RPM_server_PACKAGE_OBSOLETES} MariaDB-tokudb-engine < 5.5.34" PARENT_SCOPE) + IF (INSTALL_SYSCONF2DIR) - INSTALL(FILES tokudb.cnf DESTINATION ${INSTALL_SYSCONF2DIR} COMPONENT tokudb-engine) - SET(CPACK_RPM_tokudb-engine_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" PARENT_SCOPE) + INSTALL(FILES tokudb.cnf DESTINATION ${INSTALL_SYSCONF2DIR} COMPONENT Server) ENDIF(INSTALL_SYSCONF2DIR) diff --git a/storage/tokudb/ft-index/CMakeLists.txt b/storage/tokudb/ft-index/CMakeLists.txt index 41e3116b16d..87c04be75e5 100644 --- a/storage/tokudb/ft-index/CMakeLists.txt +++ b/storage/tokudb/ft-index/CMakeLists.txt @@ -57,7 +57,7 @@ add_subdirectory(include) add_subdirectory(toku_include) #add_subdirectory(examples) -INSTALL_DOCUMENTATION(README.md README-TOKUDB COMPONENT "tokudb-engine") +INSTALL_DOCUMENTATION(README.md README-TOKUDB COMPONENT Server) ## build tags #include(TokuBuildTagDatabases) diff --git a/storage/tokudb/ft-index/ft/CMakeLists.txt b/storage/tokudb/ft-index/ft/CMakeLists.txt index 748e501f922..c773f4b3391 100644 --- a/storage/tokudb/ft-index/ft/CMakeLists.txt +++ b/storage/tokudb/ft-index/ft/CMakeLists.txt @@ -103,7 +103,7 @@ target_link_libraries(ftverify m) install( TARGETS tokuftdump - COMPONENT "tokudb-engine" + COMPONENT Server DESTINATION ${INSTALL_BINDIR} ) From db635ab590704232308ac1aa5629a1d940de9f16 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:30:48 +0100 Subject: [PATCH 04/19] MDEV-5124 cmake failure when fullhostname is not resolved expand fullhostname inside the string, to have an empty string, not nothing, when fullhostname is not defined --- storage/tokudb/ft-index/cmake_modules/TokuSetupCTest.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/tokudb/ft-index/cmake_modules/TokuSetupCTest.cmake b/storage/tokudb/ft-index/cmake_modules/TokuSetupCTest.cmake index f6aedca0868..5ca2fb64458 100644 --- a/storage/tokudb/ft-index/cmake_modules/TokuSetupCTest.cmake +++ b/storage/tokudb/ft-index/cmake_modules/TokuSetupCTest.cmake @@ -60,7 +60,7 @@ macro(hostname out) COMMAND hostname OUTPUT_VARIABLE fullhostname OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "\\.tokutek\\.com$" "" ${out} ${fullhostname}) + string(REGEX REPLACE "\\.tokutek\\.com$" "" ${out} "${fullhostname}") endmacro(hostname) ## gather machine info From e780bd9efa6e82093ccd6e500bf592fc3c684cef Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:30:58 +0100 Subject: [PATCH 05/19] MDEV-4977 ./mysql-test/mysql-test-run.pl not identifying mariadb version quote the path when using it in a regex - the path might contain wildcards (e.g. +) --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index d7e33a1b72c..27088df0a81 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1890,7 +1890,7 @@ sub collect_mysqld_features { my @list= split '\n', $list; mtr_error("Could not find version of MariaDB") - unless shift(@list) =~ /^$exe_mysqld\s+Ver\s(\d+)\.(\d+)\.(\d+)(\S*)/; + unless shift(@list) =~ /^\Q$exe_mysqld\E\s+Ver\s(\d+)\.(\d+)\.(\d+)(\S*)/; $mysql_version_id= $1*10000 + $2*100 + $3; $mysql_version_extra= $4; mtr_report("MariaDB Version $1.$2.$3$4"); From d042e61f8e68f24897b88c6ff5ab213aa1eb59fd Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:31:02 +0100 Subject: [PATCH 06/19] MDEV-5054 Failing test(s): main.mysqld--help sys_vars.character_sets_dir_basic fix tests where a path was used as a regex. revert changes to sys_vars.character_sets_dir_basic - we don't run it on windows anyway --- .../r/character_sets_dir_basic.result | 10 +++++----- .../sys_vars/t/character_sets_dir_basic.test | 19 +++++-------------- mysql-test/t/mysqld--help.test | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/character_sets_dir_basic.result b/mysql-test/suite/sys_vars/r/character_sets_dir_basic.result index ef8ec0cd9b8..c04e5dac199 100644 --- a/mysql-test/suite/sys_vars/r/character_sets_dir_basic.result +++ b/mysql-test/suite/sys_vars/r/character_sets_dir_basic.result @@ -1,20 +1,20 @@ select @@global.character_sets_dir; @@global.character_sets_dir -MYSQL_CHARSETSDIR +MYSQL_CHARSETSDIR/ select @@session.character_sets_dir; ERROR HY000: Variable 'character_sets_dir' is a GLOBAL variable show global variables like 'character_sets_dir'; Variable_name Value -character_sets_dir MYSQL_CHARSETSDIR +character_sets_dir MYSQL_CHARSETSDIR/ show session variables like 'character_sets_dir'; Variable_name Value -character_sets_dir MYSQL_CHARSETSDIR +character_sets_dir MYSQL_CHARSETSDIR/ select * from information_schema.global_variables where variable_name='character_sets_dir'; VARIABLE_NAME VARIABLE_VALUE -CHARACTER_SETS_DIR MYSQL_CHARSETSDIR +CHARACTER_SETS_DIR MYSQL_CHARSETSDIR/ select * from information_schema.session_variables where variable_name='character_sets_dir'; VARIABLE_NAME VARIABLE_VALUE -CHARACTER_SETS_DIR MYSQL_CHARSETSDIR +CHARACTER_SETS_DIR MYSQL_CHARSETSDIR/ set global character_sets_dir="foo"; ERROR HY000: Variable 'character_sets_dir' is a read only variable set session character_sets_dir="foo"; diff --git a/mysql-test/suite/sys_vars/t/character_sets_dir_basic.test b/mysql-test/suite/sys_vars/t/character_sets_dir_basic.test index bf21db1c7dc..0bbfd04133d 100644 --- a/mysql-test/suite/sys_vars/t/character_sets_dir_basic.test +++ b/mysql-test/suite/sys_vars/t/character_sets_dir_basic.test @@ -2,26 +2,17 @@ # # show the global and session values; # - -# workaround to adjust for the directory separators being different in -# different OSes : slash on unixes and backslash or slash on windows. -# TODO: fix with a proper comparison in mysqltest -let $rcd= `SELECT REPLACE('$MYSQL_CHARSETSDIR', '\\\\\', '.')`; -let $rcd= `SELECT REPLACE('$rcd', '/', '.')`; -let $regex_charsetdir= `SELECT '/$rcd[\\\\\/\\\\\]/MYSQL_CHARSETSDIR/'`; - ---replace_regex $regex_charsetdir +--replace_result $MYSQL_CHARSETSDIR MYSQL_CHARSETSDIR select @@global.character_sets_dir; - --error ER_INCORRECT_GLOBAL_LOCAL_VAR select @@session.character_sets_dir; ---replace_regex $regex_charsetdir +--replace_result $MYSQL_CHARSETSDIR MYSQL_CHARSETSDIR show global variables like 'character_sets_dir'; ---replace_regex $regex_charsetdir +--replace_result $MYSQL_CHARSETSDIR MYSQL_CHARSETSDIR show session variables like 'character_sets_dir'; ---replace_regex $regex_charsetdir +--replace_result $MYSQL_CHARSETSDIR MYSQL_CHARSETSDIR select * from information_schema.global_variables where variable_name='character_sets_dir'; ---replace_regex $regex_charsetdir +--replace_result $MYSQL_CHARSETSDIR MYSQL_CHARSETSDIR select * from information_schema.session_variables where variable_name='character_sets_dir'; # diff --git a/mysql-test/t/mysqld--help.test b/mysql-test/t/mysqld--help.test index a41d79fa145..5f61b4b7c43 100644 --- a/mysql-test/t/mysqld--help.test +++ b/mysql-test/t/mysqld--help.test @@ -53,7 +53,7 @@ perl; s/\b2146435072\b/9223372036853727232/; s/\b196608\b/262144/; s/\b4294963200\b/18446744073709547520/; - foreach $var (@env) { s/$ENV{$var}/$var/ } + foreach $var (@env) { s/\Q$ENV{$var}\E/$var/ } next if /use --skip-(use-)?symbolic-links to disable/; # for valgrind, again next if $skip; print; From 6971eaf3f017364da96144cd1fe73db5803dbb61 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:31:05 +0100 Subject: [PATCH 07/19] MDEV-5030 RPM installation not running mysql_install_db if datadir exists before running mysql_install_db check for the existence of $datadir/mysql, not simply $datadir ($datadir might be mounted on a separate device - exists, but empty) --- support-files/rpm/server-postin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh index b5ba10bd265..b4d63815fe9 100644 --- a/support-files/rpm/server-postin.sh +++ b/support-files/rpm/server-postin.sh @@ -31,7 +31,7 @@ if [ $1 = 1 ] ; then # owns all database files. chown -R %{mysqld_user}:%{mysqld_group} $datadir - if [ ! -e $datadir ]; then + if [ ! -e $datadir/mysql ]; then # Create data directory mkdir -p $datadir/{mysql,test} From e10d42d93b373080ec9acb28f9ed29857000c0ae Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:31:09 +0100 Subject: [PATCH 08/19] MDEV-5022 Strange message or wrong errno on mismatching versions of plugin and server 1. use an appropriate errno code 2. put a comma between the errno and the error message text --- mysql-test/r/plugin_maturity.result | 8 ++--- sql/share/errmsg-utf8.txt | 48 ++++++++++++++--------------- sql/sql_plugin.cc | 8 ++--- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/mysql-test/r/plugin_maturity.result b/mysql-test/r/plugin_maturity.result index 3249ea9b3c1..cd47830cbd3 100644 --- a/mysql-test/r/plugin_maturity.result +++ b/mysql-test/r/plugin_maturity.result @@ -1,8 +1,8 @@ INSTALL PLUGIN example SONAME 'ha_example.so'; -ERROR HY000: Can't open shared library 'ha_example.so' (errno: 0 Loading of experimental plugin EXAMPLE is prohibited by --plugin-maturity=stable) +ERROR HY000: Can't open shared library 'ha_example.so' (errno: 1, Loading of experimental plugin EXAMPLE is prohibited by --plugin-maturity=stable) INSTALL SONAME 'ha_example.so'; -ERROR HY000: Can't open shared library 'ha_example.so' (errno: 0 Loading of experimental plugin EXAMPLE is prohibited by --plugin-maturity=stable) +ERROR HY000: Can't open shared library 'ha_example.so' (errno: 1, Loading of experimental plugin EXAMPLE is prohibited by --plugin-maturity=stable) show warnings; Level Code Message -Error 1126 Can't open shared library 'ha_example.so' (errno: 0 Loading of experimental plugin EXAMPLE is prohibited by --plugin-maturity=stable) -Error 1126 Can't open shared library 'ha_example.so' (errno: 0 Loading of experimental plugin UNUSABLE is prohibited by --plugin-maturity=stable) +Error 1126 Can't open shared library 'ha_example.so' (errno: 1, Loading of experimental plugin EXAMPLE is prohibited by --plugin-maturity=stable) +Error 1126 Can't open shared library 'ha_example.so' (errno: 1, Loading of experimental plugin UNUSABLE is prohibited by --plugin-maturity=stable) diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 612c415359f..4f22ffb04de 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -2958,30 +2958,30 @@ ER_UDF_EXISTS swe "Funktionen '%-.192s' finns redan" ukr "Функція '%-.192s' вже існує" ER_CANT_OPEN_LIBRARY - cze "Nemohu otev-Břít sdílenou knihovnu '%-.192s' (errno: %d %-.128s)" - dan "Kan ikke åbne delt bibliotek '%-.192s' (errno: %d %-.128s)" - nla "Kan shared library '%-.192s' niet openen (Errcode: %d %-.128s)" - eng "Can't open shared library '%-.192s' (errno: %d %-.128s)" - jps "shared library '%-.192s' を開く事ができません (errno: %d %-.128s)", - est "Ei suuda avada jagatud teeki '%-.192s' (veakood: %d %-.128s)" - fre "Impossible d'ouvrir la bibliothèque partagée '%-.192s' (errno: %d %-.128s)" - ger "Kann Shared Library '%-.192s' nicht öffnen (Fehler: %d %-.128s)" - greek "Δεν είναι δυνατή η ανάγνωση της shared library '%-.192s' (κωδικός λάθους: %d %-.128s)" - hun "A(z) '%-.192s' megosztott konyvtar nem hasznalhato (hibakod: %d %-.128s)" - ita "Impossibile aprire la libreria condivisa '%-.192s' (errno: %d %-.128s)" - jpn "shared library '%-.192s' を開く事ができません (errno: %d %-.128s)" - kor "'%-.192s' 공유 라이버러리를 열수 없습니다.(에러번호: %d %-.128s)" - nor "Can't open shared library '%-.192s' (errno: %d %-.128s)" - norwegian-ny "Can't open shared library '%-.192s' (errno: %d %-.128s)" - pol "Can't open shared library '%-.192s' (errno: %d %-.128s)" - por "Não pode abrir biblioteca compartilhada '%-.192s' (erro no. %d '%-.128s')" - rum "Nu pot deschide libraria shared '%-.192s' (Eroare: %d %-.128s)" - rus "Невозможно открыть динамическую библиотеку '%-.192s' (ошибка: %d %-.128s)" - serbian "Ne mogu da otvorim share-ovanu biblioteku '%-.192s' (errno: %d %-.128s)" - slo "Nemôžem otvoriť zdieľanú knižnicu '%-.192s' (chybový kód: %d %-.128s)" - spa "No puedo abrir libraria conjugada '%-.192s' (errno: %d %-.128s)" - swe "Kan inte öppna det dynamiska biblioteket '%-.192s' (Felkod: %d %-.128s)" - ukr "Не можу відкрити розділювану бібліотеку '%-.192s' (помилка: %d %-.128s)" + cze "Nemohu otev-Břít sdílenou knihovnu '%-.192s' (errno: %d, %-.128s)" + dan "Kan ikke åbne delt bibliotek '%-.192s' (errno: %d, %-.128s)" + nla "Kan shared library '%-.192s' niet openen (Errcode: %d, %-.128s)" + eng "Can't open shared library '%-.192s' (errno: %d, %-.128s)" + jps "shared library '%-.192s' を開く事ができません (errno: %d, %-.128s)", + est "Ei suuda avada jagatud teeki '%-.192s' (veakood: %d, %-.128s)" + fre "Impossible d'ouvrir la bibliothèque partagée '%-.192s' (errno: %d, %-.128s)" + ger "Kann Shared Library '%-.192s' nicht öffnen (Fehler: %d, %-.128s)" + greek "Δεν είναι δυνατή η ανάγνωση της shared library '%-.192s' (κωδικός λάθους: %d, %-.128s)" + hun "A(z) '%-.192s' megosztott konyvtar nem hasznalhato (hibakod: %d, %-.128s)" + ita "Impossibile aprire la libreria condivisa '%-.192s' (errno: %d, %-.128s)" + jpn "shared library '%-.192s' を開く事ができません (errno: %d, %-.128s)" + kor "'%-.192s' 공유 라이버러리를 열수 없습니다.(에러번호: %d, %-.128s)" + nor "Can't open shared library '%-.192s' (errno: %d, %-.128s)" + norwegian-ny "Can't open shared library '%-.192s' (errno: %d, %-.128s)" + pol "Can't open shared library '%-.192s' (errno: %d, %-.128s)" + por "Não pode abrir biblioteca compartilhada '%-.192s' (erro no. %d, %-.128s)" + rum "Nu pot deschide libraria shared '%-.192s' (Eroare: %d, %-.128s)" + rus "Невозможно открыть динамическую библиотеку '%-.192s' (ошибка: %d, %-.128s)" + serbian "Ne mogu da otvorim share-ovanu biblioteku '%-.192s' (errno: %d, %-.128s)" + slo "Nemôžem otvoriť zdieľanú knižnicu '%-.192s' (chybový kód: %d, %-.128s)" + spa "No puedo abrir libraria conjugada '%-.192s' (errno: %d, %-.128s)" + swe "Kan inte öppna det dynamiska biblioteket '%-.192s' (Felkod: %d, %-.128s)" + ukr "Не можу відкрити розділювану бібліотеку '%-.192s' (помилка: %d, %-.128s)" ER_CANT_FIND_DL_ENTRY cze "Nemohu naj-Bít funkci '%-.128s' v knihovně" dan "Kan ikke finde funktionen '%-.128s' i bibliotek" diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index eb8b05a9c99..c0b59dcadcb 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -644,7 +644,7 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl, (plugin_dl->mariaversion >> 8) > (MARIA_PLUGIN_INTERFACE_VERSION >> 8)) { free_plugin_mem(plugin_dl); - report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, 0, + report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, ENOEXEC, "plugin interface version mismatch"); DBUG_RETURN(TRUE); } @@ -789,7 +789,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) my_snprintf(buf, sizeof(buf), "service '%s' interface version mismatch", list_of_services[i].name); - report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, 0, buf); + report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, ENOEXEC, buf); DBUG_RETURN(0); } *(void**)sym= list_of_services[i].service; @@ -1083,7 +1083,7 @@ static bool plugin_add(MEM_ROOT *tmp_root, plugin_type_names[plugin->type].str, " plugin ", tmp.name.str, " not supported by this version of the server", NullS); - report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf); + report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, ENOEXEC, buf); goto err; } if (plugin_maturity_map[plugin->maturity] < plugin_maturity) @@ -1095,7 +1095,7 @@ static bool plugin_add(MEM_ROOT *tmp_root, " is prohibited by --plugin-maturity=", plugin_maturity_names[plugin_maturity], NullS); - report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf); + report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, EPERM, buf); goto err; } tmp.plugin= plugin; From 41fc2493ed66d334eec11d466ca09ee9049970ce Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:31:13 +0100 Subject: [PATCH 09/19] MDEV-5186 /usr/bin/mysqld_safe doesn't have NUMA options support port mysqld_safe numa extensions from percona-server: --flush-caches and --numa-interleave --- scripts/mysqld_safe.sh | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 3c63acddc0c..430b0067c11 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -18,6 +18,8 @@ niceness=0 nowatch=0 mysqld_ld_preload= mysqld_ld_library_path= +flush_caches=0 +numa_interleave=0 # Initial logging status: error log is not open, and not using syslog logging=init @@ -85,6 +87,10 @@ Usage: $0 [OPTIONS] --syslog Log messages to syslog with 'logger' --skip-syslog Log messages to error log (default) --syslog-tag=TAG Pass -t "mysqld-TAG" to 'logger' + --flush-caches Flush and purge buffers/caches before + starting the server + --numa-interleave Run mysqld with its memory interleaved + on all NUMA nodes All other options are passed to the mysqld program. @@ -244,6 +250,8 @@ parse_arguments() { --skip-syslog) want_syslog=0 ;; --syslog-tag=*) syslog_tag="$val" ;; --timezone=*) TZ="$val"; export TZ; ;; + --flush-caches) flush_caches=1 ;; + --numa-interleave) numa_interleave=1 ;; --help) usage ;; @@ -761,6 +769,41 @@ mysqld daemon not started" fi fi +# +# Flush and purge buffers/caches. +# + +if @TARGET_LINUX@ && test $flush_caches -eq 1 +then + # Locate sync, ensure it exists. + if ! my_which sync > /dev/null 2>&1 + then + log_error "sync command not found, required for --flush-caches" + exit 1 + # Flush file system buffers. + elif ! sync + then + # Huh, the sync() function is always successful... + log_error "sync failed, check if sync is properly installed" + fi + + # Locate sysctl, ensure it exists. + if ! my_which sysctl > /dev/null 2>&1 + then + log_error "sysctl command not found, required for --flush-caches" + exit 1 + # Purge page cache, dentries and inodes. + elif ! sysctl -q -w vm.drop_caches=3 + then + log_error "sysctl failed, check the error message for details" + exit 1 + fi +elif test $flush_caches -eq 1 +then + log_error "--flush-caches is not supported on this platform" + exit 1 +fi + # # Uncomment the following lines if you want all tables to be automatically # checked and repaired during startup. You should add sensible key_buffer @@ -781,6 +824,31 @@ fi cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS" +# +# Set mysqld's memory interleave policy. +# + +if @TARGET_LINUX@ && test $numa_interleave -eq 1 +then + # Locate numactl, ensure it exists. + if ! my_which numactl > /dev/null 2>&1 + then + log_error "numactl command not found, required for --numa-interleave" + exit 1 + # Attempt to run a command, ensure it works. + elif ! numactl --interleave=all true + then + log_error "numactl failed, check if numactl is properly installed" + fi + + # Launch mysqld with numactl. + cmd="$cmd numactl --interleave=all" +elif test $numa_interleave -eq 1 +then + log_error "--numa-interleave is not supported on this platform" + exit 1 +fi + for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION" do From feea10a453db89f9ea3df870caf0efb373362274 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:31:17 +0100 Subject: [PATCH 10/19] MDEV-5101 INFORMATION_SCHEMA.PROCESSLIST reports an incorrect value for Time for connecting threads by convention query execution time should be 0 if its start_time is 0 (this was lost when fixing MDEV-4578) --- sql/sql_show.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 023796af4f2..434d5b90652 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2358,7 +2358,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) command_name[tmp->command].length, cs); /* MYSQL_TIME */ ulonglong start_utime= tmp->start_time * HRTIME_RESOLUTION + tmp->start_time_sec_part; - ulonglong utime= start_utime < unow.val ? unow.val - start_utime : 0; + ulonglong utime= start_utime && start_utime < unow.val + ? unow.val - start_utime : 0; table->field[5]->store(utime / HRTIME_RESOLUTION, TRUE); /* STATE */ if ((val= thread_state_info(tmp))) From 80a523dbfbeab628a98391d77656442d58ae15a4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 09:31:20 +0100 Subject: [PATCH 11/19] MDEV-5116 MariaDB upgrade breaks replication mysql_upgrade should do --skip-write-binlog by default --- client/mysql_upgrade.c | 7 +++---- mysql-test/suite/rpl/t/rpl_mysql_upgrade.test | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index c6aaf38179f..9e39b7273ea 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -156,11 +156,10 @@ static struct my_option my_long_options[]= "version\' of the program is the version of the MySQL server with which it " "was built/distributed.", &opt_version_check, &opt_version_check, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"write-binlog", OPT_WRITE_BINLOG, - "All commands including mysqlcheck are binlogged. Enabled by default;" - "use --skip-write-binlog when commands should not be sent to replication slaves.", + {"write-binlog", OPT_WRITE_BINLOG, "All commands including those, " + "issued by mysqlcheck, are written to the binary log.", &opt_write_binlog, &opt_write_binlog, 0, GET_BOOL, NO_ARG, - 1, 0, 0, 0, 0, 0}, + 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test index fedad86ea91..10e45f5a50d 100644 --- a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test +++ b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test @@ -23,8 +23,7 @@ connection master; let $before_position= query_get_value(SHOW MASTER STATUS, Position, 1); #With '--force' option, mysql_upgrade always executes all sql statements for upgrading. -#--skip-write-binlog option disables binlog. ---exec $MYSQL_UPGRADE --skip-write-binlog --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade.log 2>&1 +--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade.log 2>&1 sync_slave_with_master; connection master; @@ -42,7 +41,7 @@ source include/wait_for_slave_sql_to_stop.inc; connection master; #With '--force' option, mysql_upgrade always executes all sql statements for upgrading. ---exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade.log 2>&1 +--exec $MYSQL_UPGRADE --skip-verbose --write-binlog --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade.log 2>&1 connection master; let $after_file= query_get_value(SHOW MASTER STATUS, File, 1); From f486f49e8dca72023f7312da138d71eb504a16f4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 16:17:32 +0100 Subject: [PATCH 12/19] MDEV-4824 userstats - wrong user statistics (and valgrind warnings) * move thd userstat initialization to the same function that was adding thd userstat to global counters. * initialize thd->start_bytes_received in THD::init (when thd->userstat_running is set) --- mysql-test/r/userstat-badlogin-4824.result | 16 +++++++++++ mysql-test/t/userstat-badlogin-4824.test | 33 ++++++++++++++++++++++ sql/event_data_objects.cc | 2 +- sql/log_event.cc | 6 ++-- sql/log_event_old.cc | 2 +- sql/sql_class.cc | 1 + sql/sql_class.h | 2 +- sql/sql_parse.cc | 31 ++++++++++---------- sql/sql_parse.h | 2 +- sql/sql_prepare.cc | 8 +++--- 10 files changed, 76 insertions(+), 27 deletions(-) create mode 100644 mysql-test/r/userstat-badlogin-4824.result create mode 100644 mysql-test/t/userstat-badlogin-4824.test diff --git a/mysql-test/r/userstat-badlogin-4824.result b/mysql-test/r/userstat-badlogin-4824.result new file mode 100644 index 00000000000..8362e8d5239 --- /dev/null +++ b/mysql-test/r/userstat-badlogin-4824.result @@ -0,0 +1,16 @@ +create user foo@localhost identified by 'foo'; +flush user_statistics; +set global userstat=1; +select 1; +1 +1 +select user, bytes_received from information_schema.user_statistics where user = 'foo'; +user bytes_received +foo 18 +connect(localhost,foo,bar,test,MASTER_PORT,MASTER_SOCKET); +ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES) +select user, bytes_received from information_schema.user_statistics where user = 'foo'; +user bytes_received +foo 18 +drop user foo@localhost; +set global userstat=0; diff --git a/mysql-test/t/userstat-badlogin-4824.test b/mysql-test/t/userstat-badlogin-4824.test new file mode 100644 index 00000000000..97370c1d081 --- /dev/null +++ b/mysql-test/t/userstat-badlogin-4824.test @@ -0,0 +1,33 @@ +# +# MDEV-4824 userstats - wrong user statistics +# +--source include/not_embedded.inc + +create user foo@localhost identified by 'foo'; +flush user_statistics; +set global userstat=1; + +connect(foo, localhost, foo, foo); +select 1; +disconnect foo; +connection default; + +# wait for user_statistics changes to become visible +let $wait_condition= select count(*) = 1 from information_schema.processlist; +--source include/wait_condition.inc + +# 41 is for ps-procotol +--replace_result 41 18 +select user, bytes_received from information_schema.user_statistics where user = 'foo'; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error ER_ACCESS_DENIED_ERROR +connect(foo, localhost, foo, bar); + +connection default; + +--replace_result 41 18 +select user, bytes_received from information_schema.user_statistics where user = 'foo'; + +drop user foo@localhost; +set global userstat=0; diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index c41194d1a8d..dfd35583581 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1337,7 +1337,7 @@ Event_job_data::execute(THD *thd, bool drop) DBUG_ENTER("Event_job_data::execute"); - mysql_reset_thd_for_next_command(thd, 0); + mysql_reset_thd_for_next_command(thd); /* MySQL parser currently assumes that current database is either diff --git a/sql/log_event.cc b/sql/log_event.cc index 928c65f3e44..e5af1e3a4af 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5353,7 +5353,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli, */ lex_start(thd); thd->lex->local_file= local_fname; - mysql_reset_thd_for_next_command(thd, 0); + mysql_reset_thd_for_next_command(thd); if (!use_rli_only_for_errors) { @@ -7353,7 +7353,7 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli) as the present method does not call mysql_parse(). */ lex_start(thd); - mysql_reset_thd_for_next_command(thd, 0); + mysql_reset_thd_for_next_command(thd); /* old copy may exist already */ mysql_file_delete(key_file_log_event_data, fname, MYF(0)); if ((fd= mysql_file_create(key_file_log_event_data, @@ -8308,7 +8308,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) we need to do any changes to that value after this function. */ lex_start(thd); - mysql_reset_thd_for_next_command(thd, 0); + mysql_reset_thd_for_next_command(thd); /* The current statement is just about to begin and has not yet modified anything. Note, all.modified is reset diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 244999fc431..4ad07793973 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -87,7 +87,7 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info we need to do any changes to that value after this function. */ lex_start(ev_thd); - mysql_reset_thd_for_next_command(ev_thd, 0); + mysql_reset_thd_for_next_command(ev_thd); /* This is a row injection, so we flag the "statement" as diff --git a/sql/sql_class.cc b/sql/sql_class.cc index be1e24c61c1..63a5af3a707 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1260,6 +1260,7 @@ void THD::init(void) reset_current_stmt_binlog_format_row(); bzero((char *) &status_var, sizeof(status_var)); bzero((char *) &org_status_var, sizeof(org_status_var)); + start_bytes_received= 0; if (variables.sql_log_bin) variables.option_bits|= OPTION_BIN_LOG; diff --git a/sql/sql_class.h b/sql/sql_class.h index dab57a680f3..e9665959d04 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1556,7 +1556,7 @@ public: /* Slave applier execution context */ Relay_log_info* rli_slave; - void reset_for_next_command(bool calculate_userstat); + void reset_for_next_command(); /* Constant for THD::where initialization in the beginning of every query. diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2d4293fc1d7..e9adc3b669f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -717,7 +717,6 @@ bool do_command(THD *thd) net_new_transaction(net); - /* Save for user statistics */ thd->start_bytes_received= thd->status_var.bytes_received; @@ -926,6 +925,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (!(server_command_flags[command] & CF_SKIP_QUESTIONS)) statistic_increment(thd->status_var.questions, &LOCK_status); + /* Copy data for user stats */ + if ((thd->userstat_running= opt_userstat_running)) + { + thd->start_cpu_time= my_getcputime(); + memcpy(&thd->org_status_var, &thd->status_var, sizeof(thd->status_var)); + thd->select_commands= thd->update_commands= thd->other_commands= 0; + } + /** Clear the set of flags that are expected to be cleared at the beginning of each command. @@ -1176,7 +1183,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; } packet= arg_end + 1; - mysql_reset_thd_for_next_command(thd, opt_userstat_running); + mysql_reset_thd_for_next_command(thd); lex_start(thd); /* Must be before we init the table list. */ if (lower_case_table_names) @@ -5446,15 +5453,15 @@ bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, ulong *yystacksize) @todo Call it after we use THD for queries, not before. */ -void mysql_reset_thd_for_next_command(THD *thd, my_bool calculate_userstat) +void mysql_reset_thd_for_next_command(THD *thd) { - thd->reset_for_next_command(calculate_userstat); + thd->reset_for_next_command(); } -void THD::reset_for_next_command(bool calculate_userstat) +void THD::reset_for_next_command() { THD *thd= this; - DBUG_ENTER("mysql_reset_thd_for_next_command"); + DBUG_ENTER("THD::reset_for_next_command"); DBUG_ASSERT(!thd->spcont); /* not for substatements of routines */ DBUG_ASSERT(! thd->in_sub_stmt); DBUG_ASSERT(thd->transaction.on); @@ -5500,14 +5507,6 @@ void THD::reset_for_next_command(bool calculate_userstat) thd->sent_row_count= thd->examined_row_count= 0; thd->accessed_rows_and_keys= 0; - /* Copy data for user stats */ - if ((thd->userstat_running= calculate_userstat)) - { - thd->start_cpu_time= my_getcputime(); - memcpy(&thd->org_status_var, &thd->status_var, sizeof(thd->status_var)); - thd->select_commands= thd->update_commands= thd->other_commands= 0; - } - thd->query_plan_flags= QPLAN_INIT; thd->query_plan_fsort_passes= 0; @@ -5716,7 +5715,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length, FIXME: cleanup the dependencies in the code to simplify this. */ lex_start(thd); - mysql_reset_thd_for_next_command(thd, opt_userstat_running); + mysql_reset_thd_for_next_command(thd); if (query_cache_send_result_to_client(thd, rawbuf, length) <= 0) { @@ -5819,7 +5818,7 @@ bool mysql_test_parse_for_slave(THD *thd, char *rawbuf, uint length) if (!(error= parser_state.init(thd, rawbuf, length))) { lex_start(thd); - mysql_reset_thd_for_next_command(thd, opt_userstat_running); + mysql_reset_thd_for_next_command(thd); if (!parse_sql(thd, & parser_state, NULL) && all_tables_not_ok(thd, lex->select_lex.table_list.first)) diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 6d47e648be2..d1d6458d22c 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -83,7 +83,7 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length); void mysql_init_select(LEX *lex); void mysql_parse(THD *thd, char *rawbuf, uint length, Parser_state *parser_state); -void mysql_reset_thd_for_next_command(THD *thd, my_bool calculate_userstat); +void mysql_reset_thd_for_next_command(THD *thd); bool mysql_new_select(LEX *lex, bool move_down); void create_select_for_variable(const char *var_name); void create_table_set_open_action_and_adjust_tables(LEX *lex); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index a0ec07b9db2..0446e8bf18c 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2269,7 +2269,7 @@ void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length) DBUG_PRINT("prep_query", ("%s", packet)); /* First of all clear possible warnings from the previous command */ - mysql_reset_thd_for_next_command(thd, opt_userstat_running); + mysql_reset_thd_for_next_command(thd); if (! (stmt= new Prepared_statement(thd))) goto end; /* out of memory: error is set in Sql_alloc */ @@ -2659,7 +2659,7 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length) packet+= 9; /* stmt_id + 5 bytes of flags */ /* First of all clear possible warnings from the previous command */ - mysql_reset_thd_for_next_command(thd, opt_userstat_running); + mysql_reset_thd_for_next_command(thd); if (!(stmt= find_prepared_statement(thd, stmt_id))) { @@ -2758,7 +2758,7 @@ void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length) DBUG_ENTER("mysqld_stmt_fetch"); /* First of all clear possible warnings from the previous command */ - mysql_reset_thd_for_next_command(thd, opt_userstat_running); + mysql_reset_thd_for_next_command(thd); status_var_increment(thd->status_var.com_stmt_fetch); if (!(stmt= find_prepared_statement(thd, stmt_id))) @@ -2818,7 +2818,7 @@ void mysqld_stmt_reset(THD *thd, char *packet) DBUG_ENTER("mysqld_stmt_reset"); /* First of all clear possible warnings from the previous command */ - mysql_reset_thd_for_next_command(thd, opt_userstat_running); + mysql_reset_thd_for_next_command(thd); status_var_increment(thd->status_var.com_stmt_reset); if (!(stmt= find_prepared_statement(thd, stmt_id))) From fb46f35f05c691fbf61cb19664559126cf81c3c0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 17:20:10 +0100 Subject: [PATCH 13/19] mark ft-index cmake variables as advanced --- storage/tokudb/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index 26955370084..a8444e3c940 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -19,6 +19,16 @@ SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb SET(USE_BDB OFF CACHE BOOL "") SET(USE_VALGRIND OFF CACHE BOOL "") SET(BUILD_TESTING OFF CACHE BOOL "") +MARK_AS_ADVANCED(BUILDNAME) +MARK_AS_ADVANCED(BUILD_TESTING) +MARK_AS_ADVANCED(CMAKE_TOKUDB_REVISION) +MARK_AS_ADVANCED(LIBTOKUDB) +MARK_AS_ADVANCED(LIBTOKUPORTABILITY) +MARK_AS_ADVANCED(TOKUDB_DATA) +MARK_AS_ADVANCED(TOKU_DEBUG_PARANOID) +MARK_AS_ADVANCED(USE_BDB) +MARK_AS_ADVANCED(USE_VALGRIND) +MARK_AS_ADVANCED(XZ_SOURCE_DIR) ############################################ IF(DEFINED ENV{TOKUDB_VERSION}) From 1585652862e9fda0b220dc497988e30e7b8c8607 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 17:20:18 +0100 Subject: [PATCH 14/19] MDEV-5236 Status variables are not all listed alphabetically sort Com_ counters. No simple fix for Binlog_ variables. --- sql/mysqld.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3177e52569b..1cc82740f6a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3291,7 +3291,6 @@ static bool init_global_datetime_format(timestamp_type format_type, SHOW_VAR com_status_vars[]= { {"admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS}, - {"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS}, {"alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS}, {"alter_db_upgrade", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB_UPGRADE]), SHOW_LONG_STATUS}, {"alter_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_EVENT]), SHOW_LONG_STATUS}, @@ -3301,6 +3300,7 @@ SHOW_VAR com_status_vars[]= { {"alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS}, {"alter_tablespace", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLESPACE]), SHOW_LONG_STATUS}, {"analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS}, + {"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS}, {"begin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS}, {"binlog", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BINLOG_BASE64_EVENT]), SHOW_LONG_STATUS}, {"call_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CALL]), SHOW_LONG_STATUS}, @@ -3368,7 +3368,6 @@ SHOW_VAR com_status_vars[]= { {"savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS}, {"select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS}, {"set_option", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS}, - {"signal", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SIGNAL]), SHOW_LONG_STATUS}, {"show_authors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_AUTHORS]), SHOW_LONG_STATUS}, {"show_binlog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS}, {"show_binlogs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS}, @@ -3386,16 +3385,16 @@ SHOW_VAR com_status_vars[]= { {"show_engine_logs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_LOGS]), SHOW_LONG_STATUS}, {"show_engine_mutex", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_MUTEX]), SHOW_LONG_STATUS}, {"show_engine_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_STATUS]), SHOW_LONG_STATUS}, - {"show_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EVENTS]), SHOW_LONG_STATUS}, {"show_errors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS}, + {"show_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EVENTS]), SHOW_LONG_STATUS}, {"show_fields", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS}, #ifndef DBUG_OFF {"show_function_code", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FUNC_CODE]), SHOW_LONG_STATUS}, #endif {"show_function_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS_FUNC]), SHOW_LONG_STATUS}, {"show_grants", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_GRANTS]), SHOW_LONG_STATUS}, - {"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS}, {"show_index_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_INDEX_STATS]), SHOW_LONG_STATUS}, + {"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS}, {"show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS}, {"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS}, {"show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS}, @@ -3419,6 +3418,7 @@ SHOW_VAR com_status_vars[]= { {"show_user_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_USER_STATS]), SHOW_LONG_STATUS}, {"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS}, {"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS}, + {"signal", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SIGNAL]), SHOW_LONG_STATUS}, {"slave_start", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS}, {"slave_stop", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_STOP]), SHOW_LONG_STATUS}, {"stmt_close", (char*) offsetof(STATUS_VAR, com_stmt_close), SHOW_LONG_STATUS}, From ea78785b8b6a27ed0d8e71e64d058e331f08ed36 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Nov 2013 22:53:40 +0100 Subject: [PATCH 15/19] MDEV-4723 "State" column of SHOW PROCESSLIST returns wrong values (non-ascii chars) for some states allocate thd_proc_info string in thd memroot, not on the stack, so that it won't be overwritten while another thread might be printing it --- storage/myisam/ha_myisam.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 6d4771d7092..893f3d92caf 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1118,14 +1118,10 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) statistics_done=1; if (THDVAR(thd, repair_threads)>1) { - char buf[40]; /* TODO: respect myisam_repair_threads variable */ - my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map)); - thd_proc_info(thd, buf); + thd_proc_info(thd, "Parallel repair"); error = mi_repair_parallel(¶m, file, fixed_name, test(param.testflag & T_QUICK)); - thd_proc_info(thd, "Repair done"); // to reset proc_info, as - // it was pointing to local buffer } else { From 88bf8b9c8fbfb79ac1690fa96467de9bbb9052e7 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 12 Nov 2013 17:37:32 +0400 Subject: [PATCH 16/19] MDEV-5257: MIN/MAX Optimization (Select tables optimized away) does not work for DateTime - MIN/MAX optimizer does a check whether a "field CMP const" comparison uses a constant that's longer than the field it is compared to. Make this check only for string columns, also compare character lengths, not byte lengths. --- mysql-test/r/func_group.result | 44 ++++++++++++++++++++++++++++ mysql-test/t/func_group.test | 53 ++++++++++++++++++++++++++++++++++ sql/opt_sum.cc | 24 +++++++++++++-- 3 files changed, 118 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 9049589b6db..8e50c045775 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -2186,3 +2186,47 @@ AVG(DISTINCT outr.col_int_nokey) 7.5000 DROP TABLE t1; # End of the bug#57932 +# +# MDEV-5257: MIN/MAX Optimization (Select tables optimized away) does not work for DateTime +# MDEV-3855: MIN/MAX optimization doesnt work for int_col > INET_ATON +# (correct the fix for Bug #884175) +# +CREATE TABLE `t1` ( +`a` int(11) NOT NULL AUTO_INCREMENT, +`b` datetime DEFAULT NULL, +PRIMARY KEY (`a`), +KEY `idx_b` (`b`) +); +INSERT INTO `t1` (b) VALUES ('2013-01-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-02-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-03-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-04-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-05-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-06-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-07-06 23:59:59'); +# The following should produce "Select tables optimized away" +EXPLAIN SELECT MIN(b) FROM t1 WHERE b <= '2013-11-06 23:59:59'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +set names utf8; +# Should be the same as above: +EXPLAIN SELECT MIN(b) FROM t1 WHERE b <= '2013-11-06 23:59:59'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +DROP TABLE t1; +CREATE TABLE `t1` ( +`a` int(11) NOT NULL AUTO_INCREMENT, +`b` bigint(20) DEFAULT NULL, +PRIMARY KEY (`a`), +KEY `idx_b` (`b`) +); +insert into t1 (b) values (INET_ATON('192.168.0.1')); +insert into t1 (b) values (INET_ATON('192.168.0.2')); +insert into t1 (b) values (INET_ATON('192.168.0.3')); +insert into t1 (b) values (INET_ATON('192.168.0.4')); +insert into t1 (b) values (INET_ATON('192.168.200.200')); +# should show "Select tables optimized away" +explain select MIN(b) from t1 where b >= inet_aton('192.168.119.32'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +DROP TABLE t1; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 0c2f28ab25d..cf5f00c3ee1 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1465,3 +1465,56 @@ SELECT AVG(DISTINCT outr.col_int_nokey) FROM t1 AS outr LEFT JOIN t1 AS outr2 ON outr.col_int_nokey = outr2.col_int_nokey; DROP TABLE t1; --echo # End of the bug#57932 + + +--echo # +--echo # MDEV-5257: MIN/MAX Optimization (Select tables optimized away) does not work for DateTime +--echo # MDEV-3855: MIN/MAX optimization doesnt work for int_col > INET_ATON +--echo # (correct the fix for Bug #884175) +--echo # + +CREATE TABLE `t1` ( + `a` int(11) NOT NULL AUTO_INCREMENT, + `b` datetime DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx_b` (`b`) +); + +INSERT INTO `t1` (b) VALUES ('2013-01-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-02-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-03-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-04-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-05-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-06-06 23:59:59'); +INSERT INTO `t1` (b) VALUES ('2013-07-06 23:59:59'); + +--echo # The following should produce "Select tables optimized away" +EXPLAIN SELECT MIN(b) FROM t1 WHERE b <= '2013-11-06 23:59:59'; + +-- connect (con1,localhost,root,,) +-- connection con1 +set names utf8; +-- echo # Should be the same as above: +EXPLAIN SELECT MIN(b) FROM t1 WHERE b <= '2013-11-06 23:59:59'; + +--connection default +--disconnect con1 + +DROP TABLE t1; + +CREATE TABLE `t1` ( + `a` int(11) NOT NULL AUTO_INCREMENT, + `b` bigint(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `idx_b` (`b`) +); + +insert into t1 (b) values (INET_ATON('192.168.0.1')); +insert into t1 (b) values (INET_ATON('192.168.0.2')); +insert into t1 (b) values (INET_ATON('192.168.0.3')); +insert into t1 (b) values (INET_ATON('192.168.0.4')); +insert into t1 (b) values (INET_ATON('192.168.200.200')); +--echo # should show "Select tables optimized away" +explain select MIN(b) from t1 where b >= inet_aton('192.168.119.32'); +DROP TABLE t1; + diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 069fe6452e8..aa8b17a2c85 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -479,6 +479,24 @@ int opt_sum_query(THD *thd, } +/* + Check if both item1 and item2 are strings, and item1 has fewer characters + than item2. +*/ + +static bool check_item1_shorter_item2(Item *item1, Item *item2) +{ + if (item1->cmp_type() == STRING_RESULT && + item2->cmp_type() == STRING_RESULT) + { + int len1= item1->max_length / item1->collation.collation->mbmaxlen; + int len2= item2->max_length / item2->collation.collation->mbmaxlen; + return len1 < len2; + } + return false; /* When the check is not applicable, it means "not bigger" */ +} + + /** Test if the predicate compares a field with constants. @@ -509,7 +527,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) if (!(item= it++)) return 0; args[0]= item->real_item(); - if (args[0]->max_length < args[1]->max_length) + if (check_item1_shorter_item2(args[0], args[1])) return 0; if (it++) return 0; @@ -544,7 +562,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) } else return 0; - if (args[0]->max_length < args[1]->max_length) + if (check_item1_shorter_item2(args[0], args[1])) return 0; break; case 3: @@ -559,7 +577,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) if (!item->const_item()) return 0; args[i]= item; - if (args[0]->max_length < args[i]->max_length) + if (check_item1_shorter_item2(args[0], args[1])) return 0; } } From 441192bfb0e620b49cb58eaef96132151531fc54 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 12 Nov 2013 15:02:25 +0100 Subject: [PATCH 17/19] MDEV-5113 Wrong result (extra row) and valgrind warnings in Item_maxmin_subselect::any_value on 2nd execution of PS with SELECT subquery When setting Item_func_not_all::test_sum_item or Item_func_not_all::test_sub_item, reset the other one to NULL - they can never be set both. When a PS is reexecuted, different executions might be optimized differently and a wrong test_su*_item might stay set from the previous execution. --- mysql-test/r/ps_max_subselect-5113.result | 16 ++++++++++++++++ mysql-test/t/ps_max_subselect-5113.test | 20 ++++++++++++++++++++ sql/item_cmpfunc.h | 4 ++-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 mysql-test/r/ps_max_subselect-5113.result create mode 100644 mysql-test/t/ps_max_subselect-5113.test diff --git a/mysql-test/r/ps_max_subselect-5113.result b/mysql-test/r/ps_max_subselect-5113.result new file mode 100644 index 00000000000..427ef628ead --- /dev/null +++ b/mysql-test/r/ps_max_subselect-5113.result @@ -0,0 +1,16 @@ +CREATE TABLE t1 (b INT NOT NULL); +INSERT INTO t1 VALUES (0),(8); +PREPARE stmt FROM ' + SELECT 1 FROM t1 AS o + WHERE o.b >= ALL ( + SELECT a2.b FROM t1 AS a1 LEFT JOIN t1 AS a2 ON ( a2.b = a1.b ) + WHERE a1.b <= a2.b + ) +'; +EXECUTE stmt; +1 +1 +EXECUTE stmt; +1 +1 +DROP TABLE t1; diff --git a/mysql-test/t/ps_max_subselect-5113.test b/mysql-test/t/ps_max_subselect-5113.test new file mode 100644 index 00000000000..255e81c1549 --- /dev/null +++ b/mysql-test/t/ps_max_subselect-5113.test @@ -0,0 +1,20 @@ +# +# MDEV-5113 Wrong result (extra row) and valgrind warnings in Item_maxmin_subselect::any_value on 2nd execution of PS with SELECT subquery +# + +CREATE TABLE t1 (b INT NOT NULL); +INSERT INTO t1 VALUES (0),(8); + +PREPARE stmt FROM ' + SELECT 1 FROM t1 AS o + WHERE o.b >= ALL ( + SELECT a2.b FROM t1 AS a1 LEFT JOIN t1 AS a2 ON ( a2.b = a1.b ) + WHERE a1.b <= a2.b + ) +'; + +EXECUTE stmt; +EXECUTE stmt; + +DROP TABLE t1; + diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index cdb4963e857..d00f177fc8e 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -508,8 +508,8 @@ public: bool fix_fields(THD *thd, Item **ref) {return Item_func::fix_fields(thd, ref);} virtual void print(String *str, enum_query_type query_type); - void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; }; - void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; }; + void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; test_sub_item= 0; }; + void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; test_sum_item= 0;}; bool empty_underlying_subquery(); Item *neg_transformer(THD *thd); }; From 229aa1d4bfe32cc77d6e87dcdd31eecf78b4c9e2 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 13 Nov 2013 07:40:46 +0400 Subject: [PATCH 18/19] MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries Apply fix suggested by Igor: - When eliminate_item_equal() generates pair-wise equalities from a multi-equality, do generate a "bridge" equality between the first field inside SJM nest and the field that's first in the overall multi-equality. --- mysql-test/r/subselect_mat.result | 21 +++++++++++++++++++++ mysql-test/r/subselect_sj_mat.result | 21 +++++++++++++++++++++ mysql-test/t/subselect_sj_mat.test | 26 ++++++++++++++++++++++++++ sql/sql_select.cc | 6 ++++-- 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index e1c9df3b00b..62ec0955e88 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -2038,6 +2038,27 @@ SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b); pk a b DROP TABLE t1; # End of 5.3 tests +# +# MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries +# +set @tmp_mdev5056=@@join_cache_level; +SET join_cache_level = 2; +CREATE TABLE t1 ( c1 VARCHAR(2), c2 VARCHAR(2), INDEX(c1) ) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('JP','OM'),('VA','JP'),('CA','ML'),('ML','EG'),('DK','CA'), +('DK','QA'),('YE','PL'),('TR','ZW'),('DK','SK'),('SK','DK'), +('RO','ML'),('ML','BG'),('BG','ZW'),('ZW','GE'),('GE','JP'), +('PL','EG'),('QA','YE'),('WF','DK'),('DK','JP'),('EG','OM'); +CREATE TABLE t2 ( c3 VARCHAR(2), c4 VARCHAR(2) ) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('CA','ML'),('IN','HU'),('HU','IN'); +SELECT * FROM t1 AS alias1, t1 AS alias2 +WHERE ( alias2.c2, alias1.c1 ) IN ( SELECT c4, c3 FROM t2 ) AND alias1.c1 IN ( SELECT c2 FROM t1 ); +c1 c2 c1 c2 +CA ML CA ML +CA ML RO ML +DROP TABLE t1,t2; +set join_cache_level=@tmp_mdev5056; +# End of 5.5 tests set @subselect_mat_test_optimizer_switch_value=null; set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result index bcdd82b790c..38ab07882de 100644 --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@ -2078,3 +2078,24 @@ SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b); pk a b DROP TABLE t1; # End of 5.3 tests +# +# MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries +# +set @tmp_mdev5056=@@join_cache_level; +SET join_cache_level = 2; +CREATE TABLE t1 ( c1 VARCHAR(2), c2 VARCHAR(2), INDEX(c1) ) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('JP','OM'),('VA','JP'),('CA','ML'),('ML','EG'),('DK','CA'), +('DK','QA'),('YE','PL'),('TR','ZW'),('DK','SK'),('SK','DK'), +('RO','ML'),('ML','BG'),('BG','ZW'),('ZW','GE'),('GE','JP'), +('PL','EG'),('QA','YE'),('WF','DK'),('DK','JP'),('EG','OM'); +CREATE TABLE t2 ( c3 VARCHAR(2), c4 VARCHAR(2) ) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('CA','ML'),('IN','HU'),('HU','IN'); +SELECT * FROM t1 AS alias1, t1 AS alias2 +WHERE ( alias2.c2, alias1.c1 ) IN ( SELECT c4, c3 FROM t2 ) AND alias1.c1 IN ( SELECT c2 FROM t1 ); +c1 c2 c1 c2 +CA ML CA ML +CA ML RO ML +DROP TABLE t1,t2; +set join_cache_level=@tmp_mdev5056; +# End of 5.5 tests diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index e9226b8884f..58831c4ffb3 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1726,3 +1726,29 @@ SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b); DROP TABLE t1; --echo # End of 5.3 tests + + +--echo # +--echo # MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries +--echo # +set @tmp_mdev5056=@@join_cache_level; +SET join_cache_level = 2; + +CREATE TABLE t1 ( c1 VARCHAR(2), c2 VARCHAR(2), INDEX(c1) ) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('JP','OM'),('VA','JP'),('CA','ML'),('ML','EG'),('DK','CA'), +('DK','QA'),('YE','PL'),('TR','ZW'),('DK','SK'),('SK','DK'), +('RO','ML'),('ML','BG'),('BG','ZW'),('ZW','GE'),('GE','JP'), +('PL','EG'),('QA','YE'),('WF','DK'),('DK','JP'),('EG','OM'); + +CREATE TABLE t2 ( c3 VARCHAR(2), c4 VARCHAR(2) ) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('CA','ML'),('IN','HU'),('HU','IN'); + +SELECT * FROM t1 AS alias1, t1 AS alias2 +WHERE ( alias2.c2, alias1.c1 ) IN ( SELECT c4, c3 FROM t2 ) AND alias1.c1 IN ( SELECT c2 FROM t1 ); + +DROP TABLE t1,t2; +set join_cache_level=@tmp_mdev5056; + +--echo # End of 5.5 tests + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ad73faee553..cd81b41d0ec 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12295,12 +12295,14 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, /* If we're inside an SJM-nest (current_sjm!=NULL), and the multi-equality doesn't include a constant, we should produce equality with the first - of the equals in this SJM. + of the equal items in this SJM (except for the first element inside the + SJM. For that, we produce the equality with the "head" item). In other cases, get the "head" item, which is either first of the equals on top level, or the constant. */ - Item *head_item= (!item_const && current_sjm)? current_sjm_head: head; + Item *head_item= (!item_const && current_sjm && + current_sjm_head != field_item) ? current_sjm_head: head; Item *head_real_item= head_item->real_item(); if (head_real_item->type() == Item::FIELD_ITEM) head_item= head_real_item; From b468cd47493cb687ce38aad01ea19f719cd8491f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 13 Nov 2013 12:43:39 +0100 Subject: [PATCH 19/19] MDEV-5284 Assertion `!(*expr)->fixed' fails in replace_where_subcondition with IN suquery --- mysql-test/r/subselect_debug.result | 7 +++++++ mysql-test/t/subselect_debug.test | 10 ++++++++++ sql/opt_subselect.cc | 6 ++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/subselect_debug.result b/mysql-test/r/subselect_debug.result index 54610d51d78..e3b5ff657b2 100644 --- a/mysql-test/r/subselect_debug.result +++ b/mysql-test/r/subselect_debug.result @@ -11,3 +11,10 @@ REVERSE(EXISTS(SELECT RAND() FROM t1)) 0 SET GLOBAL debug=@orig_debug; DROP TABLE t1; +create table t1 (i int); +insert into t1 values (1),(2); +select * from t1 where (i < 200 or i = 300) and i in (select i from t1); +i +1 +2 +drop table t1; diff --git a/mysql-test/t/subselect_debug.test b/mysql-test/t/subselect_debug.test index ee515733afa..3c9d8e80da8 100644 --- a/mysql-test/t/subselect_debug.test +++ b/mysql-test/t/subselect_debug.test @@ -15,3 +15,13 @@ SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); SET GLOBAL debug=@orig_debug; DROP TABLE t1; + +# +# MDEV-5284 Assertion `!(*expr)->fixed' fails in replace_where_subcondition with IN suquery +# + +create table t1 (i int); +insert into t1 values (1),(2); +select * from t1 where (i < 200 or i = 300) and i in (select i from t1); +drop table t1; + diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index c5f692f8128..74bb2875638 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -420,9 +420,7 @@ Currently, solution #2 is implemented. static bool subquery_types_allow_materialization(Item_in_subselect *in_subs); -static bool replace_where_subcondition(JOIN *join, Item **expr, - Item *old_cond, Item *new_cond, - bool do_fix_fields); +static bool replace_where_subcondition(JOIN *, Item **, Item *, Item *, bool); static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2, void *arg); static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred); @@ -1293,7 +1291,7 @@ static bool replace_where_subcondition(JOIN *join, Item **expr, } else if (item->type() == Item::COND_ITEM) { - DBUG_ASSERT(!(*expr)->fixed); + DBUG_ASSERT(!do_fix_fields || !(*expr)->fixed); replace_where_subcondition(join, li.ref(), old_cond, new_cond, do_fix_fields);