diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-24 10:07:56 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-24 10:07:56 +0300 |
commit | 1333da90b5628c3f7ba98015475367837d8b0174 (patch) | |
tree | e295081b3d6414c6b07a170559ebdd2bb0d424ec | |
parent | 8887effe13ad87ba0460d4d3068fb5696f089bb0 (diff) | |
parent | e3da362c037af95a85d3054243a4c9a039ceb4b4 (diff) | |
download | mariadb-git-1333da90b5628c3f7ba98015475367837d8b0174.tar.gz |
Merge 10.4 into 10.5
145 files changed, 1684 insertions, 979 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c index 0ba241f6ad3..16acc88b221 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, MariaDB Corporation. + Copyright (c) 2010, 2019, 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 @@ -1081,7 +1081,7 @@ static int get_options(int *argc, char ***argv) my_progname_short); return(EX_USAGE); } - if (strcmp(default_charset, charset_info->csname) && + if (strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME) && !(charset_info= get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))) exit(1); @@ -1546,6 +1546,9 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name) char query_buffer[QUERY_LENGTH]; size_t query_length; + if (!strcmp(cs_name, MYSQL_AUTODETECT_CHARSET_NAME)) + cs_name= (char *)my_default_csname(); + /* Server lacks facility. This is not an error, by arbitrary decision . */ if (!server_supports_switching_charsets) return FALSE; diff --git a/cmake/readline.cmake b/cmake/readline.cmake index 5eb52e3735b..69a51d8a156 100644 --- a/cmake/readline.cmake +++ b/cmake/readline.cmake @@ -160,8 +160,20 @@ MACRO (MYSQL_FIND_SYSTEM_LIBEDIT) int res= (*rl_completion_entry_function)(0,0); completion_matches(0,0); }" - LIBEDIT_INTERFACE) - SET(USE_LIBEDIT_INTERFACE ${LIBEDIT_INTERFACE}) + LIBEDIT_HAVE_COMPLETION_INT) + + CHECK_CXX_SOURCE_COMPILES(" + #include <stdio.h> + #include <readline.h> + int main(int argc, char **argv) + { + char res= *(*rl_completion_entry_function)(0,0); + completion_matches(0,0); + }" + LIBEDIT_HAVE_COMPLETION_CHAR) + IF(LIBEDIT_HAVE_COMPLETION_INT OR LIBEDIT_HAVE_COMPLETION_CHAR) + SET(USE_LIBEDIT_INTERFACE 1) + ENDIF() ENDIF() ENDMACRO() @@ -187,6 +199,7 @@ MACRO (MYSQL_CHECK_READLINE) IF(USE_LIBEDIT_INTERFACE) SET(MY_READLINE_INCLUDE_DIR ${LIBEDIT_INCLUDE_DIR}) SET(MY_READLINE_LIBRARY ${LIBEDIT_LIBRARY} ${CURSES_LIBRARY}) + SET(USE_NEW_READLINE_INTERFACE ${LIBEDIT_HAVE_COMPLETION_CHAR}) ELSE() MYSQL_USE_BUNDLED_READLINE() ENDIF() diff --git a/cmake/sign.cmake.in b/cmake/sign.cmake.in index 61ae38d152d..50768a3dcc9 100644 --- a/cmake/sign.cmake.in +++ b/cmake/sign.cmake.in @@ -1,13 +1,31 @@ +# If timestamping is used, it can (rarely) fail, when public timestamping service has issues. +# +# To handle the error gracefully and tranparently, we'll retry the signtool command, +# second time without "/t URL" parameter +SET(SIGNTOOL_PARAMETERS_NO_TIMESTAMP "@SIGNTOOL_PARAMETERS@") +LIST(FIND SIGNTOOL_PARAMETERS_NO_TIMESTAMP /t idx) +IF(NOT(idx EQUAL -1)) + LIST(REMOVE_AT SIGNTOOL_PARAMETERS_NO_TIMESTAMP ${idx}) + #remove the URL following /t , as well + LIST(REMOVE_AT SIGNTOOL_PARAMETERS_NO_TIMESTAMP ${idx}) +ENDIF() + +GET_FILENAME_COMPONENT(SIGNTOOL_DIR "@SIGNTOOL_EXECUTABLE@" DIRECTORY) +GET_FILENAME_COMPONENT(SIGNTOOL_NAME "@SIGNTOOL_EXECUTABLE@" NAME) + FILE(GLOB_RECURSE files "@CMAKE_BINARY_DIR@/*.signme") MESSAGE(STATUS "signing files") + + FOREACH(f ${files}) STRING(REPLACE ".signme" "" exe_location "${f}") string (REPLACE ";" " " params "@SIGNTOOL_PARAMETERS@") - #MESSAGE("@SIGNTOOL_EXECUTABLE@" sign ${params} "${exe_location}") EXECUTE_PROCESS(COMMAND - "@SIGNTOOL_EXECUTABLE@" sign @SIGNTOOL_PARAMETERS@ "${exe_location}" + cmd /c "${SIGNTOOL_NAME}" sign @SIGNTOOL_PARAMETERS@ "${exe_location}" 2>NUL + || "${SIGNTOOL_NAME}" sign ${SIGNTOOL_PARAMETERS_NO_TIMESTAMP} "${exe_location}" + WORKING_DIRECTORY ${SIGNTOOL_DIR} RESULT_VARIABLE ERR) IF(NOT ${ERR} EQUAL 0) MESSAGE( "Error ${ERR} signing ${exe_location}") diff --git a/dbug/dbug.c b/dbug/dbug.c index 9807db23cde..356dc319b1f 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -2259,9 +2259,14 @@ static int default_my_dbug_sanity(void) } extern my_bool my_assert; -my_bool _db_my_assert(void) +ATTRIBUTE_COLD +my_bool _db_my_assert(const char *file, int line, const char *msg) { - return my_assert; + my_bool a = my_assert; + _db_flush_(); + if (!a) + fprintf(stderr, "%s:%d: assert: %s\n", file, line, msg); + return a; } #else diff --git a/debian/additions/debian-start b/debian/additions/debian-start index 7940bbe68a5..7de59ce1fe9 100755 --- a/debian/additions/debian-start +++ b/debian/additions/debian-start @@ -15,6 +15,7 @@ fi MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" +# Don't run full mysql_upgrade on every server restart, use --version-check to do it only once MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check" MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf" MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables" diff --git a/debian/control b/debian/control index 7084c0f43dc..97275235f76 100644 --- a/debian/control +++ b/debian/control @@ -234,7 +234,8 @@ Description: MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf) Package: mariadb-client-core-10.5 Architecture: any -Depends: mariadb-common (>= ${source:Version}), libmariadb3, +Depends: libmariadb3, + mariadb-common (>= ${source:Version}), ${misc:Depends}, ${shlibs:Depends} Conflicts: mariadb-client-10.0, @@ -749,6 +750,8 @@ Depends: libcrack2 (>= 2.9.0), Description: CrackLib Password Validation Plugin for MariaDB This password validation plugin uses cracklib to allow only sufficiently secure (as defined by cracklib) user passwords in MariaDB. + . + Install and configure this to enforce stronger passwords for MariaDB users. Package: mariadb-test Architecture: any diff --git a/debian/libmariadb-dev.README.Maintainer b/debian/libmariadb-dev.README.Maintainer index 99e1c662c14..40942827d63 100644 --- a/debian/libmariadb-dev.README.Maintainer +++ b/debian/libmariadb-dev.README.Maintainer @@ -1,3 +1,6 @@ The examples directory includes files that might be needed by some developers: - the example file udf_example.c + +For more information, see MariaDB Connector/C docs at: +https://github.com/MariaDB/mariadb-connector-c/wiki/libmysql_libmariadb diff --git a/debian/mariadb-client-10.5.install b/debian/mariadb-client-10.5.install index 9cb4ee3dede..4cd0af71c24 100644 --- a/debian/mariadb-client-10.5.install +++ b/debian/mariadb-client-10.5.install @@ -10,16 +10,6 @@ usr/bin/mysqldumpslow usr/bin/mysqlimport usr/bin/mysqlshow usr/bin/mysqlslap -usr/share/man/man1/mysql_find_rows.1 -usr/share/man/man1/mysql_fix_extensions.1 -usr/share/man/man1/mysql_waitpid.1 -usr/share/man/man1/mysqlaccess.1 -usr/share/man/man1/mysqladmin.1 -usr/share/man/man1/mysqldump.1 -usr/share/man/man1/mysqldumpslow.1 -usr/share/man/man1/mysqlimport.1 -usr/share/man/man1/mysqlshow.1 -usr/share/man/man1/mysqlslap.1 usr/share/man/man1/mariadb-access.1 usr/share/man/man1/mariadb-admin.1 usr/share/man/man1/mariadb-binlog.1 @@ -31,3 +21,13 @@ usr/share/man/man1/mariadb-import.1 usr/share/man/man1/mariadb-plugin.1 usr/share/man/man1/mariadb-slap.1 usr/share/man/man1/mariadb-waitpid.1 +usr/share/man/man1/mysql_find_rows.1 +usr/share/man/man1/mysql_fix_extensions.1 +usr/share/man/man1/mysql_waitpid.1 +usr/share/man/man1/mysqlaccess.1 +usr/share/man/man1/mysqladmin.1 +usr/share/man/man1/mysqldump.1 +usr/share/man/man1/mysqldumpslow.1 +usr/share/man/man1/mysqlimport.1 +usr/share/man/man1/mysqlshow.1 +usr/share/man/man1/mysqlslap.1 diff --git a/debian/mariadb-client-core-10.5.install b/debian/mariadb-client-core-10.5.install index 0706b272e8a..4cc61674770 100644 --- a/debian/mariadb-client-core-10.5.install +++ b/debian/mariadb-client-core-10.5.install @@ -1,6 +1,6 @@ usr/bin/mysql usr/bin/mysqlcheck +usr/share/man/man1/mariadb-check.1 +usr/share/man/man1/mariadb.1 usr/share/man/man1/mysql.1 usr/share/man/man1/mysqlcheck.1 -usr/share/man/man1/mariadb.1 -usr/share/man/man1/mariadb-check.1 diff --git a/debian/mariadb-plugin-rocksdb.install b/debian/mariadb-plugin-rocksdb.install index a2b8b805cdb..3e6e3d4b00e 100644 --- a/debian/mariadb-plugin-rocksdb.install +++ b/debian/mariadb-plugin-rocksdb.install @@ -1,7 +1,7 @@ etc/mysql/conf.d/rocksdb.cnf etc/mysql/mariadb.conf.d usr/bin/myrocks_hotbackup usr/bin/mysql_ldb -usr/share/man/man1/mariadb-ldb.1 -usr/share/man/man1/mysql_ldb.1 usr/bin/sst_dump usr/lib/mysql/plugin/ha_rocksdb.so +usr/share/man/man1/mariadb-ldb.1 +usr/share/man/man1/mysql_ldb.1 diff --git a/debian/mariadb-server-10.5.install b/debian/mariadb-server-10.5.install index aa3a96ef972..761dba8ae0f 100644 --- a/debian/mariadb-server-10.5.install +++ b/debian/mariadb-server-10.5.install @@ -1,8 +1,8 @@ debian/additions/debian-start etc/mysql debian/additions/debian-start.inc.sh usr/share/mysql debian/additions/echo_stderr usr/share/mysql -debian/additions/mysqld_safe_syslog.cnf etc/mysql/conf.d debian/additions/mysql.init usr/share/mysql +debian/additions/mysqld_safe_syslog.cnf etc/mysql/conf.d etc/apparmor.d/usr.sbin.mysqld lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf usr/bin/aria_chk diff --git a/debian/mariadb-server-10.5.postinst b/debian/mariadb-server-10.5.postinst index 9d2b49f5692..05aa6426b2a 100644 --- a/debian/mariadb-server-10.5.postinst +++ b/debian/mariadb-server-10.5.postinst @@ -2,8 +2,8 @@ . /usr/share/debconf/confmodule -# assume the filename is /path/to/mariadb-server-##.#.postinst -VER=${0: -13:4} +# Automatically set version to ease maintenance of this file +MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}" if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } @@ -11,7 +11,7 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin # This command can be used as pipe to syslog. With "-s" it also logs to stderr. -ERR_LOGGER="logger -p daemon.err -t mariadb-server-$VER.postinst -i" +ERR_LOGGER="logger -p daemon.err -t mariadb-server-$MAJOR_VER.postinst -i" # This will make an error in a logged command immediately apparent by aborting # the install, rather than failing silently and leaving a broken install. set -o pipefail @@ -117,8 +117,8 @@ EOF set -e # To avoid downgrades. - touch $mysql_statedir/debian-$VER.flag - + touch $mysql_statedir/debian-$MAJOR_VER.flag + # On new installations root user can connect via unix_socket. # But on upgrades, scripts rely on debian-sys-maint user and # credentials in /etc/mysql/debian.cnf diff --git a/debian/mariadb-server-core-10.5.install b/debian/mariadb-server-core-10.5.install index 24f967252a2..9139949a24e 100644 --- a/debian/mariadb-server-core-10.5.install +++ b/debian/mariadb-server-core-10.5.install @@ -3,12 +3,12 @@ usr/bin/mysql_install_db usr/bin/mysql_upgrade usr/sbin/mysqld usr/share/man/man1/innochecksum.1 -usr/share/man/man1/mysql_install_db.1 -usr/share/man/man1/mysql_upgrade.1 -usr/share/man/man8/mysqld.8 usr/share/man/man1/mariadb-install-db.1 usr/share/man/man1/mariadb-upgrade.1 +usr/share/man/man1/mysql_install_db.1 +usr/share/man/man1/mysql_upgrade.1 usr/share/man/man8/mariadbd.8 +usr/share/man/man8/mysqld.8 usr/share/mysql/charsets usr/share/mysql/czech usr/share/mysql/danish diff --git a/debian/mariadb-test.install b/debian/mariadb-test.install index 5d3afda68d4..fc7a707c007 100644 --- a/debian/mariadb-test.install +++ b/debian/mariadb-test.install @@ -17,16 +17,16 @@ usr/lib/mysql/plugin/qa_auth_client.so usr/lib/mysql/plugin/qa_auth_interface.so usr/lib/mysql/plugin/qa_auth_server.so usr/lib/mysql/plugin/test_versioning.so +usr/share/man/man1/mariadb-client-test-embedded.1 +usr/share/man/man1/mariadb-client-test.1 +usr/share/man/man1/mariadb-test-embedded.1 +usr/share/man/man1/mariadb-test.1 usr/share/man/man1/mysql-stress-test.pl.1 usr/share/man/man1/mysql-test-run.pl.1 usr/share/man/man1/mysql_client_test.1 usr/share/man/man1/mysql_client_test_embedded.1 usr/share/man/man1/mysqltest.1 usr/share/man/man1/mysqltest_embedded.1 -usr/share/man/man1/mariadb-client-test-embedded.1 -usr/share/man/man1/mariadb-client-test.1 -usr/share/man/man1/mariadb-test-embedded.1 -usr/share/man/man1/mariadb-test.1 usr/share/mysql/mysql-test/README usr/share/mysql/mysql-test/README-gcov usr/share/mysql/mysql-test/README.stress diff --git a/debian/mariadb-test.links b/debian/mariadb-test.links index 8b9ca6fe98b..504e0a0b557 100644 --- a/debian/mariadb-test.links +++ b/debian/mariadb-test.links @@ -1,6 +1,6 @@ -usr/share/mysql/mysql-test/mysql-test-run.pl usr/share/mysql/mysql-test/mtr -usr/share/mysql/mysql-test/mysql-test-run.pl usr/share/mysql/mysql-test/mysql-test-run -usr/bin/mysql_client_test_embedded usr/bin/mariadb-client-test-embedded -usr/bin/mysqltest_embedded usr/bin/mariadb-test-embedded usr/bin/mysql_client_test usr/bin/mariadb-client-test +usr/bin/mysql_client_test_embedded usr/bin/mariadb-client-test-embedded usr/bin/mysqltest usr/bin/mariadb-test +usr/bin/mysqltest_embedded usr/bin/mariadb-test-embedded +usr/share/mysql/mysql-test/mysql-test-run.pl usr/share/mysql/mysql-test/mtr +usr/share/mysql/mysql-test/mysql-test-run.pl usr/share/mysql/mysql-test/mysql-test-run diff --git a/debian/rules b/debian/rules index df98d3be6c1..c4ec7497ee1 100755 --- a/debian/rules +++ b/debian/rules @@ -163,9 +163,6 @@ override_dh_installinit-arch: override_dh_installcron-arch: dh_installcron --name mysql-server -get-orig-source: - uscan --force-download --verbose - # If a file is not supposed to be included anywhere, add it to the not-installed # file and document the reason. Note that dh_install supports the above mentioned # white list file only starting from Debian Stretch and Ubuntu Xenial. diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 2605e33be94..21e574ae3b8 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1606,7 +1606,8 @@ bool backup_finish() return(false); } - if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO, opt_history != 0)) { + if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO, + opt_history != 0, true)) { return(false); } diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index e2c5d8405ae..9cac43dd6f8 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -1367,9 +1367,12 @@ PERCONA_SCHEMA.xtrabackup_history and writes a new history record to the table containing all the history info particular to the just completed backup. */ bool -write_xtrabackup_info(MYSQL *connection, const char * filename, bool history) +write_xtrabackup_info(MYSQL *connection, const char * filename, bool history, + bool stream) { + bool result = true; + FILE *fp = NULL; char *uuid = NULL; char *server_version = NULL; char buf_start_time[100]; @@ -1395,7 +1398,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history) || xtrabackup_databases_exclude ); - backup_file_printf(filename, + char *buf = NULL; + int buf_len = asprintf(&buf, "uuid = %s\n" "name = %s\n" "tool_name = %s\n" @@ -1407,8 +1411,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history) "end_time = %s\n" "lock_time = %d\n" "binlog_pos = %s\n" - "innodb_from_lsn = %llu\n" - "innodb_to_lsn = %llu\n" + "innodb_from_lsn = " LSN_PF "\n" + "innodb_to_lsn = " LSN_PF "\n" "partial = %s\n" "incremental = %s\n" "format = %s\n" @@ -1425,12 +1429,34 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history) (int)history_lock_time, /* lock_time */ mysql_binlog_position ? mysql_binlog_position : "", /* binlog_pos */ - incremental_lsn, /* innodb_from_lsn */ - metadata_to_lsn, /* innodb_to_lsn */ + incremental_lsn, + /* innodb_from_lsn */ + metadata_to_lsn, + /* innodb_to_lsn */ is_partial? "Y" : "N", xtrabackup_incremental ? "Y" : "N", /* incremental */ xb_stream_name[xtrabackup_stream_fmt], /* format */ xtrabackup_compress ? "compressed" : "N"); /* compressed */ + if (buf_len < 0) { + msg("Error: cannot generate xtrabackup_info"); + result = false; + goto cleanup; + } + + if (stream) { + backup_file_printf(filename, "%s", buf); + } else { + fp = fopen(filename, "w"); + if (!fp) { + msg("Error: cannot open %s", filename); + result = false; + goto cleanup; + } + if (fwrite(buf, buf_len, 1, fp) < 1) { + result = false; + goto cleanup; + } + } if (!history) { goto cleanup; @@ -1492,8 +1518,11 @@ cleanup: free(uuid); free(server_version); + free(buf); + if (fp) + fclose(fp); - return(true); + return(result); } extern const char *innodb_checksum_algorithm_names[]; diff --git a/extra/mariabackup/backup_mysql.h b/extra/mariabackup/backup_mysql.h index e2c56f88a8c..b61fa2362c6 100644 --- a/extra/mariabackup/backup_mysql.h +++ b/extra/mariabackup/backup_mysql.h @@ -68,7 +68,8 @@ bool write_binlog_info(MYSQL *connection); bool -write_xtrabackup_info(MYSQL *connection, const char * filename, bool history); +write_xtrabackup_info(MYSQL *connection, const char * filename, bool history, + bool stream); bool write_backup_config_file(); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 011547a78aa..efc4330c343 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3970,7 +3970,7 @@ static bool xtrabackup_backup_low() } sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, XTRABACKUP_INFO); - if (!write_xtrabackup_info(mysql_connection, filename, false)) { + if (!write_xtrabackup_info(mysql_connection, filename, false, false)) { msg("Error: failed to write info " "to '%s'.", filename); return false; diff --git a/include/my_dbug.h b/include/my_dbug.h index 1140f4a03d3..2bbe8ff6a30 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -58,7 +58,8 @@ extern void _db_dump_(uint _line_,const char *keyword, extern void _db_end_(void); extern void _db_lock_file_(void); extern void _db_unlock_file_(void); -extern my_bool _db_my_assert(void); +ATTRIBUTE_COLD +extern my_bool _db_my_assert(const char *file, int line, const char *msg); extern FILE *_db_fp_(void); extern void _db_flush_(void); extern void dbug_swap_code_state(void **code_state_store); @@ -104,10 +105,9 @@ extern int (*dbug_sanity)(void); #define DBUG_END() _db_end_ () #define DBUG_LOCK_FILE _db_lock_file_() #define DBUG_UNLOCK_FILE _db_unlock_file_() -#define DBUG_ASSERT(A) do { if (!(A)) { _db_flush_(); \ - if (_db_my_assert()) assert(A); \ - else fprintf(stderr, "%s:%d: assert: %s\n", __FILE__, __LINE__, #A); \ -}} while (0) +#define DBUG_ASSERT(A) do { \ + if (unlikely(!(A)) && _db_my_assert(__FILE__, __LINE__, #A)) assert(A); \ +} while (0) #define DBUG_SLOW_ASSERT(A) DBUG_ASSERT(A) #define DBUG_ASSERT_EXISTS #define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len)) diff --git a/mysql-test/include/ctype_utf8_ilseq.inc b/mysql-test/include/ctype_utf8_ilseq.inc index 1bb009f2a8b..3586946659e 100644 --- a/mysql-test/include/ctype_utf8_ilseq.inc +++ b/mysql-test/include/ctype_utf8_ilseq.inc @@ -14,6 +14,7 @@ SHOW CREATE TABLE t1; INSERT INTO t1 (ch) VALUES ('admin'),('admin1'); SELECT ch FROM t1 WHERE ch='admin𝌆'; +EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆'; SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆'; SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆'; DELETE FROM t1; diff --git a/mysql-test/main/compare.result b/mysql-test/main/compare.result index b4a6b22ba3a..c4650014326 100644 --- a/mysql-test/main/compare.result +++ b/mysql-test/main/compare.result @@ -100,3 +100,23 @@ CREATE TABLE t1(a INT ZEROFILL); SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2; 1 DROP TABLE t1; +CREATE TABLE t1 (a char(2), index (a)); +insert into t1 values ("aa"),("bb"); +select * from t1 where a="aa"; +a +aa +select * from t1 where a="aaa"; +a +select * from t1 where a="aa "; +a +aa +select * from t1 where a>="aaa"; +a +bb +explain select * from t1 where a="aaa"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 3 const 1 Using where; Using index +explain select * from t1 where a="aa "; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 3 const 1 Using where; Using index +drop table t1; diff --git a/mysql-test/main/compare.test b/mysql-test/main/compare.test index d2b2a7e5523..38bda6754d8 100644 --- a/mysql-test/main/compare.test +++ b/mysql-test/main/compare.test @@ -94,3 +94,17 @@ DROP TABLE t1; CREATE TABLE t1(a INT ZEROFILL); SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2; DROP TABLE t1; + +# +# Check what happens when comparing to long string +# + +CREATE TABLE t1 (a char(2), index (a)); +insert into t1 values ("aa"),("bb"); +select * from t1 where a="aa"; +select * from t1 where a="aaa"; +select * from t1 where a="aa "; +select * from t1 where a>="aaa"; +explain select * from t1 where a="aaa"; +explain select * from t1 where a="aa "; +drop table t1; diff --git a/mysql-test/main/create_drop_server.result b/mysql-test/main/create_drop_server.result index 29c4fe7e123..4f5d13b3541 100644 --- a/mysql-test/main/create_drop_server.result +++ b/mysql-test/main/create_drop_server.result @@ -38,9 +38,9 @@ DROP SERVER server_1; CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'Remote', HOST 'Server.Example.Com', DATABASE 'test'); SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1'; Host -server.example.com +Server.Example.Com ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org'); SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1'; Host -server.example.org +Server.Example.Org DROP SERVER server_1; diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result index 12a7e2ea789..8fba35d8ed4 100644 --- a/mysql-test/main/cte_nonrecursive.result +++ b/mysql-test/main/cte_nonrecursive.result @@ -606,7 +606,7 @@ with t(c) as (select a from t1 where b >= 'c') select * from t r1 where r1.c=4; show create view v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS with t as (select `t1`.`a` AS `c` from `t1` where `t1`.`b` >= 'c')select `r1`.`c` AS `c` from `t` `r1` where `r1`.`c` = 4 latin1 latin1_swedish_ci +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS with t(c) as (select `t1`.`a` AS `c` from `t1` where `t1`.`b` >= 'c')select `r1`.`c` AS `c` from `t` `r1` where `r1`.`c` = 4 latin1 latin1_swedish_ci select * from v3; c 4 @@ -618,7 +618,7 @@ with t(c) as (select a from t1 where b >= 'c') select * from t r1, t r2 where r1.c=r2.c and r2.c=4; show create view v4; View Create View character_set_client collation_connection -v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS with t as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c`,`r2`.`c` AS `d` from (`t` `r1` join (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c') `r2`) where `r1`.`c` = `r2`.`c` and `r2`.`c` = 4 latin1 latin1_swedish_ci +v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS with t(c) as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c`,`r2`.`c` AS `d` from (`t` `r1` join (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c') `r2`) where `r1`.`c` = `r2`.`c` and `r2`.`c` = 4 latin1 latin1_swedish_ci select * from v4; c d 4 4 diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 0b22da8f72a..b88f0ff6255 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -699,7 +699,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 5 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where; Using join buffer (flat, BNL join) NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with recursive ancestor_couple_ids as (/* select#2 */ select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where `a`.`father` is not null and `a`.`mother` is not null), coupled_ancestors as (/* select#3 */ select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where `test`.`folks`.`name` = 'Me' union all /* select#4 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where `test`.`p`.`id` = `fa`.`h_id` union all /* select#5 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where `test`.`p`.`id` = `ma`.`w_id`)/* select#1 */ select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where `h`.`id` = `c`.`h_id` and `w`.`id` = `c`.`w_id` +Note 1003 with recursive ancestor_couple_ids(h_id,w_id) as (/* select#2 */ select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where `a`.`father` is not null and `a`.`mother` is not null), coupled_ancestors(id,name,dob,father,mother) as (/* select#3 */ select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where `test`.`folks`.`name` = 'Me' union all /* select#4 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where `test`.`p`.`id` = `fa`.`h_id` union all /* select#5 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where `test`.`p`.`id` = `ma`.`w_id`)/* select#1 */ select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where `h`.`id` = `c`.`h_id` and `w`.`id` = `c`.`w_id` # simple mutual recursion with recursive ancestor_couple_ids(h_id, w_id) @@ -3091,7 +3091,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 4 DEPENDENT SUBQUERY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with recursive destinations as (/* select#2 */ select `test`.`a`.`arrival` AS `city`,1 AS `legs` from `test`.`flights` `a` where `test`.`a`.`departure` = 'Cairo' union /* select#3 */ select `test`.`b`.`arrival` AS `arrival`,`r`.`legs` + 1 AS `r.legs + 1` from `destinations` `r` join `test`.`flights` `b` where `r`.`city` = `test`.`b`.`departure` and !<in_optimizer>(`test`.`b`.`arrival`,<exists>(/* select#4 */ select `destinations`.`city` from `destinations` where trigcond(`test`.`b`.`arrival` = `destinations`.`city` or `destinations`.`city` is null) having trigcond(`destinations`.`city` is null))))/* select#1 */ select `destinations`.`city` AS `city`,`destinations`.`legs` AS `legs` from `destinations` +Note 1003 with recursive destinations(city,legs) as (/* select#2 */ select `test`.`a`.`arrival` AS `city`,1 AS `legs` from `test`.`flights` `a` where `test`.`a`.`departure` = 'Cairo' union /* select#3 */ select `test`.`b`.`arrival` AS `arrival`,`r`.`legs` + 1 AS `r.legs + 1` from `destinations` `r` join `test`.`flights` `b` where `r`.`city` = `test`.`b`.`departure` and !<in_optimizer>(`test`.`b`.`arrival`,<exists>(/* select#4 */ select `destinations`.`city` from `destinations` where trigcond(`test`.`b`.`arrival` = `destinations`.`city` or `destinations`.`city` is null) having trigcond(`destinations`.`city` is null))))/* select#1 */ select `destinations`.`city` AS `city`,`destinations`.`legs` AS `legs` from `destinations` set standard_compliant_cte=default; drop table flights; # @@ -3378,7 +3378,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with recursive rcte as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2` +Note 1003 with recursive rcte(a) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2` prepare stmt from "with recursive rcte(a) as (select 1 union select cast(a+1 as unsigned) from rcte where a < 10), diff --git a/mysql-test/main/ctype_uca.result b/mysql-test/main/ctype_uca.result index 41d2a1149ee..d4b242d035f 100644 --- a/mysql-test/main/ctype_uca.result +++ b/mysql-test/main/ctype_uca.result @@ -6748,14 +6748,13 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1 (ch) VALUES ('admin'),('admin1'); SELECT ch FROM t1 WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 +EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆'; ch SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 DELETE FROM t1; INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????'); INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b'); @@ -6771,22 +6770,14 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -6829,8 +6820,6 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -6850,14 +6839,10 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; ch a @@ -6877,8 +6862,6 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z @@ -6889,24 +6872,16 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 ALTER TABLE t1 DROP KEY ch; # 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,''''); @@ -6992,14 +6967,13 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1 (ch) VALUES ('admin'),('admin1'); SELECT ch FROM t1 WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 +EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆'; ch SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 DELETE FROM t1; INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????'); INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b'); @@ -7015,22 +6989,14 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a diff --git a/mysql-test/main/ctype_uca_innodb.result b/mysql-test/main/ctype_uca_innodb.result index bd6f3b8a21f..7c64f17190e 100644 --- a/mysql-test/main/ctype_uca_innodb.result +++ b/mysql-test/main/ctype_uca_innodb.result @@ -23,14 +23,13 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1 (ch) VALUES ('admin'),('admin1'); SELECT ch FROM t1 WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 +EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆'; ch SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 DELETE FROM t1; INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????'); INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b'); @@ -46,22 +45,14 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -104,8 +95,6 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -125,14 +114,10 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; ch a @@ -152,8 +137,6 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z @@ -164,24 +147,16 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 ALTER TABLE t1 DROP KEY ch; # 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,''''); diff --git a/mysql-test/main/ctype_utf8.result b/mysql-test/main/ctype_utf8.result index de2cd005c22..63336fc03ea 100644 --- a/mysql-test/main/ctype_utf8.result +++ b/mysql-test/main/ctype_utf8.result @@ -5467,14 +5467,13 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1 (ch) VALUES ('admin'),('admin1'); SELECT ch FROM t1 WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 +EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆'; ch SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 DELETE FROM t1; INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????'); INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b'); @@ -5490,22 +5489,14 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -5548,8 +5539,6 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -5569,14 +5558,10 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; ch a @@ -5596,8 +5581,6 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z @@ -5608,24 +5591,16 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 ALTER TABLE t1 DROP KEY ch; # 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,''''); @@ -5711,14 +5686,13 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1 (ch) VALUES ('admin'),('admin1'); SELECT ch FROM t1 WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 +EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆'; ch SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 DELETE FROM t1; INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????'); INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b'); @@ -5734,22 +5708,14 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -5792,8 +5758,6 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a @@ -5813,14 +5777,10 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a𝌆b' ORDER BY ch; ch a @@ -5840,8 +5800,6 @@ ab az aЀ aր -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z @@ -5852,24 +5810,16 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a𝌆b' ORDER BY ch; ch z -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 ALTER TABLE t1 DROP KEY ch; # 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,''''); @@ -5955,14 +5905,13 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1 (ch) VALUES ('admin'),('admin1'); SELECT ch FROM t1 WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 +EXPLAIN SELECT ch FROM t1 WHERE ch='admin𝌆'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin𝌆'; ch SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin𝌆'; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 DELETE FROM t1; INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????'); INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b'); @@ -5978,22 +5927,14 @@ EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1 EXPLAIN SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a𝌆b' ORDER BY ch; ch -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1 SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a𝌆' ORDER BY ch; ch a diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 63a86615186..72cee2a428f 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -2193,7 +2193,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "range_analysis": { "table_scan": { "rows": 1000, - "cost": 1202 + "cost": 2e308 }, "potential_range_indexes": [ { diff --git a/mysql-test/main/order_by_innodb.result b/mysql-test/main/order_by_innodb.result index 3ff1f92e94a..9cdf9800cee 100644 --- a/mysql-test/main/order_by_innodb.result +++ b/mysql-test/main/order_by_innodb.result @@ -49,6 +49,32 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using sort_union(key1,key2); Using where drop table t0, t1; # +# MDEV-18094: Query with order by limit picking index scan over filesort +# +create table t0 (a int); +INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0); +CREATE TABLE t1 ( +a int(11), +b int(11), +c int(11), +KEY a_c (a,c), +KEY a_b (a,b) +) ENGINE=InnoDB; +insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C; +# should use ref access +explain select a,b,c from t1 where a=1 and c=2 order by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a_c,a_b a_c 10 const,const 20 Using where; Using filesort +# both should use range access +explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where +explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where +drop table t1,t0; +# Start of 10.2 tests +# # MDEV-14071: wrong results with orderby_uses_equalities=on # (duplicate of MDEV-13994) # @@ -121,3 +147,4 @@ i n 656 eight set optimizer_switch= @save_optimizer_switch; DROP TABLE t1,t2,t3; +# End of 10.2 tests diff --git a/mysql-test/main/order_by_innodb.test b/mysql-test/main/order_by_innodb.test index 0debb777749..f4c738263ae 100644 --- a/mysql-test/main/order_by_innodb.test +++ b/mysql-test/main/order_by_innodb.test @@ -63,6 +63,32 @@ where key1<3 or key2<3; drop table t0, t1; --echo # +--echo # MDEV-18094: Query with order by limit picking index scan over filesort +--echo # + +create table t0 (a int); +INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0); + +CREATE TABLE t1 ( +a int(11), +b int(11), +c int(11), +KEY a_c (a,c), +KEY a_b (a,b) +) ENGINE=InnoDB; +insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C; + +--echo # should use ref access +explain select a,b,c from t1 where a=1 and c=2 order by b; + +--echo # both should use range access +explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000; +explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000; +drop table t1,t0; + +--echo # Start of 10.2 tests + +--echo # --echo # MDEV-14071: wrong results with orderby_uses_equalities=on --echo # (duplicate of MDEV-13994) --echo # @@ -108,3 +134,5 @@ eval $q2; set optimizer_switch= @save_optimizer_switch; DROP TABLE t1,t2,t3; + +--echo # End of 10.2 tests diff --git a/mysql-test/main/processlist.result b/mysql-test/main/processlist.result index ab518d961ef..4be643c1790 100644 --- a/mysql-test/main/processlist.result +++ b/mysql-test/main/processlist.result @@ -36,10 +36,6 @@ SELECT INFO, INFO_BINARY, 'xxx😎yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA INFO SELECT INFO, INFO_BINARY, 'xxx????yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%' INFO_BINARY SELECT INFO, INFO_BINARY, 'xxx😎yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%' utf8mb4_string xxx😎yyy -Warnings: -Level Warning -Code 1366 -Message Incorrect string value: '\xF0\x9F\x98\x8Eyy...' for column `information_schema`.`(temporary)`.`INFO` at row 1 # # End of 10.1 tests # diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index b3b295842cd..1fdd1bef0cc 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -4547,7 +4547,7 @@ DEALLOCATE PREPARE stmt; # PREPARE stmt FROM 'SELECT ? FROM DUAL'; EXECUTE stmt USING (SELECT 1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1)' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions DEALLOCATE PREPARE stmt; CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test'; PREPARE stmt FROM 'SELECT ? FROM DUAL'; @@ -4746,7 +4746,7 @@ ERROR 21000: Operand should contain 1 column(s) # Testing disallowed expressions in USING # EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING (SELECT 1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1)' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test'; EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING f1(); ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions @@ -4932,9 +4932,9 @@ ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2 PREPARE stmt FROM CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL'); ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat' EXECUTE IMMEDIATE (SELECT 'SELECT 1'); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 'SELECT 1')' at line 1 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions PREPARE stmt FROM (SELECT 'SELECT 1'); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 'SELECT 1')' at line 1 +ERROR 42000: PREPARE..FROM does not support subqueries or stored functions EXECUTE IMMEDIATE a; ERROR 42S22: Unknown column 'a' in 'field list' PREPARE stmt FROM a; diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index b13cf667aef..a3c9f12e582 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -4042,7 +4042,7 @@ DEALLOCATE PREPARE stmt; --echo # PREPARE stmt FROM 'SELECT ? FROM DUAL'; ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE stmt USING (SELECT 1); DEALLOCATE PREPARE stmt; @@ -4221,7 +4221,7 @@ EXECUTE IMMEDIATE 'SELECT ?' USING ROW(1,2); --echo # Testing disallowed expressions in USING --echo # ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING (SELECT 1); CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test'; @@ -4394,9 +4394,9 @@ EXECUTE IMMEDIATE CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL'); --error ER_CANT_AGGREGATE_2COLLATIONS PREPARE stmt FROM CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL'); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE (SELECT 'SELECT 1'); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PREPARE stmt FROM (SELECT 'SELECT 1'); --error ER_BAD_FIELD_ERROR diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index 1505afdfb82..7f03a7c596c 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -2115,23 +2115,15 @@ explain SELECT * FROM t1 WHERE fd='😁'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 SELECT * FROM t1 WHERE fd='😁'; id fd -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 # The following must not use range access: explain select count(*) from t1 where fd <'😁'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ix_fd ix_fd 63 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 select count(*) from t1 where fd <'😁'; count(*) 40960 -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 select count(*) from t1 ignore index (ix_fd) where fd <'😁'; count(*) 40960 @@ -2353,8 +2345,6 @@ INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'); EXPLAIN SELECT * FROM t1 WHERE a<=>'😎'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column `test`.`t1`.`a` at row 1 DROP TABLE t1; # # MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index 170df14dcba..b698ec9e2ff 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -2118,23 +2118,15 @@ explain SELECT * FROM t1 WHERE fd='😁'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 SELECT * FROM t1 WHERE fd='😁'; id fd -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 # The following must not use range access: explain select count(*) from t1 where fd <'😁'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index ix_fd ix_fd 63 NULL # Using where; Using index -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 select count(*) from t1 where fd <'😁'; count(*) 40960 -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1 select count(*) from t1 ignore index (ix_fd) where fd <'😁'; count(*) 40960 @@ -2356,8 +2348,6 @@ INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'); EXPLAIN SELECT * FROM t1 WHERE a<=>'😎'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -Warnings: -Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column `test`.`t1`.`a` at row 1 DROP TABLE t1; # # MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 43e3c88c0a1..f11fee4b985 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -1668,5 +1668,90 @@ drop table t1; set use_stat_tables= @save_use_stat_tables; set @@histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +# +# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1) +# +set @@optimizer_use_condition_selectivity=2; +set names utf8; +CREATE DATABASE world; +use world; +CREATE TABLE Country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +CREATE TABLE City ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +CREATE TABLE CountryLanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +CREATE INDEX Name ON City(Name); +CREATE INDEX CountryPopulation ON City(Country,Population); +CREATE INDEX CountryName ON City(Country,Name); +set @@optimizer_use_condition_selectivity=2; +EXPLAIN +SELECT * FROM City WHERE Country='FIN'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City ref Country,CountryPopulation,CountryName CountryName 3 const 5 Using index condition +DROP DATABASE world; +use test; +CREATE TABLE t1 ( +a INT, +b INT NOT NULL, +c char(100), +KEY (b, c), +KEY (b, a, c) +) ENGINE=MyISAM +DEFAULT CHARSET = utf8; +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); +INSERT INTO t1 SELECT a + 10, b, c FROM t1; +INSERT INTO t1 SELECT a + 20, b, c FROM t1; +INSERT INTO t1 SELECT a + 40, b, c FROM t1; +INSERT INTO t1 SELECT a + 80, b, c FROM t1; +INSERT INTO t1 SELECT a + 160, b, c FROM t1; +INSERT INTO t1 SELECT a + 320, b, c FROM t1; +INSERT INTO t1 SELECT a + 640, b, c FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80; +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +a +2071 +2061 +2051 +2041 +2031 +2021 +2011 +2001 +1991 +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +DROP TABLE t1; # End of 10.1 tests set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test index a3b69789da6..a9588ea205d 100644 --- a/mysql-test/main/selectivity.test +++ b/mysql-test/main/selectivity.test @@ -1125,6 +1125,87 @@ drop table t1; set use_stat_tables= @save_use_stat_tables; set @@histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; + +--echo # +--echo # MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1) +--echo # + +set @@optimizer_use_condition_selectivity=2; + +set names utf8; + +CREATE DATABASE world; + +use world; + +--source include/world_schema.inc + +--disable_query_log +--disable_result_log +--disable_warnings +--source include/world.inc +--enable_warnings +--enable_result_log +--enable_query_log + +CREATE INDEX Name ON City(Name); +CREATE INDEX CountryPopulation ON City(Country,Population); +CREATE INDEX CountryName ON City(Country,Name); + +--disable_query_log +--disable_result_log +--disable_warnings +ANALYZE TABLE City; +--enable_warnings +--enable_result_log +--enable_query_log + +set @@optimizer_use_condition_selectivity=2; + +EXPLAIN +SELECT * FROM City WHERE Country='FIN'; + +DROP DATABASE world; + +use test; + +CREATE TABLE t1 ( + a INT, + b INT NOT NULL, + c char(100), + KEY (b, c), + KEY (b, a, c) +) ENGINE=MyISAM +DEFAULT CHARSET = utf8; + +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); + +INSERT INTO t1 SELECT a + 10, b, c FROM t1; +INSERT INTO t1 SELECT a + 20, b, c FROM t1; +INSERT INTO t1 SELECT a + 40, b, c FROM t1; +INSERT INTO t1 SELECT a + 80, b, c FROM t1; +INSERT INTO t1 SELECT a + 160, b, c FROM t1; +INSERT INTO t1 SELECT a + 320, b, c FROM t1; +INSERT INTO t1 SELECT a + 640, b, c FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80; + +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; + +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; + +DROP TABLE t1; + --echo # End of 10.1 tests # diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 3075a060d67..80295473e9b 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -1678,6 +1678,91 @@ drop table t1; set use_stat_tables= @save_use_stat_tables; set @@histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +# +# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1) +# +set @@optimizer_use_condition_selectivity=2; +set names utf8; +CREATE DATABASE world; +use world; +CREATE TABLE Country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +CREATE TABLE City ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +CREATE TABLE CountryLanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +CREATE INDEX Name ON City(Name); +CREATE INDEX CountryPopulation ON City(Country,Population); +CREATE INDEX CountryName ON City(Country,Name); +set @@optimizer_use_condition_selectivity=2; +EXPLAIN +SELECT * FROM City WHERE Country='FIN'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City ref Country,CountryPopulation,CountryName Country 3 const 7 Using index condition +DROP DATABASE world; +use test; +CREATE TABLE t1 ( +a INT, +b INT NOT NULL, +c char(100), +KEY (b, c), +KEY (b, a, c) +) ENGINE=MyISAM +DEFAULT CHARSET = utf8; +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); +INSERT INTO t1 SELECT a + 10, b, c FROM t1; +INSERT INTO t1 SELECT a + 20, b, c FROM t1; +INSERT INTO t1 SELECT a + 40, b, c FROM t1; +INSERT INTO t1 SELECT a + 80, b, c FROM t1; +INSERT INTO t1 SELECT a + 160, b, c FROM t1; +INSERT INTO t1 SELECT a + 320, b, c FROM t1; +INSERT INTO t1 SELECT a + 640, b, c FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80; +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +a +2071 +2061 +2051 +2041 +2031 +2021 +2011 +2001 +1991 +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +DROP TABLE t1; # End of 10.1 tests set @@global.histogram_size=@save_histogram_size; set optimizer_switch=@save_optimizer_switch_for_selectivity_test; diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result index 161a04478fb..a9105308d42 100644 --- a/mysql-test/main/stat_tables.result +++ b/mysql-test/main/stat_tables.result @@ -800,7 +800,38 @@ col1 2004-01-01 2004-02-29 0000-10-31 +set @@sql_mode= @save_sql_mode; +set @@use_stat_tables=@save_use_stat_tables; +set @@histogram_size= @save_histogram_size; +set @@histogram_type=@save_histogram_type; +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; drop table t1; +# +# MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value +# +set names utf8; +create table t1 ( a varchar(255) character set utf8); +insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255)); +set use_stat_tables='preferably'; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +set @save_sql_mode= @@sql_mode; +set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; +update mysql.column_stats set min_value= REPEAT('ӥ',256) where db_name='test' and table_name='t1'; +Warnings: +Warning 1265 Data truncated for column 'min_value' at row 1 +set @@sql_mode= @save_sql_mode; +select length(a) from t1 where a=REPEAT('ӥ',255); +length(a) +510 +set names latin1; +set @@use_stat_tables=@save_use_stat_tables; +drop table t1; +# please keep this at the last +set @@global.histogram_size=@save_histogram_size; +# Start of 10.4 tests set histogram_size=0; # # MDEV-17255: New optimizer defaults and ANALYZE TABLE @@ -858,8 +889,4 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where drop table t1; set @@global.histogram_size=@save_histogram_size; -set @@histogram_size= @save_histogram_size; -set @@histogram_type=@save_histogram_type; -set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; -set @@sql_mode= @save_sql_mode; -set @@use_stat_tables=@save_use_stat_tables; +# End of 10.4 tests diff --git a/mysql-test/main/stat_tables.test b/mysql-test/main/stat_tables.test index 8dd9c361cd8..ca341a93b81 100644 --- a/mysql-test/main/stat_tables.test +++ b/mysql-test/main/stat_tables.test @@ -544,7 +544,40 @@ analyze table t1; update mysql.column_stats set min_value='2004-0-31123' where db_name='test' and table_name='t1'; select min_value from mysql.column_stats where db_name='test' and table_name='t1'; select * from t1; +set @@sql_mode= @save_sql_mode; +set @@use_stat_tables=@save_use_stat_tables; +set @@histogram_size= @save_histogram_size; +set @@histogram_type=@save_histogram_type; +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; drop table t1; + +--echo # +--echo # MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value +--echo # + +set names utf8; +create table t1 ( a varchar(255) character set utf8); +insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255)); + +set use_stat_tables='preferably'; +analyze table t1 persistent for all; + +set @save_sql_mode= @@sql_mode; +set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; +update mysql.column_stats set min_value= REPEAT('ӥ',256) where db_name='test' and table_name='t1'; +set @@sql_mode= @save_sql_mode; + +select length(a) from t1 where a=REPEAT('ӥ',255); + +set names latin1; +set @@use_stat_tables=@save_use_stat_tables; +drop table t1; + +--echo # please keep this at the last +set @@global.histogram_size=@save_histogram_size; + +--echo # Start of 10.4 tests + set histogram_size=0; --echo # @@ -590,9 +623,5 @@ select * from t1 where a=1 and b=3; drop table t1; set @@global.histogram_size=@save_histogram_size; -set @@histogram_size= @save_histogram_size; -set @@histogram_type=@save_histogram_type; -set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; -set @@sql_mode= @save_sql_mode; -set @@use_stat_tables=@save_use_stat_tables; +--echo # End of 10.4 tests diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result index c2f6981fa16..d504b531170 100644 --- a/mysql-test/main/stat_tables_innodb.result +++ b/mysql-test/main/stat_tables_innodb.result @@ -832,7 +832,38 @@ col1 2004-01-01 2004-02-29 0000-10-31 +set @@sql_mode= @save_sql_mode; +set @@use_stat_tables=@save_use_stat_tables; +set @@histogram_size= @save_histogram_size; +set @@histogram_type=@save_histogram_type; +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; drop table t1; +# +# MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value +# +set names utf8; +create table t1 ( a varchar(255) character set utf8); +insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255)); +set use_stat_tables='preferably'; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +set @save_sql_mode= @@sql_mode; +set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; +update mysql.column_stats set min_value= REPEAT('ӥ',256) where db_name='test' and table_name='t1'; +Warnings: +Warning 1265 Data truncated for column 'min_value' at row 1 +set @@sql_mode= @save_sql_mode; +select length(a) from t1 where a=REPEAT('ӥ',255); +length(a) +510 +set names latin1; +set @@use_stat_tables=@save_use_stat_tables; +drop table t1; +# please keep this at the last +set @@global.histogram_size=@save_histogram_size; +# Start of 10.4 tests set histogram_size=0; # # MDEV-17255: New optimizer defaults and ANALYZE TABLE @@ -890,11 +921,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where drop table t1; set @@global.histogram_size=@save_histogram_size; -set @@histogram_size= @save_histogram_size; -set @@histogram_type=@save_histogram_type; -set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; -set @@sql_mode= @save_sql_mode; -set @@use_stat_tables=@save_use_stat_tables; +# End of 10.4 tests set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/statement-expr.result b/mysql-test/main/statement-expr.result index c73ed2825ec..56b90e4a4cc 100644 --- a/mysql-test/main/statement-expr.result +++ b/mysql-test/main/statement-expr.result @@ -12,9 +12,9 @@ ROW(1, 7) IN (SELECT id, id1 FROM t1 WHERE id1= 8) 0 DROP TABLE t1; EXECUTE IMMEDIATE 'SELECT ?' USING (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions EXECUTE IMMEDIATE 'SELECT ?' USING (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1)' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions CREATE TABLE t1 (id INT); INSERT INTO t1 VALUES (10); CREATE PROCEDURE p1(a INT) BEGIN END; @@ -45,21 +45,21 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SIGNAL SQLSTATE '01000'; END' at line 3 PREPARE stmt FROM (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: PREPARE..FROM does not support subqueries or stored functions PREPARE stmt FROM EXISTS (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(SELECT * FROM t1)' at line 1 +ERROR 42000: PREPARE..FROM does not support subqueries or stored functions EXECUTE IMMEDIATE (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions EXECUTE IMMEDIATE EXISTS (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(SELECT * FROM t1)' at line 1 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions GET DIAGNOSTICS CONDITION (1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO' at line 1 GET DIAGNOSTICS CONDITION EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO' at line 1 PURGE BINARY LOGS BEFORE (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: PURGE..BEFORE does not support subqueries or stored functions PURGE BINARY LOGS BEFORE EXISTS (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(SELECT * FROM t1)' at line 1 +ERROR 42000: PURGE..BEFORE does not support subqueries or stored functions CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3); DO 1 IN (SELECT * FROM t1); diff --git a/mysql-test/main/statement-expr.test b/mysql-test/main/statement-expr.test index 7e968d4fb66..aab14963c54 100644 --- a/mysql-test/main/statement-expr.test +++ b/mysql-test/main/statement-expr.test @@ -15,9 +15,9 @@ SELECT ROW(1,7) IN (SELECT id, id1 FROM t1 WHERE id1= 8); EXECUTE IMMEDIATE 'SELECT ROW(1, 7) IN (SELECT id, id1 FROM t1 WHERE id1= 8)'; DROP TABLE t1; ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE 'SELECT ?' USING (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE 'SELECT ?' USING (SELECT * FROM t1); @@ -52,14 +52,14 @@ $$ DELIMITER ;$$ ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PREPARE stmt FROM (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PREPARE stmt FROM EXISTS (SELECT * FROM t1); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE EXISTS (SELECT * FROM t1); --error ER_PARSE_ERROR @@ -67,9 +67,9 @@ GET DIAGNOSTICS CONDITION (1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO; --error ER_PARSE_ERROR GET DIAGNOSTICS CONDITION EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO; ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PURGE BINARY LOGS BEFORE (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PURGE BINARY LOGS BEFORE EXISTS (SELECT * FROM t1); CREATE TABLE t1 (a INT); diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index ae75f5f354e..f2836d36c80 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -83,7 +83,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: PROCEDURE does not support subqueries or stored functions SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; ERROR 42S22: Unknown column 'a' in 'field list' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; @@ -1133,7 +1133,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 (a int, KEY(a)); HANDLER t1 OPEN; HANDLER t1 READ a=((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: HANDLER..READ does not support subqueries or stored functions HANDLER t1 CLOSE; drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index 5389e5da5cd..53773eb5e1e 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -56,7 +56,7 @@ SELECT 1 IN (SELECT 1); SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); -- error ER_PARSE_ERROR select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); --- error ER_PARSE_ERROR +-- error ER_SUBQUERIES_NOT_SUPPORTED SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -- error ER_BAD_FIELD_ERROR SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; @@ -623,7 +623,7 @@ set @a:=(SELECT a from t1); CREATE TABLE t1 (a int, KEY(a)); HANDLER t1 OPEN; --- error ER_PARSE_ERROR +-- error ER_SUBQUERIES_NOT_SUPPORTED HANDLER t1 READ a=((SELECT 1)); HANDLER t1 CLOSE; drop table t1; diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index d1f3c7a64e4..1cf1a3373a3 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -87,7 +87,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: PROCEDURE does not support subqueries or stored functions SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; ERROR 42S22: Unknown column 'a' in 'field list' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; @@ -1137,7 +1137,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 (a int, KEY(a)); HANDLER t1 OPEN; HANDLER t1 READ a=((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: HANDLER..READ does not support subqueries or stored functions HANDLER t1 CLOSE; drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index cf165182073..92ddbe34b6f 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -90,7 +90,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: PROCEDURE does not support subqueries or stored functions SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; ERROR 42S22: Unknown column 'a' in 'field list' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; @@ -1140,7 +1140,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 (a int, KEY(a)); HANDLER t1 OPEN; HANDLER t1 READ a=((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: HANDLER..READ does not support subqueries or stored functions HANDLER t1 CLOSE; drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 202ba61d0e5..a2788715194 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -86,7 +86,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: PROCEDURE does not support subqueries or stored functions SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; ERROR 42S22: Unknown column 'a' in 'field list' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; @@ -1136,7 +1136,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 (a int, KEY(a)); HANDLER t1 OPEN; HANDLER t1 READ a=((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: HANDLER..READ does not support subqueries or stored functions HANDLER t1 CLOSE; drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 2019555e237..f5c5a1dead6 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -89,7 +89,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: PROCEDURE does not support subqueries or stored functions SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; ERROR 42S22: Unknown column 'a' in 'field list' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; @@ -1139,7 +1139,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 (a int, KEY(a)); HANDLER t1 OPEN; HANDLER t1 READ a=((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: HANDLER..READ does not support subqueries or stored functions HANDLER t1 CLOSE; drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index 2f84f7cd5b0..bef256f789f 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -86,7 +86,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PROCEDURE ANALYSE(1))' at line 1 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: PROCEDURE does not support subqueries or stored functions SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; ERROR 42S22: Unknown column 'a' in 'field list' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; @@ -1136,7 +1136,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist CREATE TABLE t1 (a int, KEY(a)); HANDLER t1 OPEN; HANDLER t1 READ a=((SELECT 1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1 +ERROR 42000: HANDLER..READ does not support subqueries or stored functions HANDLER t1 CLOSE; drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_notembedded.result b/mysql-test/main/subselect_notembedded.result index 9153706fc27..23a35a28bf4 100644 --- a/mysql-test/main/subselect_notembedded.result +++ b/mysql-test/main/subselect_notembedded.result @@ -1,5 +1,5 @@ purge master logs before (select adddate(current_timestamp(), interval -4 day)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'select adddate(current_timestamp(), interval -4 day))' at line 1 +ERROR 42000: PURGE..BEFORE does not support subqueries or stored functions purge master logs before adddate(current_timestamp(), interval -4 day); drop table if exists t1; create table t1(a int,b int,key(a),key(b)); diff --git a/mysql-test/main/subselect_notembedded.test b/mysql-test/main/subselect_notembedded.test index dcda71c767f..f6e383592bc 100644 --- a/mysql-test/main/subselect_notembedded.test +++ b/mysql-test/main/subselect_notembedded.test @@ -4,7 +4,7 @@ # BUG#10308: purge log with subselect # Bug#28553: mysqld crash in "purge master log before(select time from information_schema)" # ---error 1064 +--error ER_SUBQUERIES_NOT_SUPPORTED purge master logs before (select adddate(current_timestamp(), interval -4 day)); purge master logs before adddate(current_timestamp(), interval -4 day); diff --git a/mysql-test/main/system_mysql_db.result b/mysql-test/main/system_mysql_db.result index e7cd9bc628b..6a243ca0c43 100644 --- a/mysql-test/main/system_mysql_db.result +++ b/mysql-test/main/system_mysql_db.result @@ -124,14 +124,14 @@ show create table servers; Table Create Table servers CREATE TABLE `servers` ( `Server_name` char(64) NOT NULL DEFAULT '', - `Host` char(64) NOT NULL DEFAULT '', + `Host` varchar(2048) NOT NULL DEFAULT '', `Db` char(64) NOT NULL DEFAULT '', `Username` char(80) NOT NULL DEFAULT '', `Password` char(64) NOT NULL DEFAULT '', `Port` int(4) NOT NULL DEFAULT 0, `Socket` char(64) NOT NULL DEFAULT '', `Wrapper` char(64) NOT NULL DEFAULT '', - `Owner` char(64) NOT NULL DEFAULT '', + `Owner` varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (`Server_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table' show create table proc; diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result index ad7341a2a5c..bc235227b42 100644 --- a/mysql-test/main/system_mysql_db_fix40123.result +++ b/mysql-test/main/system_mysql_db_fix40123.result @@ -162,14 +162,14 @@ show create table servers; Table Create Table servers CREATE TABLE `servers` ( `Server_name` char(64) NOT NULL DEFAULT '', - `Host` char(64) NOT NULL DEFAULT '', + `Host` varchar(2048) NOT NULL DEFAULT '', `Db` char(64) NOT NULL DEFAULT '', `Username` char(80) NOT NULL DEFAULT '', `Password` char(64) NOT NULL DEFAULT '', `Port` int(4) NOT NULL DEFAULT 0, `Socket` char(64) NOT NULL DEFAULT '', `Wrapper` char(64) NOT NULL DEFAULT '', - `Owner` char(64) NOT NULL DEFAULT '', + `Owner` varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (`Server_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table' show create table proc; diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result index 1518cee174e..54bf9c36491 100644 --- a/mysql-test/main/table_value_constr.result +++ b/mysql-test/main/table_value_constr.result @@ -2586,3 +2586,16 @@ create view v1 as union ( values (5), (7), (1), (3), (4) order by 2 limit 2 ); ERROR 42S22: Unknown column '2' in 'order clause' +# +# MDEV-20229: view defined as select using +# CTE with named columns defined as TVC +# +create view v1 as with t(a) as (values (2), (1)) select a from t; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(a) as (values (2),(1))select `t`.`a` AS `a` from `t` latin1 latin1_swedish_ci +select * from v1; +a +2 +1 +drop view v1; diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index 6b89816cc0c..4464eb7b77b 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -1316,3 +1316,13 @@ create view v1 as ( values (5), (7), (1), (3), (4) limit 2 offset 1 ) union ( values (5), (7), (1), (3), (4) order by 2 limit 2 ); + +--echo # +--echo # MDEV-20229: view defined as select using +--echo # CTE with named columns defined as TVC +--echo # + +create view v1 as with t(a) as (values (2), (1)) select a from t; +show create view v1; +select * from v1; +drop view v1; diff --git a/mysql-test/suite/compat/oracle/r/ps.result b/mysql-test/suite/compat/oracle/r/ps.result index 73aa04b972c..818c97b06ab 100644 --- a/mysql-test/suite/compat/oracle/r/ps.result +++ b/mysql-test/suite/compat/oracle/r/ps.result @@ -47,7 +47,7 @@ EXECUTE stmt USING @a, @b; # PREPARE stmt FROM 'SELECT :1 FROM DUAL'; EXECUTE stmt USING (SELECT 1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1)' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions DEALLOCATE PREPARE stmt; CREATE FUNCTION f1() RETURN VARCHAR AS @@ -155,7 +155,7 @@ DROP TABLE t1; # Testing disallowed expressions in USING # EXECUTE IMMEDIATE 'SELECT :1 FROM DUAL' USING (SELECT 1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1)' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions CREATE FUNCTION f1() RETURN VARCHAR AS BEGIN @@ -182,9 +182,9 @@ ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2 PREPARE stmt FROM _latin1'SELECT 1 AS c FROM ' || _latin2 'DUAL'; ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_operator_oracle' EXECUTE IMMEDIATE (SELECT 'SELECT 1'); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 'SELECT 1')' at line 1 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions PREPARE stmt FROM (SELECT 'SELECT 1'); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 'SELECT 1')' at line 1 +ERROR 42000: PREPARE..FROM does not support subqueries or stored functions EXECUTE IMMEDIATE a; ERROR 42S22: Unknown column 'a' in 'field list' PREPARE stmt FROM a; diff --git a/mysql-test/suite/compat/oracle/r/statement-expr.result b/mysql-test/suite/compat/oracle/r/statement-expr.result index ea3bd5232d3..ab4dce9ad74 100644 --- a/mysql-test/suite/compat/oracle/r/statement-expr.result +++ b/mysql-test/suite/compat/oracle/r/statement-expr.result @@ -13,9 +13,9 @@ ROW(1, 7) IN (SELECT id, id1 FROM t1 WHERE id1= 8) 0 DROP TABLE t1; EXECUTE IMMEDIATE 'SELECT ?' USING (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions EXECUTE IMMEDIATE 'SELECT ?' USING (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1)' at line 1 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions CREATE TABLE t1 (id INT); INSERT INTO t1 VALUES (10); CREATE PROCEDURE p1(a INT) AS BEGIN NULL; END; @@ -47,21 +47,21 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SIGNAL SQLSTATE '01000'; END' at line 3 PREPARE stmt FROM (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: PREPARE..FROM does not support subqueries or stored functions PREPARE stmt FROM EXISTS (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(SELECT * FROM t1)' at line 1 +ERROR 42000: PREPARE..FROM does not support subqueries or stored functions EXECUTE IMMEDIATE (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions EXECUTE IMMEDIATE EXISTS (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(SELECT * FROM t1)' at line 1 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions GET DIAGNOSTICS CONDITION (1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO' at line 1 GET DIAGNOSTICS CONDITION EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO' at line 1 PURGE BINARY LOGS BEFORE (1 IN (SELECT * FROM t1)); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM t1))' at line 1 +ERROR 42000: PURGE..BEFORE does not support subqueries or stored functions PURGE BINARY LOGS BEFORE EXISTS (SELECT * FROM t1); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(SELECT * FROM t1)' at line 1 +ERROR 42000: PURGE..BEFORE does not support subqueries or stored functions CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3); DO 1 IN (SELECT * FROM t1); diff --git a/mysql-test/suite/compat/oracle/t/ps.test b/mysql-test/suite/compat/oracle/t/ps.test index 357b50e0eab..39770b48ded 100644 --- a/mysql-test/suite/compat/oracle/t/ps.test +++ b/mysql-test/suite/compat/oracle/t/ps.test @@ -33,7 +33,7 @@ EXECUTE stmt USING @a, @b; --echo # PREPARE stmt FROM 'SELECT :1 FROM DUAL'; ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE stmt USING (SELECT 1); DEALLOCATE PREPARE stmt; @@ -153,7 +153,7 @@ DROP TABLE t1; --echo # Testing disallowed expressions in USING --echo # ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE 'SELECT :1 FROM DUAL' USING (SELECT 1); DELIMITER $$; @@ -189,9 +189,9 @@ EXECUTE IMMEDIATE _latin1'SELECT 1 AS c FROM ' || _latin2 'DUAL'; --error ER_CANT_AGGREGATE_2COLLATIONS PREPARE stmt FROM _latin1'SELECT 1 AS c FROM ' || _latin2 'DUAL'; ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE (SELECT 'SELECT 1'); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PREPARE stmt FROM (SELECT 'SELECT 1'); --error ER_BAD_FIELD_ERROR diff --git a/mysql-test/suite/compat/oracle/t/statement-expr.test b/mysql-test/suite/compat/oracle/t/statement-expr.test index f4a6a25eff3..1caab623524 100644 --- a/mysql-test/suite/compat/oracle/t/statement-expr.test +++ b/mysql-test/suite/compat/oracle/t/statement-expr.test @@ -17,9 +17,9 @@ SELECT ROW(1,7) IN (SELECT id, id1 FROM t1 WHERE id1= 8); EXECUTE IMMEDIATE 'SELECT ROW(1, 7) IN (SELECT id, id1 FROM t1 WHERE id1= 8)'; DROP TABLE t1; ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE 'SELECT ?' USING (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE 'SELECT ?' USING (SELECT * FROM t1); @@ -57,14 +57,14 @@ $$ DELIMITER ;$$ ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PREPARE stmt FROM (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PREPARE stmt FROM EXISTS (SELECT * FROM t1); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED EXECUTE IMMEDIATE EXISTS (SELECT * FROM t1); --error ER_PARSE_ERROR @@ -72,9 +72,9 @@ GET DIAGNOSTICS CONDITION (1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO; --error ER_PARSE_ERROR GET DIAGNOSTICS CONDITION EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO; ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PURGE BINARY LOGS BEFORE (1 IN (SELECT * FROM t1)); ---error ER_PARSE_ERROR +--error ER_SUBQUERIES_NOT_SUPPORTED PURGE BINARY LOGS BEFORE EXISTS (SELECT * FROM t1); CREATE TABLE t1 (a INT); diff --git a/mysql-test/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index 746faf49873..d92d3495cb8 100644 --- a/mysql-test/suite/encryption/disabled.def +++ b/mysql-test/suite/encryption/disabled.def @@ -12,4 +12,3 @@ innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably -innodb-redo-badkey : MDEV-13893/MDEV-12699 fix recovery of corrupted pages diff --git a/mysql-test/suite/encryption/r/innodb-redo-badkey.result b/mysql-test/suite/encryption/r/innodb-redo-badkey.result index 9104cac18da..38de3f53476 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-badkey.result +++ b/mysql-test/suite/encryption/r/innodb-redo-badkey.result @@ -6,7 +6,7 @@ call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t1\\.ibd\\[page i call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]"); call mtr.add_suppression("InnoDB: Plugin initialization aborted"); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); -# Restart mysqld --file-key-management-filename=keys2.txt +# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # Wait max 10 min for key encryption threads to encrypt all spaces SET GLOBAL innodb_file_per_table = ON; create table t1(a int not null primary key auto_increment, c char(250), b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes encryption_key_id=4; @@ -30,9 +30,9 @@ insert into t3 (c,b) values (repeat('secret9',20), repeat('secre10',6000)); insert into t4 (c,b) values (repeat('secre11',20), repeat('secre12',6000)); COMMIT; # Kill the server -# restart +# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # Kill the server -# Restart mysqld --innodb-force-recovery=1 +# restart: --innodb-force-recovery=1 # Kill the server -# Restart mysqld --file-key-management-filename=keys2.txt +# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt drop table t1, t2,t3,t4; diff --git a/mysql-test/suite/encryption/t/innodb-redo-badkey.test b/mysql-test/suite/encryption/t/innodb-redo-badkey.test index 513e8724586..b1e1be66a7a 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-badkey.test +++ b/mysql-test/suite/encryption/t/innodb-redo-badkey.test @@ -12,7 +12,6 @@ call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed f call mtr.add_suppression("InnoDB: Plugin initialization aborted"); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); ---echo # Restart mysqld --file-key-management-filename=keys2.txt -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- source include/restart_mysqld.inc @@ -68,7 +67,6 @@ let $cleanup= drop table t1,t2,t3,t4; --let CLEANUP_IF_CHECKPOINT= $cleanup; --source ../../suite/innodb/include/no_checkpoint_end.inc ---echo # restart --error 1 -- source include/start_mysqld.inc --source include/kill_mysqld.inc @@ -77,14 +75,12 @@ let $cleanup= drop table t1,t2,t3,t4; # Now test with innodb-force-recovery=1 i.e. ignore corrupt pages # ---echo # Restart mysqld --innodb-force-recovery=1 -- let $restart_parameters=--innodb-force-recovery=1 --error 1 -- source include/start_mysqld.inc --source include/kill_mysqld.inc ---echo # Restart mysqld --file-key-management-filename=keys2.txt -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- source include/start_mysqld.inc diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result index 31160f8a3ec..f5f134bd7a7 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result @@ -158,8 +158,8 @@ def mysql roles_mapping Host 1 '' NO char 60 180 NULL NULL NULL utf8 utf8_bin ch def mysql roles_mapping Role 3 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI select,insert,update,references NEVER NULL def mysql roles_mapping User 2 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI select,insert,update,references NEVER NULL def mysql servers Db 3 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL -def mysql servers Host 2 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL -def mysql servers Owner 9 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL +def mysql servers Host 2 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) select,insert,update,references NEVER NULL +def mysql servers Owner 9 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select,insert,update,references NEVER NULL def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) select,insert,update,references NEVER NULL def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NEVER NULL @@ -485,14 +485,14 @@ NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp 3.0000 mysql roles_mapping Role char 80 240 utf8 utf8_bin char(80) 3.0000 mysql roles_mapping Admin_option enum 1 3 utf8 utf8_general_ci enum('N','Y') 3.0000 mysql servers Server_name char 64 192 utf8 utf8_general_ci char(64) -3.0000 mysql servers Host char 64 192 utf8 utf8_general_ci char(64) +3.0000 mysql servers Host varchar 2048 6144 utf8 utf8_general_ci varchar(2048) 3.0000 mysql servers Db char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Username char 80 240 utf8 utf8_general_ci char(80) 3.0000 mysql servers Password char 64 192 utf8 utf8_general_ci char(64) NULL mysql servers Port int NULL NULL NULL NULL int(4) 3.0000 mysql servers Socket char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Wrapper char 64 192 utf8 utf8_general_ci char(64) -3.0000 mysql servers Owner char 64 192 utf8 utf8_general_ci char(64) +3.0000 mysql servers Owner varchar 512 1536 utf8 utf8_general_ci varchar(512) NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6) 1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext NULL mysql slow_log query_time time NULL NULL NULL NULL time(6) diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result index 6ad671a54c8..0a375faf072 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result @@ -144,8 +144,8 @@ def mysql roles_mapping Host 1 '' NO char 60 180 NULL NULL NULL utf8 utf8_bin ch def mysql roles_mapping Role 3 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI NEVER NULL def mysql roles_mapping User 2 '' NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI NEVER NULL def mysql servers Db 3 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL -def mysql servers Host 2 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL -def mysql servers Owner 9 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL +def mysql servers Host 2 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) NEVER NULL +def mysql servers Owner 9 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) NEVER NULL def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) NEVER NULL def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) NEVER NULL def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI NEVER NULL @@ -468,14 +468,14 @@ NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp 3.0000 mysql roles_mapping Role char 80 240 utf8 utf8_bin char(80) 3.0000 mysql roles_mapping Admin_option enum 1 3 utf8 utf8_general_ci enum('N','Y') 3.0000 mysql servers Server_name char 64 192 utf8 utf8_general_ci char(64) -3.0000 mysql servers Host char 64 192 utf8 utf8_general_ci char(64) +3.0000 mysql servers Host varchar 2048 6144 utf8 utf8_general_ci varchar(2048) 3.0000 mysql servers Db char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Username char 80 240 utf8 utf8_general_ci char(80) 3.0000 mysql servers Password char 64 192 utf8 utf8_general_ci char(64) NULL mysql servers Port int NULL NULL NULL NULL int(4) 3.0000 mysql servers Socket char 64 192 utf8 utf8_general_ci char(64) 3.0000 mysql servers Wrapper char 64 192 utf8 utf8_general_ci char(64) -3.0000 mysql servers Owner char 64 192 utf8 utf8_general_ci char(64) +3.0000 mysql servers Owner varchar 512 1536 utf8 utf8_general_ci varchar(512) NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6) 1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext NULL mysql slow_log query_time time NULL NULL NULL NULL time(6) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 96a31ee2906..0052c8e7557 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -10,7 +10,6 @@ # ############################################################################## -MW-286 : MDEV-19992 Galera test failure on MW-286 GCF-1081 : MDEV-18283 Galera test failure on galera.GCF-1081 MW-329 : MDEV-19962 Galera test failure on MW-329 MW-360 : needs rewrite to be MariaDB gtid compatible @@ -36,11 +35,11 @@ galera_many_tables_nopk : MDEV-18182 Galera test failure on galera.galera_many_t galera_migrate : MariaDB does not support START SLAVE USER galera_split_brain : MDEV-18280 Galera test failure on galera_split_brain and galera_kill_nochanges galera_ssl_upgrade : MDEV-19950 Galera test failure on galera_ssl_upgrade +galera_var_node_address : MDEV-20485 Galera test failure +galera_var_notify_cmd : MDEV-20600 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_var_node_address : MDEV-20485 Galera test failure on galera.galera_var_node_address galera_wan : MDEV-17259 Test failure on galera.galera_wan 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. partition : MDEV-19958 Galera test failure on galera.partition query_cache: MDEV-15805 Test failure on galera.query_cache -galera_var_notify_cmd : MDEV-20600 Galera test galera_var_notify_cmd causes hang diff --git a/mysql-test/suite/galera/r/MW-336.result b/mysql-test/suite/galera/r/MW-336.result index 2d0ebdc95b0..09c58d0cafe 100644 --- a/mysql-test/suite/galera/r/MW-336.result +++ b/mysql-test/suite/galera/r/MW-336.result @@ -8,10 +8,6 @@ SET GLOBAL wsrep_slave_threads = 1; connection node_2; INSERT INTO t1 VALUES (1); connection node_1; -SET SESSION wsrep_sync_wait=15; -SELECT COUNT(*) FROM t1; -COUNT(*) -1 SET GLOBAL wsrep_slave_threads = 10; # Set slave threads to 10 step 2 SET GLOBAL wsrep_slave_threads = 20; @@ -45,9 +41,11 @@ INSERT INTO t1 VALUES (17); INSERT INTO t1 VALUES (18); INSERT INTO t1 VALUES (19); INSERT INTO t1 VALUES (20); +INSERT INTO t1 VALUES (21); +INSERT INTO t1 VALUES (22); connection node_1; SELECT COUNT(*) FROM t1; COUNT(*) -21 +23 SET GLOBAL wsrep_slave_threads = 1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result b/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result new file mode 100644 index 00000000000..e44a925baf4 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result @@ -0,0 +1,21 @@ +connection node_2; +connection node_1; +connection node_1; +CREATE TABLE t1 (id INT PRIMARY KEY, val INT); +INSERT INTO t1 VALUES (1, 1); +connection node_2; +START TRANSACTION; +SET DEBUG_SYNC = 'wsrep_after_statement_enter SIGNAL blocked WAIT_FOR continue'; +UPDATE t1 SET val=2 WHERE id=1; +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +SET DEBUG_SYNC = 'now WAIT_FOR blocked'; +connection node_1; +UPDATE t1 SET val=3 WHERE id=1; +connection node_2a; +SET DEBUG_SYNC = 'now SIGNAL continue'; +connection node_2; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +COMMIT; +SET DEBUG_SYNC = 'RESET'; +connection node_1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-336.test b/mysql-test/suite/galera/t/MW-336.test index ee57457b0e7..0e92094da6c 100644 --- a/mysql-test/suite/galera/t/MW-336.test +++ b/mysql-test/suite/galera/t/MW-336.test @@ -23,14 +23,12 @@ SET GLOBAL wsrep_slave_threads = 1; INSERT INTO t1 VALUES (1); --connection node_1 -SET SESSION wsrep_sync_wait=15; -SELECT COUNT(*) FROM t1; - SET GLOBAL wsrep_slave_threads = 10; +# Note that above insert could be handled by one of the slave threads --echo # Set slave threads to 10 step 2 ---let $wait_condition = SELECT VARIABLE_VALUE = 10 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; ---let $wait_condition_on_error_output = SELECT COUNT(*), 10 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist +--let $wait_condition = SELECT VARIABLE_VALUE >= 9 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; +--let $wait_condition_on_error_output = SELECT COUNT(*), 9 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist --source include/wait_condition_with_debug.inc SET GLOBAL wsrep_slave_threads = 20; @@ -73,6 +71,8 @@ INSERT INTO t1 VALUES (17); INSERT INTO t1 VALUES (18); INSERT INTO t1 VALUES (19); INSERT INTO t1 VALUES (20); +INSERT INTO t1 VALUES (21); +INSERT INTO t1 VALUES (22); --connection node_1 SELECT COUNT(*) FROM t1; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test new file mode 100644 index 00000000000..b1fe3e64cd8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test @@ -0,0 +1,37 @@ +# +# This test checks that the client gets an error for a BF abort, +# specifically when it gets detected inside the wsrep_after_statement hook +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc +--source include/have_debug_sync.inc + +--connection node_1 +CREATE TABLE t1 (id INT PRIMARY KEY, val INT); +INSERT INTO t1 VALUES (1, 1); + +--connection node_2 +START TRANSACTION; +SET DEBUG_SYNC = 'wsrep_after_statement_enter SIGNAL blocked WAIT_FOR continue'; +--send UPDATE t1 SET val=2 WHERE id=1 + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +SET DEBUG_SYNC = 'now WAIT_FOR blocked'; + +--connection node_1 +# cause BF abort on other node +UPDATE t1 SET val=3 WHERE id=1; + +--connection node_2a +SET DEBUG_SYNC = 'now SIGNAL continue'; + +--connection node_2 +# check we get BF aborted +--error ER_LOCK_DEADLOCK +--reap +COMMIT; +SET DEBUG_SYNC = 'RESET'; + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result b/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result index 552805110b1..1bbc577ed93 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result @@ -204,5 +204,32 @@ connection truncate; disconnect truncate; connection default; DROP TABLE t1, t2; +# +# MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf +# on table with virtual columns and indexes +# +set @saved_dbug= @@global.debug_dbug; +set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; +create table t1 ( +pk serial, vb tinyblob as (b) virtual, b tinyblob, +primary key(pk), index (vb(64))) +engine innodb; +insert ignore into t1 (b) values ('foo'); +select * into outfile 'load.data' from t1; +load data infile 'load.data' replace into table t1; +set debug_sync= "now WAIT_FOR latch_released"; +set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; +drop table t1; +set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table"; +create table t1 ( +pk serial, vb tinyblob as (b) virtual, b tinyblob, +primary key(pk), index (vb(64))) +engine innodb; +insert ignore into t1 (b) values ('foo'); +select * into outfile 'load.data' from t1; +load data infile 'load.data' replace into table t1; +set debug_sync= "now WAIT_FOR got_no_such_table"; +set global debug_dbug= @saved_dbug; +drop table t1; set debug_sync=reset; SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; diff --git a/mysql-test/suite/innodb/t/purge_secondary_mdev-16222.opt b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.opt index a1207721427..a1207721427 100644 --- a/mysql-test/suite/innodb/t/purge_secondary_mdev-16222.opt +++ b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.opt diff --git a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test index 8568c66eccc..04ab8a88488 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test @@ -259,6 +259,54 @@ disconnect truncate; connection default; DROP TABLE t1, t2; +--echo # +--echo # MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf +--echo # on table with virtual columns and indexes +--echo # + +--let $datadir= `select @@datadir` +set @saved_dbug= @@global.debug_dbug; +set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; + +create table t1 ( + pk serial, vb tinyblob as (b) virtual, b tinyblob, + primary key(pk), index (vb(64))) +engine innodb; + +insert ignore into t1 (b) values ('foo'); + +select * into outfile 'load.data' from t1; +load data infile 'load.data' replace into table t1; + +set debug_sync= "now WAIT_FOR latch_released"; +set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; +drop table t1; +--remove_file $datadir/test/load.data + +set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table"; + +create table t1 ( + pk serial, vb tinyblob as (b) virtual, b tinyblob, + primary key(pk), index (vb(64))) +engine innodb; + +insert ignore into t1 (b) values ('foo'); + +select * into outfile 'load.data' from t1; +load data infile 'load.data' replace into table t1; + +set debug_sync= "now WAIT_FOR got_no_such_table"; + +# FIXME: Race condition here: +# 1. purge thread goes into sending got_no_such_table +# 2. test thread finishes debug_sync= "RESET" below +# 3. purge thread sends got_no_such_table +set global debug_dbug= @saved_dbug; + +# cleanup +drop table t1; +--remove_file $datadir/test/load.data + --source include/wait_until_count_sessions.inc set debug_sync=reset; SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; 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 93bbf6ee193..52051eff0bd 100644 --- a/mysql-test/suite/innodb/r/instant_alter_index_rename.result +++ b/mysql-test/suite/innodb/r/instant_alter_index_rename.result @@ -176,3 +176,10 @@ check table rename_column_and_index; Table Op Msg_type Msg_text test.rename_column_and_index check status OK drop table rename_column_and_index; +# +# MDEV-19189: ASAN memcpy-param-overlap in fill_alter_inplace_info upon adding indexes +# +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; diff --git a/mysql-test/suite/innodb/r/purge_secondary_mdev-16222.result b/mysql-test/suite/innodb/r/purge_secondary_mdev-16222.result deleted file mode 100644 index 48b948c34aa..00000000000 --- a/mysql-test/suite/innodb/r/purge_secondary_mdev-16222.result +++ /dev/null @@ -1,30 +0,0 @@ -# -# MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes -# -set @saved_frequency= @@global.innodb_purge_rseg_truncate_frequency; -set global innodb_purge_rseg_truncate_frequency= 1; -set @saved_dbug= @@global.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; -create table t1 ( -pk serial, vb tinyblob as (b) virtual, b tinyblob, -primary key(pk), index (vb(64))) -engine innodb; -insert ignore into t1 (b) values ('foo'); -select * into outfile 'load.data' from t1; -load data infile 'load.data' replace into table t1; -set debug_sync= "now WAIT_FOR latch_released"; -set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; -drop table t1; -set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table"; -create table t1 ( -pk serial, vb tinyblob as (b) virtual, b tinyblob, -primary key(pk), index (vb(64))) -engine innodb; -insert ignore into t1 (b) values ('foo'); -select * into outfile 'load.data' from t1; -load data infile 'load.data' replace into table t1; -set debug_sync= "now WAIT_FOR got_no_such_table"; -set global debug_dbug= @saved_dbug; -drop table t1; -set global innodb_purge_rseg_truncate_frequency= @saved_frequency; -set debug_sync= "RESET"; 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 3150503c815..3a608a00837 100644 --- a/mysql-test/suite/innodb/t/instant_alter_index_rename.test +++ b/mysql-test/suite/innodb/t/instant_alter_index_rename.test @@ -184,3 +184,13 @@ alter table rename_column_and_index show create table rename_column_and_index; check table rename_column_and_index; drop table rename_column_and_index; + + +--echo # +--echo # MDEV-19189: ASAN memcpy-param-overlap in fill_alter_inplace_info upon adding indexes +--echo # + +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; diff --git a/mysql-test/suite/innodb/t/purge_secondary_mdev-16222.test b/mysql-test/suite/innodb/t/purge_secondary_mdev-16222.test deleted file mode 100644 index 475eb92ed12..00000000000 --- a/mysql-test/suite/innodb/t/purge_secondary_mdev-16222.test +++ /dev/null @@ -1,53 +0,0 @@ ---source include/have_debug.inc ---source include/have_innodb.inc - ---echo # ---echo # MDEV-16222 Assertion `0' failed in row_purge_remove_sec_if_poss_leaf on table with virtual columns and indexes ---echo # - ---let $datadir= `select @@datadir` -set @saved_frequency= @@global.innodb_purge_rseg_truncate_frequency; -set global innodb_purge_rseg_truncate_frequency= 1; -set @saved_dbug= @@global.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; - -create table t1 ( - pk serial, vb tinyblob as (b) virtual, b tinyblob, - primary key(pk), index (vb(64))) -engine innodb; - -insert ignore into t1 (b) values ('foo'); - -select * into outfile 'load.data' from t1; -load data infile 'load.data' replace into table t1; - -set debug_sync= "now WAIT_FOR latch_released"; -set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; -drop table t1; ---remove_file $datadir/test/load.data - -set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table"; - -create table t1 ( - pk serial, vb tinyblob as (b) virtual, b tinyblob, - primary key(pk), index (vb(64))) -engine innodb; - -insert ignore into t1 (b) values ('foo'); - -select * into outfile 'load.data' from t1; -load data infile 'load.data' replace into table t1; - -set debug_sync= "now WAIT_FOR got_no_such_table"; -# FIXME: Racing condition here: -# 1. purge thread goes into sending got_no_such_table -# 2. test thread finishes debug_sync= "RESET" below -# 3. purge thread sends got_no_such_table -set global debug_dbug= @saved_dbug; - -# cleanup -drop table t1; ---remove_file $datadir/test/load.data - -set global innodb_purge_rseg_truncate_frequency= @saved_frequency; -set debug_sync= "RESET"; diff --git a/mysql-test/suite/innodb_fts/r/concurrent_insert.result b/mysql-test/suite/innodb_fts/r/concurrent_insert.result index 5644075038a..9871d43119a 100644 --- a/mysql-test/suite/innodb_fts/r/concurrent_insert.result +++ b/mysql-test/suite/innodb_fts/r/concurrent_insert.result @@ -9,3 +9,26 @@ disconnect dml; connection default; SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; +# +# MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX +# +CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB; +INSERT INTO t2 VALUES('mariadb'); +connection default; +SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang'; +SET DEBUG_SYNC= 'fts_instrument_sync_request + SIGNAL drop_index_start WAIT_FOR sync_op'; +INSERT INTO t1 VALUES('Keyword'); +connect con1,localhost,root,,,; +SET DEBUG_SYNC='now WAIT_FOR drop_index_start'; +SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index'; +ALTER TABLE t2 drop index idx1; +connection default; +set DEBUG_SYNC= 'now SIGNAL fts_drop_index'; +connection con1; +SET global DEBUG_DBUG=RESET; +drop table t1, t2; +connection default; +set DEBUG_SYNC=RESET; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result index bc9548b7d8e..0bcea9165b1 100644 --- a/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result @@ -700,15 +700,21 @@ count(*) DROP TABLE t1; "----------Test27---------" CREATE TABLE t1 (id INT,char_column VARCHAR(60)); +CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB; +ALTER TABLE t2 DROP a; SET @@autocommit=0; CREATE FULLTEXT INDEX i ON t1 (char_column); INSERT INTO t1 values (1,'aaa'); -"restart server..." -# Restart the server ---source include/restart_mysqld.inc -DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb') +# restart +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`FTS_DOC_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); SET @@autocommit=1; -DROP TABLE t1; +DROP TABLE t1, t2; "----------Test28---------" drop table if exists `fts_test`; Warnings: diff --git a/mysql-test/suite/innodb_fts/t/concurrent_insert.test b/mysql-test/suite/innodb_fts/t/concurrent_insert.test index e5d61cd8b05..77097d44dc5 100644 --- a/mysql-test/suite/innodb_fts/t/concurrent_insert.test +++ b/mysql-test/suite/innodb_fts/t/concurrent_insert.test @@ -18,3 +18,34 @@ reap; SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; + +--echo # +--echo # MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX +--echo # + +CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB; +INSERT INTO t2 VALUES('mariadb'); + +connection default; +SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang'; +SET DEBUG_SYNC= 'fts_instrument_sync_request + SIGNAL drop_index_start WAIT_FOR sync_op'; +send INSERT INTO t1 VALUES('Keyword'); + +connect(con1,localhost,root,,,); +SET DEBUG_SYNC='now WAIT_FOR drop_index_start'; +SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index'; +send ALTER TABLE t2 drop index idx1; + +connection default; +reap; +set DEBUG_SYNC= 'now SIGNAL fts_drop_index'; + +connection con1; +reap; +SET global DEBUG_DBUG=RESET; +drop table t1, t2; +connection default; +set DEBUG_SYNC=RESET; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test index e3d350b34a3..4563d6dde77 100644 --- a/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test @@ -670,15 +670,16 @@ DROP TABLE t1; --echo "----------Test27---------" #27 Crash after server restart CREATE TABLE t1 (id INT,char_column VARCHAR(60)); +CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB; +ALTER TABLE t2 DROP a; SET @@autocommit=0; CREATE FULLTEXT INDEX i ON t1 (char_column); INSERT INTO t1 values (1,'aaa'); -echo "restart server..." -# Restart the server --source include/restart_mysqld.inc +SHOW CREATE TABLE t2; DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); SET @@autocommit=1; -DROP TABLE t1; +DROP TABLE t1, t2; --echo "----------Test28---------" drop table if exists `fts_test`; diff --git a/mysql-test/suite/maria/icp.result b/mysql-test/suite/maria/icp.result index 110718c0a4d..ac51c5f6607 100644 --- a/mysql-test/suite/maria/icp.result +++ b/mysql-test/suite/maria/icp.result @@ -167,7 +167,7 @@ WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' ORDER BY ts DESC LIMIT 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using where +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where DROP TABLE t1; # diff --git a/mysql-test/suite/mariabackup/extra_lsndir_stream.result b/mysql-test/suite/mariabackup/extra_lsndir_stream.result new file mode 100644 index 00000000000..a25c45a13d1 --- /dev/null +++ b/mysql-test/suite/mariabackup/extra_lsndir_stream.result @@ -0,0 +1,2 @@ +xtrabackup_checkpoints +xtrabackup_info diff --git a/mysql-test/suite/mariabackup/extra_lsndir_stream.test b/mysql-test/suite/mariabackup/extra_lsndir_stream.test new file mode 100644 index 00000000000..97023cb179d --- /dev/null +++ b/mysql-test/suite/mariabackup/extra_lsndir_stream.test @@ -0,0 +1,7 @@ +let $extra_lsndir=$MYSQLTEST_VARDIR/tmp/extra_lsndir; +mkdir $extra_lsndir; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --stream=xbstream --extra-lsndir=$extra_lsndir > /dev/null; +--enable_result_log +list_files $extra_lsndir; +rmdir $extra_lsndir; diff --git a/mysql-test/suite/mariabackup/mdev-18438.result b/mysql-test/suite/mariabackup/mdev-18438.result new file mode 100644 index 00000000000..ab3b81bd484 --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-18438.result @@ -0,0 +1 @@ +stream.xb diff --git a/mysql-test/suite/mariabackup/mdev-18438.test b/mysql-test/suite/mariabackup/mdev-18438.test new file mode 100644 index 00000000000..a6ec45476ff --- /dev/null +++ b/mysql-test/suite/mariabackup/mdev-18438.test @@ -0,0 +1,11 @@ +let $basedir=$MYSQLTEST_VARDIR/tmp/mdev-18438; +mkdir $basedir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extra-lsndir=$basedir/extra_lsndir --stream=xbstream > $basedir/stream.xb; +mkdir $basedir/backup; +rmdir $basedir/extra_lsndir; +--disable_result_log +exec $XBSTREAM -x -C $basedir/backup < $basedir/stream.xb; +--enable_result_log +rmdir $basedir/backup; +list_files $basedir; +rmdir $basedir; diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_slave_reply_fail.result b/mysql-test/suite/rpl/r/rpl_semi_sync_slave_reply_fail.result new file mode 100644 index 00000000000..6b39b296cdf --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_slave_reply_fail.result @@ -0,0 +1,40 @@ +include/master-slave.inc +[connection master] +connection slave; +include/stop_slave.inc +connection master; +call mtr.add_suppression("Timeout waiting for reply of binlog*"); +set global rpl_semi_sync_master_enabled = ON; +SET @@GLOBAL.rpl_semi_sync_master_timeout=100; +create table t1 (i int); +connection slave; +set global rpl_semi_sync_slave_enabled = ON; +CALL mtr.add_suppression("Semi-sync slave net_flush*"); +SET @save_debug= @@global.debug; +SET GLOBAL debug_dbug="+d,semislave_failed_net_flush"; +include/start_slave.inc +connection master; +connection slave; +"Assert that the net_fulsh() reply failed is present in slave error log. +FOUND 1 /Semi-sync slave net_flush\(\) reply failed/ in mysqld.2.err +"Assert that Slave IO thread is up and running." +SHOW STATUS LIKE 'Slave_running'; +Variable_name Value +Slave_running ON +Slave_IO_Running= Yes +"Clear the network failure simulation." +SET GLOBAL debug_dbug= @save_debug; +connection master; +insert into t1 values (10); +connection slave; +connection slave; +# Compare the tables on master and slave. +include/diff_tables.inc [master:t1, slave:t1] +connection master; +drop table t1; +connection slave; +set global rpl_semi_sync_slave_enabled = OFF; +connection master; +set global rpl_semi_sync_master_enabled = OFF; +SET @@GLOBAL.rpl_semi_sync_master_timeout = 10000; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_slave_reply_fail.test b/mysql-test/suite/rpl/t/rpl_semi_sync_slave_reply_fail.test new file mode 100644 index 00000000000..f0eb474f00e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_slave_reply_fail.test @@ -0,0 +1,87 @@ +# ==== Purpose ==== +# +# Test verifies that slave IO thread doesn't report an error, when slave fails +# to send an acknowledgment to master with semi sync replication in use. +# +# ==== Implementation ==== +# +# Steps: +# 0 - Have semi synchronous replication in use. +# 1 - Enable a debug simulation point which simulates network flush failure +# at the time of slave reply operation. +# 2 - Do some operation on master and wait for it to be replicated. Master +# will timeout waiting for reply from slave. +# 3 - Check the slave error log for appropriate error message regarding +# net_flush operation failure. +# 4 - Remove the debug simulation and do some more DML operations on master +# and wait for them to be replicated. +# 5 - Slave will be able to replicate and data is consistent on both master +# and slave. Semi sync will be automatically turned on. +# +# ==== References ==== +# +# MDEV-20217: Semi_sync: Last_IO_Error: Fatal error: Failed to run +# 'after_queue_event' hook +# +--source include/have_debug.inc +--source include/master-slave.inc + +--connection slave +--source include/stop_slave.inc + +--connection master +call mtr.add_suppression("Timeout waiting for reply of binlog*"); +--let $sav_timeout_master=`SELECT @@GLOBAL.rpl_semi_sync_master_timeout` +set global rpl_semi_sync_master_enabled = ON; +SET @@GLOBAL.rpl_semi_sync_master_timeout=100; +create table t1 (i int); + +--connection slave +set global rpl_semi_sync_slave_enabled = ON; +CALL mtr.add_suppression("Semi-sync slave net_flush*"); +SET @save_debug= @@global.debug; +SET GLOBAL debug_dbug="+d,semislave_failed_net_flush"; +--source include/start_slave.inc + +--connection master +--sync_slave_with_master + +# Check error log for correct messages. +let $log_error_= `SELECT @@GLOBAL.log_error`; +if(!$log_error_) +{ + # MySQL Server on windows is started with --console and thus + # does not know the location of its .err log, use default location + let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err; +} +--echo "Assert that the net_fulsh() reply failed is present in slave error log. +--let SEARCH_FILE=$log_error_ +--let SEARCH_PATTERN=Semi-sync slave net_flush\(\) reply failed +--source include/search_pattern_in_file.inc + +--echo "Assert that Slave IO thread is up and running." +SHOW STATUS LIKE 'Slave_running'; +let $status= query_get_value("show slave status", Slave_IO_Running, 1); +echo Slave_IO_Running= $status; + +--echo "Clear the network failure simulation." +SET GLOBAL debug_dbug= @save_debug; + +--connection master +insert into t1 values (10); +--sync_slave_with_master + +--connection slave +--echo # Compare the tables on master and slave. +--let $diff_tables= master:t1, slave:t1 +--source include/diff_tables.inc + +--connection master +drop table t1; +--sync_slave_with_master +set global rpl_semi_sync_slave_enabled = OFF; + +--connection master +set global rpl_semi_sync_master_enabled = OFF; +--eval SET @@GLOBAL.rpl_semi_sync_master_timeout = $sav_timeout_master +--source include/rpl_end.inc diff --git a/mysql-test/suite/vcol/r/vcol_sql_mode_datetime.result b/mysql-test/suite/vcol/r/vcol_sql_mode_datetime.result index 92f790793eb..3033ffb66b4 100644 --- a/mysql-test/suite/vcol/r/vcol_sql_mode_datetime.result +++ b/mysql-test/suite/vcol/r/vcol_sql_mode_datetime.result @@ -88,5 +88,26 @@ UPDATE IGNORE t1 SET d = NOW(); DROP TABLE t1; SET sql_mode=DEFAULT; # +# MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL +# +CREATE TABLE t1 ( +a DATETIME(6), +v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS DATETIME(3))) VIRTUAL, +KEY (v) +); +ERROR HY000: Function or expression 'cast(`a` as datetime(3))' cannot be used in the GENERATED ALWAYS AS clause of `v` +CREATE TABLE t1 ( +a DATETIME(6), +v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL, +KEY (v) +); +DROP TABLE t1; +CREATE TABLE t1 ( +a DATETIME(6), +v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL, +KEY (v) +); +DROP TABLE t1; +# # End of 10.4 tests # diff --git a/mysql-test/suite/vcol/r/vcol_sql_mode_time.result b/mysql-test/suite/vcol/r/vcol_sql_mode_time.result index 7098b30a7ad..300b91726d1 100644 --- a/mysql-test/suite/vcol/r/vcol_sql_mode_time.result +++ b/mysql-test/suite/vcol/r/vcol_sql_mode_time.result @@ -88,5 +88,26 @@ UPDATE IGNORE t1 SET d = CURRENT_TIME; DROP TABLE t1; SET sql_mode=DEFAULT; # +# MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL +# +CREATE TABLE t1 ( +a TIME(6), +v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS TIME(3))) VIRTUAL, +KEY (v) +); +ERROR HY000: Function or expression 'cast(`a` as time(3))' cannot be used in the GENERATED ALWAYS AS clause of `v` +CREATE TABLE t1 ( +a TIME(6), +v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL, +KEY (v) +); +DROP TABLE t1; +CREATE TABLE t1 ( +a TIME(6), +v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL, +KEY (v) +); +DROP TABLE t1; +# # End of 10.4 tests # diff --git a/mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test b/mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test index c2a4d241820..19ebd9648a7 100644 --- a/mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test +++ b/mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test @@ -103,6 +103,31 @@ UPDATE IGNORE t1 SET d = NOW(); DROP TABLE t1; SET sql_mode=DEFAULT; +--echo # +--echo # MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL +--echo # + +--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED +CREATE TABLE t1 ( + a DATETIME(6), + v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS DATETIME(3))) VIRTUAL, + KEY (v) +); + +CREATE TABLE t1 ( + a DATETIME(6), + v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL, + KEY (v) +); +DROP TABLE t1; + +CREATE TABLE t1 ( + a DATETIME(6), + v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL, + KEY (v) +); +DROP TABLE t1; + --echo # --echo # End of 10.4 tests diff --git a/mysql-test/suite/vcol/t/vcol_sql_mode_time.test b/mysql-test/suite/vcol/t/vcol_sql_mode_time.test index fa7526c6b52..2ce2a9eb5d7 100644 --- a/mysql-test/suite/vcol/t/vcol_sql_mode_time.test +++ b/mysql-test/suite/vcol/t/vcol_sql_mode_time.test @@ -105,5 +105,31 @@ SET sql_mode=DEFAULT; --echo # +--echo # MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL +--echo # + +--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED +CREATE TABLE t1 ( + a TIME(6), + v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS TIME(3))) VIRTUAL, + KEY (v) +); + +CREATE TABLE t1 ( + a TIME(6), + v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL, + KEY (v) +); +DROP TABLE t1; + +CREATE TABLE t1 ( + a TIME(6), + v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL, + KEY (v) +); +DROP TABLE t1; + + +--echo # --echo # End of 10.4 tests --echo # diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 253cad72e0b..caa575dc091 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -358,7 +358,7 @@ then cannot_find_file fill_help_tables.sql @pkgdata_locations@ exit 1 fi - plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin` + plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin` pamtooldir=$plugindir # relative from where the script was run for a relocatable install elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mysqld" diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index 8f442dd34a2..29f2a4c1ef6 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -1,6 +1,6 @@ -- Copyright (c) 2007, 2018, Oracle and/or its affiliates. --- Copyright (c) 2008, 2014, Monty Program Ab & SkySQL Ab --- +-- Copyright (c) 2008, 2019, 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 -- the Free Software Foundation; version 2 of the License. @@ -96,7 +96,7 @@ CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=Aria transactional=1 CHARACTER SET utf8 COLLATE utf8_general_ci comment='MySQL plugins'; -CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(80) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) engine=Aria transactional=1 CHARACTER SET utf8 comment='MySQL Foreign Servers table'; +CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host varchar(2048) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(80) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) engine=Aria transactional=1 CHARACTER SET utf8 comment='MySQL Foreign Servers table'; CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(80) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(141) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger','Delete versioning rows') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=Aria transactional=1 CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index f32142e86a8..7612d2b83a6 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -938,7 +938,13 @@ do cmd="$cmd "`shell_quote_string "$i"` done cmd="$cmd $args" -[ $dry_run -eq 1 ] && return + +if [ $dry_run -eq 1 ] +then + # RETURN or EXIT depending if the script is being sourced or not. + (return 2> /dev/null) && return || exit +fi + # Avoid 'nohup: ignoring input' warning test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null" diff --git a/sql/field.cc b/sql/field.cc index 28b29e13de9..200e3e899d6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -64,7 +64,7 @@ inline bool Field::marked_for_read() const (!table->read_set || bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && - ptr < table->record[0] + table->s->reclength))); + ptr < table->record[0] + table->s->reclength))); } /* @@ -75,7 +75,7 @@ inline bool Field::marked_for_read() const inline bool Field::marked_for_write_or_computed() const { - return (is_stat_field || !table || + return (!table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || (!(ptr >= table->record[0] && @@ -2439,31 +2439,19 @@ Field *Field::clone(MEM_ROOT *root, TABLE *new_table) } - -Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff, - bool stat_flag) +Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff) { Field *tmp; if ((tmp= (Field*) memdup_root(root,(char*) this,size_of()))) { - tmp->init(new_table); + if (new_table) + tmp->init(new_table); tmp->move_field_offset(diff); } - tmp->is_stat_field= stat_flag; return tmp; } -Field *Field::clone(MEM_ROOT *root, my_ptrdiff_t diff) -{ - Field *tmp; - if ((tmp= (Field*) memdup_root(root,(char*) this,size_of()))) - { - tmp->move_field_offset(diff); - } - return tmp; -} - int Field::set_default() { if (default_value) @@ -2896,7 +2884,7 @@ int Field_decimal::store(const char *from_arg, size_t len, CHARSET_INFO *cs) /* Write digits of the frac_% parts ; - Depending on get_thd()->count_cutted_fields, we may also want + Depending on get_thd()->count_cuted_fields, we may also want to know if some non-zero tail of these parts will be truncated (for example, 0.002->0.00 will generate a warning, while 0.000->0.00 will not) @@ -7040,7 +7028,8 @@ Field_longstr::check_string_copy_error(const String_copier *copier, if (likely(!(pos= copier->most_important_error_pos()))) return FALSE; - if (!is_stat_field) + /* Ignore errors from internal expressions */ + if (get_thd()->count_cuted_fields > CHECK_FIELD_EXPRESSION) { DBUG_ASSERT(sizeof(tmp) >= convert_to_printable_required_length(6)); convert_to_printable(tmp, sizeof(tmp), pos, (end - pos), cs, 6); @@ -7074,8 +7063,9 @@ int Field_longstr::report_if_important_data(const char *pstr, const char *end, bool count_spaces) { - THD *thd= get_thd(); - if ((pstr < end) && thd->count_cuted_fields > CHECK_FIELD_EXPRESSION) + THD *thd; + if ((pstr < end) && + (thd= get_thd())->count_cuted_fields > CHECK_FIELD_EXPRESSION) { if (test_if_important_data(field_charset(), pstr, end)) { @@ -7086,7 +7076,8 @@ Field_longstr::report_if_important_data(const char *pstr, const char *end, return 2; } else if (count_spaces) - { /* If we lost only spaces then produce a NOTE, not a WARNING */ + { + /* If we lost only spaces then produce a NOTE, not a WARNING */ set_note(WARN_DATA_TRUNCATED, 1); return 2; } @@ -10938,13 +10929,17 @@ void Field::set_warning_truncated_wrong_value(const char *type_arg, const char *value) { THD *thd= get_thd(); - const char *db_name= table->s->db.str; - const char *table_name= table->s->table_name.str; + const char *db_name; + const char *table_name; + /* + table has in the past been 0 in case of wrong calls when processing + statistics tables. Let's protect against that. + */ + DBUG_ASSERT(table); - if (!db_name) - db_name= ""; - if (!table_name) - table_name= ""; + db_name= (table && table->s->db.str) ? table->s->db.str : ""; + table_name= ((table && table->s->table_name.str) ? table->s->table_name.str : + ""); push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, diff --git a/sql/field.h b/sql/field.h index 0b4dfc049bf..4fcfbe25aca 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1396,9 +1396,7 @@ public: return create_tmp_field(root, new_table, maybe_null()); } Field *clone(MEM_ROOT *mem_root, TABLE *new_table); - Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff, - bool stat_flag= FALSE); - Field *clone(MEM_ROOT *mem_root, my_ptrdiff_t diff); + Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff); inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg) { ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 0057ed45c7d..86e81fa5bf7 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2449,6 +2449,14 @@ bool Item_time_typecast::get_date(THD *thd, MYSQL_TIME *to, date_mode_t mode) } +Sql_mode_dependency Item_time_typecast::value_depends_on_sql_mode() const +{ + return Item_timefunc::value_depends_on_sql_mode() | + Sql_mode_dependency(decimals < args[0]->decimals ? + MODE_TIME_ROUND_FRACTIONAL : 0, 0); +} + + bool Item_date_typecast::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { date_mode_t tmp= (fuzzydate | sql_mode_for_dates(thd)) & ~TIME_TIME_ONLY; @@ -2469,6 +2477,14 @@ bool Item_datetime_typecast::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t f } +Sql_mode_dependency Item_datetime_typecast::value_depends_on_sql_mode() const +{ + return Item_datetimefunc::value_depends_on_sql_mode() | + Sql_mode_dependency(decimals < args[0]->decimals ? + MODE_TIME_ROUND_FRACTIONAL : 0, 0); +} + + /** MAKEDATE(a,b) is a date function that creates a date value from a year and day value. diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 9896499e172..f994d463158 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -1170,6 +1170,7 @@ public: return args[0]->type_handler()-> Item_time_typecast_fix_length_and_dec(this); } + Sql_mode_dependency value_depends_on_sql_mode() const; Item *get_copy(THD *thd) { return get_item_copy<Item_time_typecast>(thd, this); } }; @@ -1191,6 +1192,7 @@ public: return args[0]->type_handler()-> Item_datetime_typecast_fix_length_and_dec(this); } + Sql_mode_dependency value_depends_on_sql_mode() const; Item *get_copy(THD *thd) { return get_item_copy<Item_datetime_typecast>(thd, this); } }; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 2987f2ebab6..8dae20fc30f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2663,16 +2663,20 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, notnull_cond= head->notnull_cond; if (!records) records++; /* purecov: inspected */ - scan_time= (double) records / TIME_FOR_COMPARE + 1; - read_time= (double) head->file->scan_time() + scan_time + 1.1; - if (head->force_index) + + if (head->force_index || force_quick_range) scan_time= read_time= DBL_MAX; - if (limit < records) + else { - read_time= (double) records + scan_time + 1; // Force to use index - notnull_cond= NULL; + scan_time= (double) records / TIME_FOR_COMPARE + 1; + read_time= (double) head->file->scan_time() + scan_time + 1.1; + if (limit < records) + { + read_time= (double) records + scan_time + 1; // Force to use index + notnull_cond= NULL; + } } - + possible_keys.clear_all(); DBUG_PRINT("info",("Time to scan table: %g", read_time)); @@ -11063,6 +11067,16 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only, bufsize, mrr_flags, cost); if (rows != HA_POS_ERROR) { + ha_rows table_records= param->table->stat_records(); + if (rows > table_records) + { + /* + For any index the total number of records within all ranges + cannot be be bigger than the number of records in the table + */ + rows= table_records; + set_if_bigger(rows, 1); + } param->quick_rows[keynr]= rows; param->possible_keys.set_bit(keynr); if (update_tbl_stats) diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index c85536e8b79..15f9194357c 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -453,11 +453,6 @@ bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables); static SJ_MATERIALIZATION_INFO * at_sjmat_pos(const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab, uint idx, bool *loose_scan); -void best_access_path(JOIN *join, JOIN_TAB *s, - table_map remaining_tables, uint idx, - bool disable_jbuf, double record_count, - POSITION *pos, POSITION *loose_scan_pos); - static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm, Item_in_subselect *subq_pred); static bool remove_sj_conds(THD *thd, Item **tree); @@ -2781,6 +2776,14 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, uint idx, { POSITION *pos= join->positions + idx; const JOIN_TAB *new_join_tab= pos->table; + +#ifdef HAVE_valgrind + new (&pos->firstmatch_picker) Firstmatch_picker; + new (&pos->loosescan_picker) LooseScan_picker; + new (&pos->sjmat_picker) Sj_materialization_picker; + new (&pos->dups_weedout_picker) Duplicate_weedout_picker; +#endif + if (join->emb_sjm_nest || //(1) !join->select_lex->have_merged_subqueries) //(2) { @@ -3121,7 +3124,8 @@ bool Sj_materialization_picker::check_qep(JOIN *join, Json_writer_temp_disable trace_semijoin_mat_scan(thd); for (i= first_tab + mat_info->tables; i <= idx; i++) { - best_access_path(join, join->positions[i].table, rem_tables, i, + best_access_path(join, join->positions[i].table, rem_tables, + join->positions, i, disable_jbuf, prefix_rec_count, &curpos, &dummy); prefix_rec_count= COST_MULT(prefix_rec_count, curpos.records_read); prefix_cost= COST_ADD(prefix_cost, curpos.read_time); @@ -3790,7 +3794,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) Json_writer_object trace_one_table(thd); trace_one_table.add_table_name(join->best_positions[i].table); } - best_access_path(join, join->best_positions[i].table, rem_tables, i, + best_access_path(join, join->best_positions[i].table, rem_tables, + join->best_positions, i, FALSE, prefix_rec_count, join->best_positions + i, &dummy); prefix_rec_count *= join->best_positions[i].records_read; @@ -3830,8 +3835,9 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) } if (join->best_positions[idx].use_join_buffer) { - best_access_path(join, join->best_positions[idx].table, - rem_tables, idx, TRUE /* no jbuf */, + best_access_path(join, join->best_positions[idx].table, + rem_tables, join->best_positions, idx, + TRUE /* no jbuf */, record_count, join->best_positions + idx, &dummy); } record_count *= join->best_positions[idx].records_read; @@ -3869,7 +3875,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) if (join->best_positions[idx].use_join_buffer || (idx == first)) { best_access_path(join, join->best_positions[idx].table, - rem_tables, idx, TRUE /* no jbuf */, + rem_tables, join->best_positions, idx, + TRUE /* no jbuf */, record_count, join->best_positions + idx, &loose_scan_pos); if (idx==first) diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h index 6210fc972c8..14730ecbd11 100644 --- a/sql/opt_subselect.h +++ b/sql/opt_subselect.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2010, 2019, MariaDB 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 @@ -91,6 +91,7 @@ class Loose_scan_opt KEYUSE *best_loose_scan_start_key; uint best_max_loose_keypart; + table_map best_ref_depend_map; public: Loose_scan_opt(): @@ -252,13 +253,14 @@ public: best_loose_scan_records= records; best_max_loose_keypart= max_loose_keypart; best_loose_scan_start_key= start_key; + best_ref_depend_map= 0; } } } } void check_ref_access_part2(uint key, KEYUSE *start_key, double records, - double read_time) + double read_time, table_map ref_depend_map_arg) { if (part1_conds_met && read_time < best_loose_scan_cost) { @@ -268,6 +270,7 @@ public: best_loose_scan_records= records; best_max_loose_keypart= max_loose_keypart; best_loose_scan_start_key= start_key; + best_ref_depend_map= ref_depend_map_arg; } } @@ -283,6 +286,7 @@ public: best_loose_scan_records= rows2double(quick->records); best_max_loose_keypart= quick_max_loose_keypart; best_loose_scan_start_key= NULL; + best_ref_depend_map= 0; } } @@ -299,7 +303,7 @@ public: pos->use_join_buffer= FALSE; pos->table= tab; pos->range_rowid_filter_info= tab->range_rowid_filter_info; - // todo need ref_depend_map ? + pos->ref_depend_map= best_ref_depend_map; DBUG_PRINT("info", ("Produced a LooseScan plan, key %s, %s", tab->table->key_info[best_loose_scan_key].name.str, best_loose_scan_start_key? "(ref access)": diff --git a/sql/slave.cc b/sql/slave.cc index 6a0eee1d205..ed7c22221a6 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5016,13 +5016,14 @@ Stopping slave I/O thread due to out-of-memory error from master"); goto err; } - if (rpl_semi_sync_slave_status && (mi->semi_ack & SEMI_SYNC_NEED_ACK) && - repl_semisync_slave.slave_reply(mi)) + if (rpl_semi_sync_slave_status && (mi->semi_ack & SEMI_SYNC_NEED_ACK)) { - mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL, - ER_THD(thd, ER_SLAVE_FATAL_ERROR), - "Failed to run 'after_queue_event' hook"); - goto err; + /* + We deliberately ignore the error in slave_reply, such error should + not cause the slave IO thread to stop, and the error messages are + already reported. + */ + (void)repl_semisync_slave.slave_reply(mi); } if (mi->using_gtid == Master_info::USE_GTID_NO && diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index eb39cb94cef..5b3d3108da5 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1440,6 +1440,22 @@ void With_clause::print(String *str, enum_query_type query_type) void With_element::print(String *str, enum_query_type query_type) { str->append(query_name); + if (column_list.elements) + { + List_iterator_fast<LEX_CSTRING> li(column_list); + str->append('('); + for (LEX_CSTRING *col_name= li++; ; ) + { + str->append(col_name); + col_name= li++; + if (!col_name) + { + str->append(')'); + break; + } + str->append(','); + } + } str->append(STRING_WITH_LEN(" as ")); str->append('('); spec->print(str, query_type); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2e163a9d464..c5d7e5898b6 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -734,7 +734,7 @@ void LEX::start(THD *thd_arg) default_used= FALSE; query_tables= 0; reset_query_tables_list(FALSE); - expr_allows_subselect= TRUE; + clause_that_disallows_subselect= NULL; selects_allow_into= FALSE; selects_allow_procedure= FALSE; use_only_table_context= FALSE; @@ -9067,12 +9067,12 @@ bool LEX::insert_select_hack(SELECT_LEX *sel) Create an Item_singlerow_subselect for a query expression. */ Item *LEX::create_item_query_expression(THD *thd, - const char *tok_start, st_select_lex_unit *unit) { - if (!expr_allows_subselect) + if (clause_that_disallows_subselect) { - thd->parse_error(ER_SYNTAX_ERROR, tok_start); + my_error(ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), + clause_that_disallows_subselect); return NULL; } @@ -9341,11 +9341,12 @@ SELECT_LEX_UNIT *LEX::parsed_body_unit_tail(SELECT_LEX_UNIT *unit, Process subselect parsing */ -SELECT_LEX *LEX::parsed_subselect(SELECT_LEX_UNIT *unit, char *place) +SELECT_LEX *LEX::parsed_subselect(SELECT_LEX_UNIT *unit) { - if (!expr_allows_subselect) + if (clause_that_disallows_subselect) { - thd->parse_error(ER_SYNTAX_ERROR, place); + my_error(ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), + clause_that_disallows_subselect); return NULL; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index cd6c068f5d1..eebbbccc7c0 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3283,10 +3283,10 @@ public: /* Usually `expr` rule of yacc is quite reused but some commands better not support subqueries which comes standard with this rule, like - KILL, HA_READ, CREATE/ALTER EVENT etc. Set this to `false` to get - syntax error back. + KILL, HA_READ, CREATE/ALTER EVENT etc. Set this to a non-NULL + clause name to get an error. */ - bool expr_allows_subselect; + const char *clause_that_disallows_subselect; bool selects_allow_into; bool selects_allow_procedure; /* @@ -4006,9 +4006,7 @@ public: const Lex_ident_cli_st *var_name, const Lex_ident_cli_st *field_name); - Item *create_item_query_expression(THD *thd, - const char *tok_start, - st_select_lex_unit *unit); + Item *create_item_query_expression(THD *thd, st_select_lex_unit *unit); Item *make_item_func_replace(THD *thd, Item *org, Item *find, Item *replace); Item *make_item_func_substr(THD *thd, Item *a, Item *b, Item *c); @@ -4487,7 +4485,7 @@ public: bool parsed_body_unit(SELECT_LEX_UNIT *unit); SELECT_LEX_UNIT *parsed_body_unit_tail(SELECT_LEX_UNIT *unit, Lex_order_limit_lock * l); - SELECT_LEX *parsed_subselect(SELECT_LEX_UNIT *unit, char *place); + SELECT_LEX *parsed_subselect(SELECT_LEX_UNIT *unit); bool parsed_insert_select(SELECT_LEX *firs_select); bool parsed_TVC_start(); SELECT_LEX *parsed_TVC_end(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index abc7770d274..6d053068007 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1833,8 +1833,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { WSREP_DEBUG("Deadlock error for: %s", thd->query()); mysql_mutex_lock(&thd->LOCK_thd_data); - thd->killed = NOT_KILLED; - thd->mysys_var->abort = 0; + thd->reset_kill_query(); thd->wsrep_retry_counter = 0; mysql_mutex_unlock(&thd->LOCK_thd_data); goto dispatch_end; @@ -1937,8 +1936,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { WSREP_DEBUG("Deadlock error for: %s", thd->query()); mysql_mutex_lock(&thd->LOCK_thd_data); - thd->killed = NOT_KILLED; - thd->mysys_var->abort = 0; + thd->reset_kill_query(); thd->wsrep_retry_counter = 0; mysql_mutex_unlock(&thd->LOCK_thd_data); @@ -2414,13 +2412,11 @@ dispatch_end: */ DBUG_ASSERT((command != COM_QUIT && command != COM_STMT_CLOSE) || thd->get_stmt_da()->is_disabled()); + DBUG_ASSERT(thd->wsrep_trx().state() != wsrep::transaction::s_replaying); /* wsrep BF abort in query exec phase */ - mysql_mutex_lock(&thd->LOCK_thd_data); - do_end_of_statement= - thd->wsrep_trx().state() != wsrep::transaction::s_replaying - && !thd->killed; - - mysql_mutex_unlock(&thd->LOCK_thd_data); + mysql_mutex_lock(&thd->LOCK_thd_kill); + do_end_of_statement= thd_is_connection_alive(thd); + mysql_mutex_unlock(&thd->LOCK_thd_kill); } else do_end_of_statement= true; @@ -7763,14 +7759,22 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, (thd->get_stmt_da()->is_error()) ? thd->get_stmt_da()->sql_errno() : 0); - thd->killed = NOT_KILLED; + thd->reset_kill_query(); wsrep_override_error(thd, ER_LOCK_DEADLOCK); } - if (wsrep_after_statement(thd) && is_autocommit) +#ifdef ENABLED_DEBUG_SYNC + /* we need the test otherwise we get stuck in the "SET DEBUG_SYNC" itself */ + if (thd->lex->sql_command != SQLCOM_SET_OPTION) + DEBUG_SYNC(thd, "wsrep_after_statement_enter"); +#endif + + if (wsrep_after_statement(thd) && + is_autocommit && + thd_is_connection_alive(thd)) { thd->reset_for_next_command(); - thd->killed= NOT_KILLED; + thd->reset_kill_query(); if (is_autocommit && thd->lex->sql_command != SQLCOM_SELECT && thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit) @@ -7800,7 +7804,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, thd->variables.wsrep_retry_autocommit, WSREP_QUERY(thd)); my_error(ER_LOCK_DEADLOCK, MYF(0)); - thd->killed= NOT_KILLED; + thd->reset_kill_query(); thd->wsrep_retry_counter= 0; // reset } } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4724f3a7e72..06227081417 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -107,10 +107,6 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select, TABLE *table, const key_map *keys,ha_rows limit); -void best_access_path(JOIN *join, JOIN_TAB *s, - table_map remaining_tables, uint idx, - bool disable_jbuf, double record_count, - POSITION *pos, POSITION *loose_scan_pos); static void optimize_straight_join(JOIN *join, table_map join_tables); static bool greedy_search(JOIN *join, table_map remaining_tables, uint depth, uint prune_level, @@ -5490,6 +5486,13 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, { if (choose_plan(join, all_table_map & ~join->const_table_map)) goto error; + +#ifdef HAVE_valgrind + // JOIN::positions holds the current query plan. We've already + // made the plan choice, so we should only use JOIN::best_positions + for (uint k=join->const_tables; k < join->table_count; k++) + MEM_UNDEFINED(&join->positions[k], sizeof(join->positions[k])); +#endif } else { @@ -7193,6 +7196,7 @@ void best_access_path(JOIN *join, JOIN_TAB *s, table_map remaining_tables, + const POSITION *join_positions, uint idx, bool disable_jbuf, double record_count, @@ -7313,7 +7317,7 @@ best_access_path(JOIN *join, if (!keyuse->val->maybe_null || keyuse->null_rejecting) notnull_part|=keyuse->keypart_map; - double tmp2= prev_record_reads(join->positions, idx, + double tmp2= prev_record_reads(join_positions, idx, (found_ref | keyuse->used_tables)); if (tmp2 < best_prev_record_reads) { @@ -7355,7 +7359,7 @@ best_access_path(JOIN *join, Really, there should be records=0.0 (yes!) but 1.0 would be probably safer */ - tmp= prev_record_reads(join->positions, idx, found_ref); + tmp= prev_record_reads(join_positions, idx, found_ref); records= 1.0; type= JT_FT; trace_access_idx.add("access_type", join_type_str[type]) @@ -7384,7 +7388,7 @@ best_access_path(JOIN *join, type= JT_EQ_REF; trace_access_idx.add("access_type", join_type_str[type]) .add("index", keyinfo->name); - tmp = prev_record_reads(join->positions, idx, found_ref); + tmp = prev_record_reads(join_positions, idx, found_ref); records=1.0; } else @@ -7672,7 +7676,8 @@ best_access_path(JOIN *join, } tmp= COST_ADD(tmp, s->startup_cost); - loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp); + loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp, + found_ref); } /* not ft_key */ if (records < DBL_MAX) @@ -8462,7 +8467,8 @@ optimize_straight_join(JOIN *join, table_map join_tables) trace_one_table.add_table_name(s); } /* Find the best access method from 's' to the current partial plan */ - best_access_path(join, s, join_tables, idx, disable_jbuf, record_count, + best_access_path(join, s, join_tables, join->positions, idx, + disable_jbuf, record_count, position, &loose_scan_pos); /* compute the cost of the new plan extended with 's' */ @@ -9085,7 +9091,19 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, } keyparts++; } + /* + Here we discount selectivity of the constant range CR. To calculate + this selectivity we use elements from the quick_rows[] array. + If we have indexes i1,...,ik with the same prefix compatible + with CR any of the estimate quick_rows[i1], ... quick_rows[ik] could + be used for this calculation but here we don't know which one was + actually used. So sel could be greater than 1 and we have to cap it. + However if sel becomes greater than 2 then with high probability + something went wrong. + */ sel /= (double)table->quick_rows[key] / (double) table->stat_records(); + // MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0); + set_if_smaller(sel, 1.0); used_range_selectivity= true; } } @@ -9131,8 +9149,9 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1; if (table->field[fldno]->cond_selectivity > 0) - { + { sel /= table->field[fldno]->cond_selectivity; + // MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0); set_if_smaller(sel, 1.0); } /* @@ -9186,10 +9205,11 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, next_field= next_field->next_equal_field) { if (!(next_field->table->map & rem_tables) && next_field->table != table) - { + { if (field->cond_selectivity > 0) - { + { sel/= field->cond_selectivity; + // MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0); set_if_smaller(sel, 1.0); } break; @@ -9201,6 +9221,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables, keyparts, ref_keyuse_steps); + DBUG_ASSERT(0.0 < sel && sel <= 1.0); return sel; } @@ -9391,8 +9412,8 @@ best_extension_by_limited_search(JOIN *join, /* Find the best access method from 's' to the current partial plan */ POSITION loose_scan_pos; - best_access_path(join, s, remaining_tables, idx, disable_jbuf, - record_count, position, &loose_scan_pos); + best_access_path(join, s, remaining_tables, join->positions, idx, + disable_jbuf, record_count, position, &loose_scan_pos); /* Compute the cost of extending the plan with 's' */ current_record_count= COST_MULT(record_count, position->records_read); @@ -9796,11 +9817,11 @@ cache_record_length(JOIN *join,uint idx) */ double -prev_record_reads(POSITION *positions, uint idx, table_map found_ref) +prev_record_reads(const POSITION *positions, uint idx, table_map found_ref) { double found=1.0; - POSITION *pos_end= positions - 1; - for (POSITION *pos= positions + idx - 1; pos != pos_end; pos--) + const POSITION *pos_end= positions - 1; + for (const POSITION *pos= positions + idx - 1; pos != pos_end; pos--) { if (pos->table->table->map & found_ref) { @@ -16690,7 +16711,8 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab, if ((i == first_tab && first_alt) || join->positions[i].use_join_buffer) { /* Find the best access method that would not use join buffering */ - best_access_path(join, rs, reopt_remaining_tables, i, + best_access_path(join, rs, reopt_remaining_tables, + join->positions, i, TRUE, rec_count, &pos, &loose_scan_pos); } diff --git a/sql/sql_select.h b/sql/sql_select.h index 2fafdd74ad9..4f7bf49f635 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -854,6 +854,7 @@ public: friend void best_access_path(JOIN *join, JOIN_TAB *s, table_map remaining_tables, + const struct st_position *join_positions, uint idx, bool disable_jbuf, double record_count, @@ -2072,6 +2073,11 @@ protected: } }; +void best_access_path(JOIN *join, JOIN_TAB *s, + table_map remaining_tables, + const POSITION *join_positions, uint idx, + bool disable_jbuf, double record_count, + POSITION *pos, POSITION *loose_scan_pos); bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref); bool error_if_full_join(JOIN *join); int report_error(TABLE *table, int error); @@ -2443,7 +2449,7 @@ bool instantiate_tmp_table(TABLE *table, KEY *keyinfo, ulonglong options); bool open_tmp_table(TABLE *table); void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps); -double prev_record_reads(POSITION *positions, uint idx, table_map found_ref); +double prev_record_reads(const POSITION *positions, uint idx, table_map found_ref); void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist); double get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size); double get_tmp_table_write_cost(THD *thd, double row_count, uint row_size); diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 438a9248a31..1222d0e0d5f 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -1,4 +1,5 @@ /* Copyright (C) 2009 MySQL AB + Copyright (c) 2019, 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 @@ -1023,7 +1024,9 @@ public: { char buff[MAX_FIELD_WIDTH]; String val(buff, sizeof(buff), &my_charset_bin); + my_bitmap_map *old_map; + old_map= dbug_tmp_use_all_columns(stat_table, stat_table->read_set); for (uint i= COLUMN_STAT_MIN_VALUE; i <= COLUMN_STAT_HISTOGRAM; i++) { Field *stat_field= stat_table->field[i]; @@ -1081,6 +1084,7 @@ public: } } } + dbug_tmp_restore_column_map(stat_table->read_set, old_map); } @@ -1132,12 +1136,18 @@ public: case COLUMN_STAT_MIN_VALUE: table_field->read_stats->min_value->set_notnull(); stat_field->val_str(&val); +#if 0 /* MDEV-20589 FIXME: This fails! */ + DBUG_ASSERT(table_field->read_stats->min_value->is_stat_field); +#endif table_field->read_stats->min_value->store(val.ptr(), val.length(), &my_charset_bin); break; case COLUMN_STAT_MAX_VALUE: table_field->read_stats->max_value->set_notnull(); stat_field->val_str(&val); +#if 0 /* MDEV-20589 FIXME: This fails! */ + DBUG_ASSERT(table_field->read_stats->min_value->is_stat_field); +#endif table_field->read_stats->max_value->store(val.ptr(), val.length(), &my_charset_bin); break; @@ -1985,7 +1995,7 @@ void create_min_max_statistical_fields_for_table(TABLE *table) my_ptrdiff_t diff= record-table->record[0]; if (!bitmap_is_set(table->read_set, table_field->field_index)) continue; - if (!(fld= table_field->clone(&table->mem_root, table, diff, TRUE))) + if (!(fld= table_field->clone(&table->mem_root, table, diff))) continue; if (i == 0) table_field->collected_stats->min_value= fld; @@ -2052,7 +2062,7 @@ void create_min_max_statistical_fields_for_table_share(THD *thd, Field *fld; Field *table_field= *field_ptr; my_ptrdiff_t diff= record - table_share->default_values; - if (!(fld= table_field->clone(&stats_cb->mem_root, diff))) + if (!(fld= table_field->clone(&stats_cb->mem_root, NULL, diff))) continue; if (i == 0) table_field->read_stats->min_value= fld; @@ -3046,9 +3056,12 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables) KEY *key_info, *key_info_end; TABLE_SHARE *table_share= table->s; Table_statistics *read_stats= table_share->stats_cb.table_stats; - + enum_check_fields old_check_level= thd->count_cuted_fields; DBUG_ENTER("read_statistics_for_table"); + /* Don't write warnings for internal field conversions */ + thd->count_cuted_fields= CHECK_FIELD_IGNORE; + /* Read statistics from the statistical table table_stats */ stat_table= stat_tables[TABLE_STAT].table; Table_stat table_stat(stat_table, table); @@ -3129,6 +3142,7 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables) } table->stats_is_read= TRUE; + thd->count_cuted_fields= old_check_level; DBUG_RETURN(0); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4128942f4fc..13a89e93378 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7138,10 +7138,10 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar, --ha_alter_info->index_add_count; --ha_alter_info->index_drop_count; - memcpy(add_buffer + i, add_buffer + i + 1, - sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i)); - memcpy(drop_buffer + j, drop_buffer + j + 1, - sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j)); + memmove(add_buffer + i, add_buffer + i + 1, + sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i)); + memmove(drop_buffer + j, drop_buffer + j + 1, + sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j)); --i; // this index once again break; } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index a7d0d08feb2..f3fde2e59a0 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -2535,6 +2535,7 @@ bool st_select_lex_unit::cleanup() DBUG_RETURN(FALSE); } } + columns_are_renamed= false; cleaned= 1; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 440a27d2e35..164dbe8bb88 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1879,7 +1879,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type <item> literal insert_ident order_ident temporal_literal - simple_ident expr expr_no_subselect sum_expr in_sum_expr + simple_ident expr sum_expr in_sum_expr variable variable_aux bool_pri predicate bit_expr parenthesized_expr table_wild simple_expr column_default_non_parenthesized_expr udf_expr @@ -2346,19 +2346,13 @@ deallocate_or_drop: ; prepare: - PREPARE_SYM ident FROM expr_no_subselect - { - if (Lex->stmt_prepare($2, $4)) - MYSQL_YYABORT; - } - ; - -expr_no_subselect: - { Lex->expr_allows_subselect= false; } + PREPARE_SYM ident FROM + { Lex->clause_that_disallows_subselect= "PREPARE..FROM"; } expr { - Lex->expr_allows_subselect= true; - $$= $2; + Lex->clause_that_disallows_subselect= NULL; + if (Lex->stmt_prepare($2, $5)) + MYSQL_YYABORT; } ; @@ -2368,20 +2362,25 @@ execute: if (Lex->stmt_execute($2, $3)) MYSQL_YYABORT; } - | EXECUTE_SYM IMMEDIATE_SYM expr_no_subselect execute_using + | EXECUTE_SYM IMMEDIATE_SYM + { Lex->clause_that_disallows_subselect= "EXECUTE IMMEDIATE"; } + expr + { Lex->clause_that_disallows_subselect= NULL; } + execute_using { - if (Lex->stmt_execute_immediate($3, $4)) + if (Lex->stmt_execute_immediate($4, $6)) MYSQL_YYABORT; } ; execute_using: /* nothing */ { $$= NULL; } - | USING { Lex->expr_allows_subselect= false; } + | USING + { Lex->clause_that_disallows_subselect= "EXECUTE..USING"; } execute_params { $$= $3; - Lex->expr_allows_subselect= true; + Lex->clause_that_disallows_subselect= NULL; } ; @@ -3081,8 +3080,6 @@ server_option: { MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0); Lex->server_options.host= $2; - my_casedn_str(system_charset_info, - (char*) Lex->server_options.host.str); } | DATABASE TEXT_STRING_sys { @@ -6788,10 +6785,9 @@ parse_vcol_expr: ; parenthesized_expr: - remember_tok_start query_expression { - if (!($$= Lex->create_item_query_expression(thd, $1, $2))) + if (!($$= Lex->create_item_query_expression(thd, $1))) MYSQL_YYABORT; } | expr @@ -9381,10 +9377,9 @@ query_expression: ; subselect: - remember_tok_start query_expression { - if (!($$= Lex->parsed_subselect($2, $1))) + if (!($$= Lex->parsed_subselect($1))) YYABORT; } ; @@ -12922,17 +12917,16 @@ procedure_clause: /* PROCEDURE CLAUSE cannot handle subquery as one of its parameter, - so set expr_allows_subselect as false to disallow any subqueries - further. Reset expr_allows_subselect back to true once the - parameters are reduced. + so disallow any subqueries further. + Alow subqueries back once the parameters are reduced. */ - Lex->expr_allows_subselect= false; + Lex->clause_that_disallows_subselect= "PROCEDURE"; Select->options|= OPTION_PROCEDURE_CLAUSE; } '(' procedure_list ')' { /* Subqueries are allowed from now.*/ - Lex->expr_allows_subselect= true; + Lex->clause_that_disallows_subselect= NULL; } ; @@ -14685,9 +14679,12 @@ purge: { Lex->stmt_purge_to($5); } - | PURGE master_or_binary LOGS_SYM BEFORE_SYM expr_no_subselect + | PURGE master_or_binary LOGS_SYM BEFORE_SYM + { Lex->clause_that_disallows_subselect= "PURGE..BEFORE"; } + expr { - if (Lex->stmt_purge_before($5)) + Lex->clause_that_disallows_subselect= NULL; + if (Lex->stmt_purge_before($6)) MYSQL_YYABORT; } ; @@ -16855,7 +16852,7 @@ handler_tail: LEX *lex=Lex; if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "HANDLER")); - lex->expr_allows_subselect= FALSE; + lex->clause_that_disallows_subselect= "HANDLER..READ"; lex->sql_command = SQLCOM_HA_READ; lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */ Item *one= new (thd->mem_root) Item_int(thd, (int32) 1); @@ -16870,7 +16867,7 @@ handler_tail: handler_read_or_scan opt_where_clause opt_global_limit_clause { LEX *lex=Lex; - lex->expr_allows_subselect= TRUE; + lex->clause_that_disallows_subselect= NULL; if (!lex->current_select->explicit_limit) { Item *one= new (thd->mem_root) Item_int(thd, (int32) 1); diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index f976c1f68e1..2314997c9d9 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -1352,7 +1352,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type <item> literal insert_ident order_ident temporal_literal - simple_ident expr expr_no_subselect sum_expr in_sum_expr + simple_ident expr sum_expr in_sum_expr variable variable_aux bool_pri predicate bit_expr parenthesized_expr table_wild simple_expr column_default_non_parenthesized_expr udf_expr @@ -1838,19 +1838,13 @@ deallocate_or_drop: ; prepare: - PREPARE_SYM ident FROM expr_no_subselect - { - if (Lex->stmt_prepare($2, $4)) - MYSQL_YYABORT; - } - ; - -expr_no_subselect: - { Lex->expr_allows_subselect= false; } + PREPARE_SYM ident FROM + { Lex->clause_that_disallows_subselect= "PREPARE..FROM"; } expr { - Lex->expr_allows_subselect= true; - $$= $2; + Lex->clause_that_disallows_subselect= NULL; + if (Lex->stmt_prepare($2, $5)) + MYSQL_YYABORT; } ; @@ -1860,20 +1854,25 @@ execute: if (Lex->stmt_execute($2, $3)) MYSQL_YYABORT; } - | EXECUTE_SYM IMMEDIATE_SYM expr_no_subselect execute_using + | EXECUTE_SYM IMMEDIATE_SYM + { Lex->clause_that_disallows_subselect= "EXECUTE IMMEDIATE"; } + expr + { Lex->clause_that_disallows_subselect= NULL; } + execute_using { - if (Lex->stmt_execute_immediate($3, $4)) + if (Lex->stmt_execute_immediate($4, $6)) MYSQL_YYABORT; } ; execute_using: /* nothing */ { $$= NULL; } - | USING { Lex->expr_allows_subselect= false; } + | USING + { Lex->clause_that_disallows_subselect= "EXECUTE..USING"; } execute_params { $$= $3; - Lex->expr_allows_subselect= true; + Lex->clause_that_disallows_subselect= NULL; } ; @@ -2846,8 +2845,6 @@ server_option: { MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0); Lex->server_options.host= $2; - my_casedn_str(system_charset_info, - (char*) Lex->server_options.host.str); } | DATABASE TEXT_STRING_sys { @@ -6787,10 +6784,9 @@ parse_vcol_expr: ; parenthesized_expr: - remember_tok_start query_expression { - if (!($$= Lex->create_item_query_expression(thd, $1, $2))) + if (!($$= Lex->create_item_query_expression(thd, $1))) MYSQL_YYABORT; } | expr @@ -9472,10 +9468,9 @@ query_expression: ; subselect: - remember_tok_start query_expression { - if (!($$= Lex->parsed_subselect($2, $1))) + if (!($$= Lex->parsed_subselect($1))) YYABORT; } ; @@ -13022,17 +13017,16 @@ procedure_clause: /* PROCEDURE CLAUSE cannot handle subquery as one of its parameter, - so set expr_allows_subselect as false to disallow any subqueries - further. Reset expr_allows_subselect back to true once the - parameters are reduced. + so disallow any subqueries further. + Alow subqueries back once the parameters are reduced. */ - Lex->expr_allows_subselect= false; + Lex->clause_that_disallows_subselect= "PROCEDURE"; Select->options|= OPTION_PROCEDURE_CLAUSE; } '(' procedure_list ')' { /* Subqueries are allowed from now.*/ - Lex->expr_allows_subselect= true; + Lex->clause_that_disallows_subselect= NULL; } ; @@ -14808,9 +14802,12 @@ purge: { Lex->stmt_purge_to($5); } - | PURGE master_or_binary LOGS_SYM BEFORE_SYM expr_no_subselect + | PURGE master_or_binary LOGS_SYM BEFORE_SYM + { Lex->clause_that_disallows_subselect= "PURGE..BEFORE"; } + expr { - if (Lex->stmt_purge_before($5)) + Lex->clause_that_disallows_subselect= NULL; + if (Lex->stmt_purge_before($6)) MYSQL_YYABORT; } ; @@ -17075,7 +17072,7 @@ handler_tail: LEX *lex=Lex; if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "HANDLER")); - lex->expr_allows_subselect= FALSE; + lex->clause_that_disallows_subselect= "HANDLER..READ"; lex->sql_command = SQLCOM_HA_READ; lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */ Item *one= new (thd->mem_root) Item_int(thd, (int32) 1); @@ -17090,7 +17087,7 @@ handler_tail: handler_read_or_scan opt_where_clause opt_global_limit_clause { LEX *lex=Lex; - lex->expr_allows_subselect= TRUE; + lex->clause_that_disallows_subselect= NULL; if (!lex->current_select->explicit_limit) { Item *one= new (thd->mem_root) Item_int(thd, (int32) 1); diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index 02ab3b50388..84c89ccb705 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -616,7 +616,7 @@ Wsrep_replayer_service::~Wsrep_replayer_service() if (m_replay_status == wsrep::provider::success) { DBUG_ASSERT(replayer_thd->wsrep_cs().current_error() == wsrep::e_success); - orig_thd->killed= NOT_KILLED; + orig_thd->reset_kill_query(); my_ok(orig_thd, m_da_shadow.affected_rows, m_da_shadow.last_insert_id); } else if (m_replay_status == wsrep::provider::error_certification_failed) diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index fea537166f9..876854cb25d 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -2439,30 +2439,6 @@ dict_table_copy_types( dict_table_copy_v_types(tuple, table); } -/******************************************************************** -Wait until all the background threads of the given table have exited, i.e., -bg_threads == 0. Note: bg_threads_mutex must be reserved when -calling this. */ -void -dict_table_wait_for_bg_threads_to_exit( -/*===================================*/ - dict_table_t* table, /*< in: table */ - ulint delay) /*< in: time in microseconds to wait between - checks of bg_threads. */ -{ - fts_t* fts = table->fts; - - ut_ad(mutex_own(&fts->bg_threads_mutex)); - - while (fts->bg_threads > 0) { - mutex_exit(&fts->bg_threads_mutex); - - os_thread_sleep(delay); - - mutex_enter(&fts->bg_threads_mutex); - } -} - /*******************************************************************//** Builds the internal dictionary cache representation for a clustered index, containing also system fields not defined by the user. diff --git a/storage/innobase/fts/fts0config.cc b/storage/innobase/fts/fts0config.cc index fd7422171f0..410d60a5f4e 100644 --- a/storage/innobase/fts/fts0config.cc +++ b/storage/innobase/fts/fts0config.cc @@ -215,8 +215,7 @@ fts_config_set_value( pars_info_bind_varchar_literal(info, "value", value->f_str, value->f_len); - const bool dict_locked = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + const bool dict_locked = fts_table->table->fts->dict_locked; fts_table->suffix = "CONFIG"; fts_get_table_name(fts_table, table_name, dict_locked); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 246f1ce574c..adeda4c9487 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -459,7 +459,7 @@ fts_load_user_stopword( dberr_t error = DB_SUCCESS; ibool ret = TRUE; trx_t* trx; - ibool has_lock = fts->fts_status & TABLE_DICT_LOCKED; + ibool has_lock = fts->dict_locked; trx = trx_create(); trx->op_info = "Load user stopword table into FTS cache"; @@ -917,18 +917,16 @@ fts_que_graph_free_check_lock( const fts_index_cache_t*index_cache, /*!< in: FTS index cache */ que_t* graph) /*!< in: query graph */ { - ibool has_dict = FALSE; + bool has_dict = FALSE; if (fts_table && fts_table->table) { ut_ad(fts_table->table->fts); - has_dict = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + has_dict = fts_table->table->fts->dict_locked; } else if (index_cache) { ut_ad(index_cache->index->table->fts); - has_dict = index_cache->index->table->fts->fts_status - & TABLE_DICT_LOCKED; + has_dict = index_cache->index->table->fts->dict_locked; } if (!has_dict) { @@ -2780,7 +2778,7 @@ fts_update_sync_doc_id( pars_info_bind_varchar_literal(info, "doc_id", id, id_len); fts_get_table_name(&fts_table, fts_name, - table->fts->fts_status & TABLE_DICT_LOCKED); + table->fts->dict_locked); pars_info_bind_id(info, true, "table_name", fts_name); graph = fts_parse_sql( @@ -2894,7 +2892,7 @@ fts_delete( into cache from last crash (delete Doc will not initialize the sync). Avoid any added counter accounting until the FTS cache is re-established and sync-ed */ - if (table->fts->fts_status & ADDED_TABLE_SYNCED + if (table->fts->added_synced && doc_id > cache->synced_doc_id) { mutex_enter(&table->fts->cache->deleted_lock); @@ -3347,7 +3345,7 @@ fts_add_doc_from_tuple( ut_ad(cache->get_docs); - if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!ftt->table->fts->added_synced) { fts_init_index(ftt->table, FALSE); } @@ -3432,7 +3430,7 @@ fts_add_doc_by_id( /* If Doc ID has been supplied by the user, then the table might not yet be sync-ed */ - if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!ftt->table->fts->added_synced) { fts_init_index(ftt->table, FALSE); } @@ -4853,7 +4851,7 @@ fts_init_doc_id( fts_init_index((dict_table_t*) table, TRUE); } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; table->fts->cache->first_doc_id = max_doc_id; @@ -5237,67 +5235,6 @@ fts_cache_append_deleted_doc_ids( } /*********************************************************************//** -Wait for the background thread to start. We poll to detect change -of state, which is acceptable, since the wait should happen only -once during startup. -@return true if the thread started else FALSE (i.e timed out) */ -ibool -fts_wait_for_background_thread_to_start( -/*====================================*/ - dict_table_t* table, /*!< in: table to which the thread - is attached */ - ulint max_wait) /*!< in: time in microseconds, if - set to 0 then it disables - timeout checking */ -{ - ulint count = 0; - ibool done = FALSE; - - ut_a(max_wait == 0 || max_wait >= FTS_MAX_BACKGROUND_THREAD_WAIT); - - for (;;) { - fts_t* fts = table->fts; - - mutex_enter(&fts->bg_threads_mutex); - - if (fts->fts_status & BG_THREAD_READY) { - - done = TRUE; - } - - mutex_exit(&fts->bg_threads_mutex); - - if (!done) { - os_thread_sleep(FTS_MAX_BACKGROUND_THREAD_WAIT); - - if (max_wait > 0) { - - max_wait -= FTS_MAX_BACKGROUND_THREAD_WAIT; - - /* We ignore the residual value. */ - if (max_wait < FTS_MAX_BACKGROUND_THREAD_WAIT) { - break; - } - } - - ++count; - } else { - break; - } - - if (count >= FTS_BACKGROUND_THREAD_WAIT_COUNT) { - ib::error() << "The background thread for the FTS" - " table " << table->name - << " refuses to start"; - - count = 0; - } - } - - return(done); -} - -/*********************************************************************//** Add the FTS document id hidden column. */ void fts_add_doc_id_column( @@ -5379,8 +5316,8 @@ fts_t::fts_t( const dict_table_t* table, mem_heap_t* heap) : + in_queue(0), added_synced(0), dict_locked(0), bg_threads(0), - fts_status(0), add_wq(NULL), cache(NULL), doc_col(ULINT_UNDEFINED), @@ -5450,42 +5387,6 @@ fts_free( table->fts = NULL; } -#if 0 // TODO: Enable this in WL#6608 -/*********************************************************************//** -Signal FTS threads to initiate shutdown. */ -void -fts_start_shutdown( -/*===============*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance that needs - to be informed about shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - fts->fts_status |= BG_THREAD_STOP; - - mutex_exit(&fts->bg_threads_mutex); - -} - -/*********************************************************************//** -Wait for FTS threads to shutdown. */ -void -fts_shutdown( -/*=========*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance to shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - ut_a(fts->fts_status & BG_THREAD_STOP); - - dict_table_wait_for_bg_threads_to_exit(table, 20000); - - mutex_exit(&fts->bg_threads_mutex); -} -#endif - /*********************************************************************//** Take a FTS savepoint. */ UNIV_INLINE @@ -7467,7 +7368,7 @@ fts_init_index( } rw_lock_x_unlock(&cache->init_lock); - if (table->fts->fts_status & ADDED_TABLE_SYNCED) { + if (table->fts->added_synced) { goto func_exit; } @@ -7509,7 +7410,7 @@ fts_init_index( } } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; fts_get_docs_clear(cache->get_docs); diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 6a3e52d8ace..a7204974f84 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -2553,12 +2553,22 @@ void fts_optimize_add_table(dict_table_t* table) return; } + /* If there is no fts index present then don't add to + optimize queue. */ + if (!ib_vector_size(table->fts->indexes)) { + return; + } + /* Make sure table with FTS index cannot be evicted */ dict_table_prevent_eviction(table); msg = fts_optimize_create_msg(FTS_MSG_ADD_TABLE, table); ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + + mutex_enter(&table->fts->bg_threads_mutex); + table->fts->in_queue = true; + mutex_exit(&table->fts->bg_threads_mutex); } /**********************************************************************//** @@ -2585,6 +2595,15 @@ fts_optimize_remove_table( return; } + fts_t* fts = table->fts; + mutex_enter(&fts->bg_threads_mutex); + bool is_in_optimize_queue = fts->in_queue; + mutex_exit(&fts->bg_threads_mutex); + + if (!is_in_optimize_queue) { + return; + } + msg = fts_optimize_create_msg(FTS_MSG_DEL_TABLE, NULL); /* We will wait on this event until signalled by the consumer. */ @@ -2602,6 +2621,10 @@ fts_optimize_remove_table( os_event_wait(event); os_event_destroy(event); + + mutex_enter(&fts->bg_threads_mutex); + fts->in_queue = false; + mutex_exit(&fts->bg_threads_mutex); } /** Send sync fts cache for the table. @@ -2633,6 +2656,10 @@ fts_optimize_request_sync_table( msg->ptr = table_id; ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + + mutex_enter(&table->fts->bg_threads_mutex); + table->fts->in_queue = true; + mutex_exit(&table->fts->bg_threads_mutex); } /** Add a table to fts_slots if it doesn't already exist. */ @@ -2776,6 +2803,10 @@ static void fts_optimize_sync_table(table_id_t table_id) fts_sync_table(table, false); } + DBUG_EXECUTE_IF( + "ib_optimize_wq_hang", + os_thread_sleep(6000000);); + dict_table_close(table, FALSE, FALSE); } } diff --git a/storage/innobase/fts/fts0sql.cc b/storage/innobase/fts/fts0sql.cc index a38c3f7a488..6873df102bf 100644 --- a/storage/innobase/fts/fts0sql.cc +++ b/storage/innobase/fts/fts0sql.cc @@ -154,8 +154,7 @@ fts_parse_sql( str = ut_str3cat(fts_sql_begin, sql, fts_sql_end); dict_locked = (fts_table && fts_table->table->fts - && (fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED)); + && fts_table->table->fts->dict_locked); if (!dict_locked) { ut_ad(!mutex_own(&dict_sys.mutex)); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index c592dfaf0b8..8e6725200c2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9767,10 +9767,10 @@ ha_innobase::ft_init_ext( return(NULL); } - if (!(ft_table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!(ft_table->fts->added_synced)) { fts_init_index(ft_table, FALSE); - ft_table->fts->fts_status |= ADDED_TABLE_SYNCED; + ft_table->fts->added_synced = true; } const byte* q = reinterpret_cast<const byte*>( diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 5a7360e516a..14125272daf 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -5933,7 +5933,7 @@ empty_table: index->set_modified(mtr); err = row_ins_clust_index_entry_low( BTR_NO_LOCKING_FLAG, BTR_MODIFY_TREE, index, - index->n_uniq, entry, 0, thr, false); + index->n_uniq, entry, 0, thr); } else { err_exit: err = DB_CORRUPTION; @@ -6997,15 +6997,13 @@ op_ok: goto error_handling; } - ctx->new_table->fts->fts_status - |= TABLE_DICT_LOCKED; + ctx->new_table->fts->dict_locked = true; error = innobase_fts_load_stopword( ctx->new_table, ctx->trx, ctx->prebuilt->trx->mysql_thd) ? DB_SUCCESS : DB_ERROR; - ctx->new_table->fts->fts_status - &= ulint(~TABLE_DICT_LOCKED); + ctx->new_table->fts->dict_locked = false; if (error != DB_SUCCESS) { goto error_handling; @@ -10357,6 +10355,7 @@ commit_cache_norebuild( || (index->type & DICT_CORRUPT)); DBUG_ASSERT(index->table->fts); + DEBUG_SYNC_C("norebuild_fts_drop"); fts_drop_index(index->table, index, trx); } diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 32782c27b55..6f2a8f034d8 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -968,17 +968,6 @@ dict_table_copy_types( dtuple_t* tuple, /*!< in/out: data tuple */ const dict_table_t* table) /*!< in: table */ MY_ATTRIBUTE((nonnull)); -/******************************************************************** -Wait until all the background threads of the given table have exited, i.e., -bg_threads == 0. Note: bg_threads_mutex must be reserved when -calling this. */ -void -dict_table_wait_for_bg_threads_to_exit( -/*===================================*/ - dict_table_t* table, /* in: table */ - ulint delay) /* in: time in microseconds to wait between - checks of bg_threads. */ - MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 07be853efad..8643f0f79a3 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -304,27 +304,6 @@ struct fts_table_t { index auxiliary table */ }; -enum fts_status { - BG_THREAD_STOP = 1, /*!< TRUE if the FTS background thread - has finished reading the ADDED table, - meaning more items can be added to - the table. */ - - BG_THREAD_READY = 2, /*!< TRUE if the FTS background thread - is ready */ - - ADD_THREAD_STARTED = 4, /*!< TRUE if the FTS add thread - has started */ - - ADDED_TABLE_SYNCED = 8, /*!< TRUE if the ADDED table record is - sync-ed after crash recovery */ - - TABLE_DICT_LOCKED = 16 /*!< Set if the table has - dict_sys.mutex */ -}; - -typedef enum fts_status fts_status_t; - /** The state of the FTS sub system. */ class fts_t { public: @@ -341,13 +320,19 @@ public: /** Mutex protecting bg_threads* and fts_add_wq. */ ib_mutex_t bg_threads_mutex; + /** Whether the table was added to fts_optimize_wq(); + protected by bg_threads_mutex */ + unsigned in_queue:1; + /** Whether the ADDED table record sync-ed after + crash recovery; protected by bg_threads_mutex */ + unsigned added_synced:1; + /** Whether the table holds dict_sys.mutex; + protected by bg_threads_mutex */ + unsigned dict_locked:1; + /** Number of background threads accessing this table. */ ulint bg_threads; - /** Status bit regarding fts running state. TRUE if background - threads running should stop themselves. */ - ulint fts_status; - /** Work queue for scheduling jobs for the FTS 'Add' thread, or NULL if the thread has not yet been created. Each work item is a fts_trx_doc_ids_t*. */ @@ -632,28 +617,6 @@ void fts_startup(void); /*==============*/ -#if 0 // TODO: Enable this in WL#6608 -/******************************************************************//** -Signal FTS threads to initiate shutdown. */ -void -fts_start_shutdown( -/*===============*/ - dict_table_t* table, /*!< in: table with FTS - indexes */ - fts_t* fts); /*!< in: fts instance to - shutdown */ - -/******************************************************************//** -Wait for FTS threads to shutdown. */ -void -fts_shutdown( -/*=========*/ - dict_table_t* table, /*!< in: table with FTS - indexes */ - fts_t* fts); /*!< in: fts instance to - shutdown */ -#endif - /******************************************************************//** Create an instance of fts_t. @return instance of fts_t */ diff --git a/storage/innobase/include/fts0priv.h b/storage/innobase/include/fts0priv.h index f41280c22f8..018e801409b 100644 --- a/storage/innobase/include/fts0priv.h +++ b/storage/innobase/include/fts0priv.h @@ -442,19 +442,6 @@ fts_cache_append_deleted_doc_ids( cache, /*!< in: cache to use */ ib_vector_t* vector); /*!< in: append to this vector */ /******************************************************************//** -Wait for the background thread to start. We poll to detect change -of state, which is acceptable, since the wait should happen only -once during startup. -@return true if the thread started else FALSE (i.e timed out) */ -ibool -fts_wait_for_background_thread_to_start( -/*====================================*/ - dict_table_t* table, /*!< in: table to which the thread - is attached */ - ulint max_wait); /*!< in: time in microseconds, if set - to 0 then it disables timeout - checking */ -/******************************************************************//** Search the index specific cache for a particular FTS index. @return the index specific cache else NULL */ fts_index_cache_t* diff --git a/storage/innobase/include/row0ins.h b/storage/innobase/include/row0ins.h index 82bb3c91171..ddc3db8c694 100644 --- a/storage/innobase/include/row0ins.h +++ b/storage/innobase/include/row0ins.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, 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 the Free Software @@ -92,10 +92,7 @@ row_ins_clust_index_entry_low( ulint n_uniq, /*!< in: 0 or index->n_uniq */ dtuple_t* entry, /*!< in/out: index entry to insert */ ulint n_ext, /*!< in: number of externally stored columns */ - que_thr_t* thr, /*!< in: query thread or NULL */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + que_thr_t* thr) /*!< in: query thread or NULL */ MY_ATTRIBUTE((warn_unused_result)); /***************************************************************//** @@ -120,10 +117,7 @@ row_ins_sec_index_entry_low( dtuple_t* entry, /*!< in/out: index entry to insert */ trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during row_log_table_apply(), or 0 */ - que_thr_t* thr, /*!< in: query thread */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + que_thr_t* thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); /***************************************************************//** @@ -138,10 +132,7 @@ row_ins_clust_index_entry( dict_index_t* index, /*!< in: clustered index */ dtuple_t* entry, /*!< in/out: index entry to insert */ que_thr_t* thr, /*!< in: query thread */ - ulint n_ext, /*!< in: number of externally stored columns */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + ulint n_ext) /*!< in: number of externally stored columns */ MY_ATTRIBUTE((warn_unused_result)); /***************************************************************//** Inserts an entry into a secondary index. Tries first optimistic, @@ -154,10 +145,7 @@ row_ins_sec_index_entry( /*====================*/ dict_index_t* index, /*!< in: secondary index */ dtuple_t* entry, /*!< in/out: index entry to insert */ - que_thr_t* thr, /*!< in: query thread */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + que_thr_t* thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); /***********************************************************//** Inserts a row to a table. This is a high-level function used in diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 9ba3a33f583..b2a2f40e777 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -6083,6 +6083,8 @@ lock_cancel_waiting_and_release( } lock_table_dequeue(lock); + /* Remove the lock from table lock vector too. */ + lock_trx_table_locks_remove(lock); } /* Reset the wait flag and the back pointer to lock in trx. */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 64e38f7ff2f..bb654f08cdb 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2577,10 +2577,7 @@ row_ins_clust_index_entry_low( ulint n_uniq, /*!< in: 0 or index->n_uniq */ dtuple_t* entry, /*!< in/out: index entry to insert */ ulint n_ext, /*!< in: number of externally stored columns */ - que_thr_t* thr, /*!< in: query thread */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + que_thr_t* thr) /*!< in: query thread */ { btr_pcur_t pcur; btr_cur_t* cursor; @@ -2676,7 +2673,6 @@ row_ins_clust_index_entry_low( ut_ad(flags == BTR_NO_LOCKING_FLAG); ut_ad(index->is_instant()); ut_ad(!dict_index_is_online_ddl(index)); - ut_ad(!dup_chk_only); const rec_t* rec = btr_cur_get_rec(cursor); @@ -2732,11 +2728,6 @@ err_exit: } } - if (dup_chk_only) { - mtr_commit(&mtr); - goto func_exit; - } - /* Note: Allowing duplicates would qualify for modification of an existing record as the new entry is exactly same as old entry. */ if (row_ins_must_modify_rec(cursor)) { @@ -2898,10 +2889,7 @@ row_ins_sec_index_entry_low( dtuple_t* entry, /*!< in/out: index entry to insert */ trx_id_t trx_id, /*!< in: PAGE_MAX_TRX_ID during row_log_table_apply(), or 0 */ - que_thr_t* thr, /*!< in: query thread */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + que_thr_t* thr) /*!< in: query thread */ { DBUG_ENTER("row_ins_sec_index_entry_low"); @@ -3098,10 +3086,6 @@ row_ins_sec_index_entry_low( &cursor, 0, __FILE__, __LINE__, &mtr); } - if (dup_chk_only) { - goto func_exit; - } - if (row_ins_must_modify_rec(&cursor)) { /* There is already an index entry with a long enough common prefix, we must convert the insert into a modify of an @@ -3190,10 +3174,7 @@ row_ins_clust_index_entry( dict_index_t* index, /*!< in: clustered index */ dtuple_t* entry, /*!< in/out: index entry to insert */ que_thr_t* thr, /*!< in: query thread */ - ulint n_ext, /*!< in: number of externally stored columns */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + ulint n_ext) /*!< in: number of externally stored columns */ { dberr_t err; ulint n_uniq; @@ -3250,7 +3231,7 @@ row_ins_clust_index_entry( err = row_ins_clust_index_entry_low( flags, BTR_MODIFY_LEAF, index, n_uniq, entry, - n_ext, thr, dup_chk_only); + n_ext, thr); entry->n_fields = orig_n_fields; @@ -3267,7 +3248,7 @@ row_ins_clust_index_entry( err = row_ins_clust_index_entry_low( flags, BTR_MODIFY_TREE, index, n_uniq, entry, - n_ext, thr, dup_chk_only); + n_ext, thr); entry->n_fields = orig_n_fields; @@ -3285,10 +3266,7 @@ row_ins_sec_index_entry( /*====================*/ dict_index_t* index, /*!< in: secondary index */ dtuple_t* entry, /*!< in/out: index entry to insert */ - que_thr_t* thr, /*!< in: query thread */ - bool dup_chk_only) - /*!< in: if true, just do duplicate check - and return. don't execute actual insert. */ + que_thr_t* thr) /*!< in: query thread */ { dberr_t err; mem_heap_t* offsets_heap; @@ -3331,7 +3309,7 @@ row_ins_sec_index_entry( err = row_ins_sec_index_entry_low( flags, BTR_MODIFY_LEAF, index, offsets_heap, heap, entry, - trx_id, thr, dup_chk_only); + trx_id, thr); if (err == DB_FAIL) { mem_heap_empty(heap); @@ -3345,8 +3323,7 @@ row_ins_sec_index_entry( err = row_ins_sec_index_entry_low( flags, BTR_MODIFY_TREE, index, - offsets_heap, heap, entry, 0, thr, - dup_chk_only); + offsets_heap, heap, entry, 0, thr); } mem_heap_free(heap); @@ -3375,9 +3352,9 @@ row_ins_index_entry( return(DB_LOCK_WAIT);}); if (index->is_primary()) { - return(row_ins_clust_index_entry(index, entry, thr, 0, false)); + return row_ins_clust_index_entry(index, entry, thr, 0); } else { - return(row_ins_sec_index_entry(index, entry, thr, false)); + return row_ins_sec_index_entry(index, entry, thr); } } diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index fb0a376dd34..caffeab6af0 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1722,7 +1722,7 @@ row_log_table_apply_insert_low( error = row_ins_clust_index_entry_low( flags, BTR_MODIFY_TREE, index, index->n_uniq, - entry, 0, thr, false); + entry, 0, thr); switch (error) { case DB_SUCCESS: @@ -1746,7 +1746,7 @@ row_log_table_apply_insert_low( error = row_ins_sec_index_entry_low( flags, BTR_MODIFY_TREE, index, offsets_heap, heap, entry, - thr_get_trx(thr)->id, thr, false); + thr_get_trx(thr)->id, thr); if (error != DB_SUCCESS) { if (error == DB_DUPLICATE_KEY) { @@ -2377,7 +2377,7 @@ func_exit_committed: BTR_CREATE_FLAG | BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG | BTR_KEEP_SYS_FLAG, BTR_MODIFY_TREE, index, offsets_heap, heap, - entry, thr_get_trx(thr)->id, thr, false); + entry, thr_get_trx(thr)->id, thr); /* Report correct index name for duplicate key error. */ if (error == DB_DUPLICATE_KEY) { diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 7e593d1ebec..3c80cb1596f 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -3233,10 +3233,9 @@ row_drop_ancillary_fts_tables( DICT_TF2_FTS flag set. So keep this out of above dict_table_has_fts_index condition */ if (table->fts != NULL) { - /* Need to set TABLE_DICT_LOCKED bit, since - fts_que_graph_free_check_lock would try to acquire + /* fts_que_graph_free_check_lock would try to acquire dict mutex lock */ - table->fts->fts_status |= TABLE_DICT_LOCKED; + table->fts->dict_locked = true; fts_free(table); } diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 8b1ddfc36a6..db39b486d0e 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2509,7 +2509,7 @@ row_upd_sec_index_entry( ut_a(entry); /* Insert new index entry */ - err = row_ins_sec_index_entry(index, entry, thr, false); + err = row_ins_sec_index_entry(index, entry, thr); func_exit: mem_heap_free(heap); @@ -2792,7 +2792,7 @@ check_fk: err = row_ins_clust_index_entry( index, entry, thr, - node->upd_ext ? node->upd_ext->n_ext : 0, false); + node->upd_ext ? node->upd_ext->n_ext : 0); node->state = UPD_NODE_INSERT_CLUSTERED; mem_heap_free(heap); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index cdabaad5f53..5d42650953b 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -504,7 +504,7 @@ inline void trx_t::release_locks() mem_heap_empty(lock.lock_heap); } - lock.table_locks.clear(); /* outside "if" to work around MDEV-20483 */ + lock.table_locks.clear(); } /** At shutdown, frees a transaction object. */ @@ -1156,26 +1156,14 @@ trx_finalize_for_fts_table( fts_t* fts = ftt->table->fts; fts_doc_ids_t* doc_ids = ftt->added_doc_ids; - mutex_enter(&fts->bg_threads_mutex); + ut_a(fts->add_wq); - if (fts->fts_status & BG_THREAD_STOP) { - /* The table is about to be dropped, no use - adding anything to its work queue. */ + mem_heap_t* heap = static_cast<mem_heap_t*>(doc_ids->self_heap->arg); - mutex_exit(&fts->bg_threads_mutex); - } else { - mem_heap_t* heap; - mutex_exit(&fts->bg_threads_mutex); - - ut_a(fts->add_wq); - - heap = static_cast<mem_heap_t*>(doc_ids->self_heap->arg); + ib_wqueue_add(fts->add_wq, doc_ids, heap); - ib_wqueue_add(fts->add_wq, doc_ids, heap); - - /* fts_trx_table_t no longer owns the list. */ - ftt->added_doc_ids = NULL; - } + /* fts_trx_table_t no longer owns the list. */ + ftt->added_doc_ids = NULL; } /******************************************************************//** @@ -1277,16 +1265,10 @@ trx_update_mod_tables_timestamp( trx_mod_tables_t::const_iterator end = trx->mod_tables.end(); #ifdef UNIV_DEBUG -# if MYSQL_VERSION_ID >= 100405 -# define dict_sys_mutex dict_sys.mutex -# else -# define dict_sys_mutex dict_sys->mutex -# endif - const bool preserve_tables = !innodb_evict_tables_on_commit_debug || trx->is_recovered /* avoid trouble with XA recovery */ # if 1 /* if dict_stats_exec_sql() were not playing dirty tricks */ - || mutex_own(&dict_sys_mutex) + || mutex_own(&dict_sys.mutex) # else /* this would be more proper way to do it */ || trx->dict_operation_lock_mode || trx->dict_operation # endif @@ -1316,15 +1298,11 @@ trx_update_mod_tables_timestamp( } /* recheck while holding the mutex that blocks table->acquire() */ - mutex_enter(&dict_sys_mutex); + mutex_enter(&dict_sys.mutex); if (!table->get_ref_count()) { -# if MYSQL_VERSION_ID >= 100405 dict_sys.remove(table, true); -# else - dict_table_remove_from_cache_low(table, true); -# endif } - mutex_exit(&dict_sys_mutex); + mutex_exit(&dict_sys.mutex); #endif } @@ -1403,6 +1381,16 @@ trx_commit_in_memory( DBUG_LOG("trx", "Autocommit in memory: " << trx); trx->state = TRX_STATE_NOT_STARTED; } else { +#ifdef UNIV_DEBUG + if (!UT_LIST_GET_LEN(trx->lock.trx_locks)) { + for (lock_list::iterator it + = trx->lock.table_locks.begin(); + it != trx->lock.table_locks.end(); + it++) { + ut_ad(!*it); + } + } +#endif /* UNIV_DEBUG */ trx->commit_state(); if (trx->id) { diff --git a/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result index 8a2e193a083..6507aa43ae1 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result @@ -292,37 +292,37 @@ b i421 l421 b m422 p422 explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by @@ -1602,13 +1602,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by @@ -1728,7 +1728,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by @@ -1802,16 +1802,16 @@ Warnings: Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where `test`.`t1`.`b` = 'a' and `test`.`t1`.`c` = 'i121' and `test`.`t1`.`a2` >= 'b' explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by explain select distinct b from t1 where (a2 >= 'b') and (b = 'a'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by explain select distinct a1,a2,b from t2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by @@ -1831,10 +1831,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL idx_t2_2 146 NULL 164 Using where; Using index explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 37 Using where; Using index for group-by +1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 6 Using where; Using index for group-by explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 37 Using where; Using index for group-by +1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 6 Using where; Using index for group-by select distinct a1,a2,b from t1; a1 a2 b a a a @@ -1972,16 +1972,16 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 39 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by explain select distinct a1,a2,b from t2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by @@ -2091,7 +2091,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 100.00 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 100.00 Using where; Using index for group-by Warnings: Note 1003 select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`b` = 'c' and `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a' explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); @@ -2099,7 +2099,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index explain extended select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 133 100.00 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 100.00 Using where; Using index for group-by Warnings: Note 1003 select 98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `98 + count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a' select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); @@ -2119,16 +2119,16 @@ select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); 104 explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 133 Using where; Using index for group-by +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by @@ -2207,19 +2207,19 @@ id select_type table type possible_keys key key_len ref rows Extra explain extended select a1,a2,min(b),max(b) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 128 99.22 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2` explain extended select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 128 75.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select a1,a2,b,c from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using where +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 128 75.00 Using where Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; @@ -2236,7 +2236,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 128 99.22 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; @@ -2260,12 +2260,12 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 128 100.00 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 128 100.00 Using where; Using index Warnings: Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1; @@ -2470,7 +2470,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,b PRIMARY 8 NULL 500 Using where; Using index for group-by +1 SIMPLE t1 range PRIMARY,b PRIMARY 8 NULL 2 Using where; Using index for group-by SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; MAX(b) a 1 1 @@ -2485,7 +2485,7 @@ test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 500 Using where; Using index for group-by +1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 2 Using where; Using index for group-by SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; MIN(c) 2 @@ -2557,7 +2557,7 @@ EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index -2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by +2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra @@ -2566,32 +2566,32 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index -2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1_outer index a a 10 NULL 15 Using where; Using index -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t1_outer.a 1 -2 MATERIALIZED t1 range a a 5 NULL 400 Using where; Using index for group-by +1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 6 +1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 3 Using index +2 MATERIALIZED t1 range a a 5 NULL 6 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer range NULL a 5 NULL 6 Using index for group-by -2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by +2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) AND t1_outer1.b = t1_outer2.b; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1_outer1 ref a a 5 const 3 Using where; Using index -1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join) -2 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by +1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index +1 PRIMARY t1_outer1 ref a a 10 const,test.t1_outer2.b 1 Using where; Using index +2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index 2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index -3 SUBQUERY t1 range a a 5 NULL 400 Using where; Using index for group-by +3 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by CREATE TABLE t3 LIKE t1; FLUSH STATUS; INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; @@ -3322,14 +3322,14 @@ a c COUNT(DISTINCT c, a, b) EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2 WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range a a 15 NULL 1062 Using where; Using index for group-by (scanning) +1 SIMPLE t2 range a a 15 NULL 17 Using where; Using index for group-by SELECT COUNT(DISTINCT c, a, b) FROM t2 WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; COUNT(DISTINCT c, a, b) EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5 GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref a a 5 const 1000 Using where; Using index +1 SIMPLE t2 ref a a 5 const 16 Using where; Using index SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5 GROUP BY b; COUNT(DISTINCT b) SUM(DISTINCT b) @@ -3505,7 +3505,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref c1 c1 5 const 1000 Using index +1 SIMPLE t1 ref c1 c1 5 const 28 Using index FLUSH STATUS; SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; MAX(c2) c1 diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result index 90de5447891..395c84edfe9 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result @@ -101,6 +101,7 @@ a b SELECT * FROM t1 FORCE INDEX (kb); a b DROP TABLE t1; +set global rocksdb_compact_cf= 'default'; # Read filtering index scan tests (None of these queries should return any results) CREATE TABLE t1 ( a int, diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test index d6be7d95f8d..f6042cc517e 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test @@ -121,6 +121,9 @@ SELECT * FROM t1 FORCE INDEX (kb); DROP TABLE t1; +# Compact away the dropped data +set global rocksdb_compact_cf= 'default'; + --echo # Read filtering index scan tests (None of these queries should return any results) CREATE TABLE t1 ( a int, diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 9cf10df4189..55b39b00c54 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -2156,7 +2156,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort ) #if MYSQL_VERSION_ID>=50515 struct addrinfo *hp = NULL; tmp_errno = getaddrinfo ( sHost, NULL, NULL, &hp ); - if ( !tmp_errno || !hp || !hp->ai_addr ) + if ( tmp_errno || !hp || !hp->ai_addr ) { bError = true; if ( hp ) @@ -2183,8 +2183,9 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort ) } #if MYSQL_VERSION_ID>=50515 - memcpy ( &sin.sin_addr, hp->ai_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->ai_addrlen ) ); - freeaddrinfo ( hp ); + struct sockaddr_in *in = (sockaddr_in *)hp->ai_addr; + memcpy ( &sin.sin_addr, &in->sin_addr, Min ( sizeof(sin.sin_addr), sizeof(in->sin_addr) ) ); + freeaddrinfo ( hp ); #else memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) ); my_gethostbyname_r_free(); diff --git a/storage/sphinx/mysql-test/sphinx/sphinx.result b/storage/sphinx/mysql-test/sphinx/sphinx.result index 3536ba42af8..c462d0cc883 100644 --- a/storage/sphinx/mysql-test/sphinx/sphinx.result +++ b/storage/sphinx/mysql-test/sphinx/sphinx.result @@ -75,3 +75,23 @@ id w q 1 2 test;range=meta.foo_count,100,500 5 1 test;range=meta.foo_count,100,500 drop table ts; +# +# MDEV-19205: Sphinx unable to connect using a host name +# +create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://localhost:SPHINXSEARCH_PORT/*"; +select * from ts where q=';filter=meta.foo_count,100'; +id w q +1 1 ;filter=meta.foo_count,100 +select * from ts where q='test;filter=meta.sub.int,7'; +id w q +5 1 test;filter=meta.sub.int,7 +select * from ts where q=';filter=meta.sub.list[0],4'; +id w q +select * from ts where q=';filter=meta.sub.list[1],4'; +id w q +5 1 ;filter=meta.sub.list[1],4 +select * from ts where q='test;range=meta.foo_count,100,500'; +id w q +1 2 test;range=meta.foo_count,100,500 +5 1 test;range=meta.foo_count,100,500 +drop table ts; diff --git a/storage/sphinx/mysql-test/sphinx/sphinx.test b/storage/sphinx/mysql-test/sphinx/sphinx.test index fe388f7ddd2..b733a3fc5ff 100644 --- a/storage/sphinx/mysql-test/sphinx/sphinx.test +++ b/storage/sphinx/mysql-test/sphinx/sphinx.test @@ -41,3 +41,16 @@ select * from ts where q=';filter=meta.sub.list[0],4'; select * from ts where q=';filter=meta.sub.list[1],4'; select * from ts where q='test;range=meta.foo_count,100,500'; drop table ts; + +--echo # +--echo # MDEV-19205: Sphinx unable to connect using a host name +--echo # + +--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT +eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://localhost:$SPHINXSEARCH_PORT/*"; +select * from ts where q=';filter=meta.foo_count,100'; +select * from ts where q='test;filter=meta.sub.int,7'; +select * from ts where q=';filter=meta.sub.list[0],4'; +select * from ts where q=';filter=meta.sub.list[1],4'; +select * from ts where q='test;range=meta.foo_count,100,500'; +drop table ts; diff --git a/storage/spider/CMakeLists.txt b/storage/spider/CMakeLists.txt index 62dfc968579..706b11ac141 100644 --- a/storage/spider/CMakeLists.txt +++ b/storage/spider/CMakeLists.txt @@ -55,6 +55,9 @@ ELSE() DESTINATION ${INSTALL_MYSQLSHAREDIR} COMPONENT Server ) MYSQL_ADD_PLUGIN(spider ${SPIDER_SOURCES} STORAGE_ENGINE MODULE_ONLY MODULE_OUTPUT_NAME "ha_spider") + IF(NOT TARGET spider) + RETURN() + ENDIF() ENDIF() IF(ORACLE_INCLUDE_DIR AND ORACLE_OCI_LIBRARY) diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index b6332ea5075..b1371fafa71 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -1,16 +1,22 @@ +# It's not recommended to modify this file in-place, because it will be +# overwritten during package upgrades. If you want to customize, the +# best way is to create a file "/etc/systemd/system/mariadb.service", +# containing +# .include /usr/lib/systemd/system/mariadb.service +# ...make your changes here... +# or create a file "/etc/systemd/system/mariadb.service.d/foo.conf", +# which doesn't need to include ".include" call and which will be parsed +# after the file mariadb.service itself is parsed. # -# /etc/systemd/system/mariadb.service +# For more info about custom unit files, see systemd.unit(5) or +# https://mariadb.com/kb/en/mariadb/systemd/ +# +# Copyright notice: # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. -# -# Thanks to: -# Daniel Black -# Erkan Yanar -# David Strauss -# and probably others [Unit] Description=MariaDB @VERSION@ database server @@ -85,12 +91,15 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ # Use the [Service] section and Environment="MYSQLD_OPTS=...". # This isn't a replacement for my.cnf. # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster -ExecStart=@sbindir@/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION -@SYSTEMD_EXECSTARTPOST@ +# Note: we set --basedir to prevent probes that might trigger SELinux alarms, +# per bug https://bugzilla.redhat.com/show_bug.cgi?id=547485 +ExecStart=@sbindir@/mysqld $MYSQLD_OPTS --basedir=@prefix@ $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION # Unset _WSREP_START_POSITION environment variable. ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" +@SYSTEMD_EXECSTARTPOST@ + KillSignal=SIGTERM # Don't want to see an automated SIGKILL ever diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index 326d8e52b3c..c66f5a776eb 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -6,6 +6,19 @@ # scripts are needed. # # +# It's not recommended to modify this file in-place, because it will be +# overwritten during package upgrades. If you want to customize, the +# best way is to create a file "/etc/systemd/system/mariadb@.service", +# containing +# .include /usr/lib/systemd/system/mariadb@.service +# ...make your changes here... +# or create a file "/etc/systemd/system/mariadb@.service.d/foo.conf", +# which doesn't need to include ".include" call and which will be parsed +# after the file mariadb@.service itself is parsed. +# +# For more info about custom unit files, see systemd.unit(5) or +# https://mariadb.com/kb/en/mariadb/systemd/ +# # Copyright notice: # # This file is free software; you can redistribute it and/or modify it @@ -131,7 +144,7 @@ # systemd.service(5) [Unit] -Description=MariaDB @VERSION@ database server (multi-instance) +Description=MariaDB @VERSION@ database server (multi-instance %I) Documentation=man:mysqld(8) Documentation=https://mariadb.com/kb/en/library/systemd/ After=network.target @@ -195,6 +208,8 @@ ExecStartPre=@scriptdir@/mysql_install_db $MYSQLD_MULTI_INSTANCE # Note 1: Place $MYSQLD_OPTS at the very end for its options to take precedence. ExecStart=@sbindir@/mysqld $MYSQLD_MULTI_INSTANCE $MYSQLD_OPTS +@SYSTEMD_EXECSTARTPOST@ + KillSignal=SIGTERM # Don't want to see an automated SIGKILL ever diff --git a/support-files/use_galera_new_cluster.conf b/support-files/use_galera_new_cluster.conf index 90e0365ffd8..4d8ad253ce5 100644 --- a/support-files/use_galera_new_cluster.conf +++ b/support-files/use_galera_new_cluster.conf @@ -15,8 +15,11 @@ ConditionPathExists= Type=oneshot Restart=no +ExecStartPre= + # Override the multi instance service for a bootstrap start instance ExecStart= ExecStart=/usr/bin/echo "Please use galera_new_cluster to start the mariadb service with --wsrep-new-cluster" ExecStart=/usr/bin/false +ExecStartPost= |