diff --git a/THIRDPARTY b/THIRDPARTY index 87f9bb7a3b5..62e91df1f48 100644 --- a/THIRDPARTY +++ b/THIRDPARTY @@ -1712,3 +1712,32 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *************************************************************************** + +%%The following software may be included in this product: +socketpair.c + +Copyright 2007, 2010 by Nathan C. Myers +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + The name of the author must not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/VERSION b/VERSION index 5af2fd0259a..c22fcab7203 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=11 MYSQL_VERSION_MINOR=4 -MYSQL_VERSION_PATCH=0 -SERVER_MATURITY=alpha +MYSQL_VERSION_PATCH=1 +SERVER_MATURITY=gamma diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8e42d29c4ba..3aa59299437 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -16,7 +16,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/mysys_ssl ${ZLIB_INCLUDE_DIR} ${SSL_INCLUDE_DIRS} diff --git a/client/mysql.cc b/client/mysql.cc index 99bc5b14ef0..9ef1b75d5bd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -261,6 +261,9 @@ static int connect_flag=CLIENT_INTERACTIVE; static my_bool opt_binary_mode= FALSE; static my_bool opt_connect_expired_password= FALSE; static int interrupted_query= 0; +#ifdef USE_LIBEDIT_INTERFACE +static int sigint_received= 0; +#endif static char *current_host,*current_db,*current_user=0,*opt_password=0, *current_prompt=0, *delimiter_str= 0, *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME, @@ -1166,6 +1169,8 @@ extern "C" sig_handler handle_sigint(int sig); static sig_handler window_resize(int sig); #endif +static void end_in_sig_handler(int sig); +static bool kill_query(const char *reason); const char DELIMITER_NAME[]= "delimiter"; const uint DELIMITER_NAME_LEN= sizeof(DELIMITER_NAME) - 1; @@ -1306,8 +1311,8 @@ int main(int argc,char *argv[]) if (opt_sigint_ignore) signal(SIGINT, SIG_IGN); else - signal(SIGINT, handle_sigint); // Catch SIGINT to clean up - signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up + signal(SIGINT, handle_sigint); // Catch SIGINT to clean up + signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up #if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL) /* Readline will call this if it installs a handler */ @@ -1518,30 +1523,35 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user, } -/* - This function handles sigint calls - If query is in process, kill query - If 'source' is executed, abort source command - no query in process, terminate like previous behavior - */ +void end_in_sig_handler(int sig) +{ +#ifdef _WIN32 + /* + When SIGINT is raised on Windows, the OS creates a new thread to handle the + interrupt. Once that thread completes, the main thread continues running + only to find that it's resources have already been free'd when the sigint + handler called mysql_end(). + */ + mysql_thread_end(); +#else + mysql_end(sig); +#endif +} -sig_handler handle_sigint(int sig) + +/* + Kill a running query. Returns true if we were unable to connect to the server. +*/ +bool kill_query(const char *reason) { char kill_buffer[40]; MYSQL *kill_mysql= NULL; - /* terminate if no query being executed, or we already tried interrupting */ - if (!executing_query || (interrupted_query == 2)) - { - tee_fprintf(stdout, "Ctrl-C -- exit!\n"); - goto err; - } - kill_mysql= mysql_init(kill_mysql); if (!do_connect(kill_mysql,current_host, current_user, opt_password, "", 0)) { - tee_fprintf(stdout, "Ctrl-C -- sorry, cannot connect to server to kill query, giving up ...\n"); - goto err; + tee_fprintf(stdout, "%s -- sorry, cannot connect to server to kill query, giving up ...\n", reason); + return true; } /* First time try to kill the query, second time the connection */ @@ -1556,27 +1566,62 @@ sig_handler handle_sigint(int sig) (interrupted_query == 1) ? "QUERY " : "", mysql_thread_id(&mysql)); if (verbose) - tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n", + tee_fprintf(stdout, "%s -- sending \"%s\" to server ...\n", reason, kill_buffer); mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer)); mysql_close(kill_mysql); - tee_fprintf(stdout, "Ctrl-C -- query killed. Continuing normally.\n"); + if (interrupted_query == 1) + tee_fprintf(stdout, "%s -- query killed.\n", reason); + else + tee_fprintf(stdout, "%s -- connection killed.\n", reason); + if (in_com_source) aborted= 1; // Abort source command - return; + return false; +} -err: -#ifdef _WIN32 +/* + This function handles sigint calls + If query is in process, kill query + If 'source' is executed, abort source command + no query in process, regenerate prompt. +*/ +sig_handler handle_sigint(int sig) +{ /* - When SIGINT is raised on Windows, the OS creates a new thread to handle the - interrupt. Once that thread completes, the main thread continues running - only to find that it's resources have already been free'd when the sigint - handler called mysql_end(). + On Unix only, if no query is being executed just clear the prompt, + don't exit. On Windows we exit. */ - mysql_thread_end(); + if (!executing_query) + { +#ifndef _WIN32 + tee_fprintf(stdout, "^C\n"); +#ifdef USE_LIBEDIT_INTERFACE + /* Libedit will regenerate it outside of the signal handler. */ + sigint_received= 1; #else - mysql_end(sig); -#endif + rl_on_new_line(); // Regenerate the prompt on a newline + rl_replace_line("", 0); // Clear the previous text + rl_redisplay(); +#endif +#else // WIN32 + tee_fprintf(stdout, "Ctrl-C -- exit!\n"); + end_in_sig_handler(sig); +#endif + return; + } + + /* + When executing a query, this newline makes the prompt look like so: + ^C + Ctrl-C -- query killed. + */ + tee_fprintf(stdout, "\n"); + if (kill_query("Ctrl-C")) + { + aborted= 1; + end_in_sig_handler(sig); + } } @@ -2147,6 +2192,15 @@ static int get_options(int argc, char **argv) return(0); } + +#if !defined(_WIN32) && defined(USE_LIBEDIT_INTERFACE) +static inline void reset_prompt(char *in_string, bool *ml_comment) { + glob_buffer.length(0); + *ml_comment = false; + *in_string = 0; +} +#endif + static int read_and_execute(bool interactive) { char *line= NULL; @@ -2238,7 +2292,30 @@ static int read_and_execute(bool interactive) if (line) free(line); line= readline(prompt); -#endif /* defined(_WIN32) */ +#ifdef USE_LIBEDIT_INTERFACE + /* + libedit handles interrupts different than libreadline. + libreadline has its own signal handlers, thus a sigint during readline + doesn't force readline to return null string. + + However libedit returns null if the interrupt signal is raised. + We can also get an empty string when ctrl+d is pressed (EoF). + + We need this sigint_received flag, to differentiate between the two + cases. This flag is only set during our handle_sigint function when + LIBEDIT_INTERFACE is used. + */ + if (!line && sigint_received) + { + // User asked to clear the input. + sigint_received= 0; + reset_prompt(&in_string, &ml_comment); + continue; + } + // For safety, we always mark this as cleared. + sigint_received= 0; +#endif +#endif /* defined(__WIN__) */ /* When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS diff --git a/client/mysqltest.cc b/client/mysqltest.cc index a258a8db950..c7d20446c7f 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -4706,15 +4706,11 @@ void do_perl(struct st_command *command) /* Check for error code that indicates perl could not be started */ int exstat= WEXITSTATUS(error); -#ifdef _WIN32 - if (exstat == 1) - /* Text must begin 'perl not found' as mtr looks for it */ - abort_not_supported_test("perl not found in path or did not start"); -#else +#ifndef _WIN32 if (exstat == 127) abort_not_supported_test("perl not found in path"); -#endif else +#endif handle_command_error(command, exstat, my_errno); } dynstr_free(&ds_delimiter); diff --git a/cmake/libfmt.cmake b/cmake/libfmt.cmake index 70b6a07216f..da3479424b1 100644 --- a/cmake/libfmt.cmake +++ b/cmake/libfmt.cmake @@ -1,4 +1,4 @@ -INCLUDE (CheckCXXSourceCompiles) +INCLUDE (CheckCXXSourceRuns) INCLUDE (ExternalProject) SET(WITH_LIBFMT "auto" CACHE STRING @@ -27,17 +27,15 @@ ENDMACRO() MACRO (CHECK_LIBFMT) IF(WITH_LIBFMT STREQUAL "system" OR WITH_LIBFMT STREQUAL "auto") SET(CMAKE_REQUIRED_INCLUDES ${LIBFMT_INCLUDE_DIR}) - CHECK_CXX_SOURCE_COMPILES( + CHECK_CXX_SOURCE_RUNS( "#define FMT_STATIC_THOUSANDS_SEPARATOR ',' #define FMT_HEADER_ONLY 1 #include - #include int main() { - int answer= 42; + int answer= 4321; fmt::format_args::format_arg arg= fmt::detail::make_arg(answer); - std::cout << fmt::vformat(\"The answer is {}.\", - fmt::format_args(&arg, 1)); + return fmt::vformat(\"{:L}\", fmt::format_args(&arg, 1)).compare(\"4,321\"); }" HAVE_SYSTEM_LIBFMT) SET(CMAKE_REQUIRED_INCLUDES) ENDIF() diff --git a/cmake/os/AIX.cmake b/cmake/os/AIX.cmake index 299b79198c6..7513c4f42c2 100644 --- a/cmake/os/AIX.cmake +++ b/cmake/os/AIX.cmake @@ -34,5 +34,8 @@ ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -maix64 -pthread -mcmodel=large") ENDIF() +# fcntl(fd, F_SETFL, O_DIRECT) is not supported; O_DIRECT is an open(2) flag +SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "") + # make it WARN by default, not AUTO (that implies -Werror) SET(MYSQL_MAINTAINER_MODE "WARN" CACHE STRING "Enable MariaDB maintainer-specific warnings. One of: NO (warnings are disabled) WARN (warnings are enabled) ERR (warnings are errors) AUTO (warnings are errors in Debug only)") diff --git a/cmake/os/SunOS.cmake b/cmake/os/SunOS.cmake index 3a9d2dccb87..3d99d34789a 100644 --- a/cmake/os/SunOS.cmake +++ b/cmake/os/SunOS.cmake @@ -17,6 +17,10 @@ INCLUDE(CheckSymbolExists) INCLUDE(CheckCSourceRuns) INCLUDE(CheckCSourceCompiles) +# fcntl(fd, F_SETFL, O_DIRECT) is not supported, +# and directio(3C) would only work on UFS or NFS, not ZFS. +SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "") + # Enable 64 bit file offsets SET(_FILE_OFFSET_BITS 64) diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 09158c08baa..16f6060fdff 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -43,6 +43,7 @@ SET(HAVE_EXECINFO_H CACHE INTERNAL "") SET(HAVE_FCHMOD CACHE INTERNAL "") SET(HAVE_FCNTL CACHE INTERNAL "") SET(HAVE_FCNTL_H 1 CACHE INTERNAL "") +SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "") SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "") SET(HAVE_FDATASYNC CACHE INTERNAL "") SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "") @@ -241,7 +242,6 @@ SET(HAVE_TERMCAP_H CACHE INTERNAL "") SET(HAVE_TERMIOS_H CACHE INTERNAL "") SET(HAVE_TERMIO_H CACHE INTERNAL "") SET(HAVE_TERM_H CACHE INTERNAL "") -SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "") SET(HAVE_THR_YIELD CACHE INTERNAL "") SET(HAVE_TIME 1 CACHE INTERNAL "") SET(HAVE_TIMES CACHE INTERNAL "") diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index ff7f5ba700f..9c25e426756 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -102,11 +102,7 @@ IF(NOT VERSION) SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}") ENDIF() ELSE() - IF(64BIT) - SET(DEFAULT_MACHINE "x86_64") - ELSE() - SET(DEFAULT_MACHINE "i386") - ENDIF() + SET(DEFAULT_MACHINE ${CMAKE_SYSTEM_PROCESSOR}) ENDIF() IF(DEFAULT_MACHINE MATCHES "i386") diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 65dc2ae28f6..3c427b881fc 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -1,4 +1,3 @@ -INCLUDE (CheckCSourceRuns) INCLUDE (ExternalProject) SET(WITH_PCRE "auto" CACHE STRING @@ -6,7 +5,8 @@ SET(WITH_PCRE "auto" CACHE STRING MACRO(BUNDLE_PCRE2) SET(dir "${CMAKE_BINARY_DIR}/extra/pcre2") - SET(PCRE_INCLUDES ${dir}/src/pcre2-build ${dir}/src/pcre2/src) + SET(PCRE_INCLUDE_DIRS ${dir}/src/pcre2-build ${dir}/src/pcre2/src) + MESSAGE(STATUS "Will download and bundle pcre2") SET(byproducts) FOREACH(lib pcre2-posix pcre2-8) ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL) @@ -76,18 +76,23 @@ SET_TARGET_PROPERTIES(pcre2 PROPERTIES EXCLUDE_FROM_ALL TRUE) ENDMACRO() MACRO (CHECK_PCRE) - IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") - CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" HAVE_PCRE2) - ENDIF() - IF(NOT HAVE_PCRE2 OR WITH_PCRE STREQUAL "bundled") - IF (WITH_PCRE STREQUAL "system") - MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") + IF (NOT TARGET pcre2 AND NOT PCRE_FOUND) + IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") + FIND_PACKAGE(PkgConfig QUIET) + PKG_CHECK_MODULES(PCRE libpcre2-8) + # in case pkg-config or libpcre2-8.pc is not installed: + CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "${PCRE_LIBRARY_DIRS}" HAVE_PCRE2_MATCH_8) ENDIF() - BUNDLE_PCRE2() - ELSE() - CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) - IF(NEEDS_PCRE2_DEBIAN_HACK) - SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + IF(NOT HAVE_PCRE2_MATCH_8 OR WITH_PCRE STREQUAL "bundled") + IF (WITH_PCRE STREQUAL "system") + MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") + ENDIF() + BUNDLE_PCRE2() + ELSE() + CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "${PCRE_LIBRARY_DIRS}" NEEDS_PCRE2_DEBIAN_HACK) + IF(NEEDS_PCRE2_DEBIAN_HACK) + SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + ENDIF() ENDIF() ENDIF() ENDMACRO() diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index d3f214c6146..e8ba59f2873 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -44,7 +44,7 @@ MACRO(MYSQL_ADD_PLUGIN) # Add common include directories INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) diff --git a/cmake/readline.cmake b/cmake/readline.cmake index 9c35d8c7d22..55a2867d2a3 100644 --- a/cmake/readline.cmake +++ b/cmake/readline.cmake @@ -114,6 +114,9 @@ MACRO (MYSQL_FIND_SYSTEM_READLINE) { rl_completion_func_t *func1= (rl_completion_func_t*)0; rl_compentry_func_t *func2= (rl_compentry_func_t*)0; + rl_on_new_line(); + rl_replace_line(\"\", 0); + rl_redisplay(); }" NEW_READLINE_INTERFACE) diff --git a/config.h.cmake b/config.h.cmake index 124694c8fc1..4dbeb45d561 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -30,6 +30,7 @@ #cmakedefine HAVE_DLFCN_H 1 #cmakedefine HAVE_EXECINFO_H 1 #cmakedefine HAVE_FCNTL_H 1 +#cmakedefine HAVE_FCNTL_DIRECT 1 #cmakedefine HAVE_FENV_H 1 #cmakedefine HAVE_FLOAT_H 1 #cmakedefine HAVE_FNMATCH_H 1 @@ -72,6 +73,7 @@ #cmakedefine HAVE_SYS_IOCTL_H 1 #cmakedefine HAVE_SYS_MALLOC_H 1 #cmakedefine HAVE_SYS_MMAN_H 1 +#cmakedefine HAVE_SYS_MNTENT_H 1 #cmakedefine HAVE_SYS_NDIR_H 1 #cmakedefine HAVE_SYS_PTE_H 1 #cmakedefine HAVE_SYS_PTEM_H 1 @@ -231,7 +233,6 @@ #cmakedefine HAVE_STRTOUL 1 #cmakedefine HAVE_STRTOULL 1 #cmakedefine HAVE_TELL 1 -#cmakedefine HAVE_THR_SETCONCURRENCY 1 #cmakedefine HAVE_THR_YIELD 1 #cmakedefine HAVE_TIME 1 #cmakedefine HAVE_TIMES 1 diff --git a/configure.cmake b/configure.cmake index 44ff753dd46..c46b8cc71ab 100644 --- a/configure.cmake +++ b/configure.cmake @@ -417,7 +417,6 @@ CHECK_FUNCTION_EXISTS (strtoul HAVE_STRTOUL) CHECK_FUNCTION_EXISTS (strtoull HAVE_STRTOULL) CHECK_FUNCTION_EXISTS (strcasecmp HAVE_STRCASECMP) CHECK_FUNCTION_EXISTS (tell HAVE_TELL) -CHECK_FUNCTION_EXISTS (thr_setconcurrency HAVE_THR_SETCONCURRENCY) CHECK_FUNCTION_EXISTS (thr_yield HAVE_THR_YIELD) CHECK_FUNCTION_EXISTS (vasprintf HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF) @@ -706,6 +705,7 @@ CHECK_SYMBOL_EXISTS(O_NONBLOCK "unistd.h;fcntl.h" HAVE_FCNTL_NONBLOCK) IF(NOT HAVE_FCNTL_NONBLOCK) SET(NO_FCNTL_NONBLOCK 1) ENDIF() +CHECK_SYMBOL_EXISTS(O_DIRECT "fcntl.h" HAVE_FCNTL_DIRECT) # # Test for how the C compiler does inline, if at all diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 9916ca18953..faf443f8628 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -129,13 +129,6 @@ in add_lsb_base_depends ;& "lunar"|"mantic") - # mariadb-plugin-rocksdb s390x not supported by us (yet) - # ubuntu doesn't support mips64el yet, so keep this just - # in case something changes. - if [[ ! "$architecture" =~ amd64|arm64|ppc64el|s390x ]] - then - remove_rocksdb_tools - fi if [[ ! "$architecture" =~ amd64|arm64|ppc64el ]] then disable_pmem @@ -144,6 +137,15 @@ in then replace_uring_with_aio fi + ;& + "noble") + # mariadb-plugin-rocksdb s390x not supported by us (yet) + # ubuntu doesn't support mips64el yet, so keep this just + # in case something changes. + if [[ ! "$architecture" =~ amd64|arm64|ppc64el|s390x ]] + then + remove_rocksdb_tools + fi ;; *) echo "Error: Unknown release '$LSBNAME'" >&2 diff --git a/debian/control b/debian/control index 960cf1cf47f..7e3643169d6 100644 --- a/debian/control +++ b/debian/control @@ -31,8 +31,7 @@ Build-Depends: bison, liblz4-dev, liblzma-dev, liblzo2-dev, - libncurses5-dev (>= 5.0-6~), - libncurses5-dev:native (>= 5.0-6~), + libncurses-dev, libnuma-dev [linux-any], libpam0g-dev, libpcre2-dev, diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt index 1ee2261f878..9b39321628b 100644 --- a/extra/mariabackup/CMakeLists.txt +++ b/extra/mariabackup/CMakeLists.txt @@ -36,7 +36,7 @@ INCLUDE_DIRECTORIES( ) IF(NOT HAVE_SYSTEM_REGEX) - INCLUDE_DIRECTORIES(${PCRE_INCLUDES}) + INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIRS}) ADD_DEFINITIONS(${PCRE2_DEBIAN_HACK}) ENDIF() diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index f930e052a8b..1482c5f3507 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2187,7 +2187,7 @@ static bool innodb_init_param() /* Check that values don't overflow on 32-bit systems. */ if (sizeof(ulint) == 4) { - if (xtrabackup_use_memory > UINT_MAX32) { + if (xtrabackup_use_memory > (longlong) UINT_MAX32) { msg("mariabackup: use-memory can't be over 4GB" " on 32-bit systems"); } diff --git a/extra/wolfssl/user_settings.h.in b/extra/wolfssl/user_settings.h.in index 83491051ce0..8f37b3be0a9 100644 --- a/extra/wolfssl/user_settings.h.in +++ b/extra/wolfssl/user_settings.h.in @@ -28,6 +28,11 @@ #define NO_OLD_TIMEVAL_NAME #define HAVE_SECURE_RENEGOTIATION #define HAVE_EXTENDED_MASTER +/* + Following is workaround about a WolfSSL 5.6.6 bug. + The bug is about undefined sessionCtxSz during compilation. +*/ +#define WOLFSSL_SESSION_ID_CTX #define WOLFSSL_KEY_GEN #define WOLFSSL_CERT_GEN diff --git a/extra/wolfssl/wolfssl b/extra/wolfssl/wolfssl index 3b3c175af0e..66596ad9e1d 160000 --- a/extra/wolfssl/wolfssl +++ b/extra/wolfssl/wolfssl @@ -1 +1 @@ -Subproject commit 3b3c175af0e993ffaae251871421e206cc41963f +Subproject commit 66596ad9e1d7efa8479656872cf09c9c1870a02e diff --git a/include/my_pthread.h b/include/my_pthread.h index 2d57242631b..8f3b04a2636 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -147,9 +147,6 @@ int pthread_cancel(pthread_t thread); #ifndef _REENTRANT #define _REENTRANT #endif -#ifdef HAVE_THR_SETCONCURRENCY -#include /* Probably solaris */ -#endif #ifdef HAVE_SCHED_H #include #endif @@ -617,9 +614,6 @@ extern int my_rw_trywrlock(my_rw_lock_t *); #define GETHOSTBYADDR_BUFF_SIZE 2048 -#ifndef HAVE_THR_SETCONCURRENCY -#define thr_setconcurrency(A) pthread_dummy(0) -#endif #if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize) #define pthread_attr_setstacksize(A,B) pthread_dummy(0) #endif diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 14c752511c7..a5763a029ce 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -531,7 +531,13 @@ struct st_mysql_plugin const char *author; /* plugin author (for I_S.PLUGINS) */ const char *descr; /* general descriptive text (for I_S.PLUGINS) */ int license; /* the plugin license (PLUGIN_LICENSE_XXX) */ - int (*init)(void *); /* the function to invoke when plugin is loaded */ + /* + The function to invoke when plugin is loaded. Plugin + initialisation done here should defer any ALTER TABLE queries to + after the ddl recovery is done, in the signal_ddl_recovery_done() + callback called by ha_signal_ddl_recovery_done(). + */ + int (*init)(void *); int (*deinit)(void *);/* the function to invoke when plugin is unloaded */ unsigned int version; /* plugin version (for I_S.PLUGINS) */ struct st_mysql_show_var *status_vars; @@ -555,7 +561,13 @@ struct st_maria_plugin const char *author; /* plugin author (for SHOW PLUGINS) */ const char *descr; /* general descriptive text (for SHOW PLUGINS ) */ int license; /* the plugin license (PLUGIN_LICENSE_XXX) */ - int (*init)(void *); /* the function to invoke when plugin is loaded */ + /* + The function to invoke when plugin is loaded. Plugin + initialisation done here should defer any ALTER TABLE queries to + after the ddl recovery is done, in the signal_ddl_recovery_done() + callback called by ha_signal_ddl_recovery_done(). + */ + int (*init)(void *); int (*deinit)(void *);/* the function to invoke when plugin is unloaded */ unsigned int version; /* plugin version (for SHOW PLUGINS) */ struct st_mysql_show_var *status_vars; diff --git a/include/mysql_com.h b/include/mysql_com.h index 969e5364ce7..0d50981ecd5 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -456,7 +456,7 @@ typedef struct st_net { char net_skip_rest_factor; my_bool thread_specific_malloc; unsigned char compress; - my_bool unused3; /* Please remove with the next incompatible ABI change. */ + my_bool pkt_nr_can_be_reset; /* Pointer to query object in query cache, do not equal NULL (0) for queries in cache that have not stored its results yet diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index ee643e60709..c981e96f771 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -23,7 +23,7 @@ ${CMAKE_SOURCE_DIR}/libmysqld ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/tpool ${CMAKE_BINARY_DIR}/sql -${PCRE_INCLUDES} +${PCRE_INCLUDE_DIRS} ${LIBFMT_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${SSL_INCLUDE_DIRS} diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index 2a10def8e2e..d6646a128ca 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -15,7 +15,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${MY_READLINE_INCLUDE_DIR} ) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index c22127f0807..0be844fbd20 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -634,8 +634,6 @@ int init_embedded_server(int argc, char **argv, char **groups) udf_init(); #endif - (void) thr_setconcurrency(concurrency); // 10 by default - if (flush_time && flush_time != ~(ulong) 0L) start_handle_manager(); diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index e82ce852516..da6f3a2d8fa 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -3212,7 +3212,8 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, size_t { longlong data= my_strtoll10(value, &endptr, &err); *param->error= (IS_TRUNCATED(data, param->is_unsigned, - INT_MIN32, INT_MAX32, UINT_MAX32) || err > 0); + (longlong) INT_MIN32, (longlong) INT_MAX32, + (longlong) UINT_MAX32) || err > 0); longstore(buffer, (int32) data); break; } @@ -3329,7 +3330,8 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, break; case MYSQL_TYPE_LONG: *param->error= IS_TRUNCATED(value, param->is_unsigned, - INT_MIN32, INT_MAX32, UINT_MAX32); + (longlong) INT_MIN32, (longlong) INT_MAX32, + (longlong) UINT_MAX32); longstore(buffer, (int32) value); break; case MYSQL_TYPE_LONGLONG: diff --git a/mysql-test/include/have_normal_bzip.inc b/mysql-test/include/have_normal_zlib.inc similarity index 67% rename from mysql-test/include/have_normal_bzip.inc rename to mysql-test/include/have_normal_zlib.inc index 36c06274398..a4531e687bc 100644 --- a/mysql-test/include/have_normal_bzip.inc +++ b/mysql-test/include/have_normal_zlib.inc @@ -1,9 +1,9 @@ --source include/have_compress.inc -# Test that the system is using the default/standard bzip library. +# Test that the system is using the default/standard zlib library. # If not, we have to skip the test as the compression lengths displayed # in the test will not match the results from used compression library. if (`select length(COMPRESS(space(5000))) != 33`) { - skip Test skipped as standard bzip is needed; + skip Test skipped as standard zlib is needed; } diff --git a/mysql-test/include/read_head.inc b/mysql-test/include/read_head.inc new file mode 100644 index 00000000000..98818d76703 --- /dev/null +++ b/mysql-test/include/read_head.inc @@ -0,0 +1,30 @@ +# Purpose: +# Print first LINES_TO_READ from a file. +# The environment variables SEARCH_FILE and LINES_TO_READ must be set +# before sourcing this routine. +# Use: +# When the test is slow ( example because of ASAN build) then it +# may not flush the lines when 'cat' command is called and the +# test could fail with missing lines. Hence this can be used to +# to print first N lines. +# + +perl; + +use strict; + +my $search_file = $ENV{SEARCH_FILE} or die "SEARCH_FILE not set"; +my $lines_to_read = $ENV{LINES_TO_READ} or die "LINES_TO_READ not set"; + +open(FILE, '<', $search_file) or die "Can't open file $search_file: $!"; + +my $line_count = 0; +while ($line_count < $lines_to_read and my $line = ) +{ + print $line; + $line_count++; +} + +close(FILE); + +EOF diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc index a899a9294cc..3105f7f9077 100644 --- a/mysql-test/include/search_pattern_in_file.inc +++ b/mysql-test/include/search_pattern_in_file.inc @@ -51,12 +51,15 @@ # Created: 2011-11-11 mleich # +--error 0,1 perl; use strict; die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE}; my @search_files= glob($ENV{SEARCH_FILE}); my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set"; my $search_range= $ENV{SEARCH_RANGE}; + my $silent= $ENV{SEARCH_SILENT}; + my $search_result= 0; my $content; foreach my $search_file (@search_files) { open(FILE, '<', $search_file) || die("Can't open file $search_file: $!"); @@ -89,16 +92,39 @@ perl; { @matches=($content =~ /$search_pattern/gm); } - my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND"; + my $res; + if (@matches) + { + $res="FOUND " . scalar(@matches); + $search_result= 1; + } + else + { + $res= "NOT FOUND"; + } $ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1}; - if ($ENV{SEARCH_OUTPUT} eq "matches") { - foreach (@matches) { - print $_ . "\n"; - } - } else { - print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n"; + if (!$silent || $search_result) + { + if ($ENV{SEARCH_OUTPUT} eq "matches") + { + foreach (@matches) + { + print $_ . "\n"; + } + } + else + { + print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n"; + } } die "$ENV{SEARCH_ABORT}\n" if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/; + exit($search_result != 1); EOF + +let $SEARCH_RESULT= 1; # Found pattern +if ($errno) +{ + let $SEARCH_RESULT= 0; # Did not find pattern +} diff --git a/mysql-test/include/wait_for_pattern_in_file.inc b/mysql-test/include/wait_for_pattern_in_file.inc new file mode 100644 index 00000000000..52226acd2da --- /dev/null +++ b/mysql-test/include/wait_for_pattern_in_file.inc @@ -0,0 +1,56 @@ +# ==== Purpose ==== +# +# Waits until pattern comes into log file or until a timeout is reached. +# This is a timeout wrapper for search_pattern_in_file.inc +# +# +# ==== Usage ==== +# +# [--let $timeout= NUMBER in seconds] +# For other parameters, check search_pattern_in_file.inc + +--let $wait_save_keep_include_silent=$keep_include_silent +--let $include_filename= wait_for_pattern_in_file.inc +--source include/begin_include_file.inc +--let $keep_include_silent= 1 + +let $_timeout= $timeout; +if (!$_timeout) +{ + let $_timeout= 10; + if ($VALGRIND_TEST) + { + let $_timeout= 30; + } +} + +let $_timeout_counter=`SELECT $_timeout * 10`; +let SEARCH_SILENT=1; + +let $_continue= 1; +while ($_continue) +{ + source include/search_pattern_in_file.inc; + if ($SEARCH_RESULT) + { + # Found match + let $_continue= 0; + } + if (!$SEARCH_RESULT) + { + dec $_timeout_counter; + if ($_timeout_counter == 1) + { + let $SEARCH_SILENT= 0; + } + if (!$_timeout_counter) + { + let $_continue= 0; + } + } +} + +let SEARCH_SILENT=0; + +--source include/end_include_file.inc +--let $keep_include_silent=$wait_save_keep_include_silent diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 4abb9f11704..be1c2be8d3f 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -892,6 +892,12 @@ sub collect_one_test_case { } my @no_combs = grep { $test_combs{$_} == 1 } keys %test_combs; if (@no_combs) { + if ($::opt_skip_not_found) { + push @{$tinfo->{combinations}}, @no_combs; + $tinfo->{'skip'}= 1; + $tinfo->{'comment'}= "combination not found"; + return $tinfo; + } mtr_error("Could not run $name with '".( join(',', sort @no_combs))."' combination(s)"); } diff --git a/mysql-test/main/cast.test b/mysql-test/main/cast.test index ce4b1f6a574..5a0f87beb69 100644 --- a/mysql-test/main/cast.test +++ b/mysql-test/main/cast.test @@ -768,14 +768,11 @@ INSERT INTO t1 VALUES (-1.0); SELECT * FROM t1; DROP TABLE t1; -#enable after MDEV-32645 is fixed ---disable_view_protocol SELECT CAST(-1e0 AS UNSIGNED); CREATE TABLE t1 (a BIGINT UNSIGNED); INSERT INTO t1 VALUES (-1e0); SELECT * FROM t1; DROP TABLE t1; ---enable_view_protocol SELECT CAST(-1e308 AS UNSIGNED); CREATE TABLE t1 (a BIGINT UNSIGNED); diff --git a/mysql-test/main/column_compression.test b/mysql-test/main/column_compression.test index 642399be1f6..5fa8192df3b 100644 --- a/mysql-test/main/column_compression.test +++ b/mysql-test/main/column_compression.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc --source include/have_csv.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc let $MYSQLD_DATADIR= `select @@datadir`; diff --git a/mysql-test/main/column_compression_rpl.test b/mysql-test/main/column_compression_rpl.test index df8e889016b..18992f33f3c 100644 --- a/mysql-test/main/column_compression_rpl.test +++ b/mysql-test/main/column_compression_rpl.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc +--source include/have_normal_zlib.inc --source include/master-slave.inc ---source include/have_normal_bzip.inc --let $engine_type= myisam --let $engine_type2= innodb diff --git a/mysql-test/main/connect_debug.result b/mysql-test/main/connect_debug.result index 2adafc2c4a9..1be7722fb5b 100644 --- a/mysql-test/main/connect_debug.result +++ b/mysql-test/main/connect_debug.result @@ -18,3 +18,23 @@ connect(localhost,root,,test,MASTER_MYPORT,MYSQL_TMP_DIR/mysqld.1.sock); connect con2,localhost,root; ERROR HY000: Received malformed packet set global debug_dbug=@old_dbug; +# +# Start of 11.2 tests +# +# +# MDEV-33182 Server assertion fails when trying to test the connection with DBeaver +# +SET global debug_dbug='+d,thd_init_client_charset_utf8mb3_bin'; +connect con1,localhost,root; +connection con1; +SHOW VARIABLES LIKE 'collation%'; +Variable_name Value +collation_connection utf8mb3_bin +collation_database latin1_swedish_ci +collation_server latin1_swedish_ci +disconnect con1; +connection default; +SET global debug_dbug=@old_debug; +# +# End of 11.2 tests +# diff --git a/mysql-test/main/connect_debug.test b/mysql-test/main/connect_debug.test index 169ba6e9fff..89bc2dac2ce 100644 --- a/mysql-test/main/connect_debug.test +++ b/mysql-test/main/connect_debug.test @@ -37,3 +37,24 @@ set global debug_dbug='+d,poison_srv_handshake_scramble_len'; --error 2027 connect con2,localhost,root; set global debug_dbug=@old_dbug; + + +--echo # +--echo # Start of 11.2 tests +--echo # + +--echo # +--echo # MDEV-33182 Server assertion fails when trying to test the connection with DBeaver +--echo # + +SET global debug_dbug='+d,thd_init_client_charset_utf8mb3_bin'; +connect con1,localhost,root; +connection con1; +SHOW VARIABLES LIKE 'collation%'; +disconnect con1; +connection default; +SET global debug_dbug=@old_debug; + +--echo # +--echo # End of 11.2 tests +--echo # diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result index 316e39b455a..88c27492948 100644 --- a/mysql-test/main/cte_nonrecursive.result +++ b/mysql-test/main/cte_nonrecursive.result @@ -2636,4 +2636,49 @@ a 1 1 DROP TABLE t1; +# +# MDEV-31657: CTE with the same name as base table used twice +# in another CTE +# +create table t (a int); +insert into t values (3), (7), (1); +with +t as (select * from t), +cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a) +select * from cte; +t1a t2a +3 3 +7 7 +1 1 +create table s (a int); +insert into s values (1), (4), (7); +with +t as (select * from t), +s as (select a-1 as a from s), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a +union +select t.a+1, s.a+1 from t, s where t.a=s.a+1) +select * from cte; +ta sa +3 3 +2 1 +8 7 +with +t as (select * from t), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a +union +select t.a+1, s.a+1 from t, s where t.a=s.a), +s as (select a+10 as a from s) +select * from cte; +ta sa +1 1 +7 7 +2 2 +8 8 +drop table t,s; +with +t as (select * from t), +cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a) +select * from cte; +ERROR 42S02: Table 'test.t' doesn't exist # End of 10.4 tests diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test index aa573a76454..bebf02eafd9 100644 --- a/mysql-test/main/cte_nonrecursive.test +++ b/mysql-test/main/cte_nonrecursive.test @@ -1979,4 +1979,50 @@ SELECT * FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-31657: CTE with the same name as base table used twice +--echo # in another CTE +--echo # + +create table t (a int); +insert into t values (3), (7), (1); + +let $q1= +with +t as (select * from t), +cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a) +select * from cte; + +eval $q1; + +create table s (a int); +insert into s values (1), (4), (7); + +let $q2= +with +t as (select * from t), +s as (select a-1 as a from s), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a + union + select t.a+1, s.a+1 from t, s where t.a=s.a+1) +select * from cte; + +eval $q2; + +let $q3= +with +t as (select * from t), +cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a + union + select t.a+1, s.a+1 from t, s where t.a=s.a), +s as (select a+10 as a from s) +select * from cte; + +eval $q3; + +drop table t,s; + +--ERROR ER_NO_SUCH_TABLE +eval $q1; + --echo # End of 10.4 tests diff --git a/mysql-test/main/explain.result b/mysql-test/main/explain.result index 1e546d42d0a..6e2dc0a5af7 100644 --- a/mysql-test/main/explain.result +++ b/mysql-test/main/explain.result @@ -459,3 +459,43 @@ id select_type table type possible_keys key key_len ref rows Extra NULL UNION RESULT ALL NULL NULL NULL NULL NULL Warnings: Note 1249 Select 4 was reduced during optimization +# +# End of 10.4 tests +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); +EXPLAIN SELECT * FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +prepare stmt from "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)"; +execute stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +execute stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/explain.test b/mysql-test/main/explain.test index 0e4a3b8c2c0..4bcdb54e287 100644 --- a/mysql-test/main/explain.test +++ b/mysql-test/main/explain.test @@ -373,3 +373,26 @@ drop table t1; explain VALUES ( (VALUES (2))) UNION VALUES ( (SELECT 3)); --enable_ps_protocol + +--echo # +--echo # End of 10.4 tests +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); + +EXPLAIN SELECT * FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +prepare stmt from "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)"; +execute stmt; +execute stmt; + +# Cleanup + +DROP TABLE t1, t2; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/func_compress.test b/mysql-test/main/func_compress.test index 221dddd59f5..d18af140ed3 100644 --- a/mysql-test/main/func_compress.test +++ b/mysql-test/main/func_compress.test @@ -1,5 +1,5 @@ -- source include/have_compress.inc --- source include/have_normal_bzip.inc +-- source include/have_normal_zlib.inc # # Test for compress and uncompress functions: # diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 9f032171169..ccb68431716 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1460,6 +1460,39 @@ f foo SET @@COLLATION_CONNECTION= @old_collation_connection; # +# MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation +# +select JSON_VALID(' {"number": 1E-4}'); +JSON_VALID(' {"number": 1E-4}') +1 +select JSON_VALID(' {"number": 0E-4}'); +JSON_VALID(' {"number": 0E-4}') +1 +select JSON_VALID(' {"number": 0.0}'); +JSON_VALID(' {"number": 0.0}') +1 +select JSON_VALID(' {"number": 0.1E-4}'); +JSON_VALID(' {"number": 0.1E-4}') +1 +select JSON_VALID(' {"number": 0e-4}'); +JSON_VALID(' {"number": 0e-4}') +1 +select JSON_VALID(' {"number": -0E-4}'); +JSON_VALID(' {"number": -0E-4}') +1 +select JSON_VALUE(' {"number": 0E-4}', '$.number'); +JSON_VALUE(' {"number": 0E-4}', '$.number') +0E-4 +select JSON_VALID(' {"number": 00E-4}'); +JSON_VALID(' {"number": 00E-4}') +0 +select JSON_VALID(' {"number": 01E-4}'); +JSON_VALID(' {"number": 01E-4}') +0 +select JSON_VALID(' {"number": 0E-4.0}'); +JSON_VALID(' {"number": 0E-4.0}') +0 +# # End of 10.4 tests # # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index f76dd232893..721c6b6eef8 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -949,6 +949,22 @@ SELECT JSON_VALUE('["foo"]', '$**[0]') AS f; SET @@COLLATION_CONNECTION= @old_collation_connection; +--echo # +--echo # MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation +--echo # +# Passing +select JSON_VALID(' {"number": 1E-4}'); +select JSON_VALID(' {"number": 0E-4}'); +select JSON_VALID(' {"number": 0.0}'); +select JSON_VALID(' {"number": 0.1E-4}'); +select JSON_VALID(' {"number": 0e-4}'); +select JSON_VALID(' {"number": -0E-4}'); +select JSON_VALUE(' {"number": 0E-4}', '$.number'); +# Failing +select JSON_VALID(' {"number": 00E-4}'); +select JSON_VALID(' {"number": 01E-4}'); +select JSON_VALID(' {"number": 0E-4.0}'); + --echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index 2e6e27136bf..f0b6fdcb7ed 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5286,6 +5286,33 @@ ERROR 42000: Incorrect parameter count in the call to native function 'DECODE' # End of 10.4 tests # # +# Start of 10.5 tests +# +# +# MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL') +# +CREATE VIEW v1 AS SELECT quote(NULL); +SELECT * FROM v1; +quote(NULL) +NULL +DESCRIBE v1; +Field Type Null Key Default Extra +quote(NULL) varbinary(4) YES NULL +CREATE TABLE t1 AS SELECT * FROM v1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `quote(NULL)` varbinary(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT * FROM t1; +quote(NULL) +NULL +DROP TABLE t1; +DROP VIEW v1; +# +# End of 10.5 tests +# +# # MDEV-25704 Function random_bytes # create table t1 as select random_bytes(100); diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 91b57e354ae..fda4d4aed7d 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2333,6 +2333,28 @@ SELECT DECODE(NULL, NULL, NULL); --echo # End of 10.4 tests --echo # +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL') +--echo # + +CREATE VIEW v1 AS SELECT quote(NULL); +SELECT * FROM v1; +DESCRIBE v1; +CREATE TABLE t1 AS SELECT * FROM v1; +SHOW CREATE TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; +DROP VIEW v1; + + +--echo # +--echo # End of 10.5 tests +--echo # + --echo # --echo # MDEV-25704 Function random_bytes --echo # diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index 99d41aad0f5..d8d424897fb 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -5328,5 +5328,112 @@ SELECT BIT_XOR(a) FROM t1; ERROR HY000: Illegal parameter data type geometry for operation 'bit_xor(' DROP TABLE t1; # +# MDEV-27666 User variable not parsed as geometry variable in geometry function. +# +set @g= point(1, 1); +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); +ST_AsWKT(GeometryCollection(Point(44, 6), @g)) +GEOMETRYCOLLECTION(POINT(44 6),POINT(1 1)) +set @g= "just a string"; +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); +ERROR HY000: Illegal parameter data type longblob for operation 'geometrycollection' +SET @g= LineString(Point(0,0), Point(0,1)); +SELECT AsText(PointN(@g, 1)); +AsText(PointN(@g, 1)) +POINT(0 0) +SELECT AsText(PointN(@g, 2)); +AsText(PointN(@g, 2)) +POINT(0 1) +SET @g= Point(1, 1); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` point DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +POINT(1 1) +DROP TABLE t1; +SET @g= MultiPoint(Point(1, 1), Point(-1,-1)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` multipoint DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +MULTIPOINT(1 1,-1 -1) +DROP TABLE t1; +SET @g= LineString(Point(1, 1), Point(2,2)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` linestring DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +LINESTRING(1 1,2 2) +DROP TABLE t1; +SET @g= MultiLineString(LineString(Point(1, 1), Point(2,2)), +LineString(Point(-1, -1), Point(-2,-2))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` multilinestring DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +MULTILINESTRING((1 1,2 2),(-1 -1,-2 -2)) +DROP TABLE t1; +SET @g= Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` polygon DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +POLYGON((0 0,30 0,30 30,0 0)) +DROP TABLE t1; +SET @g= MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), +Point(3, 0), Point(0, 3)))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` multipolygon DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +DROP TABLE t1; +SET @g= GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` geometrycollection DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +DROP TABLE t1; +SET @g= GeometryFromText('POINT(1 1)'); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `g` geometry DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT AsText(g) FROM t1; +AsText(g) +POINT(1 1) +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index e68b1f140b2..659636b14d3 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -1,5 +1,5 @@ -- source include/have_geometry.inc - +-- source include/not_embedded.inc # # Spatial objects @@ -3374,6 +3374,69 @@ SELECT BIT_OR(a) FROM t1; SELECT BIT_XOR(a) FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-27666 User variable not parsed as geometry variable in geometry function. +--echo # + +set @g= point(1, 1); +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); +set @g= "just a string"; +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +select ST_AsWKT(GeometryCollection(Point(44, 6), @g)); + +SET @g= LineString(Point(0,0), Point(0,1)); +SELECT AsText(PointN(@g, 1)); +SELECT AsText(PointN(@g, 2)); + +SET @g= Point(1, 1); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= MultiPoint(Point(1, 1), Point(-1,-1)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= LineString(Point(1, 1), Point(2,2)); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= MultiLineString(LineString(Point(1, 1), Point(2,2)), + LineString(Point(-1, -1), Point(-2,-2))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), + Point(3, 0), Point(0, 3)))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; + +SET @g= GeometryFromText('POINT(1 1)'); +CREATE TABLE t1 AS SELECT @g AS g; +SHOW CREATE TABLE t1; +SELECT AsText(g) FROM t1; +DROP TABLE t1; --echo # --echo # End of 10.5 tests diff --git a/mysql-test/main/log_tables.result b/mysql-test/main/log_tables.result index 1d642c0ade1..e64b71d4ed7 100644 --- a/mysql-test/main/log_tables.result +++ b/mysql-test/main/log_tables.result @@ -1,14 +1,9 @@ SET SQL_MODE=""; -SET @old_general_log_state = @@global.general_log; SET @old_log_output= @@global.log_output; SET @old_slow_query_log= @@global.slow_query_log; SET @old_general_log= @@global.general_log; SET @old_long_query_time= @@session.long_query_time; use mysql; -SET @saved_long_query_time = @@long_query_time; -SET @saved_log_output = @@log_output; -SET @saved_general_log = @@GLOBAL.general_log; -SET @saved_slow_query_log = @@GLOBAL.slow_query_log; truncate table general_log; select * from general_log; event_time user_host thread_id server_id command_type argument @@ -120,6 +115,9 @@ show open tables; Database Table In_use Name_locked SET GLOBAL GENERAL_LOG=ON; SET GLOBAL SLOW_QUERY_LOG=ON; +# +# Bug#23924 general_log truncates queries with character set introducers. +# truncate table mysql.general_log; set names binary; select _koi8r'ΤΕΣΤ' as test; @@ -131,6 +129,9 @@ TIMESTAMP USER_HOST THREAD_ID 1 Query set names binary TIMESTAMP USER_HOST THREAD_ID 1 Query select _koi8r'\xD4\xC5\xD3\xD4' as test TIMESTAMP USER_HOST THREAD_ID 1 Query select * from mysql.general_log set names utf8; +# +# Bug #16905 Log tables: unicode statements are logged incorrectly +# truncate table mysql.general_log; set names utf8; create table bug16905 (s char(15) character set utf8 default 'пусто'); @@ -142,6 +143,9 @@ TIMESTAMP USER_HOST THREAD_ID 1 Query create table bug16905 (s char(15) characte TIMESTAMP USER_HOST THREAD_ID 1 Query insert into bug16905 values ('Π½ΠΎΠ²ΠΎΠ΅') TIMESTAMP USER_HOST THREAD_ID 1 Query select * from mysql.general_log drop table bug16905; +# +# Bug #17600: Invalid data logged into mysql.slow_log +# truncate table mysql.slow_log; set session long_query_time=1; select sleep(2); @@ -150,7 +154,11 @@ sleep(2) select * from mysql.slow_log; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id rows_affected TIMESTAMP USER_HOST QUERY_TIME 00:00:00.000000 1 0 mysql 0 0 1 select sleep(2) THREAD_ID 0 -set @@session.long_query_time = @saved_long_query_time; +set @@session.long_query_time = @old_long_query_time; +# +# Bug #18559 log tables cannot change engine, and gets deadlocked when +# dropping w/ log on +# alter table mysql.general_log engine=myisam; ERROR HY000: You cannot 'ALTER' a log table if logging is enabled alter table mysql.slow_log engine=myisam; @@ -232,7 +240,7 @@ TIMESTAMP USER_HOST THREAD_ID 1 Query truncate table mysql.slow_log TIMESTAMP USER_HOST THREAD_ID 1 Query set session long_query_time=1 TIMESTAMP USER_HOST THREAD_ID 1 Query select sleep(2) TIMESTAMP USER_HOST THREAD_ID 1 Query select * from mysql.slow_log -TIMESTAMP USER_HOST THREAD_ID 1 Query set @@session.long_query_time = @saved_long_query_time +TIMESTAMP USER_HOST THREAD_ID 1 Query set @@session.long_query_time = @old_long_query_time TIMESTAMP USER_HOST THREAD_ID 1 Query alter table mysql.general_log engine=myisam TIMESTAMP USER_HOST THREAD_ID 1 Query alter table mysql.slow_log engine=myisam TIMESTAMP USER_HOST THREAD_ID 1 Query drop table mysql.general_log @@ -300,17 +308,20 @@ ON UPDATE CURRENT_TIMESTAMP, set global general_log='ON'; set global slow_query_log='ON'; use test; +# +# Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log" +# flush tables with read lock; unlock tables; use mysql; lock tables general_log read local, help_category read local; ERROR HY000: You can't use locks with log tables unlock tables; +# +# Bug #17544 Cannot do atomic log rotate and +# Bug #21785 Server crashes after rename of the log table +# SET SESSION long_query_time = 1000; -drop table if exists mysql.renamed_general_log; -drop table if exists mysql.renamed_slow_log; -drop table if exists mysql.general_log_new; -drop table if exists mysql.slow_log_new; use mysql; RENAME TABLE general_log TO renamed_general_log; ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log' @@ -356,13 +367,16 @@ set global slow_query_log='ON'; ERROR 42S02: Table 'mysql.slow_log' doesn't exist RENAME TABLE general_log2 TO general_log; RENAME TABLE slow_log2 TO slow_log; -SET SESSION long_query_time = @saved_long_query_time; +SET SESSION long_query_time = @old_long_query_time; set global general_log='ON'; set global slow_query_log='ON'; flush logs; flush logs; drop table renamed_general_log, renamed_slow_log; use test; +# +# Bug #21966 Strange warnings on repair of the log tables +# use mysql; repair table general_log; Table Op Msg_type Msg_text @@ -380,6 +394,10 @@ slow_log slow_log_new drop table slow_log_new, general_log_new; use test; +# +# Bug#69953 / MDEV-4851 +# Log tables should be modifable on LOG_OUTPUT != TABLE +# SET GLOBAL LOG_OUTPUT = 'FILE'; SET GLOBAL slow_query_log = 1; SET GLOBAL general_log = 1; @@ -388,6 +406,10 @@ ALTER TABLE mysql.general_log ADD COLUMN comment_text TEXT NOT NULL; SET GLOBAL LOG_OUTPUT = 'NONE'; ALTER TABLE mysql.slow_log DROP COLUMN comment_text; ALTER TABLE mysql.general_log DROP COLUMN comment_text; +# +# Bug#27857 (Log tables supplies the wrong value for generating +# AUTO_INCREMENT numbers) +# SET GLOBAL LOG_OUTPUT = 'TABLE'; SET GLOBAL general_log = 0; FLUSH LOGS; @@ -451,16 +473,15 @@ START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own sl START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) THREAD_ID 0 3 START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) THREAD_ID 0 4 SET GLOBAL slow_query_log = 0; -SET SESSION long_query_time =@saved_long_query_time; +SET SESSION long_query_time =@old_long_query_time; FLUSH LOGS; ALTER TABLE mysql.slow_log DROP COLUMN seq; ALTER TABLE mysql.slow_log ENGINE = CSV; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; -drop procedure if exists proc25422_truncate_slow; -drop procedure if exists proc25422_truncate_general; -drop procedure if exists proc25422_alter_slow; -drop procedure if exists proc25422_alter_general; +# +# Bug#25422 (Hang with log tables) +# use test// create procedure proc25422_truncate_slow (loops int) begin @@ -485,26 +506,26 @@ end// create procedure proc25422_alter_slow (loops int) begin declare v1 int default 0; +declare old_log_state int default @@global.slow_query_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do -set @old_log_state = @@global.slow_query_log; set global slow_query_log = 'OFF'; alter table mysql.slow_log engine = CSV; -set global slow_query_log = @old_log_state; +set global slow_query_log = old_log_state; set v1 = v1 + 1; end while; end// create procedure proc25422_alter_general (loops int) begin declare v1 int default 0; +declare old_log_state int default @@global.general_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do -set @old_log_state = @@global.general_log; set global general_log = 'OFF'; alter table mysql.general_log engine = CSV; -set global general_log = @old_log_state; +set global general_log = old_log_state; set v1 = v1 + 1; end while; end// @@ -563,17 +584,19 @@ drop procedure proc25422_truncate_slow; drop procedure proc25422_truncate_general; drop procedure proc25422_alter_slow; drop procedure proc25422_alter_general; +# +# Bug#23044 (Warnings on flush of a log table) +# FLUSH TABLE mysql.general_log; show warnings; Level Code Message FLUSH TABLE mysql.slow_log; show warnings; Level Code Message -DROP TABLE IF EXISTS `db_17876.slow_log_data`; -DROP TABLE IF EXISTS `db_17876.general_log_data`; -DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`; -DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; -DROP DATABASE IF EXISTS `db_17876`; +# +# Bug#17876 (Truncating mysql.slow_log in a SP after using cursor locks the +# thread) +# CREATE DATABASE db_17876; CREATE TABLE `db_17876.slow_log_data` ( `start_time` timestamp(6) default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, @@ -686,6 +709,9 @@ DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; DROP DATABASE IF EXISTS `db_17876`; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; +# +# Bug#21557 entries in the general query log truncated at 1000 characters. +# select CONNECTION_ID() into @thread_id; truncate table mysql.general_log; set global general_log = on; @@ -902,9 +928,9 @@ select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 016 017 0 set global general_log = off deallocate prepare long_query; set global general_log = @old_general_log; -DROP TABLE IF EXISTS log_count; -DROP TABLE IF EXISTS slow_log_copy; -DROP TABLE IF EXISTS general_log_copy; +# +# Bug#34306: Can't make copy of log tables when server binary log is enabled +# CREATE TABLE log_count (count BIGINT(21)); SET GLOBAL general_log = ON; SET GLOBAL slow_query_log = ON; @@ -926,9 +952,12 @@ CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; INSERT INTO general_log_copy SELECT * FROM mysql.general_log; INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); DROP TABLE general_log_copy; -SET GLOBAL general_log = @saved_general_log; -SET GLOBAL slow_query_log = @saved_slow_query_log; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; DROP TABLE log_count; +# +# Bug #31700: thd->examined_row_count not incremented for 'const' type queries +# SET SESSION long_query_time = 0; SET GLOBAL slow_query_log = ON; FLUSH LOGS; @@ -954,9 +983,10 @@ TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 TIMESTAMP 1 1 SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2 DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; +# +# Bug #47924 main.log_tables times out sporadically +# use mysql; -drop table if exists renamed_general_log; -drop table if exists renamed_slow_log; RENAME TABLE general_log TO renamed_general_log; ERROR HY000: Cannot rename 'general_log'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to 'general_log' RENAME TABLE slow_log TO renamed_slow_log; @@ -964,7 +994,34 @@ ERROR HY000: Cannot rename 'slow_log'. When logging enabled, rename to/from log use test; flush tables with read lock; unlock tables; -SET @@session.long_query_time= @old_long_query_time; +# +# MDEV-33267 User with minimal permissions can intentionally corrupt mysql.slow_log table +# +truncate mysql.slow_log; +set global log_output= 'TABLE'; +create user u@localhost; +set slow_query_log=on, long_query_time=0.1; +select 'before evil-doing', sleep(0.2); +before evil-doing sleep(0.2) +before evil-doing 0 +connect con1,localhost,u,,; +set @@timestamp= 2147483647; +set slow_query_log=on, long_query_time=0.1; +select 'evil-doing', sleep(1.1); +evil-doing sleep(1.1) +evil-doing 0 +disconnect con1; +connection default; +select 'after evil-doing', sleep(0.2); +after evil-doing sleep(0.2) +after evil-doing 0 +select distinct sql_text from mysql.slow_log where sql_text like '%evil%'; +sql_text +select 'before evil-doing', sleep(0.2) +select 'evil-doing', sleep(1.1) +select 'after evil-doing', sleep(0.2) +set global log_output=default; +drop user u@localhost; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; SET @@global.general_log= @old_general_log; diff --git a/mysql-test/main/log_tables.test b/mysql-test/main/log_tables.test index 1eee6be0524..37df8d46859 100644 --- a/mysql-test/main/log_tables.test +++ b/mysql-test/main/log_tables.test @@ -1,13 +1,9 @@ # this test needs multithreaded mysqltest -- source include/not_embedded.inc -# -# Basic log tables test -# -# check that CSV engine was compiled in + --source include/have_csv.inc SET SQL_MODE=""; -SET @old_general_log_state = @@global.general_log; SET @old_log_output= @@global.log_output; SET @old_slow_query_log= @@global.slow_query_log; SET @old_general_log= @@global.general_log; @@ -16,16 +12,9 @@ SET @old_long_query_time= @@session.long_query_time; --disable_ps_protocol use mysql; -# Capture initial settings of system variables -# so that we can revert to old state after manipulation for testing -# NOTE: PLEASE USE THESE VALUES TO 'RESET' SYSTEM VARIABLES -# Capturing old values within the tests results in loss of values -# due to people not paying attention to previous tests' changes, captures -# or improper cleanup -SET @saved_long_query_time = @@long_query_time; -SET @saved_log_output = @@log_output; -SET @saved_general_log = @@GLOBAL.general_log; -SET @saved_slow_query_log = @@GLOBAL.slow_query_log; +# +# Basic log tables test +# # # Check that log tables work and we can do basic selects. This also @@ -147,9 +136,9 @@ show open tables; SET GLOBAL GENERAL_LOG=ON; SET GLOBAL SLOW_QUERY_LOG=ON; -# -# Bug#23924 general_log truncates queries with character set introducers. -# +--echo # +--echo # Bug#23924 general_log truncates queries with character set introducers. +--echo # truncate table mysql.general_log; set names binary; select _koi8r'ΤΕΣΤ' as test; @@ -157,9 +146,9 @@ select _koi8r' select * from mysql.general_log; set names utf8; -# -# Bug #16905 Log tables: unicode statements are logged incorrectly -# +--echo # +--echo # Bug #16905 Log tables: unicode statements are logged incorrectly +--echo # truncate table mysql.general_log; set names utf8; @@ -169,21 +158,21 @@ insert into bug16905 values ('Π½ΠΎΠ²ΠΎΠ΅'); select * from mysql.general_log; drop table bug16905; -# -# Bug #17600: Invalid data logged into mysql.slow_log -# +--echo # +--echo # Bug #17600: Invalid data logged into mysql.slow_log +--echo # truncate table mysql.slow_log; set session long_query_time=1; select sleep(2); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID select * from mysql.slow_log; -set @@session.long_query_time = @saved_long_query_time; +set @@session.long_query_time = @old_long_query_time; -# -# Bug #18559 log tables cannot change engine, and gets deadlocked when -# dropping w/ log on -# +--echo # +--echo # Bug #18559 log tables cannot change engine, and gets deadlocked when +--echo # dropping w/ log on +--echo # # check that appropriate error messages are given when one attempts to alter # or drop a log tables, while corresponding logs are enabled @@ -322,9 +311,9 @@ set global general_log='ON'; set global slow_query_log='ON'; use test; -# -# Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log" -# +--echo # +--echo # Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log" +--echo # flush tables with read lock; unlock tables; @@ -333,18 +322,12 @@ use mysql; lock tables general_log read local, help_category read local; unlock tables; -# -# Bug #17544 Cannot do atomic log rotate and -# Bug #21785 Server crashes after rename of the log table -# +--echo # +--echo # Bug #17544 Cannot do atomic log rotate and +--echo # Bug #21785 Server crashes after rename of the log table +--echo # SET SESSION long_query_time = 1000; ---disable_warnings -drop table if exists mysql.renamed_general_log; -drop table if exists mysql.renamed_slow_log; -drop table if exists mysql.general_log_new; -drop table if exists mysql.slow_log_new; ---enable_warnings use mysql; # Should result in error @@ -399,7 +382,7 @@ set global slow_query_log='ON'; RENAME TABLE general_log2 TO general_log; RENAME TABLE slow_log2 TO slow_log; -SET SESSION long_query_time = @saved_long_query_time; +SET SESSION long_query_time = @old_long_query_time; # this should work set global general_log='ON'; @@ -427,13 +410,6 @@ use test; # TODO: improve filtering of expected errors in master.err in # mysql-test-run.pl (based on the test name ?), and uncomment this test. -# --disable_warnings -# drop table if exists mysql.bad_general_log; -# drop table if exists mysql.bad_slow_log; -# drop table if exists mysql.general_log_hide; -# drop table if exists mysql.slow_log_hide; -# --enable_warnings -# # create table mysql.bad_general_log (a int) engine= CSV; # create table mysql.bad_slow_log (a int) engine= CSV; # @@ -459,9 +435,9 @@ use test; # drop table mysql.bad_general_log; # drop table mysql.bad_slow_log; -# -# Bug #21966 Strange warnings on repair of the log tables -# +--echo # +--echo # Bug #21966 Strange warnings on repair of the log tables +--echo # use mysql; # check that no warning occurs on repair of the log tables @@ -474,11 +450,10 @@ show tables like "%log%"; drop table slow_log_new, general_log_new; use test; -# -# Bug#69953 / MDEV-4851 -# Log tables should be modifable on LOG_OUTPUT != TABLE -# -# +--echo # +--echo # Bug#69953 / MDEV-4851 +--echo # Log tables should be modifable on LOG_OUTPUT != TABLE +--echo # SET GLOBAL LOG_OUTPUT = 'FILE'; SET GLOBAL slow_query_log = 1; @@ -492,10 +467,10 @@ ALTER TABLE mysql.slow_log DROP COLUMN comment_text; ALTER TABLE mysql.general_log DROP COLUMN comment_text; -# -# Bug#27857 (Log tables supplies the wrong value for generating -# AUTO_INCREMENT numbers) -# +--echo # +--echo # Bug#27857 (Log tables supplies the wrong value for generating +--echo # AUTO_INCREMENT numbers) +--echo # SET GLOBAL LOG_OUTPUT = 'TABLE'; @@ -554,7 +529,7 @@ SELECT "My own slow query", sleep(2); SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; SET GLOBAL slow_query_log = 0; -SET SESSION long_query_time =@saved_long_query_time; +SET SESSION long_query_time =@old_long_query_time; FLUSH LOGS; ALTER TABLE mysql.slow_log DROP COLUMN seq; @@ -563,16 +538,9 @@ ALTER TABLE mysql.slow_log ENGINE = CSV; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; -# -# Bug#25422 (Hang with log tables) -# - ---disable_warnings -drop procedure if exists proc25422_truncate_slow; -drop procedure if exists proc25422_truncate_general; -drop procedure if exists proc25422_alter_slow; -drop procedure if exists proc25422_alter_general; ---enable_warnings +--echo # +--echo # Bug#25422 (Hang with log tables) +--echo # delimiter //; @@ -602,14 +570,14 @@ end// create procedure proc25422_alter_slow (loops int) begin declare v1 int default 0; + declare old_log_state int default @@global.slow_query_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do - set @old_log_state = @@global.slow_query_log; set global slow_query_log = 'OFF'; alter table mysql.slow_log engine = CSV; - set global slow_query_log = @old_log_state; + set global slow_query_log = old_log_state; set v1 = v1 + 1; end while; end// @@ -617,14 +585,14 @@ end// create procedure proc25422_alter_general (loops int) begin declare v1 int default 0; + declare old_log_state int default @@global.general_log; declare ER_BAD_LOG_STATEMENT condition for 1575; declare continue handler for ER_BAD_LOG_STATEMENT begin end; while v1 < loops do - set @old_log_state = @@global.general_log; set global general_log = 'OFF'; alter table mysql.general_log engine = CSV; - set global general_log = @old_log_state; + set global general_log = old_log_state; set v1 = v1 + 1; end while; end// @@ -713,9 +681,9 @@ drop procedure proc25422_alter_general; --enable_ps_protocol -# -# Bug#23044 (Warnings on flush of a log table) -# +--echo # +--echo # Bug#23044 (Warnings on flush of a log table) +--echo # FLUSH TABLE mysql.general_log; show warnings; @@ -723,18 +691,10 @@ show warnings; FLUSH TABLE mysql.slow_log; show warnings; -# -# Bug#17876 (Truncating mysql.slow_log in a SP after using cursor locks the -# thread) -# - ---disable_warnings -DROP TABLE IF EXISTS `db_17876.slow_log_data`; -DROP TABLE IF EXISTS `db_17876.general_log_data`; -DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`; -DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; -DROP DATABASE IF EXISTS `db_17876`; ---enable_warnings +--echo # +--echo # Bug#17876 (Truncating mysql.slow_log in a SP after using cursor locks the +--echo # thread) +--echo # CREATE DATABASE db_17876; @@ -872,9 +832,9 @@ DROP DATABASE IF EXISTS `db_17876`; SET GLOBAL general_log = @old_general_log; SET GLOBAL slow_query_log = @old_slow_query_log; -# -# Bug#21557 entries in the general query log truncated at 1000 characters. -# +--echo # +--echo # Bug#21557 entries in the general query log truncated at 1000 characters. +--echo # select CONNECTION_ID() into @thread_id; --disable_ps_protocol @@ -993,15 +953,9 @@ AND (command_type = 'Query' OR command_type= 'Execute'); deallocate prepare long_query; set global general_log = @old_general_log; -# -# Bug#34306: Can't make copy of log tables when server binary log is enabled -# - ---disable_warnings -DROP TABLE IF EXISTS log_count; -DROP TABLE IF EXISTS slow_log_copy; -DROP TABLE IF EXISTS general_log_copy; ---enable_warnings +--echo # +--echo # Bug#34306: Can't make copy of log tables when server binary log is enabled +--echo # CREATE TABLE log_count (count BIGINT(21)); @@ -1031,14 +985,14 @@ INSERT INTO general_log_copy SELECT * FROM mysql.general_log; INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); DROP TABLE general_log_copy; -SET GLOBAL general_log = @saved_general_log; -SET GLOBAL slow_query_log = @saved_slow_query_log; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; DROP TABLE log_count; -# -# Bug #31700: thd->examined_row_count not incremented for 'const' type queries -# +--echo # +--echo # Bug #31700: thd->examined_row_count not incremented for 'const' type queries +--echo # SET SESSION long_query_time = 0; SET GLOBAL slow_query_log = ON; @@ -1065,16 +1019,12 @@ DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; -# -# Bug #47924 main.log_tables times out sporadically -# +--echo # +--echo # Bug #47924 main.log_tables times out sporadically +--echo # use mysql; # Should result in error ---disable_warnings -drop table if exists renamed_general_log; -drop table if exists renamed_slow_log; ---enable_warnings --error ER_CANT_RENAME_LOG_TABLE RENAME TABLE general_log TO renamed_general_log; --error ER_CANT_RENAME_LOG_TABLE @@ -1084,7 +1034,24 @@ use test; flush tables with read lock; unlock tables; -SET @@session.long_query_time= @old_long_query_time; +--echo # +--echo # MDEV-33267 User with minimal permissions can intentionally corrupt mysql.slow_log table +--echo # +truncate mysql.slow_log; +set global log_output= 'TABLE'; +create user u@localhost; +set slow_query_log=on, long_query_time=0.1; +select 'before evil-doing', sleep(0.2); +--connect (con1,localhost,u,,) +set @@timestamp= 2147483647; +set slow_query_log=on, long_query_time=0.1; +select 'evil-doing', sleep(1.1); +--disconnect con1 +--connection default +select 'after evil-doing', sleep(0.2); +select distinct sql_text from mysql.slow_log where sql_text like '%evil%'; +set global log_output=default; +drop user u@localhost; SET @@global.log_output= @old_log_output; SET @@global.slow_query_log= @old_slow_query_log; diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 6b5ffc704a6..b8fbd40baed 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -653,5 +653,29 @@ f1 f2 f3 f4 f5 f6 f7 4 00004 0001009089999 netstes psit e drop table t1; # +# MDEV-29954 Unique hash key on column prefix is computed incorrectly +# +create table t1 (c char(10),unique key a using hash (c(1))); +insert into t1 values (0); +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +# +# MDEV-32837 long unique does not work like unique key when using replace +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +REPLACE INTO t1 VALUES (3,1,1); +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +REPLACE INTO t1 VALUES (3,2,2); +SELECT * FROM t1; +a b c +3 2 2 +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index ad6220dfa30..01c3f736df8 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -634,6 +634,27 @@ replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netst select * from t1; drop table t1; +--echo # +--echo # MDEV-29954 Unique hash key on column prefix is computed incorrectly +--echo # +create table t1 (c char(10),unique key a using hash (c(1))); +insert into t1 values (0); +check table t1 extended; +drop table t1; + + +--echo # +--echo # MDEV-32837 long unique does not work like unique key when using replace +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +REPLACE INTO t1 VALUES (3,1,1); +SELECT * FROM t1 ORDER BY a; +REPLACE INTO t1 VALUES (3,2,2); +SELECT * FROM t1; +DROP TABLE t1; + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/long_unique_bugs_no_sp_protocol.result b/mysql-test/main/long_unique_bugs_no_sp_protocol.result new file mode 100644 index 00000000000..0776a130167 --- /dev/null +++ b/mysql-test/main/long_unique_bugs_no_sp_protocol.result @@ -0,0 +1,95 @@ +# +# Start of 10.5 tests +# +# +# MDEV-32837 long unique does not work like unique key when using replace +# +# +# Normal unique key + long unique key +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_delete 1 +Handler_read_key 2 +Handler_read_rnd 1 +Handler_write 1 +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 2 +Handler_update 1 +Handler_write 1 +SELECT * FROM t1; +a b c +3 2 2 +DROP TABLE t1; +# +# Two long unique keys +# +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY a (a) USING HASH,UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 2 +Handler_update 1 +SELECT * FROM t1; +a b c +3 2 2 +DROP TABLE t1; +# +# One long unique key +# +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_update 1 +SELECT * FROM t1 ORDER BY a; +a b c +2 2 2 +3 1 1 +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_update 1 +SELECT * FROM t1; +a b c +3 1 1 +3 2 2 +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/long_unique_bugs_no_sp_protocol.test b/mysql-test/main/long_unique_bugs_no_sp_protocol.test new file mode 100644 index 00000000000..6bfa6182096 --- /dev/null +++ b/mysql-test/main/long_unique_bugs_no_sp_protocol.test @@ -0,0 +1,68 @@ +if (`SELECT $SP_PROTOCOL > 0`) +{ + --skip Test requires: sp-protocol disabled +} + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-32837 long unique does not work like unique key when using replace +--echo # + +# This test produces different Handler commands in the SHOW STATUS output +# with --sp-protocol. So it's here, in this *.test file with --sp-protocol disabled. + +--echo # +--echo # Normal unique key + long unique key +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1 ORDER BY a; +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # Two long unique keys +--echo # + +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY a (a) USING HASH,UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1 ORDER BY a; +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # One long unique key +--echo # + +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE KEY `test` (b,c) USING HASH) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,1),(2,2,2); +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,1,1); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1 ORDER BY a; +FLUSH STATUS; +REPLACE INTO t1 VALUES (3,2,2); +SHOW STATUS WHERE Variable_name LIKE 'handler%' AND Value>0; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/mysql-interactive.result b/mysql-test/main/mysql-interactive.result new file mode 100644 index 00000000000..a18c018b932 --- /dev/null +++ b/mysql-test/main/mysql-interactive.result @@ -0,0 +1,24 @@ +# +# regression introduced by MDEV-14448 +# +delimiter $ +select 1; +$ +Welcome to the MariaDB monitor. Commands end with ; or \g. +Your MariaDB connection id is X +Server version: Y +Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. + +Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. + +MariaDB [(none)]> delimiter $ +MariaDB [(none)]> select 1; + -> $ ++---+ +| 1 | ++---+ +| 1 | ++---+ +1 row in set + +MariaDB [(none)]> \ No newline at end of file diff --git a/mysql-test/main/mysql-interactive.test b/mysql-test/main/mysql-interactive.test new file mode 100644 index 00000000000..2015e9d667d --- /dev/null +++ b/mysql-test/main/mysql-interactive.test @@ -0,0 +1,29 @@ +--echo # +--echo # regression introduced by MDEV-14448 +--echo # +source include/not_embedded.inc; +source include/not_windows.inc; + +error 0,1; +exec $MYSQL -V|grep -q readline; +if ($sys_errno == 1) +{ + # strangely enough + skip does not work with libedit; +} + +write_file $MYSQL_TMP_DIR/mysql_in; +delimiter $ +select 1; +$ +EOF +let TERM=dumb; +replace_regex /id is \d+/id is X/ /Server version: .*/Server version: Y/ / \(\d+\.\d+ sec\)//; +error 0,127; +exec socat EXEC:"$MYSQL",pty STDIO < $MYSQL_TMP_DIR/mysql_in; +if ($sys_errno == 127) +{ + remove_file $MYSQL_TMP_DIR/mysql_in; + skip no socat; +} +remove_file $MYSQL_TMP_DIR/mysql_in; diff --git a/mysql-test/main/mysql_json_table_recreate.result b/mysql-test/main/mysql_json_table_recreate.result index 207dde9d8ad..a61377fe21d 100644 --- a/mysql-test/main/mysql_json_table_recreate.result +++ b/mysql-test/main/mysql_json_table_recreate.result @@ -30,6 +30,12 @@ show create table mysql_json_test; ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! select * from mysql_json_test; ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +CREATE TABLE t2 AS SELECT * FROM mysql_json_test; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +CREATE TABLE t2 (a mysql_json /*new column*/) AS SELECT * FROM mysql_json_test; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TABLE t2 (actual mysql_json /*existing column*/) AS SELECT * FROM mysql_json_test; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context LOCK TABLES mysql_json_test WRITE; ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! alter table mysql_json_test force; @@ -169,3 +175,67 @@ Total_Number_of_Tests Succesful_Tests String_is_valid_JSON drop table tempty; drop table mysql_json_test; drop table mysql_json_test_big; +# +# MDEV-32790: Output result in show create table +# for mysql_json type should be longtext +# +create table t1(j json); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `j` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`j`)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table t1; +create table t1(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +create table `testjson` ( +`t` json /* JSON from MySQL 5.7*/ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +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 'CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=InnoDB DEFAULT CH...' at line 2 +create table `testjson` ( +`t` json /* JSON from MySQL 5.7*/ COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +Table Create Table +testjson CREATE TABLE `testjson` ( + `t` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`t`)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table testjson; +create table `testjson` ( +`t` longtext /* JSON from MySQL 5.7 */ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +Table Create Table +testjson CREATE TABLE `testjson` ( + `t` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table testjson; +# +# MDEV-32235: mysql_json cannot be used on newly created table +# +CREATE TABLE t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TABLE IF NOT EXISTS t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE OR REPLACE TABLE t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TEMPORARY TABLE t(j mysql_json); +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE TABLE t1 (a TEXT); +ALTER TABLE t1 MODIFY a mysql_json; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +DROP TABLE t1; +CREATE FUNCTION f1() RETURNS mysql_json RETURN NULL; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE FUNCTION f1(a mysql_json) RETURNS INT RETURN 0; +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +CREATE PROCEDURE p1() +BEGIN +DECLARE a mysql_json; +END; +$$ +ERROR HY000: 'MYSQL_JSON' is not allowed in this context +# +# End of 10.5 tests +# diff --git a/mysql-test/main/mysql_json_table_recreate.test b/mysql-test/main/mysql_json_table_recreate.test index a399b546591..a6f1d3194ae 100644 --- a/mysql-test/main/mysql_json_table_recreate.test +++ b/mysql-test/main/mysql_json_table_recreate.test @@ -51,6 +51,13 @@ show create table mysql_json_test; --error ER_TABLE_NEEDS_REBUILD select * from mysql_json_test; +--error ER_TABLE_NEEDS_REBUILD +CREATE TABLE t2 AS SELECT * FROM mysql_json_test; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE t2 (a mysql_json /*new column*/) AS SELECT * FROM mysql_json_test; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE t2 (actual mysql_json /*existing column*/) AS SELECT * FROM mysql_json_test; + --error ER_TABLE_NEEDS_REBUILD LOCK TABLES mysql_json_test WRITE; @@ -88,3 +95,69 @@ from mysql_json_test_big; drop table tempty; drop table mysql_json_test; drop table mysql_json_test_big; + +--echo # +--echo # MDEV-32790: Output result in show create table +--echo # for mysql_json type should be longtext +--echo # + +create table t1(j json); +show create table t1; +drop table t1; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +create table t1(j mysql_json); +# `json` type should not have character set and collation other than utf8mb4_bin +--error ER_PARSE_ERROR +create table `testjson` ( + `t` json /* JSON from MySQL 5.7*/ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; + +# By removing character set from `json` field query should work and +# expand to `longtext` with characterset +create table `testjson` ( + `t` json /* JSON from MySQL 5.7*/ COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +drop table testjson; + +# `longtext` that is alias can have character set +create table `testjson` ( + `t` longtext /* JSON from MySQL 5.7 */ CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +show create table testjson; +drop table testjson; + +--echo # +--echo # MDEV-32235: mysql_json cannot be used on newly created table +--echo # + +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE t(j mysql_json); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TABLE IF NOT EXISTS t(j mysql_json); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE OR REPLACE TABLE t(j mysql_json); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE TEMPORARY TABLE t(j mysql_json); + +CREATE TABLE t1 (a TEXT); +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +ALTER TABLE t1 MODIFY a mysql_json; +DROP TABLE t1; + +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE FUNCTION f1() RETURNS mysql_json RETURN NULL; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE FUNCTION f1(a mysql_json) RETURNS INT RETURN 0; +DELIMITER $$; +--error ER_NOT_ALLOWED_IN_THIS_CONTEXT +CREATE PROCEDURE p1() +BEGIN + DECLARE a mysql_json; +END; +$$ +DELIMITER ;$$ + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/mysqlbinlog_row_compressed.test b/mysql-test/main/mysqlbinlog_row_compressed.test index be9736347c9..03868d3e6b3 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.test +++ b/mysql-test/main/mysqlbinlog_row_compressed.test @@ -4,7 +4,7 @@ --source include/have_log_bin.inc --source include/have_binlog_format_row.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc # # diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.test b/mysql-test/main/mysqlbinlog_stmt_compressed.test index 08db2009d60..4a65124339d 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.test +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.test @@ -4,7 +4,7 @@ --source include/have_log_bin.inc --source include/have_binlog_format_statement.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc # # # mysqlbinlog: compressed query event diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 9f4090890fa..431c37c25ed 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -762,6 +762,8 @@ The following specify which files/extra groups are read (specified before remain max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors (Automatically configured unless set explicitly) + --optimizer-adjust-secondary-key-costs=# + Unused, will be removed. --optimizer-disk-read-cost=# Cost of reading a block of IO_SIZE (4096) from a disk (in usec). @@ -1235,7 +1237,7 @@ The following specify which files/extra groups are read (specified before remain The tracing level for semi-sync replication. --rpl-semi-sync-master-wait-no-slave Wait until timeout when no semi-synchronous replication - slave available (enabled by default). + slave is available. (Defaults to on; use --skip-rpl-semi-sync-master-wait-no-slave to disable.) --rpl-semi-sync-master-wait-point=name Should transaction wait for semi-sync ack after having @@ -1800,6 +1802,7 @@ old FALSE old-mode UTF8_IS_UTF8MB3 old-passwords FALSE old-style-user-limits FALSE +optimizer-adjust-secondary-key-costs 0 optimizer-disk-read-cost 10.24 optimizer-disk-read-ratio 0.02 optimizer-extra-pruning-depth 8 diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 3528c363d0b..9ed81592b24 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -12499,6 +12499,18 @@ json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) set in_predicate_conversion_threshold=@tmp; drop table t0; # +# MDEV-29298: INSERT ... SELECT Does not produce an optimizer trace +# +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5); +set optimizer_trace=1; +insert into t2 select * from t1 where a<= b and a>4; +select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace; +QUERY LENGTH(trace)>1 +insert into t2 select * from t1 where a<= b and a>4 1 +drop table t1, t2; +# # End of 10.5 tests # # diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index 1a4f0c4b041..f69a200f629 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -846,6 +846,20 @@ set in_predicate_conversion_threshold=@tmp; drop table t0; --enable_view_protocol +--echo # +--echo # MDEV-29298: INSERT ... SELECT Does not produce an optimizer trace +--echo # +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5); +set optimizer_trace=1; + +insert into t2 select * from t1 where a<= b and a>4; + +select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace; + +drop table t1, t2; + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 2f343c7bca8..b10af81a42f 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1502,7 +1502,7 @@ BEGIN NOT ATOMIC DECLARE history INT; SET history=10; SELECT history; END SELECT history FROM t1 SELECT history 'alias' FROM t1 SELECT history() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history.history() Error 1630 FUNCTION history.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history DATE FROM t1 @@ -1525,7 +1525,7 @@ BEGIN NOT ATOMIC DECLARE next INT; SET next=10; SELECT next; END SELECT next FROM t1 SELECT next 'alias' FROM t1 SELECT next() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next.next() Error 1630 FUNCTION next.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next DATE FROM t1 @@ -1572,7 +1572,7 @@ BEGIN NOT ATOMIC DECLARE previous INT; SET previous=10; SELECT previous; END SELECT previous FROM t1 SELECT previous 'alias' FROM t1 SELECT previous() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous.previous() Error 1630 FUNCTION previous.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous DATE FROM t1 @@ -1596,7 +1596,7 @@ BEGIN NOT ATOMIC DECLARE system INT; SET system=10; SELECT system; END SELECT system FROM t1 SELECT system 'alias' FROM t1 SELECT system() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system.system() Error 1630 FUNCTION system.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system DATE FROM t1 @@ -1619,7 +1619,7 @@ BEGIN NOT ATOMIC DECLARE system_time INT; SET system_time=10; SELECT system_time SELECT system_time FROM t1 SELECT system_time 'alias' FROM t1 SELECT system_time() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time.system_time() Error 1630 FUNCTION system_time.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time DATE FROM t1 @@ -1690,7 +1690,7 @@ BEGIN NOT ATOMIC DECLARE transaction INT; SET transaction=10; SELECT transaction SELECT transaction FROM t1 SELECT transaction 'alias' FROM t1 SELECT transaction() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction.transaction() Error 1630 FUNCTION transaction.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction DATE FROM t1 @@ -1736,7 +1736,7 @@ BEGIN NOT ATOMIC DECLARE versioning INT; SET versioning=10; SELECT versioning; E SELECT versioning FROM t1 SELECT versioning 'alias' FROM t1 SELECT versioning() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning.versioning() Error 1630 FUNCTION versioning.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning DATE FROM t1 @@ -1759,7 +1759,7 @@ BEGIN NOT ATOMIC DECLARE without INT; SET without=10; SELECT without; END SELECT without FROM t1 SELECT without 'alias' FROM t1 SELECT without() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without.without() Error 1630 FUNCTION without.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without DATE FROM t1 diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index 276b57a106c..24b80881c6e 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -2917,7 +2917,7 @@ ORDER BY timestamp DESC; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL ixEventWhoisDomainDomain,ixEventWhoisDomainTimestamp NULL NULL NULL 60 22.22 Using where; Using filesort Warnings: -Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`domain` AS `domain`,`test`.`t1`.`registrant_name` AS `registrant_name`,`test`.`t1`.`registrant_organization` AS `registrant_organization`,`test`.`t1`.`registrant_street1` AS `registrant_street1`,`test`.`t1`.`registrant_street2` AS `registrant_street2`,`test`.`t1`.`registrant_street3` AS `registrant_street3`,`test`.`t1`.`registrant_street4` AS `registrant_street4`,`test`.`t1`.`registrant_street5` AS `registrant_street5`,`test`.`t1`.`registrant_city` AS `registrant_city`,`test`.`t1`.`registrant_postal_code` AS `registrant_postal_code`,`test`.`t1`.`registrant_country` AS `registrant_country`,`test`.`t1`.`registrant_email` AS `registrant_email`,`test`.`t1`.`registrant_telephone` AS `registrant_telephone`,`test`.`t1`.`administrative_name` AS `administrative_name`,`test`.`t1`.`administrative_organization` AS `administrative_organization`,`test`.`t1`.`administrative_street1` AS `administrative_street1`,`test`.`t1`.`administrative_street2` AS `administrative_street2`,`test`.`t1`.`administrative_street3` AS `administrative_street3`,`test`.`t1`.`administrative_street4` AS `administrative_street4`,`test`.`t1`.`administrative_street5` AS `administrative_street5`,`test`.`t1`.`administrative_city` AS `administrative_city`,`test`.`t1`.`administrative_postal_code` AS `administrative_postal_code`,`test`.`t1`.`administrative_country` AS `administrative_country`,`test`.`t1`.`administrative_email` AS `administrative_email`,`test`.`t1`.`administrative_telephone` AS `administrative_telephone`,`test`.`t1`.`technical_name` AS `technical_name`,`test`.`t1`.`technical_organization` AS `technical_organization`,`test`.`t1`.`technical_street1` AS `technical_street1`,`test`.`t1`.`technical_street2` AS `technical_street2`,`test`.`t1`.`technical_street3` AS `technical_street3`,`test`.`t1`.`technical_street4` AS `technical_street4`,`test`.`t1`.`technical_street5` AS `technical_street5`,`test`.`t1`.`technical_city` AS `technical_city`,`test`.`t1`.`technical_postal_code` AS `technical_postal_code`,`test`.`t1`.`technical_country` AS `technical_country`,`test`.`t1`.`technical_email` AS `technical_email`,`test`.`t1`.`technical_telephone` AS `technical_telephone`,`test`.`t1`.`json` AS `json`,`test`.`t1`.`timestamp` AS `timestamp` from `test`.`t1` where `test`.`t1`.`domain` = 'www.mailhost.i-dev.fr' and `test`.`t1`.`timestamp` >= ('2017-01-30 08:24:51' + interval -1 month) order by `test`.`t1`.`timestamp` desc +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`domain` AS `domain`,`test`.`t1`.`registrant_name` AS `registrant_name`,`test`.`t1`.`registrant_organization` AS `registrant_organization`,`test`.`t1`.`registrant_street1` AS `registrant_street1`,`test`.`t1`.`registrant_street2` AS `registrant_street2`,`test`.`t1`.`registrant_street3` AS `registrant_street3`,`test`.`t1`.`registrant_street4` AS `registrant_street4`,`test`.`t1`.`registrant_street5` AS `registrant_street5`,`test`.`t1`.`registrant_city` AS `registrant_city`,`test`.`t1`.`registrant_postal_code` AS `registrant_postal_code`,`test`.`t1`.`registrant_country` AS `registrant_country`,`test`.`t1`.`registrant_email` AS `registrant_email`,`test`.`t1`.`registrant_telephone` AS `registrant_telephone`,`test`.`t1`.`administrative_name` AS `administrative_name`,`test`.`t1`.`administrative_organization` AS `administrative_organization`,`test`.`t1`.`administrative_street1` AS `administrative_street1`,`test`.`t1`.`administrative_street2` AS `administrative_street2`,`test`.`t1`.`administrative_street3` AS `administrative_street3`,`test`.`t1`.`administrative_street4` AS `administrative_street4`,`test`.`t1`.`administrative_street5` AS `administrative_street5`,`test`.`t1`.`administrative_city` AS `administrative_city`,`test`.`t1`.`administrative_postal_code` AS `administrative_postal_code`,`test`.`t1`.`administrative_country` AS `administrative_country`,`test`.`t1`.`administrative_email` AS `administrative_email`,`test`.`t1`.`administrative_telephone` AS `administrative_telephone`,`test`.`t1`.`technical_name` AS `technical_name`,`test`.`t1`.`technical_organization` AS `technical_organization`,`test`.`t1`.`technical_street1` AS `technical_street1`,`test`.`t1`.`technical_street2` AS `technical_street2`,`test`.`t1`.`technical_street3` AS `technical_street3`,`test`.`t1`.`technical_street4` AS `technical_street4`,`test`.`t1`.`technical_street5` AS `technical_street5`,`test`.`t1`.`technical_city` AS `technical_city`,`test`.`t1`.`technical_postal_code` AS `technical_postal_code`,`test`.`t1`.`technical_country` AS `technical_country`,`test`.`t1`.`technical_email` AS `technical_email`,`test`.`t1`.`technical_telephone` AS `technical_telephone`,`test`.`t1`.`json` AS `json`,`test`.`t1`.`timestamp` AS `timestamp` from `test`.`t1` where `test`.`t1`.`domain` = 'www.mailhost.i-dev.fr' and `test`.`t1`.`timestamp` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2016-12-30 08:24:51' order by `test`.`t1`.`timestamp` desc SET optimizer_switch=@save_optimizer_switch; DROP TABLE t1; # diff --git a/mysql-test/main/secondary_key_costs.result b/mysql-test/main/secondary_key_costs.result new file mode 100644 index 00000000000..3c56b50d44a --- /dev/null +++ b/mysql-test/main/secondary_key_costs.result @@ -0,0 +1,160 @@ +create table t1 ( +pk int primary key auto_increment, +nm varchar(32), +fl1 tinyint default 0, +fl2 tinyint default 0, +index idx1(nm, fl1), +index idx2(fl2) +) engine=myisam; +create table name ( +pk int primary key auto_increment, +nm bigint +) engine=myisam; +create table flag2 ( +pk int primary key auto_increment, +fl2 tinyint +) engine=myisam; +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); +insert into t1(nm,fl2) +select nm, fl2 from name, flag2 where name.pk = flag2.pk; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +set optimizer_trace="enabled=on"; +set optimizer_switch='rowid_filter=on'; +set statement optimizer_adjust_secondary_key_costs=0 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where +Warnings: +Warning 1287 '@@optimizer_adjust_secondary_key_costs' is deprecated and will be removed in a future release +Warning 1287 '@@optimizer_adjust_secondary_key_costs' is deprecated and will be removed in a future release +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); +json_detailed(json_extract(@trace, '$**.considered_access_paths')) +[ + [ + { + "access_type": "ref", + "index": "idx2", + "used_range_estimates": true, + "filter": + { + "rowid_filter_index": "idx1", + "index_only_cost": 0.045598762, + "filter_startup_cost": 0.000899465, + "find_key_and_filter_lookup_cost": 0.03086808, + "filter_selectivity": 0.001, + "original_rows": 492, + "new_rows": 0.492, + "original_access_cost": 0.59235049, + "with_filter_access_cost": 0.077013594, + "original_found_rows_cost": 0.546751728, + "with_filter_found_rows_cost": 5.467517e-4, + "org_cost": 0.60809449, + "filter_cost": 0.077928803, + "filter_used": true + }, + "rows": 0.492, + "cost": 0.077928803, + "chosen": true + }, + { + "filter": + { + "rowid_filter_index": "idx2", + "index_only_cost": 0.000881127, + "filter_startup_cost": 0.066293508, + "find_key_and_filter_lookup_cost": 8.646449e-5, + "filter_selectivity": 0.492, + "original_rows": 1, + "new_rows": 0.492, + "original_access_cost": 0.001992411, + "with_filter_access_cost": 0.001514343, + "original_found_rows_cost": 0.001111284, + "with_filter_found_rows_cost": 5.467517e-4, + "org_cost": 0.002024411, + "filter_cost": 0.067823595, + "filter_used": false + }, + "access_type": "range", + "range_index": "idx1", + "rows": 1, + "rows_after_filter": 1, + "rows_out": 0.492, + "cost": 0.002574553, + "chosen": true + } + ] +] + +The following trace should have a different rowid_filter_key cost + +set statement optimizer_adjust_secondary_key_costs=2 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range idx1,idx2 idx1 35 NULL 1 Using index condition; Using where +Warnings: +Warning 1287 '@@optimizer_adjust_secondary_key_costs' is deprecated and will be removed in a future release +Warning 1287 '@@optimizer_adjust_secondary_key_costs' is deprecated and will be removed in a future release +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); +json_detailed(json_extract(@trace, '$**.considered_access_paths')) +[ + [ + { + "access_type": "ref", + "index": "idx2", + "used_range_estimates": true, + "filter": + { + "rowid_filter_index": "idx1", + "index_only_cost": 0.045598762, + "filter_startup_cost": 0.000899465, + "find_key_and_filter_lookup_cost": 0.03086808, + "filter_selectivity": 0.001, + "original_rows": 492, + "new_rows": 0.492, + "original_access_cost": 0.59235049, + "with_filter_access_cost": 0.077013594, + "original_found_rows_cost": 0.546751728, + "with_filter_found_rows_cost": 5.467517e-4, + "org_cost": 0.60809449, + "filter_cost": 0.077928803, + "filter_used": true + }, + "rows": 0.492, + "cost": 0.077928803, + "chosen": true + }, + { + "filter": + { + "rowid_filter_index": "idx2", + "index_only_cost": 0.000881127, + "filter_startup_cost": 0.066293508, + "find_key_and_filter_lookup_cost": 8.646449e-5, + "filter_selectivity": 0.492, + "original_rows": 1, + "new_rows": 0.492, + "original_access_cost": 0.001992411, + "with_filter_access_cost": 0.001514343, + "original_found_rows_cost": 0.001111284, + "with_filter_found_rows_cost": 5.467517e-4, + "org_cost": 0.002024411, + "filter_cost": 0.067823595, + "filter_used": false + }, + "access_type": "range", + "range_index": "idx1", + "rows": 1, + "rows_after_filter": 1, + "rows_out": 0.492, + "cost": 0.002574553, + "chosen": true + } + ] +] +drop table t1, name, flag2; diff --git a/mysql-test/main/secondary_key_costs.test b/mysql-test/main/secondary_key_costs.test new file mode 100644 index 00000000000..d3db137653b --- /dev/null +++ b/mysql-test/main/secondary_key_costs.test @@ -0,0 +1,53 @@ +--source include/have_sequence.inc +--source include/not_embedded.inc + +# +# Show the costs for rowid filter +# + +create table t1 ( + pk int primary key auto_increment, + nm varchar(32), + fl1 tinyint default 0, + fl2 tinyint default 0, + index idx1(nm, fl1), + index idx2(fl2) +) engine=myisam; + +create table name ( + pk int primary key auto_increment, + nm bigint +) engine=myisam; + +create table flag2 ( + pk int primary key auto_increment, + fl2 tinyint +) engine=myisam; + +insert into name(nm) select seq from seq_1_to_1000 order by rand(17); +insert into flag2(fl2) select seq mod 2 from seq_1_to_1000 order by rand(19); + +insert into t1(nm,fl2) + select nm, fl2 from name, flag2 where name.pk = flag2.pk; + +analyze table t1 persistent for all; + +--disable_ps_protocol +set optimizer_trace="enabled=on"; +set optimizer_switch='rowid_filter=on'; +set statement optimizer_adjust_secondary_key_costs=0 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); + +--echo +--echo The following trace should have a different rowid_filter_key cost +--echo +set statement optimizer_adjust_secondary_key_costs=2 for +explain select * from t1 where nm like '500%' AND fl2 = 0; +set @trace=(select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@trace, '$**.considered_access_paths')); + +--enable_ps_protocol + +drop table t1, name, flag2; diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 77af394fae1..155e497140a 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -8948,6 +8948,21 @@ DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP VIEW v1; +# +# MDEV-33270: Call of SP invoking another SP with a parameter +# requiring type conversion +# +SET NAMES latin1; +CREATE PROCEDURE p1 (a text) BEGIN SELECT a; END | +CREATE PROCEDURE p2 () CALL p1(concat('x',_utf8'x')) | +CALL p2(); +a +xx +CALL p2(); +a +xx +DROP PROCEDURE p1; +DROP PROCEDURE p2; # End of 10.4 tests # # @@ -9001,6 +9016,79 @@ BEGIN NOT ATOMIC DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1); SELECT r.a r.a 1 SET SESSION log_slow_verbosity= @tmp; +# +# MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6. +# +CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'empty' has the same name as a native function +SELECT empty('1'); +empty('1') +0 +Warnings: +Note 1585 This function 'empty' has the same name as a native function +DROP FUNCTION empty; +CREATE OR REPLACE FUNCTION json_table(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'json_table' has the same name as a native function +SELECT json_table('1'); +json_table('1') +0 +Warnings: +Note 1585 This function 'json_table' has the same name as a native function +DROP FUNCTION json_table; +CREATE OR REPLACE FUNCTION nested(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'nested' has the same name as a native function +SELECT nested('1'); +nested('1') +0 +Warnings: +Note 1585 This function 'nested' has the same name as a native function +DROP FUNCTION nested; +CREATE OR REPLACE FUNCTION ordinality(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'ordinality' has the same name as a native function +SELECT ordinality('1'); +ordinality('1') +0 +Warnings: +Note 1585 This function 'ordinality' has the same name as a native function +DROP FUNCTION ordinality; +CREATE OR REPLACE FUNCTION path(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'path' has the same name as a native function +SELECT path('1'); +path('1') +0 +Warnings: +Note 1585 This function 'path' has the same name as a native function +DROP FUNCTION path; +CREATE OR REPLACE FUNCTION fast(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'fast' has the same name as a native function +SELECT fast('1'); +fast('1') +0 +Warnings: +Note 1585 This function 'fast' has the same name as a native function +DROP FUNCTION fast; +CREATE OR REPLACE FUNCTION relay(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'relay' has the same name as a native function +SELECT relay('1'); +relay('1') +0 +Warnings: +Note 1585 This function 'relay' has the same name as a native function +DROP FUNCTION relay; +CREATE OR REPLACE FUNCTION database() RETURNS int RETURN 333; +Warnings: +Note 1585 This function 'database' has the same name as a native function +SELECT database(); +database() +test +DROP FUNCTION database; DROP TABLE t1; # # MDEV-28129: MariaDB UAF issue at lex_end_nops(LEX*) diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 6882eecd9e8..4deb1d05cb0 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -10565,6 +10565,26 @@ DROP FUNCTION f2; DROP FUNCTION f3; DROP VIEW v1; +--echo # +--echo # MDEV-33270: Call of SP invoking another SP with a parameter +--echo # requiring type conversion +--echo # + +SET NAMES latin1; + +--delimiter | + +CREATE PROCEDURE p1 (a text) BEGIN SELECT a; END | +CREATE PROCEDURE p2 () CALL p1(concat('x',_utf8'x')) | + +--delimiter ; + +CALL p2(); +CALL p2(); + +DROP PROCEDURE p1; +DROP PROCEDURE p2; + --echo # End of 10.4 tests --echo # @@ -10617,6 +10637,44 @@ BEGIN NOT ATOMIC DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1); SELECT r.a --delimiter ; SET SESSION log_slow_verbosity= @tmp; + +--echo # +--echo # MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6. +--echo # +CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT empty('1'); +DROP FUNCTION empty; + +CREATE OR REPLACE FUNCTION json_table(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT json_table('1'); +DROP FUNCTION json_table; + +CREATE OR REPLACE FUNCTION nested(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT nested('1'); +DROP FUNCTION nested; + +CREATE OR REPLACE FUNCTION ordinality(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT ordinality('1'); +DROP FUNCTION ordinality; + +CREATE OR REPLACE FUNCTION path(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT path('1'); +DROP FUNCTION path; + + +CREATE OR REPLACE FUNCTION fast(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT fast('1'); +DROP FUNCTION fast; + +CREATE OR REPLACE FUNCTION relay(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT relay('1'); +DROP FUNCTION relay; + +CREATE OR REPLACE FUNCTION database() RETURNS int RETURN 333; +SELECT database(); +DROP FUNCTION database; + + # Cleanup DROP TABLE t1; diff --git a/mysql-test/main/strict.result b/mysql-test/main/strict.result index 3163059956c..d9d92402927 100644 --- a/mysql-test/main/strict.result +++ b/mysql-test/main/strict.result @@ -897,7 +897,7 @@ ERROR 22003: Out of range value for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ERROR 22003: Out of range value for column 'col2' at row 1 UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; -ERROR 22003: DOUBLE value is out of range in '"test"."t1"."col1" * 5000' +Got one of the listed errors UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; ERROR 22012: Division by 0 UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0; diff --git a/mysql-test/main/strict.test b/mysql-test/main/strict.test index 830f051a5f6..1819f399041 100644 --- a/mysql-test/main/strict.test +++ b/mysql-test/main/strict.test @@ -824,7 +824,7 @@ INSERT INTO t1 (col2) VALUES (-1.1E-3); INSERT INTO t1 (col1) VALUES ('+1.8E+309'); --error 1264 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ---error ER_DATA_OUT_OF_RANGE +--error ER_DATA_OUT_OF_RANGE, ER_WARN_DATA_OUT_OF_RANGE UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; --error 1365 UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; diff --git a/mysql-test/main/subselect_nulls_innodb.result b/mysql-test/main/subselect_nulls_innodb.result new file mode 100644 index 00000000000..2cab41760b3 --- /dev/null +++ b/mysql-test/main/subselect_nulls_innodb.result @@ -0,0 +1,27 @@ +# +# MDEV-32090 Index does not handle null-safe equals operator correctly in join +# +CREATE TEMPORARY TABLE t1 ( +`id` int(10) unsigned NOT NULL, +`number` int(10) unsigned DEFAULT 0, +`name` varchar(47) DEFAULT NULL, +`street` mediumint(8) unsigned DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `streetNumber` (`street`,`number`,`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +INSERT INTO t1 (id, number, name, street) VALUES (100733476, 14, NULL, 1115569); +SELECT +b1.id +FROM +t1 b1 +INNER JOIN t1 b2 ON ( +b1.street = b2.street +AND b1.number <=> b2.number +AND b1.name <=> b2.name +); +id +100733476 +DROP TABLE t1; +# +# End of 10.11 tests +# diff --git a/mysql-test/main/subselect_nulls_innodb.test b/mysql-test/main/subselect_nulls_innodb.test new file mode 100644 index 00000000000..79d572a2e0e --- /dev/null +++ b/mysql-test/main/subselect_nulls_innodb.test @@ -0,0 +1,32 @@ +--source include/have_innodb.inc + +--echo # +--echo # MDEV-32090 Index does not handle null-safe equals operator correctly in join +--echo # + +CREATE TEMPORARY TABLE t1 ( + `id` int(10) unsigned NOT NULL, + `number` int(10) unsigned DEFAULT 0, + `name` varchar(47) DEFAULT NULL, + `street` mediumint(8) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `streetNumber` (`street`,`number`,`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO t1 (id, number, name, street) VALUES (100733476, 14, NULL, 1115569); + +SELECT + b1.id +FROM + t1 b1 + INNER JOIN t1 b2 ON ( + b1.street = b2.street + AND b1.number <=> b2.number + AND b1.name <=> b2.name + ); + +DROP TABLE t1; + +--echo # +--echo # End of 10.11 tests +--echo # diff --git a/mysql-test/main/temp.test b/mysql-test/main/temp.test deleted file mode 100644 index 7e29df49b71..00000000000 --- a/mysql-test/main/temp.test +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE t1 ( c1 longtext , c2 longtext ); - -INSERT INTO t1 VALUES('[1,2,3]', '[2, 3, 4]'), ('[1,2,3]', '[2, 3, 4]'); - -SELECT JSON_ARRAY_INTERSECT(c1, c2) FROM t1; - -DROP TABLE t1; diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result index 4ec979273b5..ac5d82bab44 100644 --- a/mysql-test/main/temp_table.result +++ b/mysql-test/main/temp_table.result @@ -601,6 +601,25 @@ DROP TEMPORARY TABLE t1; # # End of 10.2 tests # +# +# MDEV-31523: Using two temporary tables in OPTIMIZE TABLE lead to crash +# +CREATE TEMPORARY TABLE t1 (c INT) ENGINE=MyISAM; +CREATE TEMPORARY TABLE t2 (c INT) ENGINE=MyISAM; +optimize TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 optimize status Table is already up to date +test.t2 optimize status Table is already up to date +SHOW TABLES; +Tables_in_test +t2 +t1 +tmp +# in 11.2 and above here should be listed above used temporary tables +DROP TEMPORARY TABLE t1, t2; +# +# End of 10.4 tests +# create function f1() returns int begin drop temporary table t1, t2; diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test index 6ed5dbd88db..11a667435d1 100644 --- a/mysql-test/main/temp_table.test +++ b/mysql-test/main/temp_table.test @@ -657,6 +657,22 @@ DROP TEMPORARY TABLE t1; --echo # End of 10.2 tests --echo # +--echo # +--echo # MDEV-31523: Using two temporary tables in OPTIMIZE TABLE lead to crash +--echo # + +CREATE TEMPORARY TABLE t1 (c INT) ENGINE=MyISAM; +CREATE TEMPORARY TABLE t2 (c INT) ENGINE=MyISAM; +optimize TABLE t1,t2; +SHOW TABLES; +--echo # in 11.2 and above here should be listed above used temporary tables + +DROP TEMPORARY TABLE t1, t2; + +--echo # +--echo # End of 10.4 tests +--echo # + # # DROP TEMPORARY TABLE fails in the middle # diff --git a/mysql-test/main/timezone2.result b/mysql-test/main/timezone2.result index 787552d9159..382ed447c92 100644 --- a/mysql-test/main/timezone2.result +++ b/mysql-test/main/timezone2.result @@ -678,3 +678,188 @@ SELECT a, UNIX_TIMESTAMP(a) FROM t1 WHERE a >= ALL (SELECT * FROM t1); a UNIX_TIMESTAMP(a) 2010-10-31 02:25:25 1288481125 DROP TABLE t1; +# +# MDEV-32148 Inefficient WHERE timestamp_column=datetime_expr +# +# +# Testing a DST change (fall back) +# +SET time_zone='Europe/Moscow'; +SET @first_second_after_dst_fall_back=1288479600; +CREATE TABLE t1 (a TIMESTAMP NULL); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31'); +# +# Optimized (more than 24 hours before the DST fall back) +# +SET timestamp=@first_second_after_dst_fall_back-24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1288393199 2010-10-30 02:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2010-10-30 02:59:59' +# +# Not optimized (24 hours before the DST fall back) +# +SET timestamp=@first_second_after_dst_fall_back-24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1288393200 2010-10-30 03:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (current_timestamp()) +# +# Not optimized (less than 24 hours after the DST fall back) +# +SET timestamp=@first_second_after_dst_fall_back+24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1288565999 2010-11-01 01:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (current_timestamp()) +# +# Optimized (24 hours after the DST fall back) +# +SET timestamp=@first_second_after_dst_fall_back+24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1288566000 2010-11-01 02:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2010-11-01 02:00:00' +DROP TABLE t1; +SET time_zone=DEFAULT; +# +# Testing a DST change (spring forward) +# +SET time_zone='Europe/Moscow'; +SET @first_second_after_dst_spring_forward=1301180400; +CREATE TABLE t1 (a TIMESTAMP NULL); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31'); +# +# Optimized (more than 24 hours before the DST sprint forward) +# +SET timestamp=@first_second_after_dst_spring_forward-24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1301093999 2011-03-26 01:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2011-03-26 01:59:59' +# +# Not optimized (24 hours before the DST sprint forward) +# +SET timestamp=@first_second_after_dst_spring_forward-24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1301094000 2011-03-26 02:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (current_timestamp()) +# +# Not optimized (less than 24 hours after the DST sprint forward) +# +SET timestamp=@first_second_after_dst_spring_forward+24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1301266799 2011-03-28 02:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (current_timestamp()) +# +# Optimized (24 hours after the DST sprint forward) +# +SET timestamp=@first_second_after_dst_spring_forward+24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +1301266800 2011-03-28 03:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2011-03-28 03:00:00' +DROP TABLE t1; +# +# Testing a leap second +# +SET time_zone='leap/Europe/Moscow'; +SET @leap_second=362793609; +/*The 60th leap second*/ +CREATE TABLE t1 (a TIMESTAMP); +SET timestamp=@leap_second-1; +INSERT INTO t1 VALUES (NOW()); +SET timestamp=@leap_second; +INSERT INTO t1 VALUES (NOW()); +SET timestamp=@leap_second+1; +INSERT INTO t1 VALUES (NOW()); +SELECT UNIX_TIMESTAMP(a), a FROM t1 ORDER BY UNIX_TIMESTAMP(a); +UNIX_TIMESTAMP(a) a +362793608 1981-07-01 03:59:59 +362793609 1981-07-01 03:59:59 +362793610 1981-07-01 04:00:00 +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'); +# +# Optimized (more than 24 hours before the leap second) +# +SET timestamp=@leap_second-24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +362707208 1981-06-30 03:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'1981-06-30 03:59:59' +# +# Not optimized (24 hours before the leap second) +# +SET timestamp=@leap_second-24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +362707209 1981-06-30 04:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (current_timestamp()) +# +# Not optimized (less than 24 hours after the leap second) +# +SET timestamp=@leap_second+24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +362880008 1981-07-02 03:59:58 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (current_timestamp()) +# +# Not optimized (24 hours after the leap second) +# +SET timestamp=@leap_second+24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +UNIX_TIMESTAMP() NOW() +362880009 1981-07-02 03:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'1981-07-02 03:59:59' +DROP TABLE t1; +SET time_zone=DEFAULT; diff --git a/mysql-test/main/timezone2.test b/mysql-test/main/timezone2.test index b5045203903..09be74089ce 100644 --- a/mysql-test/main/timezone2.test +++ b/mysql-test/main/timezone2.test @@ -630,3 +630,155 @@ SELECT a, UNIX_TIMESTAMP(a) FROM t1 ORDER BY a; SELECT a, UNIX_TIMESTAMP(a) FROM t1 WHERE a <= ALL (SELECT * FROM t1); SELECT a, UNIX_TIMESTAMP(a) FROM t1 WHERE a >= ALL (SELECT * FROM t1); DROP TABLE t1; + + +--echo # +--echo # MDEV-32148 Inefficient WHERE timestamp_column=datetime_expr +--echo # + +--echo # +--echo # Testing a DST change (fall back) +--echo # + +SET time_zone='Europe/Moscow'; +# '2010-10-31 02:59:59' (1288479599) +# '2010-10-31 02:00:00' (1288479600) +SET @first_second_after_dst_fall_back=1288479600; + +CREATE TABLE t1 (a TIMESTAMP NULL); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31'); + +--echo # +--echo # Optimized (more than 24 hours before the DST fall back) +--echo # + +SET timestamp=@first_second_after_dst_fall_back-24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Not optimized (24 hours before the DST fall back) +--echo # + +SET timestamp=@first_second_after_dst_fall_back-24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Not optimized (less than 24 hours after the DST fall back) +--echo # + +SET timestamp=@first_second_after_dst_fall_back+24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Optimized (24 hours after the DST fall back) +--echo # + +SET timestamp=@first_second_after_dst_fall_back+24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +DROP TABLE t1; +SET time_zone=DEFAULT; + + +--echo # +--echo # Testing a DST change (spring forward) +--echo # + +SET time_zone='Europe/Moscow'; +# '2011-03-27 01:59:59' (1301180399) +# '2011-03-27 03:00:00' (1301180400) +SET @first_second_after_dst_spring_forward=1301180400; + +CREATE TABLE t1 (a TIMESTAMP NULL); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31'); + +--echo # +--echo # Optimized (more than 24 hours before the DST sprint forward) +--echo # + +SET timestamp=@first_second_after_dst_spring_forward-24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Not optimized (24 hours before the DST sprint forward) +--echo # + +SET timestamp=@first_second_after_dst_spring_forward-24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Not optimized (less than 24 hours after the DST sprint forward) +--echo # + +SET timestamp=@first_second_after_dst_spring_forward+24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Optimized (24 hours after the DST sprint forward) +--echo # + +SET timestamp=@first_second_after_dst_spring_forward+24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +DROP TABLE t1; + +--echo # +--echo # Testing a leap second +--echo # + +SET time_zone='leap/Europe/Moscow'; +SET @leap_second=362793609; /*The 60th leap second*/ + +CREATE TABLE t1 (a TIMESTAMP); +SET timestamp=@leap_second-1; +INSERT INTO t1 VALUES (NOW()); +SET timestamp=@leap_second; +INSERT INTO t1 VALUES (NOW()); +SET timestamp=@leap_second+1; +INSERT INTO t1 VALUES (NOW()); +SELECT UNIX_TIMESTAMP(a), a FROM t1 ORDER BY UNIX_TIMESTAMP(a); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'); + +--echo # +--echo # Optimized (more than 24 hours before the leap second) +--echo # + +SET timestamp=@leap_second-24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Not optimized (24 hours before the leap second) +--echo # + +SET timestamp=@leap_second-24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Not optimized (less than 24 hours after the leap second) +--echo # + +SET timestamp=@leap_second+24*3600-1; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +--echo # +--echo # Not optimized (24 hours after the leap second) +--echo # + +SET timestamp=@leap_second+24*3600; +SELECT UNIX_TIMESTAMP(), NOW(); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now(); + +DROP TABLE t1; + +SET time_zone=DEFAULT; diff --git a/mysql-test/main/type_float.result b/mysql-test/main/type_float.result index 9f01f22b3c7..877cdec864e 100644 --- a/mysql-test/main/type_float.result +++ b/mysql-test/main/type_float.result @@ -1171,6 +1171,43 @@ d 50 fdbl 123.456.789,12345678000000000000000000000000000000 fdec 123.456.789,12345678900000000000000000000000000000 # +# MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol +# +SELECT +CAST(-1e0 AS UNSIGNED), +CAST(--2e0 AS UNSIGNED), +CAST(---3e0 AS UNSIGNED), +CAST(----4e0 AS UNSIGNED); +CAST(-1e0 AS UNSIGNED) CAST(--2e0 AS UNSIGNED) CAST(---3e0 AS UNSIGNED) CAST(----4e0 AS UNSIGNED) +0 2 0 4 +Warnings: +Note 1916 Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated +Note 1916 Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated +EXPLAIN EXTENDED SELECT +CAST(-1e0 AS UNSIGNED), +CAST(--2e0 AS UNSIGNED), +CAST(---3e0 AS UNSIGNED), +CAST(----4e0 AS UNSIGNED); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select cast(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)` +CREATE VIEW v1 AS SELECT +CAST(-1e0 AS UNSIGNED), +CAST(--2e0 AS UNSIGNED), +CAST(---3e0 AS UNSIGNED), +CAST(----4e0 AS UNSIGNED); +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 select cast(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)` latin1 latin1_swedish_ci +SELECT * FROM v1; +CAST(-1e0 AS UNSIGNED) CAST(--2e0 AS UNSIGNED) CAST(---3e0 AS UNSIGNED) CAST(----4e0 AS UNSIGNED) +0 2 0 4 +Warnings: +Note 1916 Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated +Note 1916 Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated +DROP VIEW v1; +# # End of 10.4 tests # # diff --git a/mysql-test/main/type_float.test b/mysql-test/main/type_float.test index 12e3f070fde..c90d8b8aa79 100644 --- a/mysql-test/main/type_float.test +++ b/mysql-test/main/type_float.test @@ -716,6 +716,32 @@ $$ DELIMITER ;$$ --horizontal_results +--echo # +--echo # MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol +--echo # + +SELECT + CAST(-1e0 AS UNSIGNED), + CAST(--2e0 AS UNSIGNED), + CAST(---3e0 AS UNSIGNED), + CAST(----4e0 AS UNSIGNED); + +EXPLAIN EXTENDED SELECT + CAST(-1e0 AS UNSIGNED), + CAST(--2e0 AS UNSIGNED), + CAST(---3e0 AS UNSIGNED), + CAST(----4e0 AS UNSIGNED); + +CREATE VIEW v1 AS SELECT + CAST(-1e0 AS UNSIGNED), + CAST(--2e0 AS UNSIGNED), + CAST(---3e0 AS UNSIGNED), + CAST(----4e0 AS UNSIGNED); + +SHOW CREATE VIEW v1; +SELECT * FROM v1; +DROP VIEW v1; + --echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index 78e860661c5..b01f37ba125 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -872,13 +872,13 @@ SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=' 2001-01-01 00:00:00'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00' EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=' 2001-01-01 00:00:00'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00' and (octet_length(TIMESTAMP'2001-01-01 00:00:00')) = 19 + rand() +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00' and (octet_length(TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00')) = 19 + rand() EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=30+RAND() AND a=' garbage '; id select_type table type possible_keys key key_len ref rows filtered Extra @@ -905,13 +905,13 @@ SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=TIMESTAMP'2001-01-01 00:00:00.000000'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00.000000' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00.000000' EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=30+RAND() AND a=TIMESTAMP'2001-01-01 00:00:00.000000'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00.000000' and (octet_length(TIMESTAMP'2001-01-01 00:00:00')) = 30 + rand() +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00.000000' and (octet_length(TIMESTAMP'2001-01-01 00:00:00')) = 30 + rand() DROP TABLE t1; CREATE TABLE t1 (a TIMESTAMP(6));; INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'),('2001-01-01 00:00:01.000000'); @@ -930,13 +930,13 @@ SELECT * FROM t1 WHERE LENGTH(a)=26 AND a=TIMESTAMP'2001-01-01 00:00:00.000000'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00.000000' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00.000000' EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=40+RAND() AND a=TIMESTAMP'2001-01-01 00:00:00.000000'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00.000000' and (octet_length(TIMESTAMP'2001-01-01 00:00:00.000000')) = 40 + rand() +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00.000000' and (octet_length(TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00.000000')) = 40 + rand() DROP TABLE t1; SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30'); CREATE TABLE t1 (a TIMESTAMP);; @@ -956,13 +956,13 @@ SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=TIME'00:00:00'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00' EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=40+RAND() AND a=TIME'00:00:00'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00' and (octet_length(TIMESTAMP'2001-01-01 00:00:00')) = 40 + rand() +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00' and (octet_length(TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00')) = 40 + rand() DROP TABLE t1; # # End of 10.1 tests @@ -1347,6 +1347,540 @@ SET time_zone=DEFAULT; # End of 10.4 tests # # +# Start of 10.6 tests +# +# +# MDEV-32148 Inefficient WHERE timestamp_column=datetime_expr +# +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'), ('2001-01-01 10:20:31'); +# +# Comparison predicates: Bad TIMESTAMP values preserve DATETIME comparison +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'1001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2001-01-00 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2001-01-00 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2040-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2040-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='1001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'1001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-00 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2001-01-00 00:00:00' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = '2001-01-00 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2040-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2040-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10010101102030; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 10010101102030 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010100000000; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 20010100000000 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20400101102030; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 20400101102030 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10010101102030e0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 10010101102030e0 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010100000000e0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 20010100000000e0 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20400101102030e0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 20400101102030e0 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10010101102030.0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 10010101102030.0 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010100000000.0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 20010100000000.0 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20400101102030.0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 20400101102030.0 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=DATE_ADD('2020-01-01 10:20:30', INTERVAL 30 YEAR); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2050-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(NULL, a)=DATE_ADD('2020-01-01 10:20:30', INTERVAL 30 YEAR); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where coalesce(NULL,`test`.`t1`.`a`) = ('2020-01-01 10:20:30' + interval 30 year) +# +# Comparison predicates: Good TIMESTAMP values switch to TIMESTAMP comparison +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'0000-00-00 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='0000-00-00 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010101102030; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=0e0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00.000000' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010101102030e0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.000000' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=0.0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00.0' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010101102030.0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.0' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=DATE_ADD('2001-01-01 10:20:00', INTERVAL 30 SECOND); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(NULL, a)=DATE_ADD('2001-01-01 10:20:00', INTERVAL 30 SECOND); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where coalesce(NULL,`test`.`t1`.`a`) = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +# +# Corner cases: DATETIME values before the supported optimization range +# FROM_UNIXTIME(0)..FROM_UNIXTIME(24*3600-1) +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'1970-01-01 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'1970-01-01 23:59:59' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.999999'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'1970-01-01 23:59:59.999999' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.9999999'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1292 Truncated incorrect DATETIME value: '1970-01-01 23:59:59.9999999' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'1970-01-01 23:59:59.999999' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(24*3600-1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (from_unixtime(24 * 3600 - 1)) +# +# Corner cases: DATETIME values inside the supported optimization range: +# FROM_UNIXTIME(24*3600) .. FROM_UNIXTIME(0x7FFFFFFF-24*3600) +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(24*3600); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'1970-01-02 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-02 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'1970-01-02 00:00:00' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:07'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2038-01-18 03:14:07' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(0x7FFFFFFF-24*3600); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2038-01-18 03:14:07' +# +# Corner cases: DATETIME values after the supported optimization range +# FROM_UNIXTIME(0x7FFFFFFF-24*3600+1) .. FROM_UNIXTIME(0x7FFFFFFF) +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(0x7FFFFFFF-24*3600+1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (from_unixtime(0x7fffffff - 24 * 3600 + 1)) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:08'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2038-01-18 03:14:08' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-19 03:14:07'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2038-01-19 03:14:07' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(0x7FFFFFFF); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (from_unixtime(0x7fffffff)) +# +# Corner cases: rounding +# +SET sql_mode=TIME_ROUND_FRACTIONAL; +# +# Not optimized (before the supported range) +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.999999'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'1970-01-01 23:59:59.999999' +# +# Optimized +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.9999999'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1292 Truncated incorrect DATETIME value: '1970-01-01 23:59:59.9999999' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'1970-01-02 00:00:00.000000' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:07.999999'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2038-01-18 03:14:07.999999' +# +# Not optimized (after the supported range) +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:07.9999999'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1292 Truncated incorrect DATETIME value: '2038-01-18 03:14:07.9999999' +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'2038-01-18 03:14:08.000000' +SET sql_mode=DEFAULT; +# +# NULLIF: Bad TIMESTAMP values preserve DATETIME comparison +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'1001-01-01 10:20:30'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP'1001-01-01 10:20:30') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'2001-01-00 00:00:00'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP'2001-01-00 00:00:00') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'2040-01-01 10:20:30'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP'2040-01-01 10:20:30') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'1001-01-01 10:20:30'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,'1001-01-01 10:20:30') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'2001-01-00 00:00:00'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,'2001-01-00 00:00:00') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'2040-01-01 10:20:30'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,'2040-01-01 10:20:30') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,10010101102030); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,10010101102030) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010100000000); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,20010100000000) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20400101102030); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,20400101102030) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,10010101102030e0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,10010101102030e0) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010100000000e0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,20010100000000e0) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20400101102030e0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,20400101102030e0) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,10010101102030.0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,10010101102030.0) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010100000000.0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,20010100000000.0) +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20400101102030.0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,20400101102030.0) +# +# NULLIF: Good TIMESTAMP values switch to TIMESTAMP comparison +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'0000-00-00 00:00:00'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'2001-01-01 10:20:30'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'0000-00-00 00:00:00'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'2001-01-01 10:20:30'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010101102030); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,0e0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00.000000') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010101102030e0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.000000') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,0.0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'0000-00-00 00:00:00.0') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010101102030.0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where nullif(`test`.`t1`.`a`,TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.0') +# +# Subqueries with bad TIMESTAMP values +# It's not clear from the output if the comparison is done as DATETIME or TIMESTAMP +# +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('1001-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (/* select#2 */ select max('1001-01-01 10:20:30') from dual) +DROP TABLE t2; +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('2001-00-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (/* select#2 */ select max('2001-00-00 00:00:00') from dual) +DROP TABLE t2; +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('2040-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (/* select#2 */ select max('2040-01-01 10:20:30') from dual) +DROP TABLE t2; +# +# Subqueries with good TIMESTAMP values +# It's not clear from the output if the comparison is done as DATETIME or TIMESTAMP +# +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('0000-00-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (/* select#2 */ select max('0000-00-00 00:00:00') from dual) +DROP TABLE t2; +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('2001-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = (/* select#2 */ select max('2001-01-01 10:20:30') from dual) +DROP TABLE t2; +# +# Trivial equality elimination +# Covers Type_handler_timestamp_common::Item_const_eq() +# +EXPLAIN EXTENDED SELECT * FROM t1 +WHERE IF(a='2001-01-01 00:00:00',1,0)=IF(a='2001-01-01 00:00:00',1,0); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where if(`test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00',1,0) = if(`test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 00:00:00',1,0) +EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a<=>?)=(a<=>?)' + USING '2001-01-01 00:00:00', '2001-01-01 00:00:00'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1 +# +# Equal field propagation: Good TIMESTAMP values switch to TIMESTAMP comparison +# +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=TIMESTAMP'2001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a='2001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=20010101102030; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=20010101102030e0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.000000' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=20010101102030.0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.0' +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=TIMESTAMP'2001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' and (octet_length(TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30')) = 19 + rand() +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a='2001-01-01 10:20:30'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' and (octet_length(TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30')) = 19 + rand() +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=20010101102030; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30' and (octet_length(TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30')) = 19 + rand() +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=20010101102030e0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.000000' and (octet_length(TIMESTAMP'2001-01-01 10:20:30')) = 19 + rand() +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=20010101102030.0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2001-01-01 10:20:30.0' and (octet_length(TIMESTAMP'2001-01-01 10:20:30')) = 19 + rand() +DROP TABLE t1; +SET time_zone=DEFAULT; +# +# End of 10.6 tests +# +# # MDEV-29225 make explicit_defaults_for_timestamps SESSION variable # set explicit_defaults_for_timestamp=OFF; @@ -1492,3 +2026,186 @@ DROP TABLE t2; DROP TABLE t1; SET note_verbosity=DEFAULT; # End of 10.6 tests +# +# Start of 11.3 tests +# +# +# MDEV-33299 Assertion `(tm->tv_usec % (int) log_10_int[6 - dec]) == 0' failed in void my_timestamp_to_binary(const timeval*, uchar*, uint) +# +CREATE TABLE t1(a TIMESTAMP,KEY(a)); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23' ; +a +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +a +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP,KEY(a)); +INSERT INTO t1 VALUES ('2023-12-31 23:59:59'); +INSERT INTO t1 VALUES ('2024-01-22 10:20:30'); +INSERT INTO t1 VALUES ('2024-01-23 10:20:30'); +INSERT INTO t1 VALUES ('2024-01-23 23:59:59'); +INSERT INTO t1 VALUES ('2024-01-24 00:00:00'); +INSERT INTO t1 VALUES ('2024-12-31 23:59:59'); +INSERT INTO t1 VALUES ('2025-01-01 00:00:00'); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +a +2023-12-31 23:59:59 +2024-01-22 10:20:30 +2024-01-23 10:20:30 +2024-01-23 23:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 5 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-23 23:59:59' +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +a +2023-12-31 23:59:59 +2024-01-22 10:20:30 +2024-01-23 10:20:30 +2024-01-23 23:59:59 +2024-01-24 00:00:00 +2024-12-31 23:59:59 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) <= 2024; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 5 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-12-31 23:59:59' +SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +a +2024-01-24 00:00:00 +2024-12-31 23:59:59 +2025-01-01 00:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-24 00:00:00' +SELECT * FROM t1 WHERE YEAR(a) >= 2024; +a +2024-01-22 10:20:30 +2024-01-23 10:20:30 +2024-01-23 23:59:59 +2024-01-24 00:00:00 +2024-12-31 23:59:59 +2025-01-01 00:00:00 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) >= 2024; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 5 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-01 00:00:00' +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP(3),KEY(a)); +INSERT INTO t1 VALUES ('2023-12-31 23:59:59.999'); +INSERT INTO t1 VALUES ('2024-01-22 10:20:30.001'); +INSERT INTO t1 VALUES ('2024-01-23 10:20:30.002'); +INSERT INTO t1 VALUES ('2024-01-23 23:59:59.999'); +INSERT INTO t1 VALUES ('2024-01-24 00:00:00.000'); +INSERT INTO t1 VALUES ('2024-12-31 23:59:59.999'); +INSERT INTO t1 VALUES ('2025-01-01 00:00:00.000'); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +a +2023-12-31 23:59:59.999 +2024-01-22 10:20:30.001 +2024-01-23 10:20:30.002 +2024-01-23 23:59:59.999 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 7 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-23 23:59:59.999' +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +a +2023-12-31 23:59:59.999 +2024-01-22 10:20:30.001 +2024-01-23 10:20:30.002 +2024-01-23 23:59:59.999 +2024-01-24 00:00:00.000 +2024-12-31 23:59:59.999 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) <= 2024; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 7 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-12-31 23:59:59.999' +SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +a +2024-01-24 00:00:00.000 +2024-12-31 23:59:59.999 +2025-01-01 00:00:00.000 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 7 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-24 00:00:00.000' +SELECT * FROM t1 WHERE YEAR(a) >= 2024; +a +2024-01-22 10:20:30.001 +2024-01-23 10:20:30.002 +2024-01-23 23:59:59.999 +2024-01-24 00:00:00.000 +2024-12-31 23:59:59.999 +2025-01-01 00:00:00.000 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) >= 2024; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 7 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-01 00:00:00.000' +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP(6),KEY(a)); +INSERT INTO t1 VALUES ('2023-12-31 23:59:59.999999'); +INSERT INTO t1 VALUES ('2024-01-22 10:20:30.000001'); +INSERT INTO t1 VALUES ('2024-01-23 10:20:30.000002'); +INSERT INTO t1 VALUES ('2024-01-23 23:59:59.999999'); +INSERT INTO t1 VALUES ('2024-01-24 00:00:00.000000'); +INSERT INTO t1 VALUES ('2024-12-31 23:59:59.999999'); +INSERT INTO t1 VALUES ('2025-01-01 00:00:00.000000'); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +a +2023-12-31 23:59:59.999999 +2024-01-22 10:20:30.000001 +2024-01-23 10:20:30.000002 +2024-01-23 23:59:59.999999 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 8 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-23 23:59:59.999999' +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +a +2023-12-31 23:59:59.999999 +2024-01-22 10:20:30.000001 +2024-01-23 10:20:30.000002 +2024-01-23 23:59:59.999999 +2024-01-24 00:00:00.000000 +2024-12-31 23:59:59.999999 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) <= 2024; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 8 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-12-31 23:59:59.999999' +SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +a +2024-01-24 00:00:00.000000 +2024-12-31 23:59:59.999999 +2025-01-01 00:00:00.000000 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 8 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-24 00:00:00.000000' +SELECT * FROM t1 WHERE YEAR(a) >= 2024; +a +2024-01-22 10:20:30.000001 +2024-01-23 10:20:30.000002 +2024-01-23 23:59:59.999999 +2024-01-24 00:00:00.000000 +2024-12-31 23:59:59.999999 +2025-01-01 00:00:00.000000 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) >= 2024; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 8 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-01 00:00:00.000000' +DROP TABLE t1; +# +# End of 11.3 tests +# diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index b3dfa19223d..c39965b0c42 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -907,6 +907,246 @@ SET time_zone=DEFAULT; --echo # End of 10.4 tests --echo # +--echo # +--echo # Start of 10.6 tests +--echo # + +--echo # +--echo # MDEV-32148 Inefficient WHERE timestamp_column=datetime_expr +--echo # + +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'), ('2001-01-01 10:20:31'); + +--echo # +--echo # Comparison predicates: Bad TIMESTAMP values preserve DATETIME comparison +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1001-01-01 10:20:30'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2001-01-00 00:00:00'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2040-01-01 10:20:30'; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='1001-01-01 10:20:30'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-00 00:00:00'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2040-01-01 10:20:30'; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10010101102030; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010100000000; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20400101102030; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10010101102030e0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010100000000e0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20400101102030e0; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10010101102030.0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010100000000.0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20400101102030.0; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=DATE_ADD('2020-01-01 10:20:30', INTERVAL 30 YEAR); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(NULL, a)=DATE_ADD('2020-01-01 10:20:30', INTERVAL 30 YEAR); + +--echo # +--echo # Comparison predicates: Good TIMESTAMP values switch to TIMESTAMP comparison +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'0000-00-00 00:00:00'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2001-01-01 10:20:30'; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='0000-00-00 00:00:00'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01 10:20:30'; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010101102030; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=0e0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010101102030e0; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=0.0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=20010101102030.0; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=DATE_ADD('2001-01-01 10:20:00', INTERVAL 30 SECOND); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(NULL, a)=DATE_ADD('2001-01-01 10:20:00', INTERVAL 30 SECOND); + +--echo # +--echo # Corner cases: DATETIME values before the supported optimization range +--echo # FROM_UNIXTIME(0)..FROM_UNIXTIME(24*3600-1) +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 00:00:00'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.999999'; + +# Truncation of the 7th flactional digit produces a NOTE only without --ps +--disable_ps_protocol +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.9999999'; +--enable_ps_protocol +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(24*3600-1); + +--echo # +--echo # Corner cases: DATETIME values inside the supported optimization range: +--echo # FROM_UNIXTIME(24*3600) .. FROM_UNIXTIME(0x7FFFFFFF-24*3600) +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(24*3600); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-02 00:00:00'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:07'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(0x7FFFFFFF-24*3600); + +--echo # +--echo # Corner cases: DATETIME values after the supported optimization range +--echo # FROM_UNIXTIME(0x7FFFFFFF-24*3600+1) .. FROM_UNIXTIME(0x7FFFFFFF) +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(0x7FFFFFFF-24*3600+1); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:08'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-19 03:14:07'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=FROM_UNIXTIME(0x7FFFFFFF); + +--echo # +--echo # Corner cases: rounding +--echo # + +SET sql_mode=TIME_ROUND_FRACTIONAL; + +--echo # +--echo # Not optimized (before the supported range) +--echo # +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.999999'; + +--echo # +--echo # Optimized +--echo # +--disable_ps_protocol +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'1970-01-01 23:59:59.9999999'; +--enable_ps_protocol +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:07.999999'; + +--echo # +--echo # Not optimized (after the supported range) +--echo # +--disable_ps_protocol +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=TIMESTAMP'2038-01-18 03:14:07.9999999'; +--enable_ps_protocol + +SET sql_mode=DEFAULT; + +--echo # +--echo # NULLIF: Bad TIMESTAMP values preserve DATETIME comparison +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'1001-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'2001-01-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'2040-01-01 10:20:30'); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'1001-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'2001-01-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'2040-01-01 10:20:30'); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,10010101102030); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010100000000); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20400101102030); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,10010101102030e0); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010100000000e0); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20400101102030e0); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,10010101102030.0); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010100000000.0); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20400101102030.0); + +--echo # +--echo # NULLIF: Good TIMESTAMP values switch to TIMESTAMP comparison +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'0000-00-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,TIMESTAMP'2001-01-01 10:20:30'); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'0000-00-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,'2001-01-01 10:20:30'); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,0); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010101102030); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,0e0); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010101102030e0); + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,0.0); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NULLIF(a,20010101102030.0); + + +--echo # +--echo # Subqueries with bad TIMESTAMP values +--echo # It's not clear from the output if the comparison is done as DATETIME or TIMESTAMP +--echo # + +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('1001-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +DROP TABLE t2; + +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('2001-00-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +DROP TABLE t2; + +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('2040-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +DROP TABLE t2; + +--echo # +--echo # Subqueries with good TIMESTAMP values +--echo # It's not clear from the output if the comparison is done as DATETIME or TIMESTAMP +--echo # + +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('0000-00-00 00:00:00'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +DROP TABLE t2; + +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('2001-01-01 10:20:30'); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=(SELECT MAX(a) FROM t2); +DROP TABLE t2; + +--echo # +--echo # Trivial equality elimination +--echo # Covers Type_handler_timestamp_common::Item_const_eq() +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 +WHERE IF(a='2001-01-01 00:00:00',1,0)=IF(a='2001-01-01 00:00:00',1,0); + +EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a<=>?)=(a<=>?)' + USING '2001-01-01 00:00:00', '2001-01-01 00:00:00'; + + +--echo # +--echo # Equal field propagation: Good TIMESTAMP values switch to TIMESTAMP comparison +--echo # + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=TIMESTAMP'2001-01-01 10:20:30'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a='2001-01-01 10:20:30'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=20010101102030; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=20010101102030e0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19 AND a=20010101102030.0; + +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=TIMESTAMP'2001-01-01 10:20:30'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a='2001-01-01 10:20:30'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=20010101102030; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=20010101102030e0; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(a)=19+RAND() AND a=20010101102030.0; + +DROP TABLE t1; + +SET time_zone=DEFAULT; + +--echo # +--echo # End of 10.6 tests +--echo # + --echo # --echo # MDEV-29225 make explicit_defaults_for_timestamps SESSION variable --echo # @@ -943,3 +1183,78 @@ DROP TABLE t1; SET note_verbosity=DEFAULT; --echo # End of 10.6 tests + + +--echo # +--echo # Start of 11.3 tests +--echo # + +--echo # +--echo # MDEV-33299 Assertion `(tm->tv_usec % (int) log_10_int[6 - dec]) == 0' failed in void my_timestamp_to_binary(const timeval*, uchar*, uint) +--echo # + +CREATE TABLE t1(a TIMESTAMP,KEY(a)); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23' ; +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +DROP TABLE t1; + +CREATE TABLE t1(a TIMESTAMP,KEY(a)); +INSERT INTO t1 VALUES ('2023-12-31 23:59:59'); +INSERT INTO t1 VALUES ('2024-01-22 10:20:30'); +INSERT INTO t1 VALUES ('2024-01-23 10:20:30'); +INSERT INTO t1 VALUES ('2024-01-23 23:59:59'); +INSERT INTO t1 VALUES ('2024-01-24 00:00:00'); +INSERT INTO t1 VALUES ('2024-12-31 23:59:59'); +INSERT INTO t1 VALUES ('2025-01-01 00:00:00'); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) <= 2024; +SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +SELECT * FROM t1 WHERE YEAR(a) >= 2024; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) >= 2024; +DROP TABLE t1; + + +CREATE TABLE t1(a TIMESTAMP(3),KEY(a)); +INSERT INTO t1 VALUES ('2023-12-31 23:59:59.999'); +INSERT INTO t1 VALUES ('2024-01-22 10:20:30.001'); +INSERT INTO t1 VALUES ('2024-01-23 10:20:30.002'); +INSERT INTO t1 VALUES ('2024-01-23 23:59:59.999'); +INSERT INTO t1 VALUES ('2024-01-24 00:00:00.000'); +INSERT INTO t1 VALUES ('2024-12-31 23:59:59.999'); +INSERT INTO t1 VALUES ('2025-01-01 00:00:00.000'); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) <= 2024; +SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +SELECT * FROM t1 WHERE YEAR(a) >= 2024; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) >= 2024; +DROP TABLE t1; + + +CREATE TABLE t1(a TIMESTAMP(6),KEY(a)); +INSERT INTO t1 VALUES ('2023-12-31 23:59:59.999999'); +INSERT INTO t1 VALUES ('2024-01-22 10:20:30.000001'); +INSERT INTO t1 VALUES ('2024-01-23 10:20:30.000002'); +INSERT INTO t1 VALUES ('2024-01-23 23:59:59.999999'); +INSERT INTO t1 VALUES ('2024-01-24 00:00:00.000000'); +INSERT INTO t1 VALUES ('2024-12-31 23:59:59.999999'); +INSERT INTO t1 VALUES ('2025-01-01 00:00:00.000000'); +SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) <= '2024-01-23'; +SELECT * FROM t1 WHERE YEAR(a) <= 2024; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) <= 2024; +SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE DATE(a) >= '2024-01-24'; +SELECT * FROM t1 WHERE YEAR(a) >= 2024; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) >= 2024; +DROP TABLE t1; + + +--echo # +--echo # End of 11.3 tests +--echo # diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index 2bc26ca4334..04049fbe65b 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -7044,3 +7044,49 @@ DROP TABLE t1, t2; # # End of 10.6 tests # +# +# MDEV-29587: Allowing insert into a view with columns that +# are not part the table +# +# view with 2 the same fields +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +INSERT INTO view1(x1,x) VALUES (1,1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# view with a field and expression over the field +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +INSERT INTO view1(x1,x) VALUES (1,1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# view with a field and collation expression over the field +CREATE TABLE table1 (x char(20)); +CREATE VIEW view1 AS SELECT x, x collate latin1_german1_ci as x1 FROM table1; +INSERT INTO view1(x) VALUES ("ua"); +# we can insert in the field with collation +INSERT INTO view1(x1) VALUES ("ua"); +INSERT INTO view1(x1,x) VALUES ("ua","ua"); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# view with a field and expression over other field +CREATE TABLE table1 (x INT, y INT); +CREATE VIEW view1 AS SELECT x, y + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +INSERT INTO view1(x1,x) VALUES (1,1); +ERROR HY000: The target table view1 of the INSERT is not insertable-into +DROP VIEW view1; +DROP TABLE table1; +# +# End of 10.11 test +# diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index f44b536ae48..ddcaa296dd6 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -6802,3 +6802,56 @@ DROP TABLE t1, t2; --echo # --echo # End of 10.6 tests --echo # + + +--echo # +--echo # MDEV-29587: Allowing insert into a view with columns that +--echo # are not part the table +--echo # + +--echo # view with 2 the same fields +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +INSERT INTO view1(x1) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES (1,1); +DROP VIEW view1; +DROP TABLE table1; + +--echo # view with a field and expression over the field +CREATE TABLE table1 (x INT); +CREATE VIEW view1 AS SELECT x, x + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES (1,1); +DROP VIEW view1; +DROP TABLE table1; + +--echo # view with a field and collation expression over the field +CREATE TABLE table1 (x char(20)); +CREATE VIEW view1 AS SELECT x, x collate latin1_german1_ci as x1 FROM table1; +INSERT INTO view1(x) VALUES ("ua"); +--echo # we can insert in the field with collation +INSERT INTO view1(x1) VALUES ("ua"); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES ("ua","ua"); +DROP VIEW view1; +DROP TABLE table1; + +--echo # view with a field and expression over other field +CREATE TABLE table1 (x INT, y INT); +CREATE VIEW view1 AS SELECT x, y + 1 as x1 FROM table1; +INSERT INTO view1(x) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1) VALUES (1); +--error ER_NON_INSERTABLE_TABLE +INSERT INTO view1(x1,x) VALUES (1,1); +DROP VIEW view1; +DROP TABLE table1; + +--echo # +--echo # End of 10.11 test +--echo # diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 0d0f2ecb894..9d3991fad20 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -3111,6 +3111,7 @@ sub mysql_install_db { mtr_add_arg($args, "--core-file"); mtr_add_arg($args, "--console"); mtr_add_arg($args, "--character-set-server=latin1"); + mtr_add_arg($args, "--disable-performance-schema"); if ( $opt_debug ) { @@ -4464,6 +4465,7 @@ sub extract_warning_lines ($$) { qr/InnoDB: Warning: a long semaphore wait:/, qr/InnoDB: Dumping buffer pool.*/, qr/InnoDB: Buffer pool.*/, + qr/InnoDB: Could not free any blocks in the buffer pool!/, qr/InnoDB: Warning: Writer thread is waiting this semaphore:/, qr/InnoDB: innodb_open_files .* should not be greater than/, qr/Slave: Unknown table 't1' .* 1051/, @@ -4516,7 +4518,7 @@ sub extract_warning_lines ($$) { qr|InnoDB: io_setup\(\) failed with EAGAIN|, qr|io_uring_queue_init\(\) failed with|, qr|InnoDB: liburing disabled|, - qr/InnoDB: Failed to set (O_DIRECT|DIRECTIO_ON) on file/, + qr/InnoDB: Failed to set O_DIRECT on file/, qr|setrlimit could not change the size of core files to 'infinity';|, qr|feedback plugin: failed to retrieve the MAC address|, qr|Plugin 'FEEDBACK' init function returned error|, diff --git a/mysql-test/suite/binlog/r/binlog_gis_user_var_stm.result b/mysql-test/suite/binlog/r/binlog_gis_user_var_stm.result new file mode 100644 index 00000000000..e467c9c89b4 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_gis_user_var_stm.result @@ -0,0 +1,12 @@ +SET @g0= POINT(1,1); +SET @g1= Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))); +CREATE TABLE t1 AS SELECT @g0 AS g0, @g1 AS g1; +DROP TABLE t1; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # User var # # @`g0`=/*point*/_binary X'000000000101000000000000000000F03F000000000000F03F' COLLATE binary +master-bin.000001 # User var # # @`g1`=/*polygon*/_binary X'0000000001030000000100000004000000000000000000000000000000000000000000000000003E4000000000000000000000000000003E400000000000003E4000000000000000000000000000000000' COLLATE binary +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 AS SELECT @g0 AS g0, @g1 AS g1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ diff --git a/mysql-test/suite/binlog/t/binlog_gis_user_var_stm.test b/mysql-test/suite/binlog/t/binlog_gis_user_var_stm.test new file mode 100644 index 00000000000..7e789cd7ae4 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_gis_user_var_stm.test @@ -0,0 +1,15 @@ +--source include/not_embedded.inc +--source include/have_binlog_format_statement.inc +--source include/have_geometry.inc + +--disable_query_log +reset master; # get rid of previous tests binlog +--enable_query_log + +SET @g0= POINT(1,1); +SET @g1= Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))); +CREATE TABLE t1 AS SELECT @g0 AS g0, @g1 AS g1; +DROP TABLE t1; + +--let $binlog_file = LAST +source include/show_binlog_events.inc; diff --git a/mysql-test/suite/binlog_encryption/rpl_semi_sync.result b/mysql-test/suite/binlog_encryption/rpl_semi_sync.result index edd5e7748e0..03e3443b31e 100644 --- a/mysql-test/suite/binlog_encryption/rpl_semi_sync.result +++ b/mysql-test/suite/binlog_encryption/rpl_semi_sync.result @@ -7,7 +7,6 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state call mtr.add_suppression("mysqld: Got an error reading communication packets"); connection slave; set sql_log_bin=0; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); set sql_log_bin=1; @@ -28,7 +27,7 @@ set global rpl_semi_sync_slave_enabled= 0; # Main test of semi-sync replication start here # connection master; -set global rpl_semi_sync_master_timeout= 60000; +set global rpl_semi_sync_master_timeout= 2000; [ default state of semi-sync on master should be OFF ] show variables like 'rpl_semi_sync_master_enabled'; Variable_name Value @@ -163,11 +162,15 @@ connection slave; # Test semi-sync master will switch OFF after one transaction # timeout waiting for slave reply. # +connection master; +show status like "Rpl_semi_sync_master_status"; +Variable_name Value +Rpl_semi_sync_master_status ON connection slave; include/stop_slave.inc connection master; include/kill_binlog_dump_threads.inc -set global rpl_semi_sync_master_timeout= 5000; +set global rpl_semi_sync_master_timeout= 2000; [ master status should be ON ] show status like 'Rpl_semi_sync_master_no_tx'; Variable_name Value @@ -317,6 +320,8 @@ include/kill_binlog_dump_threads.inc connection slave; include/start_slave.inc connection master; +connection slave; +connection master; create table t1 (a int) engine = ENGINE_TYPE; insert into t1 values (1); insert into t1 values (2), (3); @@ -359,6 +364,8 @@ show status like 'Rpl_semi_sync_slave_status'; Variable_name Value Rpl_semi_sync_slave_status ON connection master; +connection slave; +connection master; [ master semi-sync should be ON ] show status like 'Rpl_semi_sync_master_clients'; Variable_name Value diff --git a/mysql-test/suite/compat/oracle/r/func_qualified.result b/mysql-test/suite/compat/oracle/r/func_qualified.result index f8224b7ce81..4750a625ebd 100644 --- a/mysql-test/suite/compat/oracle/r/func_qualified.result +++ b/mysql-test/suite/compat/oracle/r/func_qualified.result @@ -1772,6 +1772,85 @@ Level Code Message Note 1003 select trim(both ' ' from 'a') AS "oracle_schema.TRIM(BOTH ' ' FROM 'a')" Warnings: Note 1003 select trim(both ' ' from 'a') AS "oracle_schema.TRIM(BOTH ' ' FROM 'a')" +CALL p3('REGEXP_REPLACE(''test'',''t'','''')'); +---------- +sql_mode='' qualifier='' +query +EXPLAIN EXTENDED SELECT REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select regexp_replace('test','t','') AS `REGEXP_REPLACE('test','t','')` +---------- +sql_mode='' qualifier='unknown_schema.' +query +EXPLAIN EXTENDED SELECT unknown_schema.REGEXP_REPLACE('test','t','') +errmsg +ERROR: FUNCTION unknown_schema.REGEXP_REPLACE does not exist +---------- +sql_mode='' qualifier='mariadb_schema.' +query +EXPLAIN EXTENDED SELECT mariadb_schema.REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select regexp_replace('test','t','') AS `mariadb_schema.REGEXP_REPLACE('test','t','')` +---------- +sql_mode='' qualifier='maxdb_schema.' +query +EXPLAIN EXTENDED SELECT maxdb_schema.REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select regexp_replace('test','t','') AS `maxdb_schema.REGEXP_REPLACE('test','t','')` +---------- +sql_mode='' qualifier='oracle_schema.' +query +EXPLAIN EXTENDED SELECT oracle_schema.REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select oracle_schema.regexp_replace('test','t','') AS `oracle_schema.REGEXP_REPLACE('test','t','')` +---------- +sql_mode='ORACLE' qualifier='' +query +EXPLAIN EXTENDED SELECT REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select regexp_replace('test','t','') AS "REGEXP_REPLACE('test','t','')" +---------- +sql_mode='ORACLE' qualifier='unknown_schema.' +query +EXPLAIN EXTENDED SELECT unknown_schema.REGEXP_REPLACE('test','t','') +errmsg +ERROR: FUNCTION unknown_schema.REGEXP_REPLACE does not exist +---------- +sql_mode='ORACLE' qualifier='mariadb_schema.' +query +EXPLAIN EXTENDED SELECT mariadb_schema.REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select mariadb_schema.regexp_replace('test','t','') AS "mariadb_schema.REGEXP_REPLACE('test','t','')" +---------- +sql_mode='ORACLE' qualifier='maxdb_schema.' +query +EXPLAIN EXTENDED SELECT maxdb_schema.REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select mariadb_schema.regexp_replace('test','t','') AS "maxdb_schema.REGEXP_REPLACE('test','t','')" +---------- +sql_mode='ORACLE' qualifier='oracle_schema.' +query +EXPLAIN EXTENDED SELECT oracle_schema.REGEXP_REPLACE('test','t','') +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 select regexp_replace('test','t','') AS "oracle_schema.REGEXP_REPLACE('test','t','')" +Warnings: +Note 1003 select regexp_replace('test','t','') AS "oracle_schema.REGEXP_REPLACE('test','t','')" CALL p3('CONCAT_OPERATOR_ORACLE(''a'')'); ---------- sql_mode='' qualifier='' diff --git a/mysql-test/suite/compat/oracle/r/func_regexp_replace.result b/mysql-test/suite/compat/oracle/r/func_regexp_replace.result new file mode 100644 index 00000000000..7d0c5f79611 --- /dev/null +++ b/mysql-test/suite/compat/oracle/r/func_regexp_replace.result @@ -0,0 +1,34 @@ +SET sql_mode=ORACLE; +# +# MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode +# +CREATE TABLE t1 (replacement VARCHAR(10)); +INSERT INTO t1 VALUES (NULL), (''); +SELECT replacement, REGEXP_REPLACE('abba','a',replacement) FROM t1 ORDER BY replacement; +replacement REGEXP_REPLACE('abba','a',replacement) +NULL bb + bb +DROP TABLE t1; +SELECT REGEXP_REPLACE('abba','a',null); +REGEXP_REPLACE('abba','a',null) +bb +EXPLAIN EXTENDED SELECT REPLACE('abba','a',null) ; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select replace('abba','a',NULL) AS "REPLACE('abba','a',null)" +CREATE VIEW v1 AS SELECT REPLACE('abba','a',null) ; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE VIEW "v1" AS select replace('abba','a',NULL) AS "REPLACE('abba','a',null)" latin1 latin1_swedish_ci +SELECT * FROM v1; +REPLACE('abba','a',null) +bb +SET sql_mode=DEFAULT; +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 select oracle_schema.replace('abba','a',NULL) AS `REPLACE('abba','a',null)` latin1 latin1_swedish_ci +SELECT * FROM v1; +REPLACE('abba','a',null) +bb +DROP VIEW v1; diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result index 32ea444ea25..0944b7f39bd 100644 --- a/mysql-test/suite/compat/oracle/r/parser.result +++ b/mysql-test/suite/compat/oracle/r/parser.result @@ -84,7 +84,7 @@ DECLARE history INT; BEGIN history:=10; SELECT history; END SELECT history FROM t1 SELECT history 'alias' FROM t1 SELECT history() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history.history() Error 1630 FUNCTION history.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history DATE FROM t1 @@ -106,7 +106,7 @@ DECLARE next INT; BEGIN next:=10; SELECT next; END SELECT next FROM t1 SELECT next 'alias' FROM t1 SELECT next() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next.next() Error 1630 FUNCTION next.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next DATE FROM t1 @@ -151,7 +151,7 @@ DECLARE previous INT; BEGIN previous:=10; SELECT previous; END SELECT previous FROM t1 SELECT previous 'alias' FROM t1 SELECT previous() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous.previous() Error 1630 FUNCTION previous.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous DATE FROM t1 @@ -174,7 +174,7 @@ DECLARE system INT; BEGIN system:=10; SELECT system; END SELECT system FROM t1 SELECT system 'alias' FROM t1 SELECT system() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system.system() Error 1630 FUNCTION system.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system DATE FROM t1 @@ -196,7 +196,7 @@ DECLARE system_time INT; BEGIN system_time:=10; SELECT system_time; END SELECT system_time FROM t1 SELECT system_time 'alias' FROM t1 SELECT system_time() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time.system_time() Error 1630 FUNCTION system_time.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time DATE FROM t1 @@ -264,7 +264,7 @@ DECLARE transaction INT; BEGIN transaction:=10; SELECT transaction; END SELECT transaction FROM t1 SELECT transaction 'alias' FROM t1 SELECT transaction() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction.transaction() Error 1630 FUNCTION transaction.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction DATE FROM t1 @@ -308,7 +308,7 @@ DECLARE versioning INT; BEGIN versioning:=10; SELECT versioning; END SELECT versioning FROM t1 SELECT versioning 'alias' FROM t1 SELECT versioning() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning.versioning() Error 1630 FUNCTION versioning.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning DATE FROM t1 @@ -330,7 +330,7 @@ DECLARE without INT; BEGIN without:=10; SELECT without; END SELECT without FROM t1 SELECT without 'alias' FROM t1 SELECT without() -Error 1064 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 '()' at line 1 +Error 1630 FUNCTION test.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without.without() Error 1630 FUNCTION without.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without DATE FROM t1 diff --git a/mysql-test/suite/compat/oracle/t/column_compression.test b/mysql-test/suite/compat/oracle/t/column_compression.test index 01d4977ba96..e8d55000bc6 100644 --- a/mysql-test/suite/compat/oracle/t/column_compression.test +++ b/mysql-test/suite/compat/oracle/t/column_compression.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc --source include/have_csv.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc SET sql_mode=ORACLE; diff --git a/mysql-test/suite/compat/oracle/t/func_qualified.test b/mysql-test/suite/compat/oracle/t/func_qualified.test index 842015dbbd6..f2c019ec063 100644 --- a/mysql-test/suite/compat/oracle/t/func_qualified.test +++ b/mysql-test/suite/compat/oracle/t/func_qualified.test @@ -165,6 +165,7 @@ CALL p3('TRIM(1,2)'); CALL p3('TRIM(''a'')'); CALL p3('TRIM(BOTH '' '' FROM ''a'')'); +CALL p3('REGEXP_REPLACE(''test'',''t'','''')'); # Deprecated compatibility XXX_ORACLE functions. # These functions are implemented as simple native functions diff --git a/mysql-test/suite/compat/oracle/t/func_regexp_replace.test b/mysql-test/suite/compat/oracle/t/func_regexp_replace.test new file mode 100644 index 00000000000..8841d524c4a --- /dev/null +++ b/mysql-test/suite/compat/oracle/t/func_regexp_replace.test @@ -0,0 +1,26 @@ +SET sql_mode=ORACLE; + +--echo # +--echo # MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode +--echo # + +#SELECT REGEXP_REPLACE(null,'a','b') ; +#SELECT REGEXP_REPLACE('ab',null,'b') ; +#SELECT REGEXP_REPLACE('ab','a',null) ; +#SELECT REGEXP_REPLACE('ab',null,null) ; + +CREATE TABLE t1 (replacement VARCHAR(10)); +INSERT INTO t1 VALUES (NULL), (''); +SELECT replacement, REGEXP_REPLACE('abba','a',replacement) FROM t1 ORDER BY replacement; +DROP TABLE t1; + +SELECT REGEXP_REPLACE('abba','a',null); +EXPLAIN EXTENDED SELECT REPLACE('abba','a',null) ; + +CREATE VIEW v1 AS SELECT REPLACE('abba','a',null) ; +SHOW CREATE VIEW v1; +SELECT * FROM v1; +SET sql_mode=DEFAULT; +SHOW CREATE VIEW v1; +SELECT * FROM v1; +DROP VIEW v1; diff --git a/mysql-test/suite/engines/funcs/r/db_use_error.result b/mysql-test/suite/engines/funcs/r/db_use_error.result index a7c76e69b0d..bf5ca852906 100644 --- a/mysql-test/suite/engines/funcs/r/db_use_error.result +++ b/mysql-test/suite/engines/funcs/r/db_use_error.result @@ -10,7 +10,7 @@ performance_schema sys test USE DATABASE nond6; -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 'DATABASE nond6' at line 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 'nond6' at line 1 DROP DATABASE d6; SHOW DATABASES; Database diff --git a/mysql-test/suite/engines/funcs/r/rpl_session_var.result b/mysql-test/suite/engines/funcs/r/rpl_session_var.result index 67863583f8d..f9794df3be7 100644 --- a/mysql-test/suite/engines/funcs/r/rpl_session_var.result +++ b/mysql-test/suite/engines/funcs/r/rpl_session_var.result @@ -1,5 +1,16 @@ include/master-slave.inc [connection master] +select @@rpl_semi_sync_master_enabled; +@@rpl_semi_sync_master_enabled +0 +connection slave; +select @@rpl_semi_sync_slave_enabled; +@@rpl_semi_sync_slave_enabled +0 +show status like "rpl_semi_sync_slave_status"; +Variable_name Value +Rpl_semi_sync_slave_status OFF +connection master; drop table if exists t1; Warnings: Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/federated/update.result b/mysql-test/suite/federated/update.result new file mode 100644 index 00000000000..1905f80ed71 --- /dev/null +++ b/mysql-test/suite/federated/update.result @@ -0,0 +1,36 @@ +connect master,127.0.0.1,root,,test,$MASTER_MYPORT,; +connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,; +connection master; +CREATE DATABASE federated; +connection slave; +CREATE DATABASE federated; +# +# MDEV-32984 Update federated table and column privileges +# +connection slave; +create database db1; +create user my@localhost identified by '1qaz2wsx'; +create table db1.t1 ( +f1 int auto_increment primary key, +f2 varchar(50), +f3 varchar(50), +unique (f2) +); +grant insert, select (f1, f2, f3), update (f3) on db1.t1 to my@localhost; +connection master; +create table tt1 engine=federated connection='mysql://my:1qaz2wsx@localhost:$SLAVE_MYPORT/db1/t1'; +insert into tt1 (f2,f3) values ('test','123'); +select * from tt1; +f1 f2 f3 +1 test 123 +update tt1 set f3='123456' where f2='test'; +drop table tt1; +connection slave; +drop database db1; +drop user my@localhost; +connection master; +DROP TABLE IF EXISTS federated.t1; +DROP DATABASE IF EXISTS federated; +connection slave; +DROP TABLE IF EXISTS federated.t1; +DROP DATABASE IF EXISTS federated; diff --git a/mysql-test/suite/federated/update.test b/mysql-test/suite/federated/update.test new file mode 100644 index 00000000000..5a0414f1e1a --- /dev/null +++ b/mysql-test/suite/federated/update.test @@ -0,0 +1,32 @@ +source include/federated.inc; +source have_federatedx.inc; + +--echo # +--echo # MDEV-32984 Update federated table and column privileges +--echo # +connection slave; +create database db1; +create user my@localhost identified by '1qaz2wsx'; +create table db1.t1 ( + f1 int auto_increment primary key, + f2 varchar(50), + f3 varchar(50), + unique (f2) +); +grant insert, select (f1, f2, f3), update (f3) on db1.t1 to my@localhost; + +connection master; +evalp create table tt1 engine=federated connection='mysql://my:1qaz2wsx@localhost:$SLAVE_MYPORT/db1/t1'; +insert into tt1 (f2,f3) values ('test','123'); +select * from tt1; +update tt1 set f3='123456' where f2='test'; + +drop table tt1; + +connection slave; +drop database db1; +drop user my@localhost; + +source include/federated_cleanup.inc; + + diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result index 02061c1bec5..1c3e5648ba6 100644 --- a/mysql-test/suite/funcs_1/r/innodb_views.result +++ b/mysql-test/suite/funcs_1/r/innodb_views.result @@ -22145,9 +22145,9 @@ DELETE FROM t1; DROP VIEW v1; CREATE VIEW v1 AS SELECT f1, f2, f3, 'HELLO' AS my_greeting FROM t1; INSERT INTO v1 SET f1 = 1; -ERROR HY000: The target table v1 of the INSERT is not insertable-into SELECT * from t1; f1 f2 f3 f4 +1 NULL NULL NULL DELETE FROM t1; INSERT INTO v1 SET f1 = 1, my_greeting = 'HELLO'; ERROR HY000: The target table v1 of the INSERT is not insertable-into diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result index f8542e7e478..800c51e6a2a 100644 --- a/mysql-test/suite/funcs_1/r/memory_views.result +++ b/mysql-test/suite/funcs_1/r/memory_views.result @@ -22147,9 +22147,9 @@ DELETE FROM t1; DROP VIEW v1; CREATE VIEW v1 AS SELECT f1, f2, f3, 'HELLO' AS my_greeting FROM t1; INSERT INTO v1 SET f1 = 1; -ERROR HY000: The target table v1 of the INSERT is not insertable-into SELECT * from t1; f1 f2 f3 f4 +1 NULL NULL NULL DELETE FROM t1; INSERT INTO v1 SET f1 = 1, my_greeting = 'HELLO'; ERROR HY000: The target table v1 of the INSERT is not insertable-into diff --git a/mysql-test/suite/funcs_1/r/myisam_views-big.result b/mysql-test/suite/funcs_1/r/myisam_views-big.result index 7b9421f2b41..e80fa2c755d 100644 --- a/mysql-test/suite/funcs_1/r/myisam_views-big.result +++ b/mysql-test/suite/funcs_1/r/myisam_views-big.result @@ -23849,9 +23849,9 @@ DELETE FROM t1; DROP VIEW v1; CREATE VIEW v1 AS SELECT f1, f2, f3, 'HELLO' AS my_greeting FROM t1; INSERT INTO v1 SET f1 = 1; -ERROR HY000: The target table v1 of the INSERT is not insertable-into SELECT * from t1; f1 f2 f3 f4 +1 NULL NULL NULL DELETE FROM t1; INSERT INTO v1 SET f1 = 1, my_greeting = 'HELLO'; ERROR HY000: The target table v1 of the INSERT is not insertable-into diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 34185710905..c043ea3f9e7 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -2088,9 +2088,11 @@ SELECT * from t1 where f2=f1; 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 'cursor() SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE database() -SELECT * from t1 where f2=f1; -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 'database() -SELECT * from t1 where f2=f1' at line 1 +SELECT 1; +CALL database(); +1 +1 +DROP PROCEDURE database; CREATE PROCEDURE databases() SELECT * from t1 where f2=f1; 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 'databases() @@ -2350,6 +2352,12 @@ CREATE PROCEDURE join() SELECT * from t1 where f2=f1; 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 'join() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE json_table() +SELECT 1; +CALL json_table(); +1 +1 +DROP PROCEDURE json_table; CREATE PROCEDURE key() SELECT * from t1 where f2=f1; 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 'key() @@ -2470,6 +2478,12 @@ CREATE PROCEDURE natural() SELECT * from t1 where f2=f1; 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 'natural() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE nested() +SELECT 1; +CALL nested(); +1 +1 +DROP PROCEDURE nested; CREATE PROCEDURE not() SELECT * from t1 where f2=f1; 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 'not() @@ -2509,6 +2523,12 @@ CREATE PROCEDURE order() SELECT * from t1 where f2=f1; 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 'order() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE ordinality() +SELECT 1; +CALL ordinality; +1 +1 +DROP PROCEDURE ordinality; CREATE PROCEDURE out() SELECT * from t1 where f2=f1; 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 'out() @@ -2521,6 +2541,12 @@ CREATE PROCEDURE outfile() SELECT * from t1 where f2=f1; 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 'outfile() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE path() +SELECT 1; +CALL path(); +1 +1 +DROP PROCEDURE path; CREATE PROCEDURE precision() SELECT * from t1 where f2=f1; 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 'precision() @@ -2602,9 +2628,11 @@ SELECT * from t1 where f2=f1; 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 'rlike() SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE schema() -SELECT * from t1 where f2=f1; -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 'schema() -SELECT * from t1 where f2=f1' at line 1 +SELECT 1; +CALL schema(); +1 +1 +DROP PROCEDURE schema; CREATE PROCEDURE schemas() SELECT * from t1 where f2=f1; 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 'schemas() @@ -4204,9 +4232,6 @@ CREATE PROCEDURE sp1() database:BEGIN SELECT @x; END// -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 'database:BEGIN -SELECT @x; -END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() databases:BEGIN @@ -4737,6 +4762,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +json_table:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() key:BEGIN SELECT @x; END// @@ -4977,6 +5007,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +nested:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() not:BEGIN SELECT @x; END// @@ -5057,6 +5092,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +ordinality:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() out:BEGIN SELECT @x; END// @@ -5081,6 +5121,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +path:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() precision:BEGIN SELECT @x; END// @@ -5253,9 +5298,6 @@ CREATE PROCEDURE sp1() schema:BEGIN SELECT @x; END// -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 'schema:BEGIN -SELECT @x; -END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() schemas:BEGIN @@ -7811,8 +7853,6 @@ CREATE PROCEDURE sp1() BEGIN declare database char; END// -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 'database char; -END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN @@ -8278,6 +8318,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare json_table char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare key char; END// 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 'key char; @@ -8488,6 +8533,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare nested char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare not char; END// 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 'not char; @@ -8556,6 +8606,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare ordinality char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare out char; END// 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 'out char; @@ -8577,6 +8632,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare path char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare precision char; END// 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 'precision char; @@ -8745,11 +8805,7 @@ CREATE PROCEDURE sp1() BEGIN declare schema char; END// -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 'schema char; -END' at line 3 DROP PROCEDURE IF EXISTS sp1; -Warnings: -Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1() BEGIN declare schemas char; @@ -9704,11 +9760,7 @@ BEGIN declare database condition for sqlstate '02000'; declare exit handler for database set @var2 = 1; END// -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 'database condition for sqlstate '02000'; -declare exit handler for database se...' at line 3 DROP PROCEDURE IF EXISTS sp1; -Warnings: -Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN declare databases condition for sqlstate '02000'; @@ -10372,6 +10424,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare json_table condition for sqlstate '02000'; +declare exit handler for json_table set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare key condition for sqlstate '02000'; declare exit handler for key set @var2 = 1; END// @@ -10672,6 +10730,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare nested condition for sqlstate '02000'; +declare exit handler for nested set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare not condition for sqlstate '02000'; declare exit handler for not set @var2 = 1; END// @@ -10768,6 +10832,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare ordinality condition for sqlstate '02000'; +declare exit handler for ordinality set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare out condition for sqlstate '02000'; declare exit handler for out set @var2 = 1; END// @@ -10798,6 +10868,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare path condition for sqlstate '02000'; +declare exit handler for path set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare precision condition for sqlstate '02000'; declare exit handler for precision set @var2 = 1; END// @@ -11021,11 +11097,7 @@ BEGIN declare schema condition for sqlstate '02000'; declare exit handler for schema set @var2 = 1; END// -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 'schema condition for sqlstate '02000'; -declare exit handler for schema set @v...' at line 3 DROP PROCEDURE IF EXISTS sp1; -Warnings: -Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN declare schemas condition for sqlstate '02000'; @@ -11974,8 +12046,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare database handler for sqlstate '02000' set @var2 = 1; END// -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 'database handler for sqlstate '02000' set @var2 = 1; -END' at line 3 +ERROR HY000: Unknown data type: 'handler' DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist @@ -12571,6 +12642,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare json_table handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare key handler for sqlstate '02000' set @var2 = 1; END// 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 'key handler for sqlstate '02000' set @var2 = 1; @@ -12841,6 +12917,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare nested handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare not handler for sqlstate '02000' set @var2 = 1; END// 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 'not handler for sqlstate '02000' set @var2 = 1; @@ -12930,6 +13011,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare ordinality handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare out handler for sqlstate '02000' set @var2 = 1; END// 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 'out handler for sqlstate '02000' set @var2 = 1; @@ -12957,6 +13043,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare path handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare precision handler for sqlstate '02000' set @var2 = 1; END// 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 'precision handler for sqlstate '02000' set @var2 = 1; @@ -13164,8 +13255,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare schema handler for sqlstate '02000' set @var2 = 1; END// -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 'schema handler for sqlstate '02000' set @var2 = 1; -END' at line 3 +ERROR HY000: Unknown data type: 'handler' DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test index 8712919e430..e9c00742f01 100644 --- a/mysql-test/suite/funcs_1/t/storedproc.test +++ b/mysql-test/suite/funcs_1/t/storedproc.test @@ -1102,9 +1102,11 @@ CREATE PROCEDURE current_user() CREATE PROCEDURE cursor() SELECT * from t1 where f2=f1; ---error ER_PARSE_ERROR CREATE PROCEDURE database() - SELECT * from t1 where f2=f1; + SELECT 1; + +CALL database(); +DROP PROCEDURE database; --error ER_PARSE_ERROR CREATE PROCEDURE databases() @@ -1367,6 +1369,12 @@ CREATE PROCEDURE iterate() CREATE PROCEDURE join() SELECT * from t1 where f2=f1; +CREATE PROCEDURE json_table() + SELECT 1; + +CALL json_table(); +DROP PROCEDURE json_table; + --error ER_PARSE_ERROR CREATE PROCEDURE key() SELECT * from t1 where f2=f1; @@ -1487,6 +1495,13 @@ CREATE PROCEDURE modifies() CREATE PROCEDURE natural() SELECT * from t1 where f2=f1; +CREATE PROCEDURE nested() + SELECT 1; + +CALL nested(); + +DROP PROCEDURE nested; + --error ER_PARSE_ERROR CREATE PROCEDURE not() SELECT * from t1 where f2=f1; @@ -1527,6 +1542,13 @@ CREATE PROCEDURE or() CREATE PROCEDURE order() SELECT * from t1 where f2=f1; +CREATE PROCEDURE ordinality() + SELECT 1; + +CALL ordinality; + +DROP PROCEDURE ordinality; + --error ER_PARSE_ERROR CREATE PROCEDURE out() SELECT * from t1 where f2=f1; @@ -1539,6 +1561,13 @@ CREATE PROCEDURE outer() CREATE PROCEDURE outfile() SELECT * from t1 where f2=f1; +CREATE PROCEDURE path() + SELECT 1; + +CALL path(); + +DROP PROCEDURE path; + --error ER_PARSE_ERROR CREATE PROCEDURE precision() SELECT * from t1 where f2=f1; @@ -1619,9 +1648,11 @@ CREATE PROCEDURE right() CREATE PROCEDURE rlike() SELECT * from t1 where f2=f1; ---error ER_PARSE_ERROR CREATE PROCEDURE schema() - SELECT * from t1 where f2=f1; + SELECT 1; + +CALL schema(); +DROP PROCEDURE schema; --error ER_PARSE_ERROR CREATE PROCEDURE schemas() @@ -3481,7 +3512,7 @@ DROP PROCEDURE IF EXISTS sp1; --enable_warnings delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() database:BEGIN SELECT @x; @@ -4284,6 +4315,15 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; +CREATE PROCEDURE sp1() + json_table:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -4644,6 +4684,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() + nested:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -4765,6 +4815,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() + ordinality:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -4801,6 +4861,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() + path:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -5066,7 +5136,7 @@ DROP PROCEDURE IF EXISTS sp1; --enable_warnings delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() schema:BEGIN SELECT @x; @@ -8938,7 +9008,7 @@ DROP PROCEDURE IF EXISTS sp1; --enable_warnings delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() BEGIN declare database char; @@ -9736,11 +9806,20 @@ BEGIN declare join char; END// delimiter ;// - --disable_warnings DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare json_table char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10101,6 +10180,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare nested char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10220,6 +10309,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare ordinality char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10256,6 +10355,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare path char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10506,7 +10615,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() BEGIN declare schema char; @@ -11624,7 +11733,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1( ) BEGIN declare database condition for sqlstate '02000'; @@ -12360,6 +12469,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare json_table condition for sqlstate '02000'; + declare exit handler for json_table set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -12690,6 +12810,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare nested condition for sqlstate '02000'; + declare exit handler for nested set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -12799,6 +12930,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare ordinality condition for sqlstate '02000'; + declare exit handler for ordinality set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -12832,6 +12974,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare path condition for sqlstate '02000'; + declare exit handler for path set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -13075,7 +13228,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1( ) BEGIN declare schema condition for sqlstate '02000'; @@ -14181,7 +14334,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1( ) BEGIN declare database handler for sqlstate '02000' set @var2 = 1; @@ -14850,6 +15003,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare json_table handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15150,6 +15311,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare nested handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15250,6 +15419,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare ordinality handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15280,6 +15457,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare path handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15511,7 +15696,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR +--error ER_UNKNOWN_DATA_TYPE CREATE PROCEDURE sp1( ) BEGIN declare schema handler for sqlstate '02000' set @var2 = 1; diff --git a/mysql-test/suite/funcs_1/views/views_master.inc b/mysql-test/suite/funcs_1/views/views_master.inc index 526e9e3426e..0e175db4d29 100644 --- a/mysql-test/suite/funcs_1/views/views_master.inc +++ b/mysql-test/suite/funcs_1/views/views_master.inc @@ -3085,8 +3085,10 @@ eval SHOW CREATE VIEW test1.v$level; # the following line as written as '--eror ER_TOO_MANY_TABLES' and the command # is successful so assuming no expected error was intended # --error ER_TOO_MANY_TABLES +--disable_ps2_protocol eval SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CAST(f2 AS CHAR) AS f2 FROM test1.v$level; +--enable_ps2_protocol let $message= The output of following EXPLAIN is deactivated, because the result differs on some platforms FIXME Is this a bug ? ; @@ -3116,16 +3118,20 @@ SELECT f1 as f2, f2 as f1 FROM test2.t1; CREATE OR REPLACE VIEW test2.v0 AS SELECT CAST('0001-01-01' AS DATE) as f1, f2 FROM test3.t1; eval SHOW CREATE VIEW test1.v$toplevel; +--disable_ps2_protocol eval SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CAST(f2 AS CHAR) AS f2 FROM test1.v$toplevel; +--enable_ps2_protocol eval EXPLAIN SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CAST(f2 AS CHAR) AS f2 FROM test1.v$toplevel; # 2.3.3 UCS2 string instead of common string CREATE OR REPLACE VIEW test3.v0 AS SELECT f1 , CONVERT('ΓŸΓ„Γ€Γ–ΓΆΓœΓΌΒ§' USING UCS2) as f2 FROM test1.t1; eval SHOW CREATE VIEW test1.v$toplevel; +--disable_ps2_protocol eval SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CAST(f2 AS CHAR) AS f2 FROM test1.v$toplevel; +--enable_ps2_protocol eval EXPLAIN SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CAST(f2 AS CHAR) AS f2 FROM test1.v$toplevel; @@ -3133,8 +3139,10 @@ eval EXPLAIN SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CREATE OR REPLACE VIEW test3.v0 AS SELECT CONVERT('ΓŸΓ„Γ€Γ–ΓΆΓœΓΌΒ§' USING UCS2) as f1, f2 FROM test1.t1; eval SHOW CREATE VIEW test1.v$toplevel; +--disable_ps2_protocol eval SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CAST(f2 AS CHAR) AS f2 FROM test1.v$toplevel; +--enable_ps2_protocol eval EXPLAIN SELECT CAST(f1 AS SIGNED INTEGER) AS f1, CAST(f2 AS CHAR) AS f2 FROM test1.v$toplevel; --enable_result_log @@ -3479,7 +3487,6 @@ CREATE VIEW v1 AS SELECT f1, f2, f3, 'HELLO' AS my_greeting FROM t1; # Maybe the SQL standard allows the following INSERT. # But it would be a very sophisticated DBMS. ---error ER_NON_INSERTABLE_TABLE INSERT INTO v1 SET f1 = 1; SELECT * from t1; DELETE FROM t1; diff --git a/mysql-test/suite/innodb/r/doublewrite.result b/mysql-test/suite/innodb/r/doublewrite.result index 0c4f2c3fe65..65ff203a28e 100644 --- a/mysql-test/suite/innodb/r/doublewrite.result +++ b/mysql-test/suite/innodb/r/doublewrite.result @@ -1,7 +1,7 @@ # # MDEV-32242 innodb.doublewrite test case always is skipped # -create table t1 (f1 int primary key, f2 blob) engine=innodb stats_persistent=0; +create table t1 (f1 int primary key, f2 blob) stats_persistent=0, engine=innodb; start transaction; insert into t1 values(1, repeat('#',12)); insert into t1 values(2, repeat('+',12)); @@ -19,6 +19,7 @@ XA PREPARE 'x'; disconnect dml; connection default; flush table t1 for export; +# Kill the server # restart FOUND 1 /InnoDB: Restoring page \[page id: space=[1-9][0-9]*, page number=0\] of datafile/ in mysqld.1.err FOUND 1 /InnoDB: Recovered page \[page id: space=[1-9][0-9]*, page number=3\]/ in mysqld.1.err @@ -33,5 +34,27 @@ f1 f2 3 //////////// 4 ------------ 5 ............ +connect dml,localhost,root,,; +XA START 'x'; +insert into t1 values (6, repeat('%', @@innodb_page_size/2)); +XA END 'x'; +XA PREPARE 'x'; +disconnect dml; +connection default; +flush table t1 for export; +# Kill the server +# restart +FOUND 1 /InnoDB: Restoring page \[page id: space=[1-9][0-9]*, page number=0\] of datafile/ in mysqld.1.err +XA ROLLBACK 'x'; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select f1, f2 from t1; +f1 f2 +1 ############ +2 ++++++++++++ +3 //////////// +4 ------------ +5 ............ drop table t1; # End of 10.5 tests diff --git a/mysql-test/suite/innodb/r/lock_move_wait_lock_race.result b/mysql-test/suite/innodb/r/lock_move_wait_lock_race.result index 572fbc9b1d1..c78102d9c3b 100644 --- a/mysql-test/suite/innodb/r/lock_move_wait_lock_race.result +++ b/mysql-test/suite/innodb/r/lock_move_wait_lock_race.result @@ -1,4 +1,5 @@ -CREATE TABLE t (pk int PRIMARY KEY, c varchar(10)) ENGINE=InnoDB; +CREATE TABLE t (pk int PRIMARY KEY, c varchar(10)) +STATS_PERSISTENT=0 ENGINE=InnoDB; INSERT INTO t VALUES (10, "0123456789"); connection default; BEGIN; diff --git a/mysql-test/suite/innodb/r/log_file_name.result b/mysql-test/suite/innodb/r/log_file_name.result index 7ac212916de..1839c9bc1e0 100644 --- a/mysql-test/suite/innodb/r/log_file_name.result +++ b/mysql-test/suite/innodb/r/log_file_name.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("InnoDB: Header page consists of zero bytes in datafile:"); FLUSH TABLES; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; # restart diff --git a/mysql-test/suite/innodb/t/doublewrite.test b/mysql-test/suite/innodb/t/doublewrite.test index 33813dabdc4..d73009908db 100644 --- a/mysql-test/suite/innodb/t/doublewrite.test +++ b/mysql-test/suite/innodb/t/doublewrite.test @@ -17,6 +17,7 @@ call mtr.add_suppression("InnoDB: A bad Space ID was found in datafile"); call mtr.add_suppression("InnoDB: Checksum mismatch in datafile: "); call mtr.add_suppression("InnoDB: Inconsistent tablespace ID in .*t1\\.ibd"); call mtr.add_suppression("\\[Warning\\] Found 1 prepared XA transactions"); +call mtr.add_suppression("InnoDB: Header page consists of zero bytes in datafile:"); --enable_query_log let INNODB_PAGE_SIZE=`select @@innodb_page_size`; @@ -24,7 +25,7 @@ let MYSQLD_DATADIR=`select @@datadir`; let ALGO=`select @@innodb_checksum_algorithm`; let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; -create table t1 (f1 int primary key, f2 blob) engine=innodb stats_persistent=0; +create table t1 (f1 int primary key, f2 blob) stats_persistent=0, engine=innodb; start transaction; insert into t1 values(1, repeat('#',12)); @@ -38,7 +39,7 @@ commit work; SET GLOBAL innodb_fast_shutdown = 0; let $shutdown_timeout=; --source include/restart_mysqld.inc - +--source ../include/no_checkpoint_start.inc connect (dml,localhost,root,,); XA START 'x'; insert into t1 values (6, repeat('%', @@innodb_page_size/2)); @@ -50,8 +51,8 @@ connection default; flush table t1 for export; let $restart_parameters=; -let $shutdown_timeout=0; ---source include/shutdown_mysqld.inc +--let CLEANUP_IF_CHECKPOINT=XA COMMIT 'x';drop table t1; +--source ../include/no_checkpoint_end.inc perl; use IO::Handle; @@ -119,6 +120,35 @@ let SEARCH_PATTERN=InnoDB: Recovered page \[page id: space=[1-9][0-9]*, page num XA ROLLBACK 'x'; check table t1; select f1, f2 from t1; + +--source ../include/no_checkpoint_start.inc +connect (dml,localhost,root,,); +XA START 'x'; +insert into t1 values (6, repeat('%', @@innodb_page_size/2)); +XA END 'x'; +XA PREPARE 'x'; +disconnect dml; +connection default; + +flush table t1 for export; + +let $restart_parameters=; +--source ../include/no_checkpoint_end.inc + +# Zero out the first page in file and try to recover from dblwr +perl; +use IO::Handle; +open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/t1.ibd") or die; +syswrite(FILE, chr(0) x $ENV{INNODB_PAGE_SIZE}); +close FILE; +EOF + +--source include/start_mysqld.inc +let SEARCH_PATTERN=InnoDB: Restoring page \[page id: space=[1-9][0-9]*, page number=0\] of datafile; +--source include/search_pattern_in_file.inc +XA ROLLBACK 'x'; +check table t1; +select f1, f2 from t1; drop table t1; --echo # End of 10.5 tests diff --git a/mysql-test/suite/innodb/t/doublewrite_debug.test b/mysql-test/suite/innodb/t/doublewrite_debug.test index ebae84e2211..ab7fd8eba22 100644 --- a/mysql-test/suite/innodb/t/doublewrite_debug.test +++ b/mysql-test/suite/innodb/t/doublewrite_debug.test @@ -17,6 +17,7 @@ call mtr.add_suppression("Plugin 'InnoDB' (init function returned error|registra call mtr.add_suppression("InnoDB: A bad Space ID was found in datafile"); call mtr.add_suppression("InnoDB: Checksum mismatch in datafile: "); call mtr.add_suppression("InnoDB: Inconsistent tablespace ID in .*t1\\.ibd"); +call mtr.add_suppression("InnoDB: Header page consists of zero bytes in datafile:"); --enable_query_log let INNODB_PAGE_SIZE=`select @@innodb_page_size`; diff --git a/mysql-test/suite/innodb/t/lock_move_wait_lock_race.test b/mysql-test/suite/innodb/t/lock_move_wait_lock_race.test index 3a04c7127c8..0f88f8d9d0f 100644 --- a/mysql-test/suite/innodb/t/lock_move_wait_lock_race.test +++ b/mysql-test/suite/innodb/t/lock_move_wait_lock_race.test @@ -3,7 +3,8 @@ --source include/have_debug.inc --source include/have_debug_sync.inc -CREATE TABLE t (pk int PRIMARY KEY, c varchar(10)) ENGINE=InnoDB; +CREATE TABLE t (pk int PRIMARY KEY, c varchar(10)) +STATS_PERSISTENT=0 ENGINE=InnoDB; INSERT INTO t VALUES (10, "0123456789"); --connection default diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test index f95a56c7e8b..9707a1535af 100644 --- a/mysql-test/suite/innodb/t/log_file_name.test +++ b/mysql-test/suite/innodb/t/log_file_name.test @@ -7,6 +7,7 @@ # Embedded server does not support crashing --source include/not_embedded.inc +call mtr.add_suppression("InnoDB: Header page consists of zero bytes in datafile:"); FLUSH TABLES; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; @@ -172,6 +173,7 @@ call mtr.add_suppression("InnoDB: Table test/u[123] in the InnoDB data dictionar call mtr.add_suppression("InnoDB: Cannot replay rename of tablespace.*"); call mtr.add_suppression("InnoDB: Attempted to open a previously opened tablespace"); call mtr.add_suppression("InnoDB: Recovery cannot access file"); +call mtr.add_suppression("InnoDB: Cannot read first page in datafile:"); FLUSH TABLES; --enable_query_log diff --git a/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test b/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test index dab9bcfa864..24029a48aa4 100644 --- a/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test +++ b/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test @@ -1,7 +1,7 @@ --source include/have_innodb.inc --source include/have_sequence.inc --source include/innodb_page_size_small.inc ---source include/have_normal_bzip.inc +--source include/have_normal_zlib.inc call mtr.add_suppression("InnoDB: Cannot add field .* in table .* because after adding it, the row size is .* which is greater than maximum allowed size (.*) for a record on index leaf page."); diff --git a/mysql-test/suite/innodb_zip/r/innochecksum_3.result b/mysql-test/suite/innodb_zip/r/innochecksum_3.result index 03a31194c63..04d2fcaa748 100644 --- a/mysql-test/suite/innodb_zip/r/innochecksum_3.result +++ b/mysql-test/suite/innodb_zip/r/innochecksum_3.result @@ -120,7 +120,6 @@ Filename::tab#.ibd #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, - #::# | Freshly allocated page | - -#::# | Freshly allocated page | - # Variables used by page type dump for ibdata1 Variables (--variable-name=value) @@ -154,7 +153,6 @@ Filename::tab#.ibd #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, - #::# | Index page | index id=#, page level=#, No. of records=#, garbage=#, - #::# | Freshly allocated page | - -#::# | Freshly allocated page | - [6]: check the valid lower bound values for option # allow-mismatches,page,start-page,end-page [9]: check the both short and long options "page" and "start-page" when diff --git a/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff b/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff index 29afd468751..9ed08fcd26a 100644 --- a/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff +++ b/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff @@ -1,3 +1,5 @@ +--- suite/mariabackup/huge_lsn.result ++++ suite/mariabackup/huge_lsn.reject @@ -1,8 +1,8 @@ # # MDEV-13416 mariabackup fails with EFAULT "Bad Address" diff --git a/mysql-test/suite/multi_source/mdev-9544.test b/mysql-test/suite/multi_source/mdev-9544.test index 56bdfd96eb4..28a5cb112da 100644 --- a/mysql-test/suite/multi_source/mdev-9544.test +++ b/mysql-test/suite/multi_source/mdev-9544.test @@ -1,6 +1,7 @@ --source include/not_embedded.inc --source include/have_innodb.inc --source include/have_debug.inc +--source include/not_windows.inc --connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) --connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) diff --git a/mysql-test/suite/perfschema/r/sxlock_func,debug.rdiff b/mysql-test/suite/perfschema/r/sxlock_func,debug.rdiff deleted file mode 100644 index 0596810e553..00000000000 --- a/mysql-test/suite/perfschema/r/sxlock_func,debug.rdiff +++ /dev/null @@ -1,22 +0,0 @@ -@@ -7,7 +7,6 @@ - WHERE name LIKE 'wait/synch/rwlock/innodb/%' - AND name!='wait/synch/rwlock/innodb/btr_search_latch' ORDER BY name; - name --wait/synch/rwlock/innodb/dict_operation_lock - wait/synch/rwlock/innodb/fil_space_latch - wait/synch/rwlock/innodb/lock_latch - wait/synch/rwlock/innodb/trx_i_s_cache_lock -@@ -19,11 +18,13 @@ - select name from performance_schema.setup_instruments - where name like "wait/synch/sxlock/%" order by name; - name -+wait/synch/sxlock/innodb/dict_operation_lock - wait/synch/sxlock/innodb/index_tree_rw_lock - SELECT DISTINCT name FROM performance_schema.rwlock_instances - WHERE name LIKE 'wait/synch/sxlock/innodb/%' - ORDER BY name; - name -+wait/synch/sxlock/innodb/dict_operation_lock - wait/synch/sxlock/innodb/index_tree_rw_lock - create table t1(a int) engine=innodb; - begin; diff --git a/mysql-test/suite/perfschema/t/misc_session_status.test b/mysql-test/suite/perfschema/t/misc_session_status.test index ea662ce6738..c9e7d066b0c 100644 --- a/mysql-test/suite/perfschema/t/misc_session_status.test +++ b/mysql-test/suite/perfschema/t/misc_session_status.test @@ -1,5 +1,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +# This does not crash on 32 bit because of less memory used +--source include/have_64bit.inc --echo # --echo # MDEV-33150 double-locking of LOCK_thd_kill in performance_schema.session_status --echo # diff --git a/mysql-test/suite/perfschema/t/sxlock_func.test b/mysql-test/suite/perfschema/t/sxlock_func.test index 24d0e07ca41..c43adc849d2 100644 --- a/mysql-test/suite/perfschema/t/sxlock_func.test +++ b/mysql-test/suite/perfschema/t/sxlock_func.test @@ -5,7 +5,6 @@ --source include/not_embedded.inc --source include/have_perfschema.inc --source include/have_innodb.inc ---source include/maybe_debug.inc UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES'; diff --git a/mysql-test/suite/plugins/r/sql_error_log.result b/mysql-test/suite/plugins/r/sql_error_log.result index 0329949a231..a0bf0ebcd6c 100644 --- a/mysql-test/suite/plugins/r/sql_error_log.result +++ b/mysql-test/suite/plugins/r/sql_error_log.result @@ -9,6 +9,7 @@ sql_error_log_rotate OFF sql_error_log_rotations 9 sql_error_log_size_limit 1000000 sql_error_log_warnings ON +sql_error_log_with_db_and_thread_info OFF set global sql_error_log_rate=1; select * from t_doesnt_exist; ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist diff --git a/mysql-test/suite/plugins/r/sql_error_log_withdbinfo.result b/mysql-test/suite/plugins/r/sql_error_log_withdbinfo.result new file mode 100644 index 00000000000..732e74d8516 --- /dev/null +++ b/mysql-test/suite/plugins/r/sql_error_log_withdbinfo.result @@ -0,0 +1,41 @@ +show variables like 'sql_error_log%'; +Variable_name Value +sql_error_log_filename sql_errors.log +sql_error_log_rate 1 +sql_error_log_rotate OFF +sql_error_log_rotations 9 +sql_error_log_size_limit 1000000 +sql_error_log_warnings ON +sql_error_log_with_db_and_thread_info ON +set global sql_error_log_rate=1; +# Trying to set the variable at runtime +SET sql_error_log_with_db_and_thread_info=OFF; +ERROR HY000: Variable 'sql_error_log_with_db_and_thread_info' is a read only variable +# +# Using test database from mtr +# +DROP DATABASE db; +ERROR HY000: Can't drop database 'db'; database doesn't exist +# +# Using no database at all +# +connect con1,localhost,root,,*NO-ONE*; +DROP DATABASE dbnodb; +ERROR HY000: Can't drop database 'dbnodb'; database doesn't exist +disconnect con1; +connection default; +# +# Using database with name `NULL` +# +CREATE DATABASE `NULL`; +USE `NULL`; +DROP DATABASE db; +ERROR HY000: Can't drop database 'db'; database doesn't exist +TIME THREAD_ID HOSTNAME `mtr` WARNING 1286: Unknown storage engine 'InnoDB' : SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' ORDER BY columns_in_mysql +TIME THREAD_ID HOSTNAME `mtr` WARNING 1286: Unknown storage engine 'InnoDB' : SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' ORDER BY columns_in_mysql +TIME THREAD_ID HOSTNAME `mtr` WARNING 1286: Unknown storage engine 'InnoDB' : SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' ORDER BY columns_in_mysql +TIME THREAD_ID HOSTNAME `test` ERROR 1238: Variable 'sql_error_log_with_db_and_thread_info' is a read only variable : SET sql_error_log_with_db_and_thread_info=OFF +TIME THREAD_ID HOSTNAME `test` ERROR 1008: Can't drop database 'db'; database doesn't exist : DROP DATABASE db +TIME THREAD_ID HOSTNAME NULL ERROR 1008: Can't drop database 'dbnodb'; database doesn't exist : DROP DATABASE dbnodb +TIME THREAD_ID HOSTNAME `NULL` ERROR 1008: Can't drop database 'db'; database doesn't exist : DROP DATABASE db +DROP DATABASE `NULL`; diff --git a/mysql-test/suite/plugins/t/sql_error_log_withdbinfo.opt b/mysql-test/suite/plugins/t/sql_error_log_withdbinfo.opt new file mode 100644 index 00000000000..7d502896977 --- /dev/null +++ b/mysql-test/suite/plugins/t/sql_error_log_withdbinfo.opt @@ -0,0 +1 @@ +--plugin-load-add=$SQL_ERRLOG_SO --sql-error-log-with-db-and-thread-info=1 --lower_case_table_names=2 diff --git a/mysql-test/suite/plugins/t/sql_error_log_withdbinfo.test b/mysql-test/suite/plugins/t/sql_error_log_withdbinfo.test new file mode 100644 index 00000000000..a9f019037a0 --- /dev/null +++ b/mysql-test/suite/plugins/t/sql_error_log_withdbinfo.test @@ -0,0 +1,49 @@ +--source include/not_embedded.inc + +if (!$SQL_ERRLOG_SO) { + skip No SQL_ERROR_LOG plugin; +} + +show variables like 'sql_error_log%'; +set global sql_error_log_rate=1; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +--echo # Trying to set the variable at runtime + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET sql_error_log_with_db_and_thread_info=OFF; + +--echo # +--echo # Using test database from mtr +--echo # + +--error ER_DB_DROP_EXISTS +DROP DATABASE db; + +--echo # +--echo # Using no database at all +--echo # + + +connect (con1,localhost,root,,*NO-ONE*); +--error ER_DB_DROP_EXISTS +DROP DATABASE dbnodb; +disconnect con1; +connection default; + +--echo # +--echo # Using database with name `NULL` +--echo # +CREATE DATABASE `NULL`; +USE `NULL`; +--error ER_DB_DROP_EXISTS +DROP DATABASE db; + + +--let SEARCH_FILE= $MYSQLD_DATADIR/sql_errors.log +--let LINES_TO_READ=7 +--replace_regex /[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]* .* @ .* `mtr` /TIME THREAD_ID HOSTNAME `mtr` //[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]* .* @ .* `test` /TIME THREAD_ID HOSTNAME `test` //[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]* .* @ .* NULL /TIME THREAD_ID HOSTNAME NULL //[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]* .* @ .* `NULL` /TIME THREAD_ID HOSTNAME `NULL` / +--source include/read_head.inc + +DROP DATABASE `NULL`; diff --git a/mysql-test/suite/rpl/include/rpl_change_master_demote.inc b/mysql-test/suite/rpl/include/rpl_change_master_demote.inc index 8ecdf0764bf..d14f0a2bf86 100644 --- a/mysql-test/suite/rpl/include/rpl_change_master_demote.inc +++ b/mysql-test/suite/rpl/include/rpl_change_master_demote.inc @@ -85,5 +85,16 @@ SELECT VARIABLE_NAME, GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHER --eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1 --source include/start_slave.inc +# Ensure master is ready to start sending new transactions. That is, because +# the master does not have log_slave_updates, the slave's transactions of +# repl_t are not binlogged, and its state is behind. If the master binlogs +# any new transactions before the slaves connection is matured, +# ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2 can be reported to the slave +# FIXME: We shouldn't need to do this, rather, the master should use +# log-slave-updates and gtid-strict-mode +--connection master +--let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE State like '%Master has sent all binlog to slave%' +--source include/wait_condition.inc + --let $include_filename= rpl_change_master_demote.inc --source include/end_include_file.inc diff --git a/mysql-test/suite/rpl/r/rpl_binlog_dump_slave_gtid_state_info.result b/mysql-test/suite/rpl/r/rpl_binlog_dump_slave_gtid_state_info.result index b913a49b509..af79b482b2f 100644 --- a/mysql-test/suite/rpl/r/rpl_binlog_dump_slave_gtid_state_info.result +++ b/mysql-test/suite/rpl/r/rpl_binlog_dump_slave_gtid_state_info.result @@ -8,6 +8,7 @@ CHANGE MASTER TO MASTER_USE_GTID=slave_pos; include/start_slave.inc connection master; "Test Case 1: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(1), gtid('')" +include/wait_for_pattern_in_file.inc FOUND 1 /using_gtid\(1\), gtid\(\'\'\).*/ in mysqld.1.err connection slave; include/stop_slave.inc @@ -15,6 +16,7 @@ CHANGE MASTER TO MASTER_USE_GTID=no; include/start_slave.inc connection master; "Test Case 2: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(0), gtid('')" +include/wait_for_pattern_in_file.inc FOUND 1 /using_gtid\(0\), gtid\(\'\'\).*/ in mysqld.1.err CREATE TABLE t (f INT) ENGINE=INNODB; INSERT INTO t VALUES(10); @@ -25,6 +27,7 @@ CHANGE MASTER TO MASTER_USE_GTID=slave_pos; include/start_slave.inc connection master; "Test Case 3: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(1), gtid('0-1-2')" +include/wait_for_pattern_in_file.inc FOUND 1 /using_gtid\(1\), gtid\(\'0-1-2\'\).*/ in mysqld.1.err SET @@SESSION.gtid_domain_id=10; INSERT INTO t VALUES(20); @@ -35,6 +38,7 @@ CHANGE MASTER TO MASTER_USE_GTID=slave_pos; include/start_slave.inc connection master; "Test Case 4: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(1), gtid('0-1-2,10-1-1')" +include/wait_for_pattern_in_file.inc FOUND 1 /using_gtid\(1\), gtid\(\'0-1-2,10-1-1\'\).*/ in mysqld.1.err "===== Clean up =====" connection slave; diff --git a/mysql-test/suite/rpl/r/rpl_change_master_demote.result b/mysql-test/suite/rpl/r/rpl_change_master_demote.result index 778fa7c1487..36a2d4a03c3 100644 --- a/mysql-test/suite/rpl/r/rpl_change_master_demote.result +++ b/mysql-test/suite/rpl/r/rpl_change_master_demote.result @@ -58,6 +58,7 @@ GTID_SLAVE_POS 0-2-3 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # # Test Case 2: If gtid_slave_pos is empty, gtid_binlog_pos will # completely overwrite it with MASTER_DEMOTE_TO_SLAVE=1. @@ -124,6 +125,7 @@ GTID_SLAVE_POS 0-2-5 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # # Test Case 3: Using a single domain id, if neither gtid_slave_pos nor # gtid_binlog_pos are empty, and gtid_binlog_pos is more recent, then @@ -183,6 +185,7 @@ GTID_SLAVE_POS 0-2-9 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # # Test Case 4: If gtid_slave_pos and gtid_binlog_pos are equivalent, # MASTER_DEMOTE_TO_SLAVE=1 will not change gtid_slave_pos. @@ -244,6 +247,7 @@ GTID_SLAVE_POS 0-2-13 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # # Test Case 5: If a new domain id is added into gtid_binlog_pos while # gtid_slave_pos already has a state, MASTER_DEMOTE_TO_SLAVE=1 will @@ -308,6 +312,7 @@ GTID_SLAVE_POS 0-2-17,1-1-2 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # # Test Case 6: If gtid_slave_pos has multiple GTID positions and # gtid_binlog_pos contains updates on existing domain ids, new @@ -390,6 +395,7 @@ GTID_SLAVE_POS 0-2-21,1-3-4,2-1-2,4-3-2 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # # Test Case 7: If MASTER_DEMOTE_TO_SLAVE=1 is combined with # IGNORE_DOMAIN_IDS such that gtid_binlog_pos has more recent GTIDs @@ -455,6 +461,7 @@ GTID_SLAVE_POS 0-2-24,1-3-4,2-1-3,3-1-2,4-3-2 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # # Test Case 8: If gtid_binlog_pos is more recent than gtid_slave_pos, # and MASTER_DEMOTE_TO_SLAVE=1 is combined with a later call to @@ -556,6 +563,7 @@ GTID_SLAVE_POS 0-2-29,1-3-4,2-1-3,3-1-2,4-3-2 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # Demote master to slave with the more recent gtid_slave_pos connection master; CHANGE MASTER TO master_host='127.0.0.1', master_port=SLAVE_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; @@ -619,6 +627,7 @@ GTID_SLAVE_POS 0-2-32,1-3-4,2-1-3,3-1-2,4-3-2 connection master; connection slave; CHANGE MASTER TO master_host='127.0.0.1', master_port=MASTER_PORT, master_user='root', master_use_gtid=slave_pos, master_demote_to_slave=1; +connection master; # Tag gtid_slave_pos now (before binlog updates) for later comparison connection master; # In domain 1, make gtid_slave_pos < gtid_binlog_pos diff --git a/mysql-test/suite/rpl/r/rpl_circular_semi_sync.result b/mysql-test/suite/rpl/r/rpl_circular_semi_sync.result index 6f64ca9ca24..9dd4aed2d29 100644 --- a/mysql-test/suite/rpl/r/rpl_circular_semi_sync.result +++ b/mysql-test/suite/rpl/r/rpl_circular_semi_sync.result @@ -1,5 +1,7 @@ include/master-slave.inc [connection master] +connection server_2; +call mtr.add_suppression("Timeout waiting for reply of binlog"); # Master server_1 and Slave server_2 initialization ... connection server_2; include/stop_slave.inc @@ -40,6 +42,8 @@ set @@global.rpl_semi_sync_master_enabled = 1; INSERT INTO t1(a) VALUES (2); include/save_master_gtid.inc connection server_1; +include/stop_slave.inc +include/start_slave.inc # # the successful sync is a required proof # diff --git a/mysql-test/suite/rpl/r/rpl_delayed_slave.result b/mysql-test/suite/rpl/r/rpl_delayed_slave.result index c8c3bc36485..7ac68e25ac5 100644 --- a/mysql-test/suite/rpl/r/rpl_delayed_slave.result +++ b/mysql-test/suite/rpl/r/rpl_delayed_slave.result @@ -70,6 +70,9 @@ include/stop_slave.inc # CHANGE MASTER TO MASTER_DELAY = 2*T include/start_slave.inc connection master; +INSERT INTO t1 VALUES ('Syncing slave', 5); +connection slave; +connection master; INSERT INTO t1 VALUES (delay_on_slave(1), 6); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result index 4169a2ddc26..a54ff99b591 100644 --- a/mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result +++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_master_crash.result @@ -38,8 +38,9 @@ connection master; include/rpl_start_server.inc [server_number=1] # Master has restarted successfully connection slave; -include/wait_for_slave_io_to_start.inc -include/wait_for_slave_sql_to_start.inc +include/stop_slave_sql.inc +include/stop_slave_io.inc +include/start_slave.inc select * from ti; a 1 diff --git a/mysql-test/suite/rpl/r/rpl_gis_user_var.result b/mysql-test/suite/rpl/r/rpl_gis_user_var.result new file mode 100644 index 00000000000..c6aab9e03f0 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gis_user_var.result @@ -0,0 +1,21 @@ +include/master-slave.inc +[connection master] +# +# +# +connection master; +SET @p=POINT(1,1); +CREATE TABLE t1 AS SELECT @p AS p; +connection slave; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `p` point DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT ST_AsWKT(p) FROM t1; +ST_AsWKT(p) +POINT(1 1) +connection master; +DROP TABLE t1; +connection slave; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result b/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result index 68e8b22dd02..fddb07c9cbf 100644 --- a/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result +++ b/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result @@ -6,6 +6,11 @@ connection slave; include/stop_slave.inc CHANGE MASTER TO MASTER_USE_GTID=NO; include/start_slave.inc +connection master; +# Ensure only the new binlog dump thread is alive (wait for the old one +# to complete its kill) +# And that it has already sent its fake rotate +connection slave; include/stop_slave.inc # Test slave with no capability gets dummy event, which is ignored. set @old_dbug= @@global.debug_dbug; diff --git a/mysql-test/suite/rpl/r/rpl_row_big_table_id.result b/mysql-test/suite/rpl/r/rpl_row_big_table_id.result index 694a6132244..0c51e58f5a7 100644 --- a/mysql-test/suite/rpl/r/rpl_row_big_table_id.result +++ b/mysql-test/suite/rpl/r/rpl_row_big_table_id.result @@ -21,23 +21,23 @@ master-bin.000001 # Gtid 1 # GTID #-#-# master-bin.000001 # Query 1 # use `test`; ALTER TABLE t comment '' master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# master-bin.000001 # Annotate_rows 1 # INSERT INTO t SET a= 1 -master-bin.000001 # Table_map 1 # table_id: 4294967295 (test.t) -master-bin.000001 # Write_rows_v1 1 # table_id: 4294967295 flags: STMT_END_F -master-bin.000001 # Query 1 # COMMIT -master-bin.000001 # Gtid 1 # GTID #-#-# -master-bin.000001 # Query 1 # use `test`; ALTER TABLE t comment '' -master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# -master-bin.000001 # Annotate_rows 1 # INSERT INTO t SET a= 2 master-bin.000001 # Table_map 1 # table_id: 4294967296 (test.t) master-bin.000001 # Write_rows_v1 1 # table_id: 4294967296 flags: STMT_END_F master-bin.000001 # Query 1 # COMMIT master-bin.000001 # Gtid 1 # GTID #-#-# master-bin.000001 # Query 1 # use `test`; ALTER TABLE t comment '' master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# -master-bin.000001 # Annotate_rows 1 # INSERT INTO t SET a= 3 +master-bin.000001 # Annotate_rows 1 # INSERT INTO t SET a= 2 master-bin.000001 # Table_map 1 # table_id: 4294967297 (test.t) master-bin.000001 # Write_rows_v1 1 # table_id: 4294967297 flags: STMT_END_F master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; ALTER TABLE t comment '' +master-bin.000001 # Gtid 1 # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows 1 # INSERT INTO t SET a= 3 +master-bin.000001 # Table_map 1 # table_id: 4294967298 (test.t) +master-bin.000001 # Write_rows_v1 1 # table_id: 4294967298 flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT connection slave; connection master; SET debug_dbug=@old_debug_dbug; diff --git a/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result b/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result index 9c7a257c06f..c208ee2efad 100644 --- a/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result +++ b/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result @@ -6,7 +6,8 @@ CHANGE MASTER TO MASTER_USE_GTID=NO; include/start_slave.inc include/stop_slave.inc SET @save_dbug= @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,pause_sql_thread_on_fde,negate_clock_diff_with_master"; +SET @@global.debug_dbug="+d,pause_sql_thread_on_relay_fde_after_trans"; +SET @@global.debug_dbug="+d,negate_clock_diff_with_master"; include/start_slave.inc # Future events must be logged at least 2 seconds after # the slave starts @@ -18,11 +19,6 @@ insert into t1 values (1); # event in its relay log flush logs; connection slave; -# Ignore FDEs that happen before the CREATE/INSERT commands -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; # On the next FDE, the slave should have the master CREATE/INSERT events SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; select count(*)=1 from t1; diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync.result b/mysql-test/suite/rpl/r/rpl_semi_sync.result index edd5e7748e0..03e3443b31e 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync.result @@ -7,7 +7,6 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state call mtr.add_suppression("mysqld: Got an error reading communication packets"); connection slave; set sql_log_bin=0; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); set sql_log_bin=1; @@ -28,7 +27,7 @@ set global rpl_semi_sync_slave_enabled= 0; # Main test of semi-sync replication start here # connection master; -set global rpl_semi_sync_master_timeout= 60000; +set global rpl_semi_sync_master_timeout= 2000; [ default state of semi-sync on master should be OFF ] show variables like 'rpl_semi_sync_master_enabled'; Variable_name Value @@ -163,11 +162,15 @@ connection slave; # Test semi-sync master will switch OFF after one transaction # timeout waiting for slave reply. # +connection master; +show status like "Rpl_semi_sync_master_status"; +Variable_name Value +Rpl_semi_sync_master_status ON connection slave; include/stop_slave.inc connection master; include/kill_binlog_dump_threads.inc -set global rpl_semi_sync_master_timeout= 5000; +set global rpl_semi_sync_master_timeout= 2000; [ master status should be ON ] show status like 'Rpl_semi_sync_master_no_tx'; Variable_name Value @@ -317,6 +320,8 @@ include/kill_binlog_dump_threads.inc connection slave; include/start_slave.inc connection master; +connection slave; +connection master; create table t1 (a int) engine = ENGINE_TYPE; insert into t1 values (1); insert into t1 values (2), (3); @@ -359,6 +364,8 @@ show status like 'Rpl_semi_sync_slave_status'; Variable_name Value Rpl_semi_sync_slave_status ON connection master; +connection slave; +connection master; [ master semi-sync should be ON ] show status like 'Rpl_semi_sync_master_clients'; Variable_name Value diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync.result b/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync.result index 7341eb547f3..a79b372f937 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync.result @@ -8,7 +8,6 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state call mtr.add_suppression("mysqld: Got an error reading communication packets"); connection slave; set sql_log_bin=0; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); set sql_log_bin=1; @@ -29,7 +28,7 @@ set global rpl_semi_sync_slave_enabled= 0; # Main test of semi-sync replication start here # connection master; -set global rpl_semi_sync_master_timeout= 60000; +set global rpl_semi_sync_master_timeout= 2000; [ default state of semi-sync on master should be OFF ] show variables like 'rpl_semi_sync_master_enabled'; Variable_name Value @@ -164,11 +163,15 @@ connection slave; # Test semi-sync master will switch OFF after one transaction # timeout waiting for slave reply. # +connection master; +show status like "Rpl_semi_sync_master_status"; +Variable_name Value +Rpl_semi_sync_master_status ON connection slave; include/stop_slave.inc connection master; include/kill_binlog_dump_threads.inc -set global rpl_semi_sync_master_timeout= 5000; +set global rpl_semi_sync_master_timeout= 2000; [ master status should be ON ] show status like 'Rpl_semi_sync_master_no_tx'; Variable_name Value @@ -318,6 +321,8 @@ include/kill_binlog_dump_threads.inc connection slave; include/start_slave.inc connection master; +connection slave; +connection master; create table t1 (a int) engine = ENGINE_TYPE; insert into t1 values (1); insert into t1 values (2), (3); @@ -360,6 +365,8 @@ show status like 'Rpl_semi_sync_slave_status'; Variable_name Value Rpl_semi_sync_slave_status ON connection master; +connection slave; +connection master; [ master semi-sync should be ON ] show status like 'Rpl_semi_sync_master_clients'; Variable_name Value diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync_row.result b/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync_row.result index d75a3a2c9b7..393c9c55a0d 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync_row.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_after_sync_row.result @@ -8,7 +8,6 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state call mtr.add_suppression("mysqld: Got an error reading communication packets"); connection slave; set sql_log_bin=0; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); set sql_log_bin=1; @@ -29,7 +28,7 @@ set global rpl_semi_sync_slave_enabled= 0; # Main test of semi-sync replication start here # connection master; -set global rpl_semi_sync_master_timeout= 60000; +set global rpl_semi_sync_master_timeout= 2000; [ default state of semi-sync on master should be OFF ] show variables like 'rpl_semi_sync_master_enabled'; Variable_name Value @@ -164,11 +163,15 @@ connection slave; # Test semi-sync master will switch OFF after one transaction # timeout waiting for slave reply. # +connection master; +show status like "Rpl_semi_sync_master_status"; +Variable_name Value +Rpl_semi_sync_master_status ON connection slave; include/stop_slave.inc connection master; include/kill_binlog_dump_threads.inc -set global rpl_semi_sync_master_timeout= 5000; +set global rpl_semi_sync_master_timeout= 2000; [ master status should be ON ] show status like 'Rpl_semi_sync_master_no_tx'; Variable_name Value @@ -318,6 +321,8 @@ include/kill_binlog_dump_threads.inc connection slave; include/start_slave.inc connection master; +connection slave; +connection master; create table t1 (a int) engine = ENGINE_TYPE; insert into t1 values (1); insert into t1 values (2), (3); @@ -360,6 +365,8 @@ show status like 'Rpl_semi_sync_slave_status'; Variable_name Value Rpl_semi_sync_slave_status ON connection master; +connection slave; +connection master; [ master semi-sync should be ON ] show status like 'Rpl_semi_sync_master_clients'; Variable_name Value diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_event.result b/mysql-test/suite/rpl/r/rpl_semi_sync_event.result index 917e7c2b02b..b1eb623cc99 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_event.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_event.result @@ -7,7 +7,6 @@ call mtr.add_suppression("Read semi-sync reply"); call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); call mtr.add_suppression("mysqld: Got an error reading communication packets"); connection slave; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); connection master; diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_event_after_sync.result b/mysql-test/suite/rpl/r/rpl_semi_sync_event_after_sync.result index 24daf0d72b5..34af8d31315 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_event_after_sync.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_event_after_sync.result @@ -8,7 +8,6 @@ call mtr.add_suppression("Read semi-sync reply"); call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); call mtr.add_suppression("mysqld: Got an error reading communication packets"); connection slave; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); connection master; diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result index 9b02d7acea1..4f0a8b421da 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result @@ -5,6 +5,7 @@ include/stop_slave.inc connection server_1; RESET MASTER; SET @@global.max_binlog_size= 4096; +set @@global.rpl_semi_sync_master_enabled = 1; connection server_2; RESET MASTER; SET @@global.max_binlog_size= 4096; @@ -14,7 +15,6 @@ CHANGE MASTER TO master_use_gtid= slave_pos; include/start_slave.inc connection server_1; ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; -set @@global.rpl_semi_sync_master_enabled = 1; set @@global.rpl_semi_sync_master_wait_point=AFTER_SYNC; CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; INSERT INTO t1 VALUES (1, 'dummy1'); diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_no_missed_ack_after_add_slave.result b/mysql-test/suite/rpl/r/rpl_semi_sync_no_missed_ack_after_add_slave.result new file mode 100644 index 00000000000..19fed30ffb7 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_no_missed_ack_after_add_slave.result @@ -0,0 +1,48 @@ +include/rpl_init.inc [topology=1->2,1->3] +connection server_1; +set @old_enabled= @@global.rpl_semi_sync_master_enabled; +set @old_timeout= @@global.rpl_semi_sync_master_timeout; +set global rpl_semi_sync_master_enabled= 1; +set global rpl_semi_sync_master_timeout= 500; +connection server_2; +include/stop_slave.inc +set @old_enabled= @@global.rpl_semi_sync_slave_enabled; +set @old_dbug= @@global.debug_dbug; +set global rpl_semi_sync_slave_enabled= 1; +set global debug_dbug="+d,simulate_delay_semisync_slave_reply"; +include/start_slave.inc +connection server_3; +include/stop_slave.inc +set @old_enabled= @@global.rpl_semi_sync_slave_enabled; +set global rpl_semi_sync_slave_enabled= 1; +include/start_slave.inc +# Ensure primary recognizes both replicas are semi-sync +connection server_1; +connection server_1; +create table t1 (a int); +connection server_2; +# Verifying server_2 did not send ACK +connection server_3; +# Verifying server_3 did send ACK +connection server_1; +# Verifying master's semi-sync status is still ON (This failed pre-MDEV-32960 fixes) +# Verifying rpl_semi_sync_master_yes_tx incremented +# +# Cleanup +connection server_2; +set global rpl_semi_sync_slave_enabled= @old_enabled; +set global debug_dbug= @old_dbug; +include/stop_slave.inc +connection server_3; +set global rpl_semi_sync_slave_enabled= @old_enabled; +include/stop_slave.inc +connection server_1; +set global rpl_semi_sync_master_enabled= @old_enabled; +set global rpl_semi_sync_master_timeout= @old_timeout; +drop table t1; +connection server_2; +include/start_slave.inc +connection server_3; +include/start_slave.inc +include/rpl_end.inc +# End of rpl_semi_sync_no_missed_ack_after_add_slave.test diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_slave_enabled_consistent.result b/mysql-test/suite/rpl/r/rpl_semi_sync_slave_enabled_consistent.result new file mode 100644 index 00000000000..99c3124957f --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_slave_enabled_consistent.result @@ -0,0 +1,35 @@ +include/master-slave.inc +[connection master] +call mtr.add_suppression("Replication event checksum verification failed"); +call mtr.add_suppression("could not queue event from master"); +# +# Set up a semisync connection +connection master; +set @@global.rpl_semi_sync_master_enabled= ON; +connection slave; +stop slave io_thread; +set @@global.rpl_semi_sync_slave_enabled= ON; +set @old_dbug= @@global.debug_dbug; +set @@global.debug_dbug= "+d,corrupt_queue_event"; +set @@global.debug_dbug= "+d,pause_before_io_read_event"; +set @@global.debug_dbug= "+d,placeholder"; +start slave io_thread; +# Disable semi-sync on the slave while the IO thread is active +set debug_sync='now wait_for io_thread_at_read_event'; +set @@global.rpl_semi_sync_slave_enabled= OFF; +set debug_sync='now signal io_thread_continue_read_event'; +# Waiting for the slave to stop with the error from corrupt_queue_event +connection slave; +include/wait_for_slave_io_error.inc [errno=1595,1743] +# Sleep 1 to give time for Ack_receiver to receive COM_QUIT +include/assert_grep.inc [Check that there is no 'Read semi-sync reply magic number error' in error log.] +# +# Cleanup +connection slave; +include/stop_slave.inc +set @@global.debug_dbug= @old_dbug; +include/start_slave.inc +connection master; +set @@global.rpl_semi_sync_master_enabled= default; +include/rpl_end.inc +# End of rpl_semi_sync_slave_enabled_consistent.test 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 index bc2cba4a06a..fca143bd780 100644 --- 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 @@ -4,6 +4,7 @@ connection slave; include/stop_slave.inc connection master; call mtr.add_suppression("Timeout waiting for reply of binlog*"); +call mtr.add_suppression("Master server does not read semi-sync messages*"); set global rpl_semi_sync_master_enabled = ON; SET @@GLOBAL.rpl_semi_sync_master_timeout=100; create table t1 (i int); @@ -15,8 +16,8 @@ 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 Master server does not read semi-sync messages" is present in slave error log. +FOUND 1 /Master server does not read semi-sync messages/ in mysqld.2.err "Assert that Slave IO thread is up and running." SHOW STATUS LIKE 'Slave_running'; Variable_name Value diff --git a/mysql-test/suite/rpl/r/rpl_semisync_ali_issues.result b/mysql-test/suite/rpl/r/rpl_semisync_ali_issues.result index 47ea3aea689..d20960a9e97 100644 --- a/mysql-test/suite/rpl/r/rpl_semisync_ali_issues.result +++ b/mysql-test/suite/rpl/r/rpl_semisync_ali_issues.result @@ -14,7 +14,6 @@ CALL mtr.add_suppression("Failed on request_dump()*"); CALL mtr.add_suppression("Semi-sync master failed on*"); CALL mtr.add_suppression("Master command COM_BINLOG_DUMP failed*"); CALL mtr.add_suppression("on master failed*"); -CALL mtr.add_suppression("Master server does not support semi-sync*"); CALL mtr.add_suppression("Semi-sync slave net_flush*"); CALL mtr.add_suppression("Failed to flush master info*"); CALL mtr.add_suppression("Request to stop slave SQL Thread received while apply*"); @@ -196,7 +195,7 @@ Variable_name Value Rpl_semi_sync_master_clients 0 show status like 'Rpl_semi_sync_master_status'; Variable_name Value -Rpl_semi_sync_master_status OFF +Rpl_semi_sync_master_status ON connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_to_start.inc diff --git a/mysql-test/suite/rpl/r/rpl_session_var.result b/mysql-test/suite/rpl/r/rpl_session_var.result index 67863583f8d..f9794df3be7 100644 --- a/mysql-test/suite/rpl/r/rpl_session_var.result +++ b/mysql-test/suite/rpl/r/rpl_session_var.result @@ -1,5 +1,16 @@ include/master-slave.inc [connection master] +select @@rpl_semi_sync_master_enabled; +@@rpl_semi_sync_master_enabled +0 +connection slave; +select @@rpl_semi_sync_slave_enabled; +@@rpl_semi_sync_slave_enabled +0 +show status like "rpl_semi_sync_slave_status"; +Variable_name Value +Rpl_semi_sync_slave_status OFF +connection master; drop table if exists t1; Warnings: Note 1051 Unknown table 'test.t1' diff --git a/mysql-test/suite/rpl/r/rpl_session_var2.result b/mysql-test/suite/rpl/r/rpl_session_var2.result new file mode 100644 index 00000000000..645eca02492 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_session_var2.result @@ -0,0 +1,69 @@ +include/master-slave.inc +[connection master] +select @@rpl_semi_sync_master_enabled; +@@rpl_semi_sync_master_enabled +1 +connection slave; +select @@rpl_semi_sync_slave_enabled; +@@rpl_semi_sync_slave_enabled +1 +show status like "rpl_semi_sync_slave_status"; +Variable_name Value +Rpl_semi_sync_slave_status ON +connection master; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +create table t1(a varchar(100),b int); +set @@session.sql_mode=pipes_as_concat; +insert into t1 values('My'||'SQL', 1); +set @@session.sql_mode=default; +insert into t1 values('1'||'2', 2); +select * from t1 where b<3 order by a; +a b +1 2 +MySQL 1 +connection slave; +select * from t1 where b<3 order by a; +a b +1 2 +MySQL 1 +connection master; +set @@session.sql_mode=ignore_space; +insert into t1 values(password ('MySQL'), 3); +set @@session.sql_mode=ansi_quotes; +create table "t2" ("a" int); +drop table t1, t2; +set @@session.sql_mode=default; +create table t1(a int auto_increment primary key); +create table t2(b int, a int); +set @@session.sql_auto_is_null=1; +insert into t1 values(null); +insert into t2 select 1,a from t1 where a is null; +set @@session.sql_auto_is_null=0; +insert into t1 values(null); +insert into t2 select 2,a from t1 where a is null; +select * from t2 order by b; +b a +1 1 +connection slave; +select * from t2 order by b; +b a +1 1 +connection master; +drop table t1,t2; +connection slave; +connection master; +CREATE TABLE t1 ( +`id` int(11) NOT NULL auto_increment, +`data` varchar(100), +PRIMARY KEY (`id`) +) ENGINE=MyISAM; +INSERT INTO t1(data) VALUES(SESSION_USER()); +connection slave; +SELECT length(data) < 100 FROM t1; +length(data) < 100 +1 +connection master; +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_restart_slave.result b/mysql-test/suite/rpl/r/rpl_start_alter_restart_slave.result index eecb4212f4b..39b98042e10 100644 --- a/mysql-test/suite/rpl/r/rpl_start_alter_restart_slave.result +++ b/mysql-test/suite/rpl/r/rpl_start_alter_restart_slave.result @@ -79,7 +79,9 @@ domain_id seq_no 0 5 include/start_slave.inc connection master; +include/save_master_gtid.inc connection slave; +include/sync_with_master_gtid.inc # Everything from the master binlog must have been applied now: select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; domain_id seq_no diff --git a/mysql-test/suite/rpl/r/rpl_using_gtid_default.result b/mysql-test/suite/rpl/r/rpl_using_gtid_default.result index 8a257195cfa..5a7b0cd84ef 100644 --- a/mysql-test/suite/rpl/r/rpl_using_gtid_default.result +++ b/mysql-test/suite/rpl/r/rpl_using_gtid_default.result @@ -117,7 +117,10 @@ include/start_slave.inc # not master_use_gtid=no should warn the user that Using_Gtid is being # changed to No. # +connection master; +include/save_master_pos.inc connection slave; +include/sync_io_with_master.inc include/stop_slave.inc CHANGE MASTER TO master_log_pos=io_log_pos, master_log_file='io_log_file'; Warnings: diff --git a/mysql-test/suite/rpl/t/rpl_binlog_dump_slave_gtid_state_info.test b/mysql-test/suite/rpl/t/rpl_binlog_dump_slave_gtid_state_info.test index bba41295d16..02b31c065f9 100644 --- a/mysql-test/suite/rpl/t/rpl_binlog_dump_slave_gtid_state_info.test +++ b/mysql-test/suite/rpl/t/rpl_binlog_dump_slave_gtid_state_info.test @@ -59,7 +59,7 @@ if(!$log_error_) --let SEARCH_FILE=$log_error_ --let SEARCH_RANGE=-50000 --let SEARCH_PATTERN=using_gtid\(1\), gtid\(\'\'\).* ---source include/search_pattern_in_file.inc +--source include/wait_for_pattern_in_file.inc --connection slave --source include/stop_slave.inc @@ -71,7 +71,7 @@ CHANGE MASTER TO MASTER_USE_GTID=no; --let SEARCH_FILE=$log_error_ --let SEARCH_RANGE=-50000 --let SEARCH_PATTERN=using_gtid\(0\), gtid\(\'\'\).* ---source include/search_pattern_in_file.inc +--source include/wait_for_pattern_in_file.inc CREATE TABLE t (f INT) ENGINE=INNODB; INSERT INTO t VALUES(10); save_master_pos; @@ -89,7 +89,7 @@ CHANGE MASTER TO MASTER_USE_GTID=slave_pos; --let SEARCH_FILE=$log_error_ --let SEARCH_RANGE=-50000 --let SEARCH_PATTERN=using_gtid\(1\), gtid\(\'0-1-2\'\).* ---source include/search_pattern_in_file.inc +--source include/wait_for_pattern_in_file.inc SET @@SESSION.gtid_domain_id=10; INSERT INTO t VALUES(20); save_master_pos; @@ -107,7 +107,7 @@ CHANGE MASTER TO MASTER_USE_GTID=slave_pos; --let SEARCH_FILE=$log_error_ --let SEARCH_RANGE=-50000 --let SEARCH_PATTERN=using_gtid\(1\), gtid\(\'0-1-2,10-1-1\'\).* ---source include/search_pattern_in_file.inc +--source include/wait_for_pattern_in_file.inc --echo "===== Clean up =====" --connection slave diff --git a/mysql-test/suite/rpl/t/rpl_circular_semi_sync.test b/mysql-test/suite/rpl/t/rpl_circular_semi_sync.test index 19b6a80fce1..75d04d6545b 100644 --- a/mysql-test/suite/rpl/t/rpl_circular_semi_sync.test +++ b/mysql-test/suite/rpl/t/rpl_circular_semi_sync.test @@ -7,6 +7,9 @@ --source include/have_binlog_format_mixed.inc --source include/master-slave.inc +connection server_2; +call mtr.add_suppression("Timeout waiting for reply of binlog"); + # The following tests prove # A. # no out-of-order gtid error is done to the stict gtid mode semisync @@ -66,10 +69,18 @@ evalp CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_2, ma --connection server_2 set @@global.gtid_strict_mode = true; set @@global.rpl_semi_sync_master_enabled = 1; + +# The following command is likely to cause the slave master is not yet setup +# for semi-sync + INSERT INTO t1(a) VALUES (2); --source include/save_master_gtid.inc --connection server_1 +# Update slave to notice that server_2 now has rpl_semi_sync_master_enabled +--source include/stop_slave.inc +--source include/start_slave.inc + --echo # --echo # the successful sync is a required proof --echo # diff --git a/mysql-test/suite/rpl/t/rpl_delayed_slave.test b/mysql-test/suite/rpl/t/rpl_delayed_slave.test index d00e796b66f..32d0b030eed 100644 --- a/mysql-test/suite/rpl/t/rpl_delayed_slave.test +++ b/mysql-test/suite/rpl/t/rpl_delayed_slave.test @@ -192,6 +192,12 @@ eval CHANGE MASTER TO MASTER_DELAY = $time2; --enable_query_log --source include/start_slave.inc +# Ensure that slave has started properly +--connection master +INSERT INTO t1 VALUES ('Syncing slave', 5); +--save_master_pos +--sync_slave_with_master + --connection master INSERT INTO t1 VALUES (delay_on_slave(1), 6); --save_master_pos diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test index b1fa9af33a4..cdfdc098f5a 100644 --- a/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test +++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test @@ -67,10 +67,26 @@ connection master; save_master_pos; --connection slave + +# Left to its own devices, the IO thread may or may not stop in error, +# depending on what it is doing when its connection to the primary is killed +# (e.g. a failed read results in an error, whereas if the IO thread is idly +# waiting for events when the connection dies, it will enter into a reconnect +# loop and reconnect). So we manually stop/start the IO thread to ensure it is +# in a consistent state +# +# FIXME: We shouldn't need to stop/start the SQL thread here, but due to +# MDEV-33268, we have to. So after fixing 33268, this should only stop/start +# the IO thread. Note the SQL thread must be stopped first due to an invalid +# DBUG_ASSERT in the IO thread's stop logic that depends on the state of the +# SQL thread (also reported and to be fixed in the same ticket). +# +--source include/stop_slave_sql.inc --let rpl_allow_error=1 ---source include/wait_for_slave_io_to_start.inc +--source include/stop_slave_io.inc --let rpl_allow_error= ---source include/wait_for_slave_sql_to_start.inc +--source include/start_slave.inc + sync_with_master; select * from ti; select * from tm; diff --git a/mysql-test/suite/rpl/t/rpl_gis_user_var.test b/mysql-test/suite/rpl/t/rpl_gis_user_var.test new file mode 100644 index 00000000000..8edd8cb9309 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gis_user_var.test @@ -0,0 +1,18 @@ +--source include/have_geometry.inc +--source include/master-slave.inc + +--echo # +--echo # +--echo # + +connection master; +SET @p=POINT(1,1); +CREATE TABLE t1 AS SELECT @p AS p; +sync_slave_with_master; +SHOW CREATE TABLE t1; +SELECT ST_AsWKT(p) FROM t1; +connection master; +DROP TABLE t1; +sync_slave_with_master; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test b/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test index 2ad9124d886..c3a7055de6d 100644 --- a/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test +++ b/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test @@ -11,13 +11,24 @@ set @old_master_binlog_checksum= @@global.binlog_checksum; # empty Gtid_list event # # Test this by binlog rotation before we log any GTIDs. -connection slave; +sync_slave_with_master; # Need to stop/start the master without GTID before setting debug_dbug --source include/stop_slave.inc CHANGE MASTER TO MASTER_USE_GTID=NO; --source include/start_slave.inc +--connection master +--echo # Ensure only the new binlog dump thread is alive (wait for the old one +--echo # to complete its kill) +--let $wait_condition= select count(*)=1 from information_schema.processlist where command='Binlog Dump' +--source include/wait_condition.inc + +--echo # And that it has already sent its fake rotate +--let $wait_condition= select count(*)=1 from information_schema.processlist where state LIKE '%Master has sent all binlog to slave%' and command='Binlog Dump' +--source include/wait_condition.inc + +--connection slave --source include/stop_slave.inc --echo # Test slave with no capability gets dummy event, which is ignored. set @old_dbug= @@global.debug_dbug; diff --git a/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test b/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test index 7c2e39dcf19..a80dedb7383 100644 --- a/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test +++ b/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test @@ -33,7 +33,8 @@ CHANGE MASTER TO MASTER_USE_GTID=NO; --source include/stop_slave.inc SET @save_dbug= @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,pause_sql_thread_on_fde,negate_clock_diff_with_master"; +SET @@global.debug_dbug="+d,pause_sql_thread_on_relay_fde_after_trans"; +SET @@global.debug_dbug="+d,negate_clock_diff_with_master"; --source include/start_slave.inc --let $sleep_time=2 @@ -52,12 +53,6 @@ insert into t1 values (1); flush logs; --connection slave ---echo # Ignore FDEs that happen before the CREATE/INSERT commands -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; - --echo # On the next FDE, the slave should have the master CREATE/INSERT events SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; select count(*)=1 from t1; @@ -138,6 +133,7 @@ while (!$caught_up) } sleep 0.1; } +set debug_sync="RESET"; --enable_query_log --connection master diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync.test b/mysql-test/suite/rpl/t/rpl_semi_sync.test index 720ec059350..ff2336151a0 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync.test @@ -23,7 +23,6 @@ connection slave; # inconsistent GTID values because the seq_nos are non-deterministic with # the masters events coming in concurrently set sql_log_bin=0; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); set sql_log_bin=1; @@ -58,7 +57,7 @@ set global rpl_semi_sync_slave_enabled= 0; connection master; -set global rpl_semi_sync_master_timeout= 60000; # 60s +set global rpl_semi_sync_master_timeout= 2000; # 2s echo [ default state of semi-sync on master should be OFF ]; show variables like 'rpl_semi_sync_master_enabled'; @@ -202,12 +201,16 @@ sync_slave_with_master; --echo # Test semi-sync master will switch OFF after one transaction --echo # timeout waiting for slave reply. --echo # + +connection master; +show status like "Rpl_semi_sync_master_status"; + connection slave; source include/stop_slave.inc; connection master; --source include/kill_binlog_dump_threads.inc -set global rpl_semi_sync_master_timeout= 5000; +set global rpl_semi_sync_master_timeout= 2000; # The first semi-sync check should be on because after slave stop, # there are no transactions on the master. @@ -239,8 +242,8 @@ show status like 'Rpl_semi_sync_master_status'; show status like 'Rpl_semi_sync_master_no_tx'; show status like 'Rpl_semi_sync_master_yes_tx'; -# Semi-sync status on master is now OFF, so all these transactions -# will be replicated asynchronously. +# Semi-sync status on master is now ON, but there are no slaves attached, +# so all these transactions will be replicated asynchronously. delete from t1 where a=10; delete from t1 where a=9; delete from t1 where a=8; @@ -374,6 +377,9 @@ let $status_var= Rpl_semi_sync_master_clients; let $status_var_value= 1; source include/wait_for_status_var.inc; +sync_slave_with_master; +connection master; + replace_result $engine_type ENGINE_TYPE; eval create table t1 (a int) engine = $engine_type; insert into t1 values (1); @@ -420,6 +426,10 @@ connection master; let $status_var= Rpl_semi_sync_master_clients; let $status_var_value= 1; source include/wait_for_status_var.inc; + +sync_slave_with_master; +connection master; + echo [ master semi-sync should be ON ]; show status like 'Rpl_semi_sync_master_clients'; show status like 'Rpl_semi_sync_master_status'; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test index d4df9b4041b..86e1522e6c4 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test @@ -14,7 +14,6 @@ call mtr.add_suppression("Unsafe statement written to the binary log using state call mtr.add_suppression("mysqld: Got an error reading communication packets"); connection slave; -call mtr.add_suppression("Master server does not support semi-sync"); call mtr.add_suppression("Semi-sync slave .* reply"); call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test index 6a691ae04f6..17d7b50d614 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test @@ -18,6 +18,7 @@ --connection server_1 RESET MASTER; SET @@global.max_binlog_size= 4096; +set @@global.rpl_semi_sync_master_enabled = 1; --connection server_2 RESET MASTER; @@ -29,7 +30,6 @@ CHANGE MASTER TO master_use_gtid= slave_pos; --connection server_1 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; -set @@global.rpl_semi_sync_master_enabled = 1; set @@global.rpl_semi_sync_master_wait_point=AFTER_SYNC; CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_no_missed_ack_after_add_slave.cnf b/mysql-test/suite/rpl/t/rpl_semi_sync_no_missed_ack_after_add_slave.cnf new file mode 100644 index 00000000000..cb7062d5602 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_no_missed_ack_after_add_slave.cnf @@ -0,0 +1,12 @@ +!include include/default_mysqld.cnf + +[mysqld.1] + +[mysqld.2] + +[mysqld.3] + +[ENV] +SERVER_MYPORT_1= @mysqld.1.port +SERVER_MYPORT_2= @mysqld.2.port +SERVER_MYPORT_3= @mysqld.3.port diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_no_missed_ack_after_add_slave.test b/mysql-test/suite/rpl/t/rpl_semi_sync_no_missed_ack_after_add_slave.test new file mode 100644 index 00000000000..c8870e47e00 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_no_missed_ack_after_add_slave.test @@ -0,0 +1,122 @@ +# +# This test ensures that a primary will listen for ACKs by newly added +# semi-sync connections connections, after a pre-existing connection is already +# established. MDEV-32960 reported that the newly added slave's ACK can be +# ignored if listen_on_sockets() does not timeout before +# rpl_semi_sync_master_timeout, and if the existing semi-sync connections fail +# to send ACKs, semi-sync is switched off. +# +# This test ensures this in a two-replica setup with a semi-sync timeout of +# 500ms, and delaying the ACK reply of the first-established replica by 800ms +# to force a timeout, and allowing the second replica to immediately ACK. +# +# References: +# MDEV-32960: Semi-sync ACKed Transaction can Timeout and Switch Off +# Semi-sync with Multiple Replicas +# +--source include/have_debug.inc +# binlog_format independent +--source include/have_binlog_format_statement.inc + +--let $rpl_topology= 1->2,1->3 +--source include/rpl_init.inc + + +--connection server_1 +set @old_enabled= @@global.rpl_semi_sync_master_enabled; +set @old_timeout= @@global.rpl_semi_sync_master_timeout; +set global rpl_semi_sync_master_enabled= 1; +set global rpl_semi_sync_master_timeout= 500; + +--connection server_2 +--source include/stop_slave.inc +set @old_enabled= @@global.rpl_semi_sync_slave_enabled; +set @old_dbug= @@global.debug_dbug; +set global rpl_semi_sync_slave_enabled= 1; +set global debug_dbug="+d,simulate_delay_semisync_slave_reply"; +--source include/start_slave.inc + +--connection server_3 +--source include/stop_slave.inc +set @old_enabled= @@global.rpl_semi_sync_slave_enabled; +set global rpl_semi_sync_slave_enabled= 1; +--source include/start_slave.inc + +--echo # Ensure primary recognizes both replicas are semi-sync +--connection server_1 +--let $status_var_value= 2 +--let $status_var= rpl_semi_sync_master_clients +--source include/wait_for_status_var.inc + +--let $master_ss_status= query_get_value(SHOW STATUS LIKE 'rpl_semi_sync_master_status', Value, 1) +if (`SELECT strcmp("$master_ss_status", "ON") != 0`) +{ + SHOW STATUS LIKE 'rpl_semi_sync_master_status'; + --die rpl_semi_sync_master_status should be ON to start +} + +--connection server_1 +--let $init_master_yes_tx= query_get_value(SHOW STATUS LIKE 'rpl_semi_sync_master_yes_tx', Value, 1) +create table t1 (a int); + +--connection server_2 +--echo # Verifying server_2 did not send ACK +--let $slave1_sent_ack= query_get_value(SHOW STATUS LIKE 'rpl_semi_sync_slave_send_ack', Value, 1) +if (`SELECT $slave1_sent_ack`) +{ + SHOW STATUS LIKE 'rpl_semi_sync_slave_send_ack'; + --die server_2 should not have sent semi-sync ACK to primary +} + +--connection server_3 +--echo # Verifying server_3 did send ACK +--let $slave2_sent_ack= query_get_value(SHOW STATUS LIKE 'rpl_semi_sync_slave_send_ack', Value, 1) +if (`SELECT NOT $slave2_sent_ack`) +{ + SHOW STATUS LIKE 'rpl_semi_sync_slave_send_ack'; + --die server_3 should have sent semi-sync ACK to primary +} + +--connection server_1 +--echo # Verifying master's semi-sync status is still ON (This failed pre-MDEV-32960 fixes) +let $master_ss_status= query_get_value(SHOW STATUS LIKE 'rpl_semi_sync_master_status', Value, 1); +if (`SELECT strcmp("$master_ss_status", "ON") != 0`) +{ + SHOW STATUS LIKE 'rpl_semi_sync_master_status'; + --die rpl_semi_sync_master_status should not have switched off after server_3 ACKed transaction +} + +--echo # Verifying rpl_semi_sync_master_yes_tx incremented +--let $cur_master_yes_tx= query_get_value(SHOW STATUS LIKE 'rpl_semi_sync_master_yes_tx', Value, 1) +if (`SELECT $cur_master_yes_tx != ($init_master_yes_tx + 1)`) +{ + --echo # Initial yes_tx: $init_master_yes_tx + --echo # Current yes_tx: $cur_master_yes_tx + --die rpl_semi_sync_master_yes_tx should have been incremented by primary +} + + +--echo # +--echo # Cleanup + +--connection server_2 +set global rpl_semi_sync_slave_enabled= @old_enabled; +set global debug_dbug= @old_dbug; +--source include/stop_slave.inc + +--connection server_3 +set global rpl_semi_sync_slave_enabled= @old_enabled; +--source include/stop_slave.inc + +--connection server_1 +set global rpl_semi_sync_master_enabled= @old_enabled; +set global rpl_semi_sync_master_timeout= @old_timeout; +drop table t1; + +--connection server_2 +--source include/start_slave.inc +--connection server_3 +--source include/start_slave.inc + +--source include/rpl_end.inc +--echo # End of rpl_semi_sync_no_missed_ack_after_add_slave.test diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_slave_enabled_consistent.test b/mysql-test/suite/rpl/t/rpl_semi_sync_slave_enabled_consistent.test new file mode 100644 index 00000000000..9e388ab4419 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_slave_enabled_consistent.test @@ -0,0 +1,73 @@ +# +# MDEV-32551: "Read semi-sync reply magic number error" warnings on master +# +# Test that changing rpl_semi_sync_master_enabled after startup does not +# cause problems with semi-sync cleanup. +# + +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# Test is binlog format independent, so save resources +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +call mtr.add_suppression("Replication event checksum verification failed"); +call mtr.add_suppression("could not queue event from master"); + +--echo # +--echo # Set up a semisync connection +--connection master +set @@global.rpl_semi_sync_master_enabled= ON; + +--connection slave +stop slave io_thread; +set @@global.rpl_semi_sync_slave_enabled= ON; +set @old_dbug= @@global.debug_dbug; + +# Force an error to abort out of the main IO thread loop +set @@global.debug_dbug= "+d,corrupt_queue_event"; + +# Pause the IO thread as soon as the main loop starts. Note we can't use +# processlist where "Waiting for master to send event" because the +# "corrupt_queue_event" will trigger before we can turn semisync OFF +set @@global.debug_dbug= "+d,pause_before_io_read_event"; + +# Because the other debug_dbug points are automatically negated when they are +# run, and there is a bug that if "-d" takes us to an empty debug string state, +# _all_ debug_print statements are output +set @@global.debug_dbug= "+d,placeholder"; + +start slave io_thread; + +--echo # Disable semi-sync on the slave while the IO thread is active +set debug_sync='now wait_for io_thread_at_read_event'; +set @@global.rpl_semi_sync_slave_enabled= OFF; +set debug_sync='now signal io_thread_continue_read_event'; + +--echo # Waiting for the slave to stop with the error from corrupt_queue_event +--connection slave +--let $slave_io_errno= 1595,1743 +--source include/wait_for_slave_io_error.inc + +--echo # Sleep 1 to give time for Ack_receiver to receive COM_QUIT +--sleep 1 + +--let $assert_text= Check that there is no 'Read semi-sync reply magic number error' in error log. +--let $assert_select=magic number error +--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err +--let $assert_count= 0 +--let $assert_only_after=CURRENT_TEST +--source include/assert_grep.inc + +--echo # +--echo # Cleanup +--connection slave +--source include/stop_slave.inc +set @@global.debug_dbug= @old_dbug; +--source include/start_slave.inc +--connection master +set @@global.rpl_semi_sync_master_enabled= default; + +--source include/rpl_end.inc +--echo # End of rpl_semi_sync_slave_enabled_consistent.test 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 index a467a38ddb0..30aeea48225 100644 --- 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 @@ -31,6 +31,7 @@ --connection master call mtr.add_suppression("Timeout waiting for reply of binlog*"); +call mtr.add_suppression("Master server does not read semi-sync messages*"); --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; @@ -54,9 +55,9 @@ if(!$log_error_) # 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. +--echo "Assert that Master server does not read semi-sync messages" is present in slave error log. --let SEARCH_FILE=$log_error_ ---let SEARCH_PATTERN=Semi-sync slave net_flush\(\) reply failed +--let SEARCH_PATTERN=Master server does not read semi-sync messages --source include/search_pattern_in_file.inc --echo "Assert that Slave IO thread is up and running." diff --git a/mysql-test/suite/rpl/t/rpl_semisync_ali_issues.test b/mysql-test/suite/rpl/t/rpl_semisync_ali_issues.test index dd4cb2fe62b..ba9c5f0458c 100644 --- a/mysql-test/suite/rpl/t/rpl_semisync_ali_issues.test +++ b/mysql-test/suite/rpl/t/rpl_semisync_ali_issues.test @@ -16,7 +16,6 @@ CALL mtr.add_suppression("Failed on request_dump()*"); CALL mtr.add_suppression("Semi-sync master failed on*"); CALL mtr.add_suppression("Master command COM_BINLOG_DUMP failed*"); CALL mtr.add_suppression("on master failed*"); -CALL mtr.add_suppression("Master server does not support semi-sync*"); CALL mtr.add_suppression("Semi-sync slave net_flush*"); CALL mtr.add_suppression("Failed to flush master info*"); CALL mtr.add_suppression("Request to stop slave SQL Thread received while apply*"); diff --git a/mysql-test/suite/rpl/t/rpl_session_var.test b/mysql-test/suite/rpl/t/rpl_session_var.test index cf3faa6578c..3ea6d5dabae 100644 --- a/mysql-test/suite/rpl/t/rpl_session_var.test +++ b/mysql-test/suite/rpl/t/rpl_session_var.test @@ -7,6 +7,12 @@ disable_query_log; call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); enable_query_log; +select @@rpl_semi_sync_master_enabled; +connection slave; +select @@rpl_semi_sync_slave_enabled; +show status like "rpl_semi_sync_slave_status"; +connection master; + drop table if exists t1; create table t1(a varchar(100),b int); set @@session.sql_mode=pipes_as_concat; diff --git a/mysql-test/suite/rpl/t/rpl_session_var2-master.opt b/mysql-test/suite/rpl/t/rpl_session_var2-master.opt new file mode 100644 index 00000000000..edb0c915bd6 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_session_var2-master.opt @@ -0,0 +1 @@ +--rpl_semi_sync_master_enabled=1 --rpl_semi_sync_slave_enabled=1 diff --git a/mysql-test/suite/rpl/t/rpl_session_var2-slave.opt b/mysql-test/suite/rpl/t/rpl_session_var2-slave.opt new file mode 100644 index 00000000000..c9f3082ed07 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_session_var2-slave.opt @@ -0,0 +1 @@ +--rpl_semi_sync_slave_enabled=1 diff --git a/mysql-test/suite/rpl/t/rpl_session_var2.test b/mysql-test/suite/rpl/t/rpl_session_var2.test new file mode 100644 index 00000000000..cbf8a5cf316 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_session_var2.test @@ -0,0 +1,3 @@ +# Replication of session variables when semi-sync is on + +--source rpl_session_var.test diff --git a/mysql-test/suite/rpl/t/rpl_shutdown_wait_semisync_slaves.test b/mysql-test/suite/rpl/t/rpl_shutdown_wait_semisync_slaves.test index 2c63df30fde..0547a97f681 100644 --- a/mysql-test/suite/rpl/t/rpl_shutdown_wait_semisync_slaves.test +++ b/mysql-test/suite/rpl/t/rpl_shutdown_wait_semisync_slaves.test @@ -28,6 +28,9 @@ while (`SELECT $i <= $slaves`) --inc $i } +# The following script will restart master and slaves. This will also set +# rpl_semi_sync_master_enabled=0 + --source include/rpl_shutdown_wait_slaves.inc --let i= 2 while (`SELECT $i <= $slaves`) diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test b/mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test index 4485b77b171..43586fdd6a4 100644 --- a/mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test +++ b/mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test @@ -90,8 +90,12 @@ SET GLOBAL debug_dbug= @old_debug_slave; select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; --source include/start_slave.inc + --connection master ---sync_slave_with_master +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc --echo # Everything from the master binlog must have been applied now: select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; --let $slave_gtid_state = `select @@gtid_binlog_state` diff --git a/mysql-test/suite/rpl/t/rpl_using_gtid_default.test b/mysql-test/suite/rpl/t/rpl_using_gtid_default.test index eab5b4dd504..c14695f98cb 100644 --- a/mysql-test/suite/rpl/t/rpl_using_gtid_default.test +++ b/mysql-test/suite/rpl/t/rpl_using_gtid_default.test @@ -271,7 +271,10 @@ eval set global gtid_slave_pos="$old_slave_pos"; --echo # not master_use_gtid=no should warn the user that Using_Gtid is being --echo # changed to No. --echo # +--connection master +--source include/save_master_pos.inc --connection slave +--source include/sync_io_with_master.inc --let $io_log_pos= query_get_value('SHOW SLAVE STATUS', Read_Master_Log_Pos, 1) --let $io_log_file= query_get_value('SHOW SLAVE STATUS', Master_Log_File, 1) --source include/stop_slave.inc diff --git a/mysql-test/suite/sql_sequence/alter.result b/mysql-test/suite/sql_sequence/alter.result index ae95bfb9cc1..75da828c59c 100644 --- a/mysql-test/suite/sql_sequence/alter.result +++ b/mysql-test/suite/sql_sequence/alter.result @@ -253,6 +253,55 @@ NEXTVAL(s) 1 DROP SEQUENCE s; # +# MDEV-33169 Alter sequence 2nd ps fails while alter sequence 2nd time (no ps) succeeds +# +create sequence s; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM +alter sequence s maxvalue 123; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM +alter sequence s maxvalue 123; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM +drop sequence s; +create sequence s; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM +prepare stmt from 'alter sequence s maxvalue 123'; +execute stmt; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM +execute stmt; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM +deallocate prepare stmt; +drop sequence s; +create sequence s; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM +create procedure p() alter sequence s maxvalue 123; +call p; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM +call p; +show create sequence s; +Table Create Table +s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM +drop procedure p; +drop sequence s; +# +# End of 10.4 tests +# +# # MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence # CREATE SEQUENCE s1 ENGINE=InnoDB; @@ -266,3 +315,6 @@ s2 CREATE SEQUENCE `s2` start with 1 minvalue 1 maxvalue 9223372036854775806 inc DROP SEQUENCE s2; RENAME TABLE s1 TO s2; DROP SEQUENCE s2; +# +# End of 10.6 tests +# diff --git a/mysql-test/suite/sql_sequence/alter.test b/mysql-test/suite/sql_sequence/alter.test index 20ac6b2cb92..7b14055d892 100644 --- a/mysql-test/suite/sql_sequence/alter.test +++ b/mysql-test/suite/sql_sequence/alter.test @@ -167,6 +167,41 @@ ALTER TABLE s ORDER BY cache_size; SELECT NEXTVAL(s); DROP SEQUENCE s; +--echo # +--echo # MDEV-33169 Alter sequence 2nd ps fails while alter sequence 2nd time (no ps) succeeds +--echo # +create sequence s; +show create sequence s; +alter sequence s maxvalue 123; +show create sequence s; +alter sequence s maxvalue 123; +show create sequence s; +drop sequence s; + +create sequence s; +show create sequence s; +prepare stmt from 'alter sequence s maxvalue 123'; +execute stmt; +show create sequence s; +execute stmt; +show create sequence s; +deallocate prepare stmt; +drop sequence s; + +create sequence s; +show create sequence s; +create procedure p() alter sequence s maxvalue 123; +call p; +show create sequence s; +call p; +show create sequence s; +drop procedure p; +drop sequence s; + +--echo # +--echo # End of 10.4 tests +--echo # + --echo # --echo # MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence --echo # @@ -180,3 +215,7 @@ RENAME TABLE s1 TO s2; DROP SEQUENCE s2; --enable_ps2_protocol + +--echo # +--echo # End of 10.6 tests +--echo # diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff index 539c88e97be..771fa906979 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff @@ -1,5 +1,5 @@ ---- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result -+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +--- sysvars_server_embedded.result 2024-02-15 09:34:10.105925200 +0100 ++++ sysvars_server_embedded,32bit.result 2024-02-15 13:49:05.823558727 +0100 @@ -44,7 +44,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_BLOCK_SIZE @@ -714,7 +714,16 @@ VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2374,7 +2374,7 @@ +@@ -2354,7 +2354,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Unused, will be removed. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 2 +@@ -2384,7 +2384,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_EXTRA_PRUNING_DEPTH VARIABLE_SCOPE SESSION @@ -723,7 +732,7 @@ VARIABLE_COMMENT If the optimizer needs to enumerate join prefix of this size or larger, then it will try aggressively prune away the search space. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2434,7 +2434,7 @@ +@@ -2444,7 +2444,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARGS VARIABLE_SCOPE SESSION @@ -732,7 +741,7 @@ VARIABLE_COMMENT The maximum number of SEL_ARG objects created when optimizing a range. If more objects would be needed, the range will not be used by the optimizer. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2444,7 +2444,7 @@ +@@ -2454,7 +2454,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARG_WEIGHT VARIABLE_SCOPE SESSION @@ -741,7 +750,7 @@ VARIABLE_COMMENT The maximum weight of the SEL_ARG graph. Set to 0 for no limit NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2454,7 +2454,7 @@ +@@ -2464,7 +2464,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_PRUNE_LEVEL VARIABLE_SCOPE SESSION @@ -750,7 +759,7 @@ VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search: 1 - prune plans based on cost and number of retrieved rows eq_ref: 2 - prune also if we find an eq_ref chain NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -2524,7 +2524,7 @@ +@@ -2534,7 +2534,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SEARCH_DEPTH VARIABLE_SCOPE SESSION @@ -759,7 +768,7 @@ VARIABLE_COMMENT Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Values smaller than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2534,7 +2534,7 @@ +@@ -2544,7 +2544,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SELECTIVITY_SAMPLING_LIMIT VARIABLE_SCOPE SESSION @@ -768,7 +777,7 @@ VARIABLE_COMMENT Controls number of record samples to check condition selectivity NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 4294967295 -@@ -2564,17 +2564,17 @@ +@@ -2574,17 +2574,17 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_TRACE_MAX_MEM_SIZE VARIABLE_SCOPE SESSION @@ -789,7 +798,7 @@ VARIABLE_COMMENT Controls selectivity of which conditions the optimizer takes into account to calculate cardinality of a partial join when it searches for the best execution plan Meaning: 1 - use selectivity of index backed range conditions to calculate the cardinality of a partial join if the last joined table is accessed by full table scan or an index scan, 2 - use selectivity of index backed range conditions to calculate the cardinality of a partial join in any case, 3 - additionally always use selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join, 4 - use histograms to calculate selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join.5 - additionally use selectivity of certain non-range predicates calculated on record samples NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 5 -@@ -2604,7 +2604,7 @@ +@@ -2614,7 +2614,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME PERFORMANCE_SCHEMA_ACCOUNTS_SIZE VARIABLE_SCOPE GLOBAL @@ -798,7 +807,7 @@ VARIABLE_COMMENT Maximum number of instrumented user@host accounts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2614,7 +2614,7 @@ +@@ -2624,7 +2624,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_DIGESTS_SIZE VARIABLE_SCOPE GLOBAL @@ -807,7 +816,7 @@ VARIABLE_COMMENT Size of the statement digest. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2624,7 +2624,7 @@ +@@ -2634,7 +2634,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -816,7 +825,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2634,7 +2634,7 @@ +@@ -2644,7 +2644,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -825,7 +834,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2644,7 +2644,7 @@ +@@ -2654,7 +2654,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -834,7 +843,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2654,7 +2654,7 @@ +@@ -2664,7 +2664,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -843,7 +852,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2664,7 +2664,7 @@ +@@ -2674,7 +2674,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -852,7 +861,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_TRANSACTIONS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2674,7 +2674,7 @@ +@@ -2684,7 +2684,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -861,7 +870,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_TRANSACTIONS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2684,7 +2684,7 @@ +@@ -2694,7 +2694,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -870,7 +879,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2694,7 +2694,7 @@ +@@ -2704,7 +2704,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -879,7 +888,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2704,7 +2704,7 @@ +@@ -2714,7 +2714,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_HOSTS_SIZE VARIABLE_SCOPE GLOBAL @@ -888,7 +897,7 @@ VARIABLE_COMMENT Maximum number of instrumented hosts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2714,7 +2714,7 @@ +@@ -2724,7 +2724,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_CLASSES VARIABLE_SCOPE GLOBAL @@ -897,7 +906,7 @@ VARIABLE_COMMENT Maximum number of condition instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2724,7 +2724,7 @@ +@@ -2734,7 +2734,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_INSTANCES VARIABLE_SCOPE GLOBAL @@ -906,7 +915,7 @@ VARIABLE_COMMENT Maximum number of instrumented condition objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2734,7 +2734,7 @@ +@@ -2744,7 +2744,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_DIGEST_LENGTH VARIABLE_SCOPE GLOBAL @@ -915,7 +924,7 @@ VARIABLE_COMMENT Maximum length considered for digest text, when stored in performance_schema tables. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2744,7 +2744,7 @@ +@@ -2754,7 +2754,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_CLASSES VARIABLE_SCOPE GLOBAL @@ -924,7 +933,7 @@ VARIABLE_COMMENT Maximum number of file instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2754,7 +2754,7 @@ +@@ -2764,7 +2764,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_HANDLES VARIABLE_SCOPE GLOBAL @@ -933,7 +942,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented files. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2764,7 +2764,7 @@ +@@ -2774,7 +2774,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -942,7 +951,7 @@ VARIABLE_COMMENT Maximum number of instrumented files. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2774,7 +2774,7 @@ +@@ -2784,7 +2784,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_INDEX_STAT VARIABLE_SCOPE GLOBAL @@ -951,7 +960,7 @@ VARIABLE_COMMENT Maximum number of index statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2784,7 +2784,7 @@ +@@ -2794,7 +2794,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MEMORY_CLASSES VARIABLE_SCOPE GLOBAL @@ -960,7 +969,7 @@ VARIABLE_COMMENT Maximum number of memory pool instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1024 -@@ -2794,7 +2794,7 @@ +@@ -2804,7 +2804,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_METADATA_LOCKS VARIABLE_SCOPE GLOBAL @@ -969,7 +978,7 @@ VARIABLE_COMMENT Maximum number of metadata locks. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2804,7 +2804,7 @@ +@@ -2814,7 +2814,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES VARIABLE_SCOPE GLOBAL @@ -978,7 +987,7 @@ VARIABLE_COMMENT Maximum number of mutex instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2814,7 +2814,7 @@ +@@ -2824,7 +2824,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES VARIABLE_SCOPE GLOBAL @@ -987,7 +996,7 @@ VARIABLE_COMMENT Maximum number of instrumented MUTEX objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2824,7 +2824,7 @@ +@@ -2834,7 +2834,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PREPARED_STATEMENTS_INSTANCES VARIABLE_SCOPE GLOBAL @@ -996,7 +1005,7 @@ VARIABLE_COMMENT Maximum number of instrumented prepared statements. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2834,7 +2834,7 @@ +@@ -2844,7 +2844,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PROGRAM_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1005,7 +1014,7 @@ VARIABLE_COMMENT Maximum number of instrumented programs. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2844,7 +2844,7 @@ +@@ -2854,7 +2854,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES VARIABLE_SCOPE GLOBAL @@ -1014,7 +1023,7 @@ VARIABLE_COMMENT Maximum number of rwlock instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2854,7 +2854,7 @@ +@@ -2864,7 +2864,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1023,7 +1032,7 @@ VARIABLE_COMMENT Maximum number of instrumented RWLOCK objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -2864,7 +2864,7 @@ +@@ -2874,7 +2874,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_CLASSES VARIABLE_SCOPE GLOBAL @@ -1032,7 +1041,7 @@ VARIABLE_COMMENT Maximum number of socket instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2874,7 +2874,7 @@ +@@ -2884,7 +2884,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1041,7 +1050,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented sockets. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2884,7 +2884,7 @@ +@@ -2894,7 +2894,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SQL_TEXT_LENGTH VARIABLE_SCOPE GLOBAL @@ -1050,7 +1059,7 @@ VARIABLE_COMMENT Maximum length of displayed sql text. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2894,7 +2894,7 @@ +@@ -2904,7 +2904,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STAGE_CLASSES VARIABLE_SCOPE GLOBAL @@ -1059,7 +1068,7 @@ VARIABLE_COMMENT Maximum number of stage instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2904,7 +2904,7 @@ +@@ -2914,7 +2914,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES VARIABLE_SCOPE GLOBAL @@ -1068,7 +1077,7 @@ VARIABLE_COMMENT Maximum number of statement instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2914,7 +2914,7 @@ +@@ -2924,7 +2924,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_STACK VARIABLE_SCOPE GLOBAL @@ -1077,7 +1086,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_CURRENT. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 256 -@@ -2924,7 +2924,7 @@ +@@ -2934,7 +2934,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES VARIABLE_SCOPE GLOBAL @@ -1086,7 +1095,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2934,7 +2934,7 @@ +@@ -2944,7 +2944,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1095,7 +1104,7 @@ VARIABLE_COMMENT Maximum number of instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2944,7 +2944,7 @@ +@@ -2954,7 +2954,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_LOCK_STAT VARIABLE_SCOPE GLOBAL @@ -1104,7 +1113,7 @@ VARIABLE_COMMENT Maximum number of lock statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2954,7 +2954,7 @@ +@@ -2964,7 +2964,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES VARIABLE_SCOPE GLOBAL @@ -1113,7 +1122,7 @@ VARIABLE_COMMENT Maximum number of thread instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2964,7 +2964,7 @@ +@@ -2974,7 +2974,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1122,7 +1131,7 @@ VARIABLE_COMMENT Maximum number of instrumented threads. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2974,7 +2974,7 @@ +@@ -2984,7 +2984,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SESSION_CONNECT_ATTRS_SIZE VARIABLE_SCOPE GLOBAL @@ -1131,7 +1140,7 @@ VARIABLE_COMMENT Size of session attribute string buffer per thread. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2984,7 +2984,7 @@ +@@ -2994,7 +2994,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_ACTORS_SIZE VARIABLE_SCOPE GLOBAL @@ -1140,7 +1149,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_ACTORS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2994,7 +2994,7 @@ +@@ -3004,7 +3004,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE VARIABLE_SCOPE GLOBAL @@ -1149,7 +1158,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_OBJECTS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3004,7 +3004,7 @@ +@@ -3014,7 +3014,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_USERS_SIZE VARIABLE_SCOPE GLOBAL @@ -1158,7 +1167,7 @@ VARIABLE_COMMENT Maximum number of instrumented users. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3054,7 +3054,7 @@ +@@ -3064,7 +3064,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PRELOAD_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1167,7 +1176,7 @@ VARIABLE_COMMENT The size of the buffer that is allocated when preloading indexes NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -3074,7 +3074,7 @@ +@@ -3084,7 +3084,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME PROFILING_HISTORY_SIZE VARIABLE_SCOPE SESSION @@ -1176,7 +1185,7 @@ VARIABLE_COMMENT Number of statements about which profiling information is maintained. If set to 0, no profiles are stored. See SHOW PROFILES. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 100 -@@ -3084,7 +3084,7 @@ +@@ -3094,7 +3094,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PROGRESS_REPORT_TIME VARIABLE_SCOPE SESSION @@ -1185,7 +1194,7 @@ VARIABLE_COMMENT Seconds between sending progress reports to the client for time-consuming statements. Set to 0 to disable progress reporting. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3144,7 +3144,7 @@ +@@ -3154,7 +3154,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME QUERY_ALLOC_BLOCK_SIZE VARIABLE_SCOPE SESSION @@ -1194,7 +1203,7 @@ VARIABLE_COMMENT Allocation block size for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -3154,7 +3154,7 @@ +@@ -3164,7 +3164,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_LIMIT VARIABLE_SCOPE GLOBAL @@ -1203,7 +1212,7 @@ VARIABLE_COMMENT Don't cache results that are bigger than this NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3164,7 +3164,7 @@ +@@ -3174,7 +3174,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_MIN_RES_UNIT VARIABLE_SCOPE GLOBAL @@ -1212,7 +1221,7 @@ VARIABLE_COMMENT The minimum size for blocks allocated by the query cache NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3177,7 +3177,7 @@ +@@ -3187,7 +3187,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The memory allocated to store results from old queries NUMERIC_MIN_VALUE 0 @@ -1221,7 +1230,7 @@ NUMERIC_BLOCK_SIZE 1024 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3214,7 +3214,7 @@ +@@ -3224,7 +3224,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME QUERY_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1230,7 +1239,7 @@ VARIABLE_COMMENT Persistent buffer for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -3227,7 +3227,7 @@ +@@ -3237,7 +3237,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1239,7 +1248,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3237,14 +3237,14 @@ +@@ -3247,14 +3247,14 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1256,7 +1265,7 @@ VARIABLE_COMMENT Allocation block size for storing ranges during optimization NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 4294967295 -@@ -3254,7 +3254,7 @@ +@@ -3264,7 +3264,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME READ_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1265,7 +1274,7 @@ VARIABLE_COMMENT Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value NUMERIC_MIN_VALUE 8192 NUMERIC_MAX_VALUE 2147483647 -@@ -3274,7 +3274,7 @@ +@@ -3284,7 +3284,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME READ_RND_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1274,7 +1283,7 @@ VARIABLE_COMMENT When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 2147483647 -@@ -3294,10 +3294,10 @@ +@@ -3304,10 +3304,10 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ROWID_MERGE_BUFF_SIZE VARIABLE_SCOPE SESSION @@ -1287,7 +1296,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3334,7 +3334,7 @@ +@@ -3344,7 +3344,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SERVER_ID VARIABLE_SCOPE SESSION @@ -1296,7 +1305,7 @@ VARIABLE_COMMENT Uniquely identifies the server instance in the community of replication partners NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -3424,7 +3424,7 @@ +@@ -3434,7 +3434,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_MAX_ALLOWED_PACKET VARIABLE_SCOPE GLOBAL @@ -1305,7 +1314,7 @@ VARIABLE_COMMENT The maximum packet length to sent successfully from the master to slave. NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -3434,7 +3434,7 @@ +@@ -3444,7 +3444,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_LAUNCH_TIME VARIABLE_SCOPE GLOBAL @@ -1314,7 +1323,7 @@ VARIABLE_COMMENT If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -3477,7 +3477,7 @@ +@@ -3487,7 +3487,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Each thread that needs to do a sort allocates a buffer of this size NUMERIC_MIN_VALUE 1024 @@ -1323,7 +1332,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3694,7 +3694,7 @@ +@@ -3704,7 +3704,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME STORED_PROGRAM_CACHE VARIABLE_SCOPE GLOBAL @@ -1332,7 +1341,7 @@ VARIABLE_COMMENT The soft upper limit for number of cached stored routines for one connection. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 524288 -@@ -3784,7 +3784,7 @@ +@@ -3794,7 +3794,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME TABLE_DEFINITION_CACHE VARIABLE_SCOPE GLOBAL @@ -1341,7 +1350,7 @@ VARIABLE_COMMENT The number of cached table definitions NUMERIC_MIN_VALUE 400 NUMERIC_MAX_VALUE 2097152 -@@ -3794,7 +3794,7 @@ +@@ -3804,7 +3804,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TABLE_OPEN_CACHE VARIABLE_SCOPE GLOBAL @@ -1350,7 +1359,7 @@ VARIABLE_COMMENT The number of cached open tables NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 1048576 -@@ -3854,7 +3854,7 @@ +@@ -3864,7 +3864,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME THREAD_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -1359,7 +1368,7 @@ VARIABLE_COMMENT How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -3927,7 +3927,7 @@ +@@ -3937,7 +3937,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Max size for data for an internal temporary on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 1024 @@ -1368,7 +1377,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3937,7 +3937,7 @@ +@@ -3947,7 +3947,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. Same as tmp_table_size. NUMERIC_MIN_VALUE 0 @@ -1377,7 +1386,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3947,14 +3947,14 @@ +@@ -3957,14 +3957,14 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Alias for tmp_memory_table_size. If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 0 @@ -1394,7 +1403,7 @@ VARIABLE_COMMENT Allocation block size for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -3974,7 +3974,7 @@ +@@ -3984,7 +3984,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME TRANSACTION_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1403,7 +1412,7 @@ VARIABLE_COMMENT Persistent buffer for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -4124,7 +4124,7 @@ +@@ -4134,7 +4134,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME WAIT_TIMEOUT VARIABLE_SCOPE SESSION @@ -1412,7 +1421,7 @@ VARIABLE_COMMENT The number of seconds the server waits for activity on a connection before closing it NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -4151,7 +4151,7 @@ +@@ -4161,7 +4161,7 @@ VARIABLE_NAME LOG_TC_SIZE GLOBAL_VALUE_ORIGIN AUTO VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index a7ecae15dd2..561d4a5e3fe 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -2352,6 +2352,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_COMMENT Unused, will be removed. +NUMERIC_MIN_VALUE 0 +NUMERIC_MAX_VALUE 2 +NUMERIC_BLOCK_SIZE 1 +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_DISK_READ_COST VARIABLE_SCOPE GLOBAL VARIABLE_TYPE DOUBLE diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff index 9da2d104d31..31978fd0bf9 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff @@ -1,5 +1,5 @@ ---- sysvars_server_notembedded.result -+++ sysvars_server_notembedded.result +--- sysvars_server_notembedded.result 2024-02-15 09:34:10.109925277 +0100 ++++ sysvars_server_notembedded,32bit.result 2024-02-15 10:35:52.037016777 +0100 @@ -44,7 +44,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME ARIA_BLOCK_SIZE @@ -723,7 +723,16 @@ VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2584,7 +2584,7 @@ +@@ -2564,7 +2564,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Unused, will be removed. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 2 +@@ -2594,7 +2594,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_EXTRA_PRUNING_DEPTH VARIABLE_SCOPE SESSION @@ -732,7 +741,7 @@ VARIABLE_COMMENT If the optimizer needs to enumerate join prefix of this size or larger, then it will try aggressively prune away the search space. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2644,7 +2644,7 @@ +@@ -2654,7 +2654,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARGS VARIABLE_SCOPE SESSION @@ -741,7 +750,7 @@ VARIABLE_COMMENT The maximum number of SEL_ARG objects created when optimizing a range. If more objects would be needed, the range will not be used by the optimizer. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2654,7 +2654,7 @@ +@@ -2664,7 +2664,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARG_WEIGHT VARIABLE_SCOPE SESSION @@ -750,7 +759,7 @@ VARIABLE_COMMENT The maximum weight of the SEL_ARG graph. Set to 0 for no limit NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -2664,7 +2664,7 @@ +@@ -2674,7 +2674,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_PRUNE_LEVEL VARIABLE_SCOPE SESSION @@ -759,7 +768,7 @@ VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search: 1 - prune plans based on cost and number of retrieved rows eq_ref: 2 - prune also if we find an eq_ref chain NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -2734,7 +2734,7 @@ +@@ -2744,7 +2744,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SEARCH_DEPTH VARIABLE_SCOPE SESSION @@ -768,7 +777,7 @@ VARIABLE_COMMENT Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Values smaller than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 62 -@@ -2744,7 +2744,7 @@ +@@ -2754,7 +2754,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_SELECTIVITY_SAMPLING_LIMIT VARIABLE_SCOPE SESSION @@ -777,7 +786,7 @@ VARIABLE_COMMENT Controls number of record samples to check condition selectivity NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 4294967295 -@@ -2774,17 +2774,17 @@ +@@ -2784,17 +2784,17 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_TRACE_MAX_MEM_SIZE VARIABLE_SCOPE SESSION @@ -798,7 +807,7 @@ VARIABLE_COMMENT Controls selectivity of which conditions the optimizer takes into account to calculate cardinality of a partial join when it searches for the best execution plan Meaning: 1 - use selectivity of index backed range conditions to calculate the cardinality of a partial join if the last joined table is accessed by full table scan or an index scan, 2 - use selectivity of index backed range conditions to calculate the cardinality of a partial join in any case, 3 - additionally always use selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join, 4 - use histograms to calculate selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join.5 - additionally use selectivity of certain non-range predicates calculated on record samples NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 5 -@@ -2814,7 +2814,7 @@ +@@ -2824,7 +2824,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME PERFORMANCE_SCHEMA_ACCOUNTS_SIZE VARIABLE_SCOPE GLOBAL @@ -807,7 +816,7 @@ VARIABLE_COMMENT Maximum number of instrumented user@host accounts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2824,7 +2824,7 @@ +@@ -2834,7 +2834,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_DIGESTS_SIZE VARIABLE_SCOPE GLOBAL @@ -816,7 +825,7 @@ VARIABLE_COMMENT Size of the statement digest. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2834,7 +2834,7 @@ +@@ -2844,7 +2844,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -825,7 +834,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2844,7 +2844,7 @@ +@@ -2854,7 +2854,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -834,7 +843,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2854,7 +2854,7 @@ +@@ -2864,7 +2864,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -843,7 +852,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2864,7 +2864,7 @@ +@@ -2874,7 +2874,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -852,7 +861,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2874,7 +2874,7 @@ +@@ -2884,7 +2884,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -861,7 +870,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_TRANSACTIONS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2884,7 +2884,7 @@ +@@ -2894,7 +2894,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -870,7 +879,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_TRANSACTIONS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2894,7 +2894,7 @@ +@@ -2904,7 +2904,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE VARIABLE_SCOPE GLOBAL @@ -879,7 +888,7 @@ VARIABLE_COMMENT Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2904,7 +2904,7 @@ +@@ -2914,7 +2914,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE VARIABLE_SCOPE GLOBAL @@ -888,7 +897,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -2914,7 +2914,7 @@ +@@ -2924,7 +2924,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_HOSTS_SIZE VARIABLE_SCOPE GLOBAL @@ -897,7 +906,7 @@ VARIABLE_COMMENT Maximum number of instrumented hosts. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2924,7 +2924,7 @@ +@@ -2934,7 +2934,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_CLASSES VARIABLE_SCOPE GLOBAL @@ -906,7 +915,7 @@ VARIABLE_COMMENT Maximum number of condition instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2934,7 +2934,7 @@ +@@ -2944,7 +2944,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_INSTANCES VARIABLE_SCOPE GLOBAL @@ -915,7 +924,7 @@ VARIABLE_COMMENT Maximum number of instrumented condition objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2944,7 +2944,7 @@ +@@ -2954,7 +2954,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_DIGEST_LENGTH VARIABLE_SCOPE GLOBAL @@ -924,7 +933,7 @@ VARIABLE_COMMENT Maximum length considered for digest text, when stored in performance_schema tables. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2954,7 +2954,7 @@ +@@ -2964,7 +2964,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_CLASSES VARIABLE_SCOPE GLOBAL @@ -933,7 +942,7 @@ VARIABLE_COMMENT Maximum number of file instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -2964,7 +2964,7 @@ +@@ -2974,7 +2974,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_HANDLES VARIABLE_SCOPE GLOBAL @@ -942,7 +951,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented files. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -2974,7 +2974,7 @@ +@@ -2984,7 +2984,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -951,7 +960,7 @@ VARIABLE_COMMENT Maximum number of instrumented files. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2984,7 +2984,7 @@ +@@ -2994,7 +2994,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_INDEX_STAT VARIABLE_SCOPE GLOBAL @@ -960,7 +969,7 @@ VARIABLE_COMMENT Maximum number of index statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -2994,7 +2994,7 @@ +@@ -3004,7 +3004,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MEMORY_CLASSES VARIABLE_SCOPE GLOBAL @@ -969,7 +978,7 @@ VARIABLE_COMMENT Maximum number of memory pool instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1024 -@@ -3004,7 +3004,7 @@ +@@ -3014,7 +3014,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_METADATA_LOCKS VARIABLE_SCOPE GLOBAL @@ -978,7 +987,7 @@ VARIABLE_COMMENT Maximum number of metadata locks. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -3014,7 +3014,7 @@ +@@ -3024,7 +3024,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES VARIABLE_SCOPE GLOBAL @@ -987,7 +996,7 @@ VARIABLE_COMMENT Maximum number of mutex instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -3024,7 +3024,7 @@ +@@ -3034,7 +3034,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES VARIABLE_SCOPE GLOBAL @@ -996,7 +1005,7 @@ VARIABLE_COMMENT Maximum number of instrumented MUTEX objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -3034,7 +3034,7 @@ +@@ -3044,7 +3044,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PREPARED_STATEMENTS_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1005,7 +1014,7 @@ VARIABLE_COMMENT Maximum number of instrumented prepared statements. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3044,7 +3044,7 @@ +@@ -3054,7 +3054,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PROGRAM_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1014,7 +1023,7 @@ VARIABLE_COMMENT Maximum number of instrumented programs. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3054,7 +3054,7 @@ +@@ -3064,7 +3064,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES VARIABLE_SCOPE GLOBAL @@ -1023,7 +1032,7 @@ VARIABLE_COMMENT Maximum number of rwlock instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -3064,7 +3064,7 @@ +@@ -3074,7 +3074,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1032,7 +1041,7 @@ VARIABLE_COMMENT Maximum number of instrumented RWLOCK objects. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 104857600 -@@ -3074,7 +3074,7 @@ +@@ -3084,7 +3084,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_CLASSES VARIABLE_SCOPE GLOBAL @@ -1041,7 +1050,7 @@ VARIABLE_COMMENT Maximum number of socket instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -3084,7 +3084,7 @@ +@@ -3094,7 +3094,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1050,7 +1059,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented sockets. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3094,7 +3094,7 @@ +@@ -3104,7 +3104,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SQL_TEXT_LENGTH VARIABLE_SCOPE GLOBAL @@ -1059,7 +1068,7 @@ VARIABLE_COMMENT Maximum length of displayed sql text. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 1048576 -@@ -3104,7 +3104,7 @@ +@@ -3114,7 +3114,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STAGE_CLASSES VARIABLE_SCOPE GLOBAL @@ -1068,7 +1077,7 @@ VARIABLE_COMMENT Maximum number of stage instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -3114,7 +3114,7 @@ +@@ -3124,7 +3124,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES VARIABLE_SCOPE GLOBAL @@ -1077,7 +1086,7 @@ VARIABLE_COMMENT Maximum number of statement instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -3124,7 +3124,7 @@ +@@ -3134,7 +3134,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_STACK VARIABLE_SCOPE GLOBAL @@ -1086,7 +1095,7 @@ VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_CURRENT. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 256 -@@ -3134,7 +3134,7 @@ +@@ -3144,7 +3144,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES VARIABLE_SCOPE GLOBAL @@ -1095,7 +1104,7 @@ VARIABLE_COMMENT Maximum number of opened instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3144,7 +3144,7 @@ +@@ -3154,7 +3154,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1104,7 +1113,7 @@ VARIABLE_COMMENT Maximum number of instrumented tables. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3154,7 +3154,7 @@ +@@ -3164,7 +3164,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_LOCK_STAT VARIABLE_SCOPE GLOBAL @@ -1113,7 +1122,7 @@ VARIABLE_COMMENT Maximum number of lock statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3164,7 +3164,7 @@ +@@ -3174,7 +3174,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES VARIABLE_SCOPE GLOBAL @@ -1122,7 +1131,7 @@ VARIABLE_COMMENT Maximum number of thread instruments. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 256 -@@ -3174,7 +3174,7 @@ +@@ -3184,7 +3184,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES VARIABLE_SCOPE GLOBAL @@ -1131,7 +1140,7 @@ VARIABLE_COMMENT Maximum number of instrumented threads. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3184,7 +3184,7 @@ +@@ -3194,7 +3194,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SESSION_CONNECT_ATTRS_SIZE VARIABLE_SCOPE GLOBAL @@ -1140,7 +1149,7 @@ VARIABLE_COMMENT Size of session attribute string buffer per thread. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3194,7 +3194,7 @@ +@@ -3204,7 +3204,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_ACTORS_SIZE VARIABLE_SCOPE GLOBAL @@ -1149,7 +1158,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_ACTORS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1024 -@@ -3204,7 +3204,7 @@ +@@ -3214,7 +3214,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE VARIABLE_SCOPE GLOBAL @@ -1158,7 +1167,7 @@ VARIABLE_COMMENT Maximum number of rows in SETUP_OBJECTS. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3214,7 +3214,7 @@ +@@ -3224,7 +3224,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PERFORMANCE_SCHEMA_USERS_SIZE VARIABLE_SCOPE GLOBAL @@ -1167,7 +1176,7 @@ VARIABLE_COMMENT Maximum number of instrumented users. Use 0 to disable, -1 for automated sizing. NUMERIC_MIN_VALUE -1 NUMERIC_MAX_VALUE 1048576 -@@ -3264,7 +3264,7 @@ +@@ -3274,7 +3274,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PRELOAD_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1176,7 +1185,7 @@ VARIABLE_COMMENT The size of the buffer that is allocated when preloading indexes NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -3284,7 +3284,7 @@ +@@ -3294,7 +3294,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME PROFILING_HISTORY_SIZE VARIABLE_SCOPE SESSION @@ -1185,7 +1194,7 @@ VARIABLE_COMMENT Number of statements about which profiling information is maintained. If set to 0, no profiles are stored. See SHOW PROFILES. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 100 -@@ -3294,7 +3294,7 @@ +@@ -3304,7 +3304,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME PROGRESS_REPORT_TIME VARIABLE_SCOPE SESSION @@ -1194,7 +1203,7 @@ VARIABLE_COMMENT Seconds between sending progress reports to the client for time-consuming statements. Set to 0 to disable progress reporting. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3354,7 +3354,7 @@ +@@ -3364,7 +3364,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME QUERY_ALLOC_BLOCK_SIZE VARIABLE_SCOPE SESSION @@ -1203,7 +1212,7 @@ VARIABLE_COMMENT Allocation block size for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -3364,7 +3364,7 @@ +@@ -3374,7 +3374,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_LIMIT VARIABLE_SCOPE GLOBAL @@ -1212,7 +1221,7 @@ VARIABLE_COMMENT Don't cache results that are bigger than this NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3374,7 +3374,7 @@ +@@ -3384,7 +3384,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME QUERY_CACHE_MIN_RES_UNIT VARIABLE_SCOPE GLOBAL @@ -1221,7 +1230,7 @@ VARIABLE_COMMENT The minimum size for blocks allocated by the query cache NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -3387,7 +3387,7 @@ +@@ -3397,7 +3397,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT The memory allocated to store results from old queries NUMERIC_MIN_VALUE 0 @@ -1230,7 +1239,7 @@ NUMERIC_BLOCK_SIZE 1024 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3424,7 +3424,7 @@ +@@ -3434,7 +3434,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME QUERY_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1239,7 +1248,7 @@ VARIABLE_COMMENT Persistent buffer for query parsing and execution NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 4294967295 -@@ -3437,7 +3437,7 @@ +@@ -3447,7 +3447,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1248,7 +1257,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3447,14 +3447,14 @@ +@@ -3457,14 +3457,14 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes NUMERIC_MIN_VALUE 0 @@ -1265,7 +1274,7 @@ VARIABLE_COMMENT Allocation block size for storing ranges during optimization NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 4294967295 -@@ -3467,14 +3467,14 @@ +@@ -3477,14 +3477,14 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Maximum speed(KB/s) to read binlog from master (0 = no limit) NUMERIC_MIN_VALUE 0 @@ -1282,7 +1291,7 @@ VARIABLE_COMMENT Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value NUMERIC_MIN_VALUE 8192 NUMERIC_MAX_VALUE 2147483647 -@@ -3494,7 +3494,7 @@ +@@ -3504,7 +3504,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME READ_RND_BUFFER_SIZE VARIABLE_SCOPE SESSION @@ -1291,7 +1300,7 @@ VARIABLE_COMMENT When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 2147483647 -@@ -3724,10 +3724,10 @@ +@@ -3734,10 +3734,10 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME ROWID_MERGE_BUFF_SIZE VARIABLE_SCOPE SESSION @@ -1304,7 +1313,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3744,20 +3744,20 @@ +@@ -3754,20 +3754,20 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME RPL_SEMI_SYNC_MASTER_TIMEOUT VARIABLE_SCOPE GLOBAL @@ -1329,7 +1338,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3814,10 +3814,10 @@ +@@ -3824,10 +3824,10 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME RPL_SEMI_SYNC_SLAVE_TRACE_LEVEL VARIABLE_SCOPE GLOBAL @@ -1342,7 +1351,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -3854,7 +3854,7 @@ +@@ -3864,7 +3864,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SERVER_ID VARIABLE_SCOPE SESSION @@ -1351,7 +1360,7 @@ VARIABLE_COMMENT Uniquely identifies the server instance in the community of replication partners NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -4004,7 +4004,7 @@ +@@ -4014,7 +4014,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_DOMAIN_PARALLEL_THREADS VARIABLE_SCOPE GLOBAL @@ -1360,7 +1369,7 @@ VARIABLE_COMMENT Maximum number of parallel threads to use on slave for events in a single replication domain. When using multiple domains, this can be used to limit a single domain from grabbing all threads and thus stalling other domains. The default of 0 means to allow a domain to grab as many threads as it wants, up to the value of slave_parallel_threads. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16383 -@@ -4034,7 +4034,7 @@ +@@ -4044,7 +4044,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_MAX_ALLOWED_PACKET VARIABLE_SCOPE GLOBAL @@ -1369,7 +1378,7 @@ VARIABLE_COMMENT The maximum packet length to sent successfully from the master to slave. NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 1073741824 -@@ -4064,7 +4064,7 @@ +@@ -4074,7 +4074,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_PARALLEL_MAX_QUEUED VARIABLE_SCOPE GLOBAL @@ -1378,7 +1387,7 @@ VARIABLE_COMMENT Limit on how much memory SQL threads should use per parallel replication thread when reading ahead in the relay log looking for opportunities for parallel replication. Only used when --slave-parallel-threads > 0. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2147483647 -@@ -4084,7 +4084,7 @@ +@@ -4094,7 +4094,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME SLAVE_PARALLEL_THREADS VARIABLE_SCOPE GLOBAL @@ -1387,7 +1396,7 @@ VARIABLE_COMMENT If non-zero, number of threads to spawn to apply in parallel events on the slave that were group-committed on the master or were logged with GTID in different replication domains. Note that these threads are in addition to the IO and SQL threads, which are always created by a replication slave NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16383 -@@ -4094,7 +4094,7 @@ +@@ -4104,7 +4104,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_PARALLEL_WORKERS VARIABLE_SCOPE GLOBAL @@ -1396,7 +1405,7 @@ VARIABLE_COMMENT Alias for slave_parallel_threads NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16383 -@@ -4134,7 +4134,7 @@ +@@ -4144,7 +4144,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SLAVE_TRANSACTION_RETRIES VARIABLE_SCOPE GLOBAL @@ -1405,7 +1414,7 @@ VARIABLE_COMMENT Number of times the slave SQL thread will retry a transaction in case it failed with a deadlock, elapsed lock wait timeout or listed in slave_transaction_retry_errors, before giving up and stopping NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 4294967295 -@@ -4154,7 +4154,7 @@ +@@ -4164,7 +4164,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLAVE_TRANSACTION_RETRY_INTERVAL VARIABLE_SCOPE GLOBAL @@ -1414,7 +1423,7 @@ VARIABLE_COMMENT Interval of the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout or listed in slave_transaction_retry_errors NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 3600 -@@ -4174,7 +4174,7 @@ +@@ -4184,7 +4184,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME SLOW_LAUNCH_TIME VARIABLE_SCOPE GLOBAL @@ -1423,7 +1432,7 @@ VARIABLE_COMMENT If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 31536000 -@@ -4217,7 +4217,7 @@ +@@ -4227,7 +4227,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Each thread that needs to do a sort allocates a buffer of this size NUMERIC_MIN_VALUE 1024 @@ -1432,7 +1441,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -4444,7 +4444,7 @@ +@@ -4454,7 +4454,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME STORED_PROGRAM_CACHE VARIABLE_SCOPE GLOBAL @@ -1441,7 +1450,7 @@ VARIABLE_COMMENT The soft upper limit for number of cached stored routines for one connection. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 524288 -@@ -4554,7 +4554,7 @@ +@@ -4564,7 +4564,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME TABLE_DEFINITION_CACHE VARIABLE_SCOPE GLOBAL @@ -1450,7 +1459,7 @@ VARIABLE_COMMENT The number of cached table definitions NUMERIC_MIN_VALUE 400 NUMERIC_MAX_VALUE 2097152 -@@ -4564,7 +4564,7 @@ +@@ -4574,7 +4574,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME TABLE_OPEN_CACHE VARIABLE_SCOPE GLOBAL @@ -1459,7 +1468,7 @@ VARIABLE_COMMENT The number of cached open tables NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 1048576 -@@ -4624,7 +4624,7 @@ +@@ -4634,7 +4634,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME THREAD_CACHE_SIZE VARIABLE_SCOPE GLOBAL @@ -1468,7 +1477,7 @@ VARIABLE_COMMENT How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16384 -@@ -4787,7 +4787,7 @@ +@@ -4797,7 +4797,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Max size for data for an internal temporary on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 1024 @@ -1477,7 +1486,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -4797,7 +4797,7 @@ +@@ -4807,7 +4807,7 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. Same as tmp_table_size. NUMERIC_MIN_VALUE 0 @@ -1486,7 +1495,7 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -4807,14 +4807,14 @@ +@@ -4817,14 +4817,14 @@ VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Alias for tmp_memory_table_size. If an internal in-memory temporary table exceeds this size, MariaDB will automatically convert it to an on-disk MyISAM or Aria table. NUMERIC_MIN_VALUE 0 @@ -1503,7 +1512,7 @@ VARIABLE_COMMENT Allocation block size for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -4834,7 +4834,7 @@ +@@ -4844,7 +4844,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME TRANSACTION_PREALLOC_SIZE VARIABLE_SCOPE SESSION @@ -1512,7 +1521,7 @@ VARIABLE_COMMENT Persistent buffer for transactions to be stored in binary log NUMERIC_MIN_VALUE 1024 NUMERIC_MAX_VALUE 134217728 -@@ -4984,7 +4984,7 @@ +@@ -4994,7 +4994,7 @@ COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME WAIT_TIMEOUT VARIABLE_SCOPE SESSION @@ -1521,7 +1530,7 @@ VARIABLE_COMMENT The number of seconds the server waits for activity on a connection before closing it NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 31536000 -@@ -5011,7 +5011,7 @@ +@@ -5021,7 +5021,7 @@ VARIABLE_NAME LOG_TC_SIZE GLOBAL_VALUE_ORIGIN AUTO VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,win.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,win.rdiff new file mode 100644 index 00000000000..acee8a39b43 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,win.rdiff @@ -0,0 +1,1465 @@ +--- suite/sys_vars/r/sysvars_server_notembedded.result ++++ suite/sys_vars/r/sysvars_server_notembedded.reject +@@ -34,7 +34,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_BLOCK_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Block size to be used for Aria index pages. + NUMERIC_MIN_VALUE 4096 + NUMERIC_MAX_VALUE 32768 +@@ -44,7 +44,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_CHECKPOINT_INTERVAL + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Interval between tries to do an automatic checkpoints. In seconds; 0 means 'no automatic checkpoints' which makes sense only for testing. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -54,7 +54,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_CHECKPOINT_LOG_ACTIVITY + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of bytes that the transaction log has to grow between checkpoints before a new checkpoint is written to the log. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -74,7 +74,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME ARIA_FORCE_START_AFTER_RECOVERY_FAILURES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of consecutive log recovery failures after which logs will be automatically deleted to cure the problem; 0 (the default) disables the feature. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 255 +@@ -94,7 +94,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_GROUP_COMMIT_INTERVAL + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Interval between commits in microseconds (1/1000000 sec). 0 stands for no waiting for other threads to come and do a commit in "hard" mode and no sync()/commit at all in "soft" mode. Option has only an effect if aria_group_commit is used + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -114,7 +114,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_LOG_FILE_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Limit for transaction log size + NUMERIC_MIN_VALUE 8388608 + NUMERIC_MAX_VALUE 4294967295 +@@ -144,10 +144,10 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_PAGECACHE_AGE_THRESHOLD + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in the page cache. + NUMERIC_MIN_VALUE 100 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 100 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -164,7 +164,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_PAGECACHE_DIVISION_LIMIT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The minimum percentage of warm blocks in key cache + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 100 +@@ -174,7 +174,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME ARIA_PAGECACHE_FILE_HASH_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of hash buckets for open and changed files. If you have a lot of Aria files open you should increase this for faster flush of changes. A good value is probably 1/10 of number of possible open Aria files. + NUMERIC_MIN_VALUE 128 + NUMERIC_MAX_VALUE 16384 +@@ -204,7 +204,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME ARIA_REPAIR_THREADS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of threads to use when repairing Aria tables. The value of 1 disables parallel repair. + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 128 +@@ -274,7 +274,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME AUTO_INCREMENT_INCREMENT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Auto-increment columns are incremented by this + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 65535 +@@ -284,7 +284,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME AUTO_INCREMENT_OFFSET + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Offset added to Auto-increment columns. Used when auto-increment-increment != 1 + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 65535 +@@ -294,7 +294,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME BACK_LOG + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of outstanding connection requests MariaDB can have. This comes into play when the main MariaDB thread gets very many connection requests in a very short time + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 65535 +@@ -364,20 +364,20 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME BINLOG_COMMIT_WAIT_COUNT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If non-zero, binlog write will wait at most binlog_commit_wait_usec microseconds for at least this many commits to queue up for group commit to the binlog. This can reduce I/O on the binlog and provide increased opportunity for parallel apply on the slave, but too high a value will decrease commit throughput. + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME BINLOG_COMMIT_WAIT_USEC + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum time, in microseconds, to wait for more commits to queue up for binlog group commit. Only takes effect if the value of binlog_commit_wait_count is non-zero. + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -394,7 +394,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME BINLOG_EXPIRE_LOGS_SECONDS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If non-zero, binary logs will be purged after binlog_expire_logs_seconds seconds; It and expire_logs_days are linked, such that changes in one are converted into the other. Possible purges happen at startup and at binary log rotation. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 8553600 +@@ -654,7 +654,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME CONNECT_TIMEOUT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake' + NUMERIC_MIN_VALUE 2 + NUMERIC_MAX_VALUE 31536000 +@@ -704,7 +704,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME DEADLOCK_SEARCH_DEPTH_LONG + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Long search depth for the two-step deadlock detection + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 33 +@@ -714,7 +714,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME DEADLOCK_SEARCH_DEPTH_SHORT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Short search depth for the two-step deadlock detection + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 32 +@@ -724,7 +724,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME DEADLOCK_TIMEOUT_LONG + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Long timeout for the two-step deadlock detection (in microseconds) + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -734,7 +734,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME DEADLOCK_TIMEOUT_SHORT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Short timeout for the two-step deadlock detection (in microseconds) + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -794,7 +794,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME DEFAULT_WEEK_FORMAT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The default week format used by WEEK() functions + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 7 +@@ -804,7 +804,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME DELAYED_INSERT_LIMIT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing. + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -814,7 +814,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME DELAYED_INSERT_TIMEOUT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT How long a INSERT DELAYED thread should wait for INSERT statements before terminating + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 31536000 +@@ -824,7 +824,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME DELAYED_QUEUE_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -854,7 +854,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME DIV_PRECISION_INCREMENT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Precision of the result of '/' operator will be increased on that value + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 38 +@@ -974,7 +974,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME EXTRA_MAX_CONNECTIONS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of connections on extra-port + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 100000 +@@ -1004,7 +1004,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME FLUSH_TIME + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT A dedicated thread is created to flush all tables at the given interval + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 31536000 +@@ -1034,7 +1034,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME FT_MAX_WORD_LEN + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable + NUMERIC_MIN_VALUE 10 + NUMERIC_MAX_VALUE 84 +@@ -1044,7 +1044,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME FT_MIN_WORD_LEN + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 84 +@@ -1054,7 +1054,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME FT_QUERY_EXPANSION_LIMIT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of best matches to use for query expansion + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 1000 +@@ -1304,7 +1304,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME HISTOGRAM_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of bytes used for a histogram. If set to 0, no histograms are created by ANALYZE. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 255 +@@ -1334,7 +1334,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME HOST_CACHE_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT How many host names should be cached to avoid resolving. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 65536 +@@ -1357,7 +1357,7 @@ + VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of seconds the server waits for read-only idle transaction + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 31536000 ++NUMERIC_MAX_VALUE 2147483 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -1367,7 +1367,7 @@ + VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of seconds the server waits for idle transaction + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 31536000 ++NUMERIC_MAX_VALUE 2147483 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -1377,7 +1377,7 @@ + VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of seconds the server waits for write idle transaction + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 31536000 ++NUMERIC_MAX_VALUE 2147483 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -1444,7 +1444,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME INTERACTIVE_TIMEOUT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of seconds the server waits for activity on an interactive connection before closing it + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 31536000 +@@ -1494,7 +1494,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME JOIN_CACHE_LEVEL + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Controls what join operations can be executed with join buffers. Odd numbers are used for plain join buffers while even numbers are used for linked buffers + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 8 +@@ -1672,19 +1672,9 @@ + ENUM_VALUE_LIST OFF,ON + READ_ONLY NO + COMMAND_LINE_ARGUMENT OPTIONAL +-VARIABLE_NAME LOCKED_IN_MEMORY +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BOOLEAN +-VARIABLE_COMMENT Whether mysqld was locked in memory with --memlock +-NUMERIC_MIN_VALUE NULL +-NUMERIC_MAX_VALUE NULL +-NUMERIC_BLOCK_SIZE NULL +-ENUM_VALUE_LIST OFF,ON +-READ_ONLY YES +-COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME LOCK_WAIT_TIMEOUT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Timeout in seconds to wait for a lock before returning an error. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 31536000 +@@ -1834,7 +1824,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME LOG_SLOW_MAX_WARNINGS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Max numbers of warnings printed to slow query log per statement + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 1000 +@@ -1844,7 +1834,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME LOG_SLOW_RATE_LIMIT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Write to slow log every #th slow query. Set to 1 to log everything. Increase it to reduce the size of the slow or the performance impact of slow logging + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -1874,7 +1864,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME LOG_WARNINGS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Log some non critical warnings to the error log.Value can be between 0 and 11. Higher values mean more verbosity + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -1934,7 +1924,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME MAX_ALLOWED_PACKET + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Max packet length to send to or receive from the server + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 1073741824 +@@ -1954,7 +1944,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_BINLOG_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Binary log will be rotated automatically when the size exceeds this value. + NUMERIC_MIN_VALUE 4096 + NUMERIC_MAX_VALUE 1073741824 +@@ -1974,7 +1964,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_CONNECTIONS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of simultaneous clients allowed + NUMERIC_MIN_VALUE 10 + NUMERIC_MAX_VALUE 100000 +@@ -1984,7 +1974,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_CONNECT_ERRORS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If there is more than this number of interrupted connections from a host this host will be blocked from further connections + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -1994,7 +1984,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_DELAYED_THREADS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 16384 +@@ -2014,7 +2004,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_ERROR_COUNT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Max number of errors/warnings to store for a statement + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 65535 +@@ -2034,7 +2024,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_INSERT_DELAYED_THREADS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero INSERT DELAYED will be not used + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 16384 +@@ -2054,7 +2044,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_LENGTH_FOR_SORT_DATA + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Max number of bytes in sorted records + NUMERIC_MIN_VALUE 4 + NUMERIC_MAX_VALUE 8388608 +@@ -2084,7 +2074,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_RECURSIVE_ITERATIONS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of iterations when executing recursive queries + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -2114,7 +2104,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_SEEKS_FOR_KEY + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Limit assumed max number of seeks when looking up rows based on a key + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -2134,7 +2124,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_SORT_LENGTH + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored) + NUMERIC_MIN_VALUE 64 + NUMERIC_MAX_VALUE 8388608 +@@ -2144,7 +2134,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_SP_RECURSION_DEPTH + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum stored procedure recursion depth + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 255 +@@ -2164,7 +2154,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_TMP_TABLES + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Unused, will be removed. + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -2184,7 +2174,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MAX_WRITE_LOCK_COUNT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT After this many write locks, allow some read locks to run in between + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -2194,7 +2184,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME METADATA_LOCKS_CACHE_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Unused + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 1048576 +@@ -2204,7 +2194,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME METADATA_LOCKS_HASH_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Unused + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 1024 +@@ -2214,7 +2204,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MIN_EXAMINED_ROW_LIMIT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Don't write queries to slow log that examine fewer rows than that + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -2224,7 +2214,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MRR_BUFFER_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Size of buffer to use when using MRR with range access + NUMERIC_MIN_VALUE 8192 + NUMERIC_MAX_VALUE 2147483647 +@@ -2234,7 +2224,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MYISAM_BLOCK_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Block size to be used for MyISAM index pages + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 16384 +@@ -2244,7 +2234,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME MYISAM_DATA_POINTER_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Default pointer size to be used for MyISAM tables + NUMERIC_MIN_VALUE 2 + NUMERIC_MAX_VALUE 7 +@@ -2284,10 +2274,10 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME MYISAM_REPAIR_THREADS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If larger than 1, when repairing a MyISAM table all indexes will be created in parallel, with one thread per index. The value of 1 disables parallel repair + NUMERIC_MIN_VALUE 1 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -2332,9 +2322,19 @@ + ENUM_VALUE_LIST OFF,ON + READ_ONLY NO + COMMAND_LINE_ARGUMENT OPTIONAL ++VARIABLE_NAME NAMED_PIPE ++VARIABLE_SCOPE GLOBAL ++VARIABLE_TYPE BOOLEAN ++VARIABLE_COMMENT Enable the named pipe (NT) ++NUMERIC_MIN_VALUE NULL ++NUMERIC_MAX_VALUE NULL ++NUMERIC_BLOCK_SIZE NULL ++ENUM_VALUE_LIST OFF,ON ++READ_ONLY YES ++COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME NET_BUFFER_LENGTH + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Buffer length for TCP/IP and socket communication + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 1048576 +@@ -2344,7 +2344,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME NET_READ_TIMEOUT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of seconds to wait for more data from a connection before aborting the read + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 31536000 +@@ -2354,7 +2354,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME NET_RETRY_COUNT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If a read on a communication port is interrupted, retry this many times before giving up + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -2364,7 +2364,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME NET_WRITE_TIMEOUT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of seconds to wait for a block to be written to a connection before aborting the write + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 31536000 +@@ -2424,7 +2424,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME OPEN_FILES_LIMIT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -2434,7 +2434,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT 0 = No changes. 1 = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. 2 = Remove 'max_seek optimization' for secondary keys and slight adjustment of filter cost. This option will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 2 +@@ -2444,7 +2444,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_MAX_SEL_ARGS + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The maximum number of SEL_ARG objects created when optimizing a range. If more objects would be needed, the range will not be used by the optimizer. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -2454,7 +2454,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_MAX_SEL_ARG_WEIGHT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The maximum weight of the SEL_ARG graph. Set to 0 for no limit + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -2464,7 +2464,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_PRUNE_LEVEL + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search; 1 - prune plans based on number of retrieved rows + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 1 +@@ -2474,7 +2474,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_SEARCH_DEPTH + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Values smaller than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 62 +@@ -2484,7 +2484,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_SELECTIVITY_SAMPLING_LIMIT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Controls number of record samples to check condition selectivity + NUMERIC_MIN_VALUE 10 + NUMERIC_MAX_VALUE 4294967295 +@@ -2514,17 +2514,17 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_TRACE_MAX_MEM_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum allowed size of an optimizer trace + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME OPTIMIZER_USE_CONDITION_SELECTIVITY + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Controls selectivity of which conditions the optimizer takes into account to calculate cardinality of a partial join when it searches for the best execution plan Meaning: 1 - use selectivity of index backed range conditions to calculate the cardinality of a partial join if the last joined table is accessed by full table scan or an index scan, 2 - use selectivity of index backed range conditions to calculate the cardinality of a partial join in any case, 3 - additionally always use selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join, 4 - use histograms to calculate selectivity of range conditions that are not backed by any index to calculate the cardinality of a partial join.5 - additionally use selectivity of certain non-range predicates calculated on record samples + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 5 +@@ -2544,7 +2544,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME PERFORMANCE_SCHEMA_ACCOUNTS_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented user@host accounts. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2554,7 +2554,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_DIGESTS_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Size of the statement digest. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2564,7 +2564,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_LONG_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2574,7 +2574,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1024 +@@ -2584,7 +2584,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_LONG_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2594,7 +2594,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_HISTORY. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1024 +@@ -2604,7 +2604,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_LONG_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows in EVENTS_TRANSACTIONS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2614,7 +2614,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows per thread in EVENTS_TRANSACTIONS_HISTORY. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1024 +@@ -2624,7 +2624,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2634,7 +2634,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1024 +@@ -2644,7 +2644,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_HOSTS_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented hosts. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2654,7 +2654,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of condition instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2664,7 +2664,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_COND_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented condition objects. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2674,7 +2674,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_DIGEST_LENGTH + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum length considered for digest text, when stored in performance_schema tables. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 1048576 +@@ -2684,7 +2684,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of file instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2694,7 +2694,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_HANDLES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of opened instrumented files. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 1048576 +@@ -2704,7 +2704,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented files. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2714,7 +2714,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_INDEX_STAT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of index statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2724,7 +2724,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MEMORY_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of memory pool instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 1024 +@@ -2734,7 +2734,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_METADATA_LOCKS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of metadata locks. Use 0 to disable, -1 for automated scaling. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 104857600 +@@ -2744,7 +2744,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of mutex instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2754,7 +2754,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented MUTEX objects. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 104857600 +@@ -2764,7 +2764,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PREPARED_STATEMENTS_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented prepared statements. Use 0 to disable, -1 for automated scaling. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2774,7 +2774,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_PROGRAM_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented programs. Use 0 to disable, -1 for automated scaling. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2784,7 +2784,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of rwlock instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2794,7 +2794,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented RWLOCK objects. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 104857600 +@@ -2804,7 +2804,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of socket instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2814,7 +2814,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SOCKET_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of opened instrumented sockets. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2824,7 +2824,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_SQL_TEXT_LENGTH + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum length of displayed sql text. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 1048576 +@@ -2834,7 +2834,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STAGE_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of stage instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2844,7 +2844,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of statement instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2854,7 +2854,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_STACK + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of rows per thread in EVENTS_STATEMENTS_CURRENT. + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 256 +@@ -2864,7 +2864,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of opened instrumented tables. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2874,7 +2874,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented tables. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2884,7 +2884,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_TABLE_LOCK_STAT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of lock statistics for instrumented tables. Use 0 to disable, -1 for automated scaling. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2894,7 +2894,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of thread instruments. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 256 +@@ -2904,7 +2904,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented threads. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2914,7 +2914,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_SESSION_CONNECT_ATTRS_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Size of session attribute string buffer per thread. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2924,7 +2924,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_ACTORS_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of rows in SETUP_ACTORS. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1024 +@@ -2934,7 +2934,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of rows in SETUP_OBJECTS. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2944,7 +2944,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PERFORMANCE_SCHEMA_USERS_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT ++VARIABLE_TYPE INT + VARIABLE_COMMENT Maximum number of instrumented users. Use 0 to disable, -1 for automated sizing. + NUMERIC_MIN_VALUE -1 + NUMERIC_MAX_VALUE 1048576 +@@ -2994,7 +2994,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PRELOAD_BUFFER_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The size of the buffer that is allocated when preloading indexes + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 1073741824 +@@ -3014,7 +3014,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME PROFILING_HISTORY_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of statements about which profiling information is maintained. If set to 0, no profiles are stored. See SHOW PROFILES. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 100 +@@ -3024,7 +3024,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME PROGRESS_REPORT_TIME + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Seconds between sending progress reports to the client for time-consuming statements. Set to 0 to disable progress reporting. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -3084,7 +3084,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME QUERY_ALLOC_BLOCK_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Allocation block size for query parsing and execution + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 4294967295 +@@ -3094,7 +3094,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME QUERY_CACHE_LIMIT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Don't cache results that are bigger than this + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -3104,7 +3104,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME QUERY_CACHE_MIN_RES_UNIT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The minimum size for blocks allocated by the query cache + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -3117,7 +3117,7 @@ + VARIABLE_TYPE BIGINT UNSIGNED + VARIABLE_COMMENT The memory allocated to store results from old queries + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1024 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -3154,7 +3154,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME QUERY_PREALLOC_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Persistent buffer for query parsing and execution + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 4294967295 +@@ -3167,7 +3167,7 @@ + VARIABLE_TYPE BIGINT UNSIGNED + VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -3177,14 +3177,14 @@ + VARIABLE_TYPE BIGINT UNSIGNED + VARIABLE_COMMENT Sets the internal state of the RAND() generator for replication purposes + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME RANGE_ALLOC_BLOCK_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Allocation block size for storing ranges during optimization + NUMERIC_MIN_VALUE 4096 + NUMERIC_MAX_VALUE 4294967295 +@@ -3197,14 +3197,14 @@ + VARIABLE_TYPE BIGINT UNSIGNED + VARIABLE_COMMENT Maximum speed(KB/s) to read binlog from master (0 = no limit) + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME READ_BUFFER_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value + NUMERIC_MIN_VALUE 8192 + NUMERIC_MAX_VALUE 2147483647 +@@ -3224,7 +3224,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME READ_RND_BUFFER_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 2147483647 +@@ -3434,10 +3434,10 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME ROWID_MERGE_BUFF_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The size of the buffers used [NOT] IN evaluation via partial matching + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 9223372036854775807 ++NUMERIC_MAX_VALUE 2147483647 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -3454,20 +3454,20 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME RPL_SEMI_SYNC_MASTER_TIMEOUT + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The timeout value (in ms) for semi-synchronous replication in the master + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME RPL_SEMI_SYNC_MASTER_TRACE_LEVEL + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The tracing level for semi-sync replication. + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -3524,10 +3524,10 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME RPL_SEMI_SYNC_SLAVE_TRACE_LEVEL + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The tracing level for semi-sync replication. + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -3564,7 +3564,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME SERVER_ID + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Uniquely identifies the server instance in the community of replication partners + NUMERIC_MIN_VALUE 1 + NUMERIC_MAX_VALUE 4294967295 +@@ -3694,7 +3694,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME SLAVE_DOMAIN_PARALLEL_THREADS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Maximum number of parallel threads to use on slave for events in a single replication domain. When using multiple domains, this can be used to limit a single domain from grabbing all threads and thus stalling other domains. The default of 0 means to allow a domain to grab as many threads as it wants, up to the value of slave_parallel_threads. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 16383 +@@ -3724,7 +3724,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME SLAVE_MAX_ALLOWED_PACKET + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The maximum packet length to sent successfully from the master to slave. + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 1073741824 +@@ -3744,7 +3744,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME SLAVE_PARALLEL_MAX_QUEUED + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Limit on how much memory SQL threads should use per parallel replication thread when reading ahead in the relay log looking for opportunities for parallel replication. Only used when --slave-parallel-threads > 0. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 2147483647 +@@ -3764,7 +3764,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME SLAVE_PARALLEL_THREADS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If non-zero, number of threads to spawn to apply in parallel events on the slave that were group-committed on the master or were logged with GTID in different replication domains. Note that these threads are in addition to the IO and SQL threads, which are always created by a replication slave + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 16383 +@@ -3774,7 +3774,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME SLAVE_PARALLEL_WORKERS + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Alias for slave_parallel_threads + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 16383 +@@ -3814,7 +3814,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME SLAVE_TRANSACTION_RETRIES + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Number of times the slave SQL thread will retry a transaction in case it failed with a deadlock, elapsed lock wait timeout or listed in slave_transaction_retry_errors, before giving up and stopping + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 4294967295 +@@ -3834,7 +3834,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME SLAVE_TRANSACTION_RETRY_INTERVAL + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Interval of the slave SQL thread will retry a transaction in case it failed with a deadlock or elapsed lock wait timeout or listed in slave_transaction_retry_errors + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 3600 +@@ -3854,7 +3854,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME SLOW_LAUNCH_TIME + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 31536000 +@@ -4124,7 +4124,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME STORED_PROGRAM_CACHE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The soft upper limit for number of cached stored routines for one connection. + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 524288 +@@ -4224,7 +4224,7 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME TABLE_DEFINITION_CACHE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of cached table definitions + NUMERIC_MIN_VALUE 400 + NUMERIC_MAX_VALUE 2097152 +@@ -4234,7 +4234,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME TABLE_OPEN_CACHE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of cached open tables + NUMERIC_MIN_VALUE 10 + NUMERIC_MAX_VALUE 1048576 +@@ -4294,7 +4294,7 @@ + COMMAND_LINE_ARGUMENT OPTIONAL + VARIABLE_NAME THREAD_CACHE_SIZE + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time + NUMERIC_MIN_VALUE 0 + NUMERIC_MAX_VALUE 16384 +@@ -4352,6 +4352,26 @@ + ENUM_VALUE_LIST NULL + READ_ONLY NO + COMMAND_LINE_ARGUMENT REQUIRED ++VARIABLE_NAME THREAD_POOL_MIN_THREADS ++VARIABLE_SCOPE GLOBAL ++VARIABLE_TYPE INT UNSIGNED ++VARIABLE_COMMENT Minimum number of threads in the thread pool. ++NUMERIC_MIN_VALUE 1 ++NUMERIC_MAX_VALUE 256 ++NUMERIC_BLOCK_SIZE 1 ++ENUM_VALUE_LIST NULL ++READ_ONLY NO ++COMMAND_LINE_ARGUMENT REQUIRED ++VARIABLE_NAME THREAD_POOL_MODE ++VARIABLE_SCOPE GLOBAL ++VARIABLE_TYPE ENUM ++VARIABLE_COMMENT Chose implementation of the threadpool ++NUMERIC_MIN_VALUE NULL ++NUMERIC_MAX_VALUE NULL ++NUMERIC_BLOCK_SIZE NULL ++ENUM_VALUE_LIST windows,generic ++READ_ONLY YES ++COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME THREAD_POOL_OVERSUBSCRIBE + VARIABLE_SCOPE GLOBAL + VARIABLE_TYPE INT UNSIGNED +@@ -4455,7 +4475,7 @@ + VARIABLE_NAME TMPDIR + VARIABLE_SCOPE GLOBAL + VARIABLE_TYPE VARCHAR +-VARIABLE_COMMENT Path for temporary files. Several paths may be specified, separated by a colon (:), in this case they are used in a round-robin fashion ++VARIABLE_COMMENT Path for temporary files. Several paths may be specified, separated by a semicolon (;), in this case they are used in a round-robin fashion + NUMERIC_MIN_VALUE NULL + NUMERIC_MAX_VALUE NULL + NUMERIC_BLOCK_SIZE NULL +@@ -4494,7 +4514,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME TRANSACTION_ALLOC_BLOCK_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Allocation block size for transactions to be stored in binary log + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 134217728 +@@ -4504,7 +4524,7 @@ + COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME TRANSACTION_PREALLOC_SIZE + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Persistent buffer for transactions to be stored in binary log + NUMERIC_MIN_VALUE 1024 + NUMERIC_MAX_VALUE 134217728 +@@ -4644,10 +4664,10 @@ + COMMAND_LINE_ARGUMENT NULL + VARIABLE_NAME WAIT_TIMEOUT + VARIABLE_SCOPE SESSION +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT The number of seconds the server waits for activity on a connection before closing it + NUMERIC_MIN_VALUE 1 +-NUMERIC_MAX_VALUE 31536000 ++NUMERIC_MAX_VALUE 2147483 + NUMERIC_BLOCK_SIZE 1 + ENUM_VALUE_LIST NULL + READ_ONLY NO +@@ -4671,7 +4691,7 @@ + VARIABLE_NAME LOG_TC_SIZE + GLOBAL_VALUE_ORIGIN AUTO + VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BIGINT UNSIGNED ++VARIABLE_TYPE INT UNSIGNED + VARIABLE_COMMENT Size of transaction coordinator log. + ENUM_VALUE_LIST NULL + READ_ONLY YES diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 9cac0f0dd5a..2740319dd05 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -2562,6 +2562,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_COMMENT Unused, will be removed. +NUMERIC_MIN_VALUE 0 +NUMERIC_MAX_VALUE 2 +NUMERIC_BLOCK_SIZE 1 +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_DISK_READ_COST VARIABLE_SCOPE GLOBAL VARIABLE_TYPE DOUBLE @@ -3765,7 +3775,7 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME RPL_SEMI_SYNC_MASTER_WAIT_NO_SLAVE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Wait until timeout when no semi-synchronous replication slave available (enabled by default). +VARIABLE_COMMENT Wait until timeout when no semi-synchronous replication slave is available. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index 65a391828b2..b3357fda3af 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE experimental +DEFAULT_VALUE beta VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded diff --git a/mysql-test/suite/sys_vars/t/sysvars_star.test b/mysql-test/suite/sys_vars/t/sysvars_star.test index 8d0aefdc4c7..f1d1c137109 100644 --- a/mysql-test/suite/sys_vars/t/sysvars_star.test +++ b/mysql-test/suite/sys_vars/t/sysvars_star.test @@ -15,7 +15,7 @@ set global low_priority_updates=1; install soname 'sql_errlog'; vertical_results; -replace_regex /\/.*\//var\//; +replace_regex /(C:)?\/.*\//var\//; select * from information_schema.system_variables where variable_name in ( 'completion_type', #session!=global, origin=compile-time @@ -32,7 +32,7 @@ create user foo@localhost; connect foo,localhost,foo; select global_value_path from information_schema.system_variables where variable_name='plugin_maturity'; connection default; -replace_regex /\/.*\//var\//; +replace_regex /(C:)?\/.*\//var\//; select global_value_path from information_schema.system_variables where variable_name='plugin_maturity'; disconnect foo; drop user foo@localhost; diff --git a/mysql-test/suite/versioning/r/cte.result b/mysql-test/suite/versioning/r/cte.result index 11d478ac456..4a9eba56006 100644 --- a/mysql-test/suite/versioning/r/cte.result +++ b/mysql-test/suite/versioning/r/cte.result @@ -40,7 +40,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 UNION e ALL NULL NULL NULL NULL 4 100.00 Using where NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` +Note 1003 with ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu')/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` select row_start into @ts_2 from emp where name="john"; explain extended /* All report to 'Bill' */ with recursive @@ -64,7 +64,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 RECURSIVE UNION ref key0 key0 5 test.e.mgr 1 100.00 NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` +Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu')/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` /* All report to 'Bill' */ with recursive ancestors @@ -105,7 +105,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 RECURSIVE UNION ref key0 key0 5 test.e.mgr 1 100.00 NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` +Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu')/* select#1 */ select `ancestors`.`emp_id` AS `emp_id`,`ancestors`.`name` AS `name`,`ancestors`.`mgr` AS `mgr`,`ancestors`.`salary` AS `salary` from `ancestors` with recursive ancestors as @@ -146,7 +146,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 RECURSIVE UNION ref key0 key0 5 test.e.mgr 1 100.00 NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `test`.`emp`.`name` AS `name` from `test`.`emp` semi join (`ancestors`) where `ancestors`.`emp_id` = `test`.`emp`.`emp_id` and `test`.`emp`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999' +Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME AS OF TIMESTAMP @`ts_1` `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`e`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu')/* select#1 */ select `test`.`emp`.`name` AS `name` from `test`.`emp` semi join (`ancestors`) where `ancestors`.`emp_id` = `test`.`emp`.`emp_id` and `test`.`emp`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999' with recursive ancestors as diff --git a/mysql-test/suite/versioning/r/derived.result b/mysql-test/suite/versioning/r/derived.result index 700c92a8d5c..50cfb4020d0 100644 --- a/mysql-test/suite/versioning/r/derived.result +++ b/mysql-test/suite/versioning/r/derived.result @@ -211,12 +211,12 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) Query A: -Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t2`.`row_end` > (current_timestamp(6)) and `test`.`t2`.`row_start` <= (current_timestamp(6)) and `test`.`t1`.`row_end` > (current_timestamp(6)) and `test`.`t1`.`row_start` <= (current_timestamp(6)) +Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t2`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t2`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) Query B: -Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t2`.`row_end` > (current_timestamp(6)) and `test`.`t2`.`row_start` <= (current_timestamp(6)) and `test`.`t1`.`row_end` > (current_timestamp(6)) and `test`.`t1`.`row_start` <= (current_timestamp(6)) +Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP current_timestamp(6) where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t2`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t2`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' Fine result: queries A and B are equal. ## LEFT JOIN: t1, t2 versioned select * from ( diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result index 36ea54bb08e..c4e8df1a743 100644 --- a/mysql-test/suite/versioning/r/select.result +++ b/mysql-test/suite/versioning/r/select.result @@ -155,21 +155,21 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`x` AS `IJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t2`.`row_end` > @`t0` and `test`.`t2`.`row_start` <= @`t0` and `test`.`t1`.`row_end` > @`t0` and `test`.`t1`.`row_start` <= @`t0` +Note 1003 select `test`.`t1`.`x` AS `IJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t2`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t2`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' explain extended select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x) for system_time as of timestamp @t0 as t; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`x` AS `LJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` left join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t2`.`row_end` > @`t0` and `test`.`t2`.`row_start` <= @`t0`) where `test`.`t1`.`row_end` > @`t0` and `test`.`t1`.`row_start` <= @`t0` +Note 1003 select `test`.`t1`.`x` AS `LJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` left join `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t2`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t2`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu') where `test`.`t1`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' explain extended select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x) for system_time as of timestamp @t0 as t; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`x` AS `RJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` left join `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` on(`test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`row_end` > @`t0` and `test`.`t1`.`row_start` <= @`t0`) where `test`.`t2`.`row_end` > @`t0` and `test`.`t2`.`row_start` <= @`t0` +Note 1003 select `test`.`t1`.`x` AS `RJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t2` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` left join `test`.`t1` FOR SYSTEM_TIME AS OF TIMESTAMP @`t0` on(`test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t1`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu') where `test`.`t2`.`row_end` > TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' and `test`.`t2`.`row_start` <= TIMESTAMP/*WITH LOCAL TIME ZONE*/'YYYY-MM-DD hh:ss:mm:.uuuuuu' select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x) for system_time as of timestamp @t0 as t; IJ2_x1 y1 x2 y2 diff --git a/mysql-test/suite/versioning/t/cte.test b/mysql-test/suite/versioning/t/cte.test index 025e1b2319d..f57f7d14cef 100644 --- a/mysql-test/suite/versioning/t/cte.test +++ b/mysql-test/suite/versioning/t/cte.test @@ -5,6 +5,8 @@ if (`SELECT $PS_PROTOCOL != 0`) --source include/have_innodb.inc --source include/default_optimizer_switch.inc +--let $replace_regex_tsltz6= /TIMESTAMP..WITH LOCAL TIME ZONE..'....-..-.. ..:..:..[.]......'/TIMESTAMP\/*WITH LOCAL TIME ZONE*\/'YYYY-MM-DD hh:ss:mm:.uuuuuu'/ + SET @saved_stats_persistent = @@GLOBAL.innodb_stats_persistent; SET GLOBAL innodb_stats_persistent = OFF; @@ -42,6 +44,7 @@ select row_start into @ts_1 from emp where name="jane"; update emp set mgr=30 where name ="john"; +--replace_regex $replace_regex_tsltz6 explain extended with ancestors as ( select e.emp_id, e.name, e.mgr, e.salary from emp as e where name = 'bill' @@ -68,6 +71,7 @@ as ) select * from ancestors; +--replace_regex $replace_regex_tsltz6 eval explain extended $q; eval $q; @@ -86,6 +90,7 @@ as ) select * from ancestors for system_time as of timestamp @ts_1; +--replace_regex $replace_regex_tsltz6 eval explain extended $q; eval $q; @@ -104,6 +109,7 @@ as ) select name from emp where emp_id in (select emp_id from ancestors for system_time as of timestamp @ts_1); +--replace_regex $replace_regex_tsltz6 eval explain extended $q; eval $q; diff --git a/mysql-test/suite/versioning/t/derived.test b/mysql-test/suite/versioning/t/derived.test index 9d96856f01f..f599ede97c1 100644 --- a/mysql-test/suite/versioning/t/derived.test +++ b/mysql-test/suite/versioning/t/derived.test @@ -1,5 +1,7 @@ --source include/default_optimizer_switch.inc +--let $replace_regex_tsltz6= /TIMESTAMP..WITH LOCAL TIME ZONE..'....-..-.. ..:..:..[.]......'/TIMESTAMP\/*WITH LOCAL TIME ZONE*\/'YYYY-MM-DD hh:ss:mm:.uuuuuu'/ + create table emp ( emp_id int, @@ -164,6 +166,7 @@ select * from ( select t1.x, t1.y as y1, t2.x as x2, t2.y as y2 from t1 join t2 on t1.x = t2.x) for system_time as of now() as t; +--replace_regex $replace_regex_tsltz6 let $a=`show warnings`; --echo Query A: echo $a; @@ -174,6 +177,7 @@ select * from ( from t1 for system_time as of now() join t2 for system_time as of now() on t1.x = t2.x) as t; +--replace_regex $replace_regex_tsltz6 let $b=`show warnings`; --echo Query B: echo $b; diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index 5603d1a3a12..b9a836f708e 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -6,6 +6,8 @@ if (`SELECT $PS_PROTOCOL != 0`) --source suite/versioning/common.inc --source include/default_optimizer_switch.inc +--let $replace_regex_tsltz6= /TIMESTAMP..WITH LOCAL TIME ZONE..'....-..-.. ..:..:..[.]......'/TIMESTAMP\/*WITH LOCAL TIME ZONE*\/'YYYY-MM-DD hh:ss:mm:.uuuuuu'/ + SET @saved_stats_persistent = @@GLOBAL.innodb_stats_persistent; SET GLOBAL innodb_stats_persistent = OFF; @@ -98,11 +100,14 @@ delete from t1; delete from t2; #384 +--replace_regex $replace_regex_tsltz6 explain extended select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x) for system_time as of timestamp @t0 as t; +--replace_regex $replace_regex_tsltz6 explain extended select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x) for system_time as of timestamp @t0 as t; #383 +--replace_regex $replace_regex_tsltz6 explain extended select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x) for system_time as of timestamp @t0 as t; diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 729a18d4e13..de9828069ef 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -1737,9 +1737,6 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) error,errno); exit(1); } -#endif -#ifdef HAVE_THR_SETCONCURRENCY - (void) thr_setconcurrency(2); #endif for (i=0 ; i < array_elements(lock_counts) ; i++) { diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index aca1c1f7731..8714a7a6003 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -667,6 +667,7 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp) my_hash_free(mp->used_mutex); my_hash_free(mp->locked_mutex); my_free(mp->locked_mutex); + mp->locked_mutex= 0; mp->create_flags|= MYF_NO_DEADLOCK_DETECTION; } } diff --git a/mysys/thr_timer.c b/mysys/thr_timer.c index f87c1f75555..d3627fea983 100644 --- a/mysys/thr_timer.c +++ b/mysys/thr_timer.c @@ -533,7 +533,6 @@ static void run_test() mysql_mutex_init(0, &LOCK_thread_count, MY_MUTEX_INIT_FAST); mysql_cond_init(0, &COND_thread_count, NULL); - thr_setconcurrency(3); pthread_attr_init(&thr_attr); pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS); printf("Main thread: %s\n",my_thread_name()); diff --git a/plugin/auth_pam/testing/pam_mariadb_mtr.c b/plugin/auth_pam/testing/pam_mariadb_mtr.c index 108aeb941ac..de34f5d8866 100644 --- a/plugin/auth_pam/testing/pam_mariadb_mtr.c +++ b/plugin/auth_pam/testing/pam_mariadb_mtr.c @@ -10,8 +10,8 @@ #include #include -#include #include +#include #define N 3 diff --git a/plugin/disks/CMakeLists.txt b/plugin/disks/CMakeLists.txt index e4cf0dc1de3..408a4324d1b 100644 --- a/plugin/disks/CMakeLists.txt +++ b/plugin/disks/CMakeLists.txt @@ -5,6 +5,8 @@ CHECK_SYMBOL_EXISTS (getmntent "sys/mnttab.h" HAVE_GETMNTENT_IN_SYS_MNTAB) CHECK_SYMBOL_EXISTS (setmntent "mntent.h" HAVE_SETMNTENT) CHECK_SYMBOL_EXISTS (getmntinfo "sys/types.h;sys/mount.h" HAVE_GETMNTINFO) +CHECK_INCLUDE_FILES (sys/mntent.h HAVE_SYS_MNTENT_H) + IF (HAVE_GETMNTINFO) CHECK_CXX_SOURCE_COMPILES(" #include diff --git a/plugin/disks/information_schema_disks.cc b/plugin/disks/information_schema_disks.cc index 18195b91044..01df32590eb 100644 --- a/plugin/disks/information_schema_disks.cc +++ b/plugin/disks/information_schema_disks.cc @@ -19,7 +19,7 @@ #include #if defined(HAVE_GETMNTENT) #include -#elif !defined(HAVE_GETMNTINFO_TAKES_statvfs) +#elif defined(HAVE_GETMNTINFO) && !defined(HAVE_GETMNTINFO_TAKES_statvfs) /* getmntinfo (the not NetBSD variants) */ #include #include @@ -28,6 +28,9 @@ #if defined(HAVE_GETMNTENT_IN_SYS_MNTAB) #include #define HAVE_GETMNTENT +#if defined(HAVE_SYS_MNTENT_H) +#include +#endif #endif #include #include diff --git a/plugin/feedback/CMakeLists.txt b/plugin/feedback/CMakeLists.txt index 2103250e5a6..fc35cbadc31 100644 --- a/plugin/feedback/CMakeLists.txt +++ b/plugin/feedback/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS}) SET(FEEDBACK_SOURCES feedback.cc sender_thread.cc diff --git a/plugin/file_key_management/parser.cc b/plugin/file_key_management/parser.cc index 57e0139a57d..a7b39f0ad16 100644 --- a/plugin/file_key_management/parser.cc +++ b/plugin/file_key_management/parser.cc @@ -260,7 +260,7 @@ int Parser::parse_line(char **line_ptr, keyentry *key) while (isdigit(*p)) { id = id * 10 + *p - '0'; - if (id > UINT_MAX32) + if (id > (longlong) UINT_MAX32) { report_error("Invalid key id", p - *line_ptr); return -1; diff --git a/plugin/qc_info/CMakeLists.txt b/plugin/qc_info/CMakeLists.txt index b8c5f926cff..329f49c1fc9 100644 --- a/plugin/qc_info/CMakeLists.txt +++ b/plugin/qc_info/CMakeLists.txt @@ -1,4 +1,4 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES}) + ${PCRE_INCLUDE_DIRS}) MYSQL_ADD_PLUGIN(QUERY_CACHE_INFO qc_info.cc RECOMPILE_FOR_EMBEDDED) diff --git a/plugin/sql_errlog/sql_errlog.c b/plugin/sql_errlog/sql_errlog.c index 0b7771f1b89..3631cd1d849 100644 --- a/plugin/sql_errlog/sql_errlog.c +++ b/plugin/sql_errlog/sql_errlog.c @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -40,6 +41,7 @@ static unsigned long long size_limit; static unsigned int rotations; static char rotate; static char warnings; +static char with_db_and_thread_info; static unsigned int count; LOGGER_HANDLE *logfile; @@ -73,6 +75,12 @@ static MYSQL_SYSVAR_BOOL(warnings, warnings, "Warnings. If set to 0, warnings are not logged.", NULL, NULL, 1); +static MYSQL_SYSVAR_BOOL(with_db_and_thread_info, with_db_and_thread_info, + PLUGIN_VAR_READONLY | PLUGIN_VAR_OPCMDARG, + "Show details about thread id and database name in the log", + NULL, NULL, + 0); + static struct st_mysql_sys_var* vars[] = { MYSQL_SYSVAR(rate), MYSQL_SYSVAR(size_limit), @@ -80,6 +88,7 @@ static struct st_mysql_sys_var* vars[] = { MYSQL_SYSVAR(rotate), MYSQL_SYSVAR(filename), MYSQL_SYSVAR(warnings), + MYSQL_SYSVAR(with_db_and_thread_info), NULL }; @@ -90,6 +99,7 @@ static void log_sql_errors(MYSQL_THD thd __attribute__((unused)), { const struct mysql_event_general *event = (const struct mysql_event_general*)ev; + if (rate && (event->event_subclass == MYSQL_AUDIT_GENERAL_ERROR || (warnings && event->event_subclass == MYSQL_AUDIT_GENERAL_WARNING))) @@ -103,12 +113,35 @@ static void log_sql_errors(MYSQL_THD thd __attribute__((unused)), count = 0; (void) localtime_r(&event_time, &t); - logger_printf(logfile, "%04d-%02d-%02d %2d:%02d:%02d " + if (with_db_and_thread_info) + { + if (event->database.str) + { + logger_printf(logfile, "%04d-%02d-%02d %2d:%02d:%02d %lu " + "%s %`s %s %d: %s : %s \n", + t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, + t.tm_sec, event->general_thread_id, event->general_user, + event->database.str, type, + event->general_error_code, event->general_command, event->general_query); + } + else + { + logger_printf(logfile, "%04d-%02d-%02d %2d:%02d:%02d %lu " + "%s NULL %s %d: %s : %s \n", + t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, + t.tm_sec, event->general_thread_id, event->general_user, type, + event->general_error_code, event->general_command, event->general_query); + } + } + else + { + logger_printf(logfile, "%04d-%02d-%02d %2d:%02d:%02d " "%s %s %d: %s : %s\n", - t.tm_year + 1900, t.tm_mon + 1, - t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, - event->general_user, type, event->general_error_code, - event->general_command, event->general_query); + t.tm_year + 1900, t.tm_mon + 1, + t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, + event->general_user, type, event->general_error_code, + event->general_command, event->general_query); + } } } } @@ -167,7 +200,7 @@ maria_declare_plugin(sql_errlog) 0x0100, NULL, vars, - "1.0", + "1.1", MariaDB_PLUGIN_MATURITY_STABLE } maria_declare_plugin_end; diff --git a/plugin/type_mysql_json/type.cc b/plugin/type_mysql_json/type.cc index a39c4ad2006..331e3bb26ab 100644 --- a/plugin/type_mysql_json/type.cc +++ b/plugin/type_mysql_json/type.cc @@ -37,6 +37,11 @@ public: Field *make_table_field(MEM_ROOT *, const LEX_CSTRING *, const Record_addr &, const Type_all_attributes &, TABLE_SHARE *) const override; + bool Column_definition_fix_attributes(Column_definition *c) const override + { + my_error(ER_NOT_ALLOWED_IN_THIS_CONTEXT, MYF(0), "MYSQL_JSON"); + return true; + } void Column_definition_reuse_fix_attributes(THD *thd, Column_definition *def, const Field *field) const override; @@ -74,7 +79,7 @@ public: bool parse_mysql(String *dest, const char *data, size_t length) const; bool send(Protocol *protocol) { return Field::send(protocol); } void sql_type(String &s) const - { s.set_ascii(STRING_WITH_LEN("json /* MySQL 5.7 */")); } + { s.set_ascii(STRING_WITH_LEN("mysql_json /* JSON from MySQL 5.7 */")); } /* this will make ALTER TABLE to consider it different from built-in field */ Compression_method *compression_method() const { return (Compression_method*)1; } }; diff --git a/plugin/user_variables/user_variables.cc b/plugin/user_variables/user_variables.cc index df2ab4af1f8..79c96704354 100644 --- a/plugin/user_variables/user_variables.cc +++ b/plugin/user_variables/user_variables.cc @@ -79,9 +79,9 @@ static int user_variables_fill(THD *thd, TABLE_LIST *tables, COND *cond) else return 1; - const LEX_CSTRING *tmp= var->unsigned_flag ? - &unsigned_result_types[var->type] : - &result_types[var->type]; + const LEX_CSTRING *tmp= var->type_handler()->is_unsigned() ? + &unsigned_result_types[var->type_handler()->result_type()] : + &result_types[var->type_handler()->result_type()]; field[2]->store(tmp->str, tmp->length, system_charset_info); if (var->charset()) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 55d59f315ac..ed54fbd5fd3 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -701,7 +701,7 @@ then then echo echo "You can start the MariaDB daemon with:" - echo "cd '$basedir' ; $bindir/mariadb-safe --datadir='$ldata'" + echo "cd '$basedir' ; $bindir/mariadbd-safe --datadir='$ldata'" echo echo "You can test the MariaDB daemon with mariadb-test-run.pl" echo "cd '$basedir/@INSTALL_MYSQLTESTDIR@' ; perl mariadb-test-run.pl" diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 0802cf0614a..44dfe5e4935 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -42,7 +42,7 @@ trap '' 1 2 3 15 # we shouldn't let anyone kill us case "$0" in *mysqld_safe) - echo "$0: Deprecated program name. It will be removed in a future release, use 'mariadb-safe' instead" 1>&2 + echo "$0: Deprecated program name. It will be removed in a future release, use 'mariadbd-safe' instead" 1>&2 ;; esac diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index a4445612beb..177cbf52c6a 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -192,21 +192,38 @@ $opt{quiet} = 0 if $opt{debug}; $opt{allowold} = 1 if $opt{keepold}; # --- connect to the database --- +## Socket takes precedence. my $dsn; -$dsn = ";host=" . (defined($opt{host}) ? $opt{host} : "localhost"); -$dsn .= ";port=$opt{port}" if $opt{port}; -$dsn .= ";mariadb_socket=$opt{socket}" if $opt{socket}; +my $prefix= 'mysql'; + +if (eval {DBI->install_driver("MariaDB")}) { + $dsn ="DBI:MariaDB:;"; + $prefix= 'mariadb'; +} +else { + $dsn = "DBI:mysql:;"; +} + +if ($opt{socket} and -S $opt{socket}) +{ + $dsn .= "${prefix}_socket=$opt{socket}"; +} +else +{ + $dsn .= "host=" . $opt{host}; + if ($opt{host} ne "localhost") + { + $dsn .= ";port=". $opt{port}; + } +} + +$dsn .= ";mariadb_read_default_group=mysqlhotcopy"; # use mariadb_read_default_group=mysqlhotcopy so that [client] and # [mysqlhotcopy] groups will be read from standard options files. - -my $dbh = DBI->connect("DBI:MariaDB:$dsn;mariadb_read_default_group=mysqlhotcopy", - $opt{user}, $opt{password}, -{ - RaiseError => 1, - PrintError => 0, - AutoCommit => 1, -}); +# make the connection to MariaDB +my $dbh= DBI->connect($dsn, $opt{user}, $opt{password}, { RaiseError => 1, PrintError => 0}) || + die("Can't make a connection to the MariaDB server.\n The error: $DBI::errstr"); # --- check that checkpoint table exists if specified --- if ( $opt{checkpoint} ) { @@ -274,6 +291,8 @@ if ( defined $opt{regexp} ) { $sth_dbs->execute; while ( my ($db_name) = $sth_dbs->fetchrow_array ) { next if $db_name =~ m/^information_schema$/i; + next if $db_name =~ m/^performance_schema$/i; + next if $db_name =~ m/^sys$/i; push @db_desc, { 'src' => $db_name, 't_regex' => $t_regex } if ( $db_name =~ m/$opt{regexp}/o ); } } diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index bf96f79e15e..2b540581253 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -1166,9 +1166,9 @@ is_local_ip() # the domain name check: if [ "${2:-0}" -eq 0 ]; then # We consider all the names of a given host to be local addresses: - [ "$1" = "$(hostname -s)" -o \ - "$1" = "$(hostname -f)" -o \ - "$1" = "$(hostname -d)" ] && return 0 + [ "$1" = "$(hostname -s 2>/dev/null)" -o \ + "$1" = "$(hostname -f 2>/dev/null)" -o \ + "$1" = "$(hostname -d 2>/dev/null)" ] && return 0 fi # If the address contains anything other than digits # and separators, it is not a local address: diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 4e0151a2cd0..aabf5bd325e 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -475,9 +475,9 @@ EOF # Preparing binlog files for transfer: wsrep_log_info "Preparing binlog files for transfer:" tar_type=0 - if tar --help | grep -qw -F -- '--transform'; then + if tar --help 2>/dev/null | grep -qw -F -- '--transform'; then tar_type=1 - elif tar --version | grep -qw -E '^bsdtar'; then + elif tar --version 2>/dev/null | grep -qw -E '^bsdtar'; then tar_type=2 fi if [ $tar_type -eq 2 ]; then @@ -980,7 +980,7 @@ EOF fi # Extracting binlog files: wsrep_log_info "Extracting binlog files:" - if tar --version | grep -qw -E '^bsdtar'; then + if tar --version 2>/dev/null | grep -qw -E '^bsdtar'; then tar -tf "$BINLOG_TAR_FILE" > "$tmpfile" && \ tar -xvf "$BINLOG_TAR_FILE" > /dev/null || RC=$? else diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 2c0082c59c9..38fa57694a6 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -57,7 +57,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${LIBFMT_INCLUDE_DIR} -${PCRE_INCLUDES} +${PCRE_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${SSL_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/sql @@ -186,6 +186,7 @@ SET (SQL_SOURCE table_cache.cc encryption.cc temporary_tables.cc json_table.cc proxy_protocol.cc backup.cc xa.cc + socketpair.c socketpair.h ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h ${GEN_SOURCES} diff --git a/sql/debug.cc b/sql/debug.cc index a24cc4e407e..38131232487 100644 --- a/sql/debug.cc +++ b/sql/debug.cc @@ -40,7 +40,8 @@ bool debug_decrement_counter(const LEX_CSTRING *name) THD *thd= current_thd; user_var_entry *entry= (user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name->str, name->length); - if (!entry || entry->type != INT_RESULT || ! entry->value) + if (!entry || !entry->value || + entry->type_handler()->result_type() != INT_RESULT) return 0; (*(ulonglong*) entry->value)= (*(ulonglong*) entry->value)-1; return !*(ulonglong*) entry->value; diff --git a/sql/field.cc b/sql/field.cc index 55d7597254c..35be045620d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7685,7 +7685,20 @@ int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) const a_ptr, field_length, b_ptr, field_length, Field_string::char_length(), - MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES); + 0); +} + + +int Field_string::cmp_prefix(const uchar *a_ptr, const uchar *b_ptr, + size_t prefix_char_len) const +{ + size_t field_len= table->field[field_index]->field_length; + + return field_charset()->coll->strnncollsp_nchars(field_charset(), + a_ptr, field_len, + b_ptr, field_len, + prefix_char_len, + 0); } diff --git a/sql/field.h b/sql/field.h index 2bd82d0e675..7f1c243a180 100644 --- a/sql/field.h +++ b/sql/field.h @@ -4093,6 +4093,8 @@ public: String *val_str(String *, String *) override; my_decimal *val_decimal(my_decimal *) override; int cmp(const uchar *,const uchar *) const override; + int cmp_prefix(const uchar *a, const uchar *b, size_t prefix_char_len) const + override; void sort_string(uchar *buff,uint length) override; void update_data_type_statistics(Data_type_statistics *st) const override { @@ -4115,9 +4117,6 @@ public: bool compatible_field_size(uint field_metadata, const Relay_log_info *rli, uint16 mflags, int *order_var) const override; uint row_pack_length() const override { return field_length; } - int pack_cmp(const uchar *a,const uchar *b,uint key_length, - bool insert_or_update); - int pack_cmp(const uchar *b,uint key_length,bool insert_or_update); uint packed_col_length(const uchar *to, uint length) override; uint max_packed_col_length(uint max_length) override; uint size_of() const override { return sizeof *this; } diff --git a/sql/handler.cc b/sql/handler.cc index 50a8ab37bfb..fec473d97bb 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1002,7 +1002,8 @@ static my_bool signal_ddl_recovery_done(THD *, plugin_ref plugin, void *) { handlerton *hton= plugin_hton(plugin); if (hton->signal_ddl_recovery_done) - (hton->signal_ddl_recovery_done)(hton); + if ((hton->signal_ddl_recovery_done)(hton)) + plugin_ref_to_int(plugin)->state= PLUGIN_IS_DELETED; return 0; } diff --git a/sql/handler.h b/sql/handler.h index 88959e55021..3b13166781d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1522,7 +1522,7 @@ struct handlerton const LEX_CUSTRING *version, ulonglong create_id); /* Called for all storage handlers after ddl recovery is done */ - void (*signal_ddl_recovery_done)(handlerton *hton); + int (*signal_ddl_recovery_done)(handlerton *hton); /* Called at startup to update default engine costs */ void (*update_optimizer_costs)(OPTIMIZER_COSTS *costs); diff --git a/sql/item.cc b/sql/item.cc index a1a5e5f3c28..54ad511cb6b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2673,7 +2673,10 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, return TRUE; if (!thd->stmt_arena->is_conventional() && - thd->lex->current_select->first_cond_optimization) + ((!thd->lex->current_select && + (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute() || + thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())) || + thd->lex->current_select->first_cond_optimization)) { Query_arena *arena, backup; arena= thd->activate_stmt_arena_if_needed(&backup); @@ -7049,7 +7052,25 @@ Item *Item_float::neg(THD *thd) else if (value < 0 && max_length) max_length--; value= -value; - presentation= 0; + if (presentation) + { + if (*presentation == '-') + { + // Strip double minus: -(-1) -> '1' instead of '--1' + presentation++; + } + else + { + size_t presentation_length= strlen(presentation); + if (char *tmp= (char*) thd->alloc(presentation_length + 2)) + { + tmp[0]= '-'; + // Copy with the trailing '\0' + memcpy(tmp + 1, presentation, presentation_length + 1); + presentation= tmp; + } + } + } name= null_clex_str; return this; } @@ -7332,6 +7353,17 @@ void Item_datetime_literal::print(String *str, enum_query_type query_type) } +void Item_timestamp_literal::print(String *str, enum_query_type query_type) +{ + str->append(STRING_WITH_LEN("TIMESTAMP/*WITH LOCAL TIME ZONE*/'")); + char buf[MAX_DATE_STRING_REP_LENGTH]; + Datetime dt= m_value.to_datetime(current_thd); + int length= my_datetime_to_str(dt.get_mysql_time(), buf, decimals); + str->append(buf, length); + str->append('\''); +} + + Item *Item_datetime_literal::clone_item(THD *thd) { return new (thd->mem_root) Item_datetime_literal(thd, &cached_time, decimals); diff --git a/sql/item.h b/sql/item.h index 16ba4514421..2d9cf135a80 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1016,6 +1016,19 @@ public: expressions with subqueries in the ORDER/GROUP clauses. */ String *val_str() { return val_str(&str_value); } + String *val_str_null_to_empty(String *to) + { + String *res= val_str(to); + if (res) + return res; + to->set_charset(collation.collation); + to->length(0); + return to; + } + String *val_str_null_to_empty(String *to, bool null_to_empty) + { + return null_to_empty ? val_str_null_to_empty(to) : val_str(to); + } virtual Item_func *get_item_func() { return NULL; } const MY_LOCALE *locale_from_val_str(); @@ -4479,6 +4492,13 @@ protected: MYSQL_TIME ltime; public: Item_datetime(THD *thd): Item_int(thd, 0) { unsigned_flag=0; } + Item_datetime(THD *thd, const Datetime &dt, decimal_digits_t dec) + :Item_int(thd, 0), + ltime(*dt.get_mysql_time()) + { + unsigned_flag= 0; + decimals= dec; + } int save_in_field(Field *field, bool no_conversions) override; longlong val_int() override; double val_real() override { return (double)val_int(); } @@ -5005,9 +5025,23 @@ class Item_timestamp_literal: public Item_literal public: Item_timestamp_literal(THD *thd) :Item_literal(thd) - { } + { + collation= DTCollation_numeric(); + } + Item_timestamp_literal(THD *thd, + const Timestamp_or_zero_datetime &value, + decimal_digits_t dec) + :Item_literal(thd), + m_value(value) + { + DBUG_ASSERT(value.is_zero_datetime() || + !value.to_timestamp().fraction_remainder(dec)); + collation= DTCollation_numeric(); + decimals= dec; + } const Type_handler *type_handler() const override { return &type_handler_timestamp2; } + void print(String *str, enum_query_type query_type) override; int save_in_field(Field *field, bool) override { Timestamp_or_zero_datetime_native native(m_value, decimals); @@ -5039,6 +5073,10 @@ public: { return m_value.to_native(to, decimals); } + const Timestamp_or_zero_datetime &value() const + { + return m_value; + } void set_value(const Timestamp_or_zero_datetime &value) { m_value= value; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b324a8f5e6a..d1891818cd6 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -392,6 +392,9 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item, This directly contradicts the manual (number and a string should be compared as doubles), but seems to provide more "intuitive" behavior in some cases (but less intuitive in others). + + This method should be moved to Type_handler::convert_item_for_comparison() + eventually. */ void Item_func::convert_const_compared_to_int_field(THD *thd) { @@ -412,6 +415,43 @@ void Item_func::convert_const_compared_to_int_field(THD *thd) } +bool Item_func::aggregate_args2_for_comparison_with_conversion( + THD *thd, + Type_handler_hybrid_field_type *th) +{ + DBUG_ASSERT(arg_count >= 2); + for (bool done= false ; !done ; ) + { + if (th->aggregate_for_comparison(func_name_cstring(), args, 2, false)) + return true; + if (thd->lex->is_ps_or_view_context_analysis()) + return false; + done= true; + for (uint subject= 0; subject < 2; subject++) + { + uint other_side= subject == 0 ? 1 : 0; + /* See comment in convert_const_to_int() */ + if (!args[subject]->with_sum_func() && + args[subject]->can_eval_in_optimize()) + { + Item *item= th->type_handler()->convert_item_for_comparison(thd, + args[subject], + args[other_side]); + if (!item) + return true; // An error happened, e.g. EOM + if (item != args[subject]) + { + thd->change_item_tree(&args[subject], item); + done= false; // Aggregate again, using the replacement item + break; + } + } + } + } + return false; +} + + /* Iterate through arguments and compare them to the original arguments in "old_args". If some argument was replaced: @@ -487,7 +527,7 @@ bool Item_bool_rowready_func2::fix_length_and_dec(THD *thd) Item_args old_args(args[0], args[1]); convert_const_compared_to_int_field(thd); Type_handler_hybrid_field_type tmp; - if (tmp.aggregate_for_comparison(func_name_cstring(), args, 2, false) || + if (aggregate_args2_for_comparison_with_conversion(thd, &tmp) || tmp.type_handler()->Item_bool_rowready_func2_fix_length_and_dec(thd, this)) { @@ -2804,7 +2844,10 @@ Item_func_nullif::fix_length_and_dec(THD *thd) set_maybe_null(); m_arg0= args[0]; convert_const_compared_to_int_field(thd); - if (cmp.set_cmp_func(thd, this, &args[0], &args[1], true/*set_null*/)) + Type_handler_hybrid_field_type tmp; + if (aggregate_args2_for_comparison_with_conversion(thd, &tmp) || + cmp.set_cmp_func(thd, this, tmp.type_handler(), + &args[0], &args[1], true/*set_null*/)) return true; /* A special code for EXECUTE..PREPARE. diff --git a/sql/item_create.cc b/sql/item_create.cc index b79a30b5d0d..1db89b24847 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -127,6 +127,19 @@ protected: }; +class Create_func_addmonths : public Create_func_arg2 +{ +public: + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); + + static Create_func_addmonths s_singleton; + +protected: + Create_func_addmonths() = default; + virtual ~Create_func_addmonths() = default; +}; + + class Create_func_aes_encrypt : public Create_native_func { public: @@ -274,6 +287,19 @@ protected: }; +class Create_func_collation : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_collation s_singleton; + +protected: + Create_func_collation() = default; + virtual ~Create_func_collation() = default; +}; + + class Create_func_chr : public Create_func_arg1 { public: @@ -361,6 +387,20 @@ protected: }; +class Create_func_coalesce : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, const LEX_CSTRING *name, + List *item_list); + + static Create_func_coalesce s_singleton; + +protected: + Create_func_coalesce() = default; + virtual ~Create_func_coalesce() = default; +}; + + class Create_func_compress : public Create_func_arg1 { public: @@ -488,6 +528,19 @@ protected: }; +class Create_func_database : public Create_func_arg0 +{ +public: + virtual Item *create_builder(THD *thd); + + static Create_func_database s_singleton; + +protected: + Create_func_database() = default; + virtual ~Create_func_database() = default; +}; + + class Create_func_nvl2 : public Create_func_arg3 { public: @@ -594,6 +647,22 @@ protected: }; +class Create_func_date_format : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, const LEX_CSTRING *name, + List *item_list); + + static Create_func_date_format s_singleton; + +protected: + Create_func_date_format() = default; + virtual ~Create_func_date_format() = default; +}; + + + + class Create_func_dayname : public Create_func_arg1 { public: @@ -1526,6 +1595,31 @@ protected: virtual ~Create_func_octet_length() = default; }; +class Create_func_old_password : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_old_password s_singleton; + +protected: + Create_func_old_password() = default; + virtual ~Create_func_old_password() = default; +}; + + +class Create_func_password : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_password s_singleton; + +protected: + Create_func_password() = default; + virtual ~Create_func_password() = default; +}; + #ifndef DBUG_OFF class Create_func_like_range_min : public Create_func_arg2 @@ -1774,6 +1868,32 @@ protected: }; +class Create_func_microsecond : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_microsecond s_singleton; + +protected: + Create_func_microsecond() = default; + virtual ~Create_func_microsecond() = default; +}; + + +class Create_func_mod : public Create_func_arg2 +{ +public: + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); + + static Create_func_mod s_singleton; + +protected: + Create_func_mod() = default; + virtual ~Create_func_mod() = default; +}; + + class Create_func_monthname : public Create_func_arg1 { public: @@ -1900,6 +2020,19 @@ protected: }; +class Create_func_quarter : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_quarter s_singleton; + +protected: + Create_func_quarter() = default; + virtual ~Create_func_quarter() = default; +}; + + class Create_func_quote : public Create_func_arg1 { public: @@ -1929,7 +2062,10 @@ protected: class Create_func_regexp_replace : public Create_func_arg3 { public: - virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); + Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) override + { + return new (thd->mem_root) Item_func_regexp_replace(thd, arg1, arg2, arg3); + } static Create_func_regexp_replace s_singleton; @@ -1938,6 +2074,28 @@ protected: virtual ~Create_func_regexp_replace() = default; }; +Create_func_regexp_replace Create_func_regexp_replace::s_singleton; + + +class Create_func_regexp_replace_oracle : public Create_func_arg3 +{ +public: + Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) override + { + return new (thd->mem_root) Item_func_regexp_replace_oracle(thd, arg1, + arg2, arg3); + } + + static Create_func_regexp_replace_oracle s_singleton; + +protected: + Create_func_regexp_replace_oracle() = default; + virtual ~Create_func_regexp_replace_oracle() = default; +}; + +Create_func_regexp_replace_oracle + Create_func_regexp_replace_oracle::s_singleton; + class Create_func_regexp_substr : public Create_func_arg2 { @@ -2054,6 +2212,19 @@ protected: }; +class Create_func_row_count : public Create_func_arg0 +{ +public: + virtual Item *create_builder(THD *thd); + + static Create_func_row_count s_singleton; + +protected: + Create_func_row_count() = default; + virtual ~Create_func_row_count() = default; +}; + + class Create_func_rpad : public Create_native_func { public: @@ -2501,6 +2672,20 @@ protected: }; +class Create_func_week : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, const LEX_CSTRING *name, + List *item_list); + + static Create_func_week s_singleton; + +protected: + Create_func_week() = default; + virtual ~Create_func_week() = default; +}; + + class Create_func_weekday : public Create_func_arg1 { public: @@ -2980,6 +3165,16 @@ Create_func_addtime::create_2_arg(THD *thd, Item *arg1, Item *arg2) } +Create_func_addmonths Create_func_addmonths::s_singleton; + +Item* +Create_func_addmonths::create_2_arg(THD *thd, Item *arg1, Item *arg2) +{ + return new (thd->mem_root) + Item_date_add_interval(thd, arg1, arg2, INTERVAL_MONTH, false); +} + + Create_func_aes_encrypt Create_func_aes_encrypt::s_singleton; Item* @@ -3165,6 +3360,15 @@ Create_func_ceiling::create_1_arg(THD *thd, Item *arg1) } +Create_func_collation Create_func_collation::s_singleton; + +Item* +Create_func_collation::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_collation(thd, arg1); +} + + Create_func_chr Create_func_chr::s_singleton; Item* @@ -3225,6 +3429,26 @@ Create_func_dyncol_json::create_1_arg(THD *thd, Item *arg1) return new (thd->mem_root) Item_func_dyncol_json(thd, arg1); } +Create_func_coalesce Create_func_coalesce::s_singleton; + +Item* +Create_func_coalesce::create_native(THD *thd, const LEX_CSTRING *name, + List *item_list) +{ + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + if (unlikely(arg_count < 1)) + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + return NULL; + } + + return new (thd->mem_root) Item_func_coalesce(thd, *item_list); +} + Create_func_concat Create_func_concat::s_singleton; Item* @@ -3319,6 +3543,16 @@ Create_func_connection_id::create_builder(THD *thd) } +Create_func_database Create_func_database::s_singleton; + +Item* +Create_func_database::create_builder(THD *thd) +{ + thd->lex->safe_to_cache_query= 0; + return new (thd->mem_root) Item_func_database(thd); +} + + Create_func_nvl2 Create_func_nvl2::s_singleton; Item* @@ -3427,6 +3661,37 @@ Create_func_datediff::create_2_arg(THD *thd, Item *arg1, Item *arg2) return new (thd->mem_root) Item_func_minus(thd, i1, i2); } +Create_func_date_format Create_func_date_format::s_singleton; + +Item* +Create_func_date_format::create_native(THD *thd, const LEX_CSTRING *name, + List *item_list) +{ + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + switch (arg_count) { + case 2: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + return new (thd->mem_root) Item_func_date_format(thd, param_1, param_2); + } + case 3: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + Item *param_3= item_list->pop(); + return new (thd->mem_root) Item_func_date_format(thd, + param_1, param_2, param_3); + } + } + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + return NULL; +} + Create_func_dayname Create_func_dayname::s_singleton; @@ -4627,6 +4892,23 @@ Create_func_length::create_1_arg(THD *thd, Item *arg1) return new (thd->mem_root) Item_func_octet_length(thd, arg1); } +Create_func_old_password Create_func_old_password::s_singleton; + +Item* +Create_func_old_password::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_password(thd, arg1, + Item_func_password::OLD); +} + +Create_func_password Create_func_password::s_singleton; + +Item* +Create_func_password::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_password(thd, arg1); +} + Create_func_octet_length Create_func_octet_length::s_singleton; Item* @@ -5001,6 +5283,24 @@ Item *Create_func_natural_sort_key::create_1_arg(THD *thd, Item* arg1) return new (thd->mem_root) Item_func_natural_sort_key(thd, arg1); } +Create_func_microsecond Create_func_microsecond::s_singleton; + +Item* +Create_func_microsecond::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_microsecond(thd, arg1); +} + + +Create_func_mod Create_func_mod::s_singleton; + +Item* +Create_func_mod::create_2_arg(THD *thd, Item *arg1, Item *arg2) +{ + return new (thd->mem_root) Item_func_mod(thd, arg1, arg2); +} + + Create_func_monthname Create_func_monthname::s_singleton; Item* @@ -5103,6 +5403,15 @@ Create_func_pow::create_2_arg(THD *thd, Item *arg1, Item *arg2) } +Create_func_quarter Create_func_quarter::s_singleton; + +Item* +Create_func_quarter::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_quarter(thd, arg1); +} + + Create_func_quote Create_func_quote::s_singleton; Item* @@ -5121,15 +5430,6 @@ Create_func_regexp_instr::create_2_arg(THD *thd, Item *arg1, Item *arg2) } -Create_func_regexp_replace Create_func_regexp_replace::s_singleton; - -Item* -Create_func_regexp_replace::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) -{ - return new (thd->mem_root) Item_func_regexp_replace(thd, arg1, arg2, arg3); -} - - Create_func_regexp_substr Create_func_regexp_substr::s_singleton; Item* @@ -5288,6 +5588,17 @@ Create_func_round::create_native(THD *thd, const LEX_CSTRING *name, } +Create_func_row_count Create_func_row_count::s_singleton; + +Item* +Create_func_row_count::create_builder(THD *thd) +{ + thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); + thd->lex->safe_to_cache_query= 0; + return new (thd->mem_root) Item_func_row_count(thd); +} + + Create_func_rpad Create_func_rpad::s_singleton; Create_func_rpad_oracle Create_func_rpad_oracle::s_singleton; @@ -5742,6 +6053,43 @@ Create_func_version::create_builder(THD *thd) } +Create_func_week Create_func_week::s_singleton; + +Item* +Create_func_week::create_native(THD *thd, const LEX_CSTRING *name, + List *item_list) +{ + Item* func= NULL; + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + switch (arg_count) { + case 1: + { + Item *param_1= item_list->pop(); + func= new (thd->mem_root) Item_func_week(thd, param_1); + break; + } + case 2: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + func= new (thd->mem_root) Item_func_week(thd, param_1, param_2); + break; + } + default: + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + break; + } + } + + return func; +} + + Create_func_weekday Create_func_weekday::s_singleton; Item* @@ -5892,6 +6240,7 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)}, { { STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)}, { { STRING_WITH_LEN("ADDTIME") }, BUILDER(Create_func_addtime)}, + { { STRING_WITH_LEN("ADD_MONTHS") }, BUILDER(Create_func_addmonths)}, { { STRING_WITH_LEN("AES_DECRYPT") }, BUILDER(Create_func_aes_decrypt)}, { { STRING_WITH_LEN("AES_ENCRYPT") }, BUILDER(Create_func_aes_encrypt)}, { { STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)}, @@ -5907,7 +6256,9 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)}, { { STRING_WITH_LEN("CHAR_LENGTH") }, BUILDER(Create_func_char_length)}, { { STRING_WITH_LEN("CHR") }, BUILDER(Create_func_chr)}, + { { STRING_WITH_LEN("COALESCE") }, BUILDER(Create_func_coalesce)}, { { STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)}, + { { STRING_WITH_LEN("COLLATION") }, BUILDER(Create_func_collation)}, { { STRING_WITH_LEN("COLUMN_CHECK") }, BUILDER(Create_func_dyncol_check)}, { { STRING_WITH_LEN("COLUMN_EXISTS") }, BUILDER(Create_func_dyncol_exists)}, { { STRING_WITH_LEN("COLUMN_LIST") }, BUILDER(Create_func_dyncol_list)}, @@ -5923,7 +6274,9 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)}, { { STRING_WITH_LEN("CRC32") }, BUILDER(Create_func_crc32)}, { { STRING_WITH_LEN("CRC32C") }, BUILDER(Create_func_crc32c)}, + { { STRING_WITH_LEN("DATABASE") }, BUILDER(Create_func_database)}, { { STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)}, + { { STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)}, { { STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)}, { { STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)}, { { STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)}, @@ -6022,6 +6375,8 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("MASTER_GTID_WAIT") }, BUILDER(Create_func_master_gtid_wait)}, { { STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)}, { { STRING_WITH_LEN("MD5") }, BUILDER(Create_func_md5)}, + { { STRING_WITH_LEN("MICROSECOND") }, BUILDER(Create_func_microsecond)}, + { { STRING_WITH_LEN("MOD") }, BUILDER(Create_func_mod)}, { { STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)}, { { STRING_WITH_LEN("NAME_CONST") }, BUILDER(Create_func_name_const)}, { {STRING_WITH_LEN("NATURAL_SORT_KEY")}, BUILDER(Create_func_natural_sort_key)}, @@ -6030,12 +6385,15 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)}, { { STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)}, { { STRING_WITH_LEN("OCTET_LENGTH") }, BUILDER(Create_func_octet_length)}, + { { STRING_WITH_LEN("OLD_PASSWORD") }, BUILDER(Create_func_old_password)}, { { STRING_WITH_LEN("ORD") }, BUILDER(Create_func_ord)}, + { { STRING_WITH_LEN("PASSWORD") }, BUILDER(Create_func_password)}, { { STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)}, { { STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)}, { { STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)}, { { STRING_WITH_LEN("POW") }, BUILDER(Create_func_pow)}, { { STRING_WITH_LEN("POWER") }, BUILDER(Create_func_pow)}, + { { STRING_WITH_LEN("QUARTER") }, BUILDER(Create_func_quarter)}, { { STRING_WITH_LEN("QUOTE") }, BUILDER(Create_func_quote)}, { { STRING_WITH_LEN("RANDOM_BYTES")}, BUILDER(Create_func_random_bytes)}, { { STRING_WITH_LEN("REGEXP_INSTR") }, BUILDER(Create_func_regexp_instr)}, @@ -6050,12 +6408,15 @@ const Native_func_registry func_array[] = BUILDER(Create_func_replace_oracle)}, { { STRING_WITH_LEN("REVERSE") }, BUILDER(Create_func_reverse)}, { { STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)}, + { { STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)}, { { STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)}, { { STRING_WITH_LEN("RPAD_ORACLE") }, BUILDER(Create_func_rpad_oracle)}, { { STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)}, { { STRING_WITH_LEN("RTRIM_ORACLE") }, BUILDER(Create_func_rtrim_oracle)}, { { STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)}, { { STRING_WITH_LEN("SFORMAT") }, BUILDER(Create_func_sformat)}, + { { STRING_WITH_LEN("SCHEMA") }, BUILDER(Create_func_database)}, + { { STRING_WITH_LEN("SCHEMAS") }, BUILDER(Create_func_database)}, { { STRING_WITH_LEN("SHA") }, BUILDER(Create_func_sha)}, { { STRING_WITH_LEN("SHA1") }, BUILDER(Create_func_sha)}, { { STRING_WITH_LEN("SHA2") }, BUILDER(Create_func_sha2)}, @@ -6088,6 +6449,7 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)}, { { STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)}, { { STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)}, + { { STRING_WITH_LEN("WEEK") }, BUILDER(Create_func_week)}, { { STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)}, { { STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)}, #ifdef WITH_WSREP @@ -6108,6 +6470,8 @@ const Native_func_registry func_array_oracle_overrides[] = { { STRING_WITH_LEN("LENGTH") }, BUILDER(Create_func_char_length)}, { { STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad_oracle)}, { { STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim_oracle)}, + { { STRING_WITH_LEN("REGEXP_REPLACE") }, + BUILDER(Create_func_regexp_replace_oracle)}, { { STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad_oracle)}, { { STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim_oracle)}, { {0, 0}, NULL} diff --git a/sql/item_func.cc b/sql/item_func.cc index d0683607d4f..b6139c96848 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4651,7 +4651,6 @@ user_var_entry *get_variable(HASH *hash, LEX_CSTRING *name, entry->length=0; entry->update_query_id=0; entry->set_charset(NULL); - entry->unsigned_flag= 0; /* If we are here, we were called from a SET or a query which sets a variable. Imagine it is this: @@ -4663,7 +4662,7 @@ user_var_entry *get_variable(HASH *hash, LEX_CSTRING *name, by Item_func_get_user_var (because that's not necessary). */ entry->used_query_id=current_thd->query_id; - entry->type=STRING_RESULT; + entry->set_handler(&type_handler_long_blob); memcpy((char*) entry->name.str, name->str, name->length+1); if (my_hash_insert(hash,(uchar*) entry)) { @@ -4739,9 +4738,12 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref) switch (args[0]->result_type()) { case STRING_RESULT: case TIME_RESULT: - set_handler(type_handler_long_blob. - type_handler_adjusted_to_max_octet_length(max_length, - collation.collation)); + if (args[0]->field_type() == MYSQL_TYPE_GEOMETRY) + set_handler(args[0]->type_handler()); + else + set_handler(type_handler_long_blob. + type_handler_adjusted_to_max_octet_length(max_length, + collation.collation)); break; case REAL_RESULT: set_handler(&type_handler_double); @@ -4866,9 +4868,9 @@ bool Item_func_set_user_var::register_field_in_bitmap(void *arg) bool update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length, - Item_result type, CHARSET_INFO *cs, - bool unsigned_arg) + const Type_handler *th, CHARSET_INFO *cs) { + entry->set_handler(th); if (set_null) { char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry)); @@ -4879,7 +4881,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length, } else { - if (type == STRING_RESULT) + if (th->result_type() == STRING_RESULT) length++; // Store strings with end \0 if (length <= extra_size) { @@ -4908,20 +4910,18 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length, return 1; } } - if (type == STRING_RESULT) + if (th->result_type() == STRING_RESULT) { length--; // Fix length change above entry->value[length]= 0; // Store end \0 } if (length) memmove(entry->value, ptr, length); - if (type == DECIMAL_RESULT) + if (th->result_type() == DECIMAL_RESULT) ((my_decimal*)entry->value)->fix_buffer_pointer(); entry->length= length; entry->set_charset(cs); - entry->unsigned_flag= unsigned_arg; } - entry->type=type; #ifdef USER_VAR_TRACKING #ifndef EMBEDDED_LIBRARY THD *thd= current_thd; @@ -4934,9 +4934,8 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length, bool Item_func_set_user_var::update_hash(void *ptr, size_t length, - Item_result res_type, - CHARSET_INFO *cs, - bool unsigned_arg) + const Type_handler *th, + CHARSET_INFO *cs) { /* If we set a variable explicitly to NULL then keep the old @@ -4950,9 +4949,8 @@ Item_func_set_user_var::update_hash(void *ptr, size_t length, else null_value= args[0]->null_value; if (null_value && null_item) - res_type= m_var_entry->type; // Don't change type of item - if (::update_hash(m_var_entry, null_value, - ptr, length, res_type, cs, unsigned_arg)) + th= m_var_entry->type_handler(); // Don't change type of item + if (::update_hash(m_var_entry, null_value, ptr, length, th, cs)) { null_value= 1; return 1; @@ -4968,7 +4966,7 @@ double user_var_entry::val_real(bool *null_value) if ((*null_value= (value == 0))) return 0.0; - switch (type) { + switch (type_handler()->result_type()) { case REAL_RESULT: return *(double*) value; case INT_RESULT: @@ -4993,7 +4991,7 @@ longlong user_var_entry::val_int(bool *null_value) const if ((*null_value= (value == 0))) return 0; - switch (type) { + switch (type_handler()->result_type()) { case REAL_RESULT: return (longlong) *(double*) value; case INT_RESULT: @@ -5022,12 +5020,12 @@ String *user_var_entry::val_str(bool *null_value, String *str, if ((*null_value= (value == 0))) return (String*) 0; - switch (type) { + switch (type_handler()->result_type()) { case REAL_RESULT: str->set_real(*(double*) value, decimals, charset()); break; case INT_RESULT: - if (!unsigned_flag) + if (!type_handler()->is_unsigned()) str->set(*(longlong*) value, charset()); else str->set(*(ulonglong*) value, charset()); @@ -5054,7 +5052,7 @@ my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val) if ((*null_value= (value == 0))) return 0; - switch (type) { + switch (type_handler()->result_type()) { case REAL_RESULT: double2my_decimal(E_DEC_FATAL_ERROR, *(double*) value, val); break; @@ -5193,33 +5191,37 @@ Item_func_set_user_var::update() case REAL_RESULT: { res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal), - REAL_RESULT, &my_charset_numeric, 0); + &type_handler_double, &my_charset_numeric); break; } case INT_RESULT: { res= update_hash((void*) &save_result.vint, sizeof(save_result.vint), - INT_RESULT, &my_charset_numeric, unsigned_flag); + unsigned_flag ? (Type_handler *) &type_handler_ulonglong : + (Type_handler *) &type_handler_slonglong, + &my_charset_numeric); break; } case STRING_RESULT: { if (!save_result.vstr) // Null value - res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, 0); + res= update_hash((void*) 0, 0, &type_handler_long_blob, &my_charset_bin); else res= update_hash((void*) save_result.vstr->ptr(), - save_result.vstr->length(), STRING_RESULT, - save_result.vstr->charset(), 0); + save_result.vstr->length(), + field_type() == MYSQL_TYPE_GEOMETRY ? + type_handler() : &type_handler_long_blob, + save_result.vstr->charset()); break; } case DECIMAL_RESULT: { if (!save_result.vdec) // Null value - res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin, 0); + res= update_hash((void*) 0, 0, &type_handler_newdecimal, &my_charset_bin); else res= update_hash((void*) save_result.vdec, - sizeof(my_decimal), DECIMAL_RESULT, - &my_charset_numeric, 0); + sizeof(my_decimal), &type_handler_newdecimal, + &my_charset_numeric); break; } case ROW_RESULT: @@ -5611,9 +5613,8 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command, user_var_event->value= (char*) user_var_event + ALIGN_SIZE(sizeof(BINLOG_USER_VAR_EVENT)); user_var_event->user_var_event= var_entry; - user_var_event->type= var_entry->type; + user_var_event->th= var_entry->type_handler(); user_var_event->charset_number= var_entry->charset()->number; - user_var_event->unsigned_flag= var_entry->unsigned_flag; if (!var_entry->value) { /* NULL value*/ @@ -5655,9 +5656,9 @@ bool Item_func_get_user_var::fix_length_and_dec(THD *thd) */ if (likely(!error && m_var_entry)) { - unsigned_flag= m_var_entry->unsigned_flag; + unsigned_flag= m_var_entry->type_handler()->is_unsigned(); max_length= (uint32)m_var_entry->length; - switch (m_var_entry->type) { + switch (m_var_entry->type_handler()->result_type()) { case REAL_RESULT: collation.set(&my_charset_numeric, DERIVATION_NUMERIC); fix_char_length(DBL_DIG + 8); @@ -5676,6 +5677,8 @@ bool Item_func_get_user_var::fix_length_and_dec(THD *thd) collation.set(m_var_entry->charset(), DERIVATION_IMPLICIT); max_length= MAX_BLOB_WIDTH - 1; set_handler(&type_handler_long_blob); + if (m_var_entry->type_handler()->field_type() == MYSQL_TYPE_GEOMETRY) + set_handler(m_var_entry->type_handler()); break; case DECIMAL_RESULT: collation.set(&my_charset_numeric, DERIVATION_NUMERIC); @@ -5748,7 +5751,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) DBUG_ASSERT(thd->lex->exchange); if (!(entry= get_variable(&thd->user_vars, &org_name, 1))) return TRUE; - entry->type= STRING_RESULT; + entry->set_handler(&type_handler_long_blob); /* Let us set the same collation which is used for loading of fields in LOAD DATA INFILE. @@ -5764,15 +5767,14 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs) { - ::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs, 0 /* unsigned_arg */); + ::update_hash(entry, TRUE, 0, 0, &type_handler_long_blob, cs); } void Item_user_var_as_out_param::set_value(const char *str, uint length, CHARSET_INFO* cs) { - ::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs, - 0 /* unsigned_arg */); + ::update_hash(entry, FALSE, (void*)str, length, &type_handler_long_blob, cs); } diff --git a/sql/item_func.h b/sql/item_func.h index e1d67a73134..79ad8fb7d05 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -83,6 +83,8 @@ protected: return print_sql_mode_qualified_name(to, query_type, func_name_cstring()); } + bool aggregate_args2_for_comparison_with_conversion(THD *thd, + Type_handler_hybrid_field_type *th); public: // Print an error message for a builtin-schema qualified function call @@ -3448,8 +3450,8 @@ public: String *str_result(String *str) override; my_decimal *val_decimal_result(my_decimal *) override; bool is_null_result() override; - bool update_hash(void *ptr, size_t length, enum Item_result type, - CHARSET_INFO *cs, bool unsigned_arg); + bool update_hash(void *ptr, size_t length, const Type_handler *th, + CHARSET_INFO *cs); bool send(Protocol *protocol, st_value *buffer) override; void make_send_field(THD *thd, Send_field *tmp_field) override; bool check(bool use_result_field); @@ -4299,7 +4301,6 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, extern bool volatile mqh_used; bool update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length, - Item_result type, CHARSET_INFO *cs, - bool unsigned_arg); + const Type_handler *th, CHARSET_INFO *cs); #endif /* ITEM_FUNC_INCLUDED */ diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 216bafea299..2a1bfbf66b8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1347,8 +1347,7 @@ bool Item_func_reverse::fix_length_and_dec(THD *thd) Fix that this works with binary strings when using USE_MB */ -String *Item_func_replace::val_str_internal(String *str, - String *empty_string_for_null) +String *Item_func_replace::val_str_internal(String *str, bool null_to_empty) { DBUG_ASSERT(fixed()); String *res,*res2,*res3; @@ -1366,13 +1365,8 @@ String *Item_func_replace::val_str_internal(String *str, res=args[0]->val_str(str); if (args[0]->null_value) goto null; - res2=args[1]->val_str(&tmp_value); - if (args[1]->null_value) - { - if (!empty_string_for_null) - goto null; - res2= empty_string_for_null; - } + if (!(res2= args[1]->val_str_null_to_empty(&tmp_value, null_to_empty))) + goto null; res->set_charset(collation.collation); #ifdef USE_MB @@ -1389,12 +1383,8 @@ String *Item_func_replace::val_str_internal(String *str, if (binary_cmp && (offset=res->strstr(*res2)) < 0) return res; #endif - if (!(res3=args[2]->val_str(&tmp_value2))) - { - if (!empty_string_for_null) - goto null; - res3= empty_string_for_null; - } + if (!(res3= args[2]->val_str_null_to_empty(&tmp_value2, null_to_empty))) + goto null; from_length= res2->length(); to_length= res3->length(); @@ -1477,7 +1467,7 @@ redo: } while ((offset=res->strstr(*res2,(uint) offset)) >= 0); } - if (empty_string_for_null && !res->length()) + if (null_to_empty && !res->length()) goto null; return res; @@ -1801,20 +1791,22 @@ bool Item_func_regexp_replace::append_replacement(String *str, } -String *Item_func_regexp_replace::val_str(String *str) +String *Item_func_regexp_replace::val_str_internal(String *str, + bool null_to_empty) { DBUG_ASSERT(fixed()); char buff0[MAX_FIELD_WIDTH]; char buff2[MAX_FIELD_WIDTH]; String tmp0(buff0,sizeof(buff0),&my_charset_bin); String tmp2(buff2,sizeof(buff2),&my_charset_bin); - String *source= args[0]->val_str(&tmp0); - String *replace= args[2]->val_str(&tmp2); + String *source, *replace; LEX_CSTRING src, rpl; size_t startoffset= 0; - if ((null_value= (args[0]->null_value || args[2]->null_value || - re.recompile(args[1])))) + if ((null_value= + (!(source= args[0]->val_str(&tmp0)) || + !(replace= args[2]->val_str_null_to_empty(&tmp2, null_to_empty)) || + re.recompile(args[1])))) return (String *) 0; if (!(source= re.convert_if_needed(source, &re.subject_converter)) || @@ -3650,7 +3642,7 @@ String *Item_func_binlog_gtid_pos::val_str(String *str) if (args[0]->null_value || args[1]->null_value) goto err; - if (pos < 0 || pos > UINT_MAX32) + if (pos < 0 || pos > (longlong) UINT_MAX32) goto err; if (gtid_state_from_binlog_pos(name->c_ptr_safe(), (uint32)pos, str)) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 470165d691f..8fba6e6fd35 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -497,12 +497,13 @@ public: class Item_func_replace :public Item_str_func { String tmp_value,tmp_value2; +protected: + String *val_str_internal(String *str, bool null_to_empty); public: Item_func_replace(THD *thd, Item *org, Item *find, Item *replace): Item_str_func(thd, org, find, replace) {} - String *val_str(String *to) override { return val_str_internal(to, NULL); }; + String *val_str(String *to) override { return val_str_internal(to, false); }; bool fix_length_and_dec(THD *thd) override; - String *val_str_internal(String *str, String *empty_string_for_null); const Schema *schema() const override { return &mariadb_schema; } void print(String *str, enum_query_type query_type) override { @@ -526,7 +527,7 @@ public: Item_func_replace_oracle(THD *thd, Item *org, Item *find, Item *replace): Item_func_replace(thd, org, find, replace) {} String *val_str(String *to) override - { return val_str_internal(to, &tmp_emtpystr); }; + { return val_str_internal(to, true); }; const Schema *schema() const override { return &oracle_schema_ref; } void print(String *str, enum_query_type query_type) override { @@ -550,10 +551,18 @@ class Item_func_regexp_replace :public Item_str_func bool append_replacement(String *str, const LEX_CSTRING *source, const LEX_CSTRING *replace); +protected: + String *val_str_internal(String *str, bool null_to_empty); public: Item_func_regexp_replace(THD *thd, Item *a, Item *b, Item *c): Item_str_func(thd, a, b, c) {} + const Schema *schema() const override { return &mariadb_schema; } + void print(String *str, enum_query_type query_type) override + { + print_sql_mode_qualified_name(str, query_type); + print_args_parenthesized(str, query_type); + } void cleanup() override { DBUG_ENTER("Item_func_regexp_replace::cleanup"); @@ -561,7 +570,10 @@ public: re.cleanup(); DBUG_VOID_RETURN; } - String *val_str(String *str) override; + String *val_str(String *str) override + { + return val_str_internal(str, false); + } bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { @@ -572,6 +584,26 @@ public: }; +class Item_func_regexp_replace_oracle: public Item_func_regexp_replace +{ +public: + Item_func_regexp_replace_oracle(THD *thd, Item *a, Item *b, Item *c) + :Item_func_regexp_replace(thd, a, b, c) + {} + const Schema *schema() const { return &oracle_schema_ref; } + bool fix_length_and_dec(THD *thd) + { + bool rc= Item_func_regexp_replace::fix_length_and_dec(thd); + set_maybe_null(); // Empty result is converted to NULL + return rc; + } + String *val_str(String *str) + { + return val_str_internal(str, true); + } +}; + + class Item_func_regexp_substr :public Item_str_func { Regexp_processor_pcre re; @@ -1842,6 +1874,9 @@ public: collation.set(args[0]->collation); ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 + 2 * collation.collation->mbmaxlen; + // NULL argument is returned as a string "NULL" without quotes + if (args[0]->maybe_null()) + set_if_bigger(max_result_length, 4 * collation.collation->mbmaxlen); max_length= (uint32) MY_MIN(max_result_length, MAX_BLOB_WIDTH); return FALSE; } diff --git a/sql/key.cc b/sql/key.cc index 4e40a3354ce..93b172c3e22 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -609,7 +609,7 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec) } /* No null values in the fields - We use the virtual method cmp_max with a max length parameter. + We use the virtual method cmp_prefix with a max length parameter. For most field types this translates into a cmp without max length. The exceptions are the BLOB and VARCHAR field types that take the max length into account. diff --git a/sql/lex.h b/sql/lex.h index fb267326562..fc1f06bd41d 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -79,9 +79,9 @@ SYMBOL symbols[] = { { "AT", SYM(AT_SYM)}, { "ATOMIC", SYM(ATOMIC_SYM)}, { "AUTHORS", SYM(AUTHORS_SYM)}, + { "AUTO", SYM(AUTO_SYM)}, { "AUTO_INCREMENT", SYM(AUTO_INC)}, { "AUTOEXTEND_SIZE", SYM(AUTOEXTEND_SIZE_SYM)}, - { "AUTO", SYM(AUTO_SYM)}, { "AVG", SYM(AVG_SYM)}, { "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH)}, { "BACKUP", SYM(BACKUP_SYM)}, @@ -428,7 +428,6 @@ SYMBOL symbols[] = { { "NCHAR", SYM(NCHAR_SYM)}, { "NESTED", SYM(NESTED_SYM)}, { "NEVER", SYM(NEVER_SYM)}, - { "NEW", SYM(NEW_SYM)}, { "NEXT", SYM(NEXT_SYM)}, { "NEXTVAL", SYM(NEXTVAL_SYM)}, { "NO", SYM(NO_SYM)}, @@ -688,7 +687,6 @@ SYMBOL symbols[] = { { "TRUE", SYM(TRUE_SYM)}, { "TRUNCATE", SYM(TRUNCATE_SYM)}, { "TYPE", SYM(TYPE_SYM)}, - { "TYPES", SYM(TYPES_SYM)}, { "UNBOUNDED", SYM(UNBOUNDED_SYM)}, { "UNCOMMITTED", SYM(UNCOMMITTED_SYM)}, { "UNDEFINED", SYM(UNDEFINED_SYM)}, @@ -755,7 +753,6 @@ SYMBOL symbols[] = { SYMBOL sql_functions[] = { { "ADDDATE", SYM(ADDDATE_SYM)}, - { "ADD_MONTHS", SYM(ADD_MONTHS_SYM)}, { "BIT_AND", SYM(BIT_AND)}, { "BIT_OR", SYM(BIT_OR)}, { "BIT_XOR", SYM(BIT_XOR)}, @@ -766,7 +763,6 @@ SYMBOL sql_functions[] = { { "CURTIME", SYM(CURTIME)}, { "DATE_ADD", SYM(DATE_ADD_INTERVAL)}, { "DATE_SUB", SYM(DATE_SUB_INTERVAL)}, - { "DATE_FORMAT", SYM(DATE_FORMAT_SYM)}, { "DENSE_RANK", SYM(DENSE_RANK_SYM)}, { "EXTRACT", SYM(EXTRACT_SYM)}, { "FIRST_VALUE", SYM(FIRST_VALUE_SYM)}, diff --git a/sql/log.cc b/sql/log.cc index 171bc97fc69..460cefea47b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1311,7 +1311,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, size_t query_length, query_utime= (current_utime - thd->start_utime); lock_utime= (thd->utime_after_lock - thd->start_utime); my_hrtime_t current_time= { hrtime_from_time(thd->start_time) + - thd->start_time_sec_part + query_utime }; + thd->start_time_sec_part }; if (!query || thd->get_command() == COM_STMT_PREPARE) { @@ -3729,7 +3729,6 @@ bool MYSQL_BIN_LOG::open(const char *log_name, bool null_created_arg, bool need_mutex) { - File file= -1; xid_count_per_binlog *new_xid_list_entry= NULL, *b; DBUG_ENTER("MYSQL_BIN_LOG::open"); @@ -4107,8 +4106,6 @@ err: sql_print_error(fatal_log_error, (name) ? name : log_name, tmp_errno); if (new_xid_list_entry) delete new_xid_list_entry; - if (file >= 0) - mysql_file_close(file, MYF(0)); close(LOG_CLOSE_INDEX); DBUG_RETURN(1); } @@ -5640,8 +5637,6 @@ int MYSQL_BIN_LOG::new_file_without_locking() /** Start writing to a new log file or reopen the old file. - @param need_lock Set to 1 if caller has not locked LOCK_log - @retval nonzero - error @@ -6475,12 +6470,13 @@ bool MYSQL_BIN_LOG::write_table_map(THD *thd, TABLE *table, bool with_annotate) int error= 1; bool is_transactional= table->file->row_logging_has_trans; DBUG_ENTER("THD::binlog_write_table_map"); - DBUG_PRINT("enter", ("table: %p (%s: #%lu)", + DBUG_PRINT("enter", ("table: %p (%s: #%llu)", table, table->s->table_name.str, table->s->table_map_id)); /* Pre-conditions */ - DBUG_ASSERT(table->s->table_map_id != ULONG_MAX); + DBUG_ASSERT((table->s->table_map_id & MAX_TABLE_MAP_ID) != UINT32_MAX && + (table->s->table_map_id & MAX_TABLE_MAP_ID) != 0); /* Ensure that all events in a GTID group are in the same cache */ if (thd->variables.option_bits & OPTION_GTID_BEGIN) @@ -7237,18 +7233,12 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) BINLOG_USER_VAR_EVENT *user_var_event; get_dynamic(&thd->user_var_events,(uchar*) &user_var_event, i); - /* setting flags for user var log event */ - uchar flags= User_var_log_event::UNDEF_F; - if (user_var_event->unsigned_flag) - flags|= User_var_log_event::UNSIGNED_F; - User_var_log_event e(thd, user_var_event->user_var_event->name.str, user_var_event->user_var_event->name.length, user_var_event->value, user_var_event->length, - user_var_event->type, - user_var_event->charset_number, - flags, + user_var_event->th->user_var_log_event_data_type( + user_var_event->charset_number), using_trans, direct); if (write_event(&e, cache_data, file)) @@ -11646,7 +11636,7 @@ Recovery_context::Recovery_context() : prev_event_pos(0), last_gtid_standalone(false), last_gtid_valid(false), last_gtid_no2pc(false), last_gtid_engines(0), - do_truncate(rpl_semi_sync_slave_enabled), + do_truncate(repl_semisync_slave.get_slave_enabled()), truncate_validated(false), truncate_reset_done(false), truncate_set_in_1st(false), id_binlog(MAX_binlog_id), checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF), gtid_maybe_to_truncate(NULL) diff --git a/sql/log.h b/sql/log.h index 4be98c3cfb3..fc5209d1922 100644 --- a/sql/log.h +++ b/sql/log.h @@ -364,13 +364,13 @@ struct Rows_event_factory { int type_code; - Rows_log_event *(*create)(THD*, TABLE*, ulong, bool is_transactional); + Rows_log_event *(*create)(THD*, TABLE*, ulonglong, bool is_transactional); template static Rows_event_factory get() { return { RowsEventT::TYPE_CODE, - [](THD* thd, TABLE* table, ulong flags, bool is_transactional) + [](THD* thd, TABLE* table, ulonglong flags, bool is_transactional) -> Rows_log_event* { return new RowsEventT(thd, table, flags, is_transactional); diff --git a/sql/log_event.cc b/sql/log_event.cc index 54046b7f8bd..e60f822e751 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2718,6 +2718,41 @@ XA_prepare_log_event(const uchar *buf, User_var_log_event methods **************************************************************************/ +bool Log_event_data_type::unpack_optional_attributes(const char *pos, + const char *end) + +{ + for ( ; pos < end; ) + { + switch (*pos) { + case CHUNK_SIGNED: + m_is_unsigned= false; + pos++; + continue; + case CHUNK_UNSIGNED: + m_is_unsigned= true; + pos++; + continue; + case CHUNK_DATA_TYPE_NAME: + { + pos++; + if (pos >= end) + return true; + uint length= (uchar) *pos++; + if (pos + length > end) + return true; + m_data_type_name= {pos, length}; + pos+= length; + continue; + } + default: + break; // Unknown chunk + } + } + return false; +} + + User_var_log_event:: User_var_log_event(const uchar *buf, uint event_len, const Format_description_log_event* description_event) @@ -2727,7 +2762,8 @@ User_var_log_event(const uchar *buf, uint event_len, #endif { bool error= false; - const uchar *buf_start= buf, *buf_end= buf + event_len; + const uchar *const buf_start= buf; + const char *buf_end= reinterpret_cast(buf) + event_len; /* The Post-Header is empty. The Variable Data part begins immediately. */ buf+= description_event->common_header_len + @@ -2755,11 +2791,8 @@ User_var_log_event(const uchar *buf, uint event_len, buf+= UV_NAME_LEN_SIZE + name_len; is_null= (bool) *buf; - flags= User_var_log_event::UNDEF_F; // defaults to UNDEF_F if (is_null) { - type= STRING_RESULT; - charset_number= my_charset_bin.number; val_len= 0; val= 0; } @@ -2774,8 +2807,8 @@ User_var_log_event(const uchar *buf, uint event_len, goto err; } - type= (Item_result) buf[UV_VAL_IS_NULL]; - charset_number= uint4korr(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE); + m_type= (Item_result) buf[UV_VAL_IS_NULL]; + m_charset_number= uint4korr(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE); val_len= uint4korr(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + UV_CHARSET_NUMBER_SIZE); @@ -2788,20 +2821,14 @@ User_var_log_event(const uchar *buf, uint event_len, the flags value. Old events will not have this extra byte, thence, - we keep the flags set to UNDEF_F. + we keep m_is_unsigned==false. */ - size_t bytes_read= (val + val_len) - (char*) buf_start; - if (bytes_read > event_len) + const char *pos= val + val_len; + if (pos > buf_end || unpack_optional_attributes(pos, buf_end)) { error= true; goto err; } - if ((data_written - bytes_read) > 0) - { - flags= (uint) *(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + - UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE + - val_len); - } } err: @@ -3009,7 +3036,7 @@ Rows_log_event::Rows_log_event(const uchar *buf, uint event_len, } else { - m_table_id= (ulong) uint6korr(post_start); + m_table_id= (ulonglong) uint6korr(post_start); post_start+= RW_FLAGS_OFFSET; } @@ -3372,11 +3399,12 @@ Table_map_log_event::Table_map_log_event(const uchar *buf, uint event_len, else { DBUG_ASSERT(post_header_len == TABLE_MAP_HEADER_LEN); - m_table_id= (ulong) uint6korr(post_start); + m_table_id= (ulonglong) uint6korr(post_start); post_start+= TM_FLAGS_OFFSET; } - DBUG_ASSERT(m_table_id != ~0ULL); + DBUG_ASSERT((m_table_id & MAX_TABLE_MAP_ID) != UINT32_MAX && + (m_table_id & MAX_TABLE_MAP_ID) != 0); m_flags= uint2korr(post_start); diff --git a/sql/log_event.h b/sql/log_event.h index 3d213c14d22..0c5683006f3 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -60,6 +60,8 @@ typedef ulong enum_slave_exec_mode; #include "rpl_gtid.h" +#include "log_event_data_type.h" + /* Forward declarations */ #ifndef MYSQL_CLIENT class String; @@ -159,6 +161,12 @@ class String; #define NUM_LOAD_DELIM_STRS 5 +/* + The following is the max table_map_id. This is limited by that we + are using 6 bytes for it in replication +*/ +#define MAX_TABLE_MAP_ID ((1ULL << (6*8)) -1) + /***************************************************************************** MySQL Binary Log @@ -3001,33 +3009,27 @@ private: @section User_var_log_event_binary_format Binary Format */ -class User_var_log_event: public Log_event + +class User_var_log_event: public Log_event, public Log_event_data_type { public: - enum { - UNDEF_F= 0, - UNSIGNED_F= 1 - }; const char *name; size_t name_len; const char *val; size_t val_len; - Item_result type; - uint charset_number; bool is_null; - uchar flags; #ifdef MYSQL_SERVER bool deferred; query_id_t query_id; User_var_log_event(THD* thd_arg, const char *name_arg, size_t name_len_arg, const char *val_arg, size_t val_len_arg, - Item_result type_arg, - uint charset_number_arg, uchar flags_arg, + const Log_event_data_type &data_type, bool using_trans, bool direct) :Log_event(thd_arg, 0, using_trans), + Log_event_data_type(data_type), name(name_arg), name_len(name_len_arg), val(val_arg), - val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg), - flags(flags_arg), deferred(false) + val_len(val_len_arg), + deferred(false) { is_null= !val; if (direct) @@ -4412,7 +4414,8 @@ public: flag_set get_flags(flag_set flag) const { return m_flags & flag; } #ifdef MYSQL_SERVER - Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, bool is_transactional); + Table_map_log_event(THD *thd, TABLE *tbl, ulonglong tid, + bool is_transactional); #endif #ifdef HAVE_REPLICATION Table_map_log_event(const uchar *buf, uint event_len, @@ -4744,7 +4747,7 @@ protected: this class, not create instances of this class. */ #ifdef MYSQL_SERVER - Rows_log_event(THD*, TABLE*, ulong table_id, + Rows_log_event(THD*, TABLE*, ulonglong table_id, MY_BITMAP const *cols, bool is_transactional, Log_event_type event_type); #endif @@ -4974,7 +4977,7 @@ public: static constexpr Log_event_type TYPE_CODE = WRITE_ROWS_EVENT; #if defined(MYSQL_SERVER) - Write_rows_log_event(THD*, TABLE*, ulong table_id, + Write_rows_log_event(THD*, TABLE*, ulonglong table_id, bool is_transactional); #endif #ifdef HAVE_REPLICATION @@ -5023,7 +5026,7 @@ class Write_rows_compressed_log_event : public Write_rows_log_event { public: #if defined(MYSQL_SERVER) - Write_rows_compressed_log_event(THD*, TABLE*, ulong table_id, + Write_rows_compressed_log_event(THD*, TABLE*, ulonglong table_id, bool is_transactional); virtual bool write(Log_event_writer *writer); #endif @@ -5056,7 +5059,7 @@ public: static constexpr Log_event_type TYPE_CODE = UPDATE_ROWS_EVENT; #ifdef MYSQL_SERVER - Update_rows_log_event(THD*, TABLE*, ulong table_id, + Update_rows_log_event(THD*, TABLE*, ulonglong table_id, bool is_transactional); void init(MY_BITMAP const *cols); @@ -5112,7 +5115,7 @@ class Update_rows_compressed_log_event : public Update_rows_log_event { public: #if defined(MYSQL_SERVER) - Update_rows_compressed_log_event(THD*, TABLE*, ulong table_id, + Update_rows_compressed_log_event(THD*, TABLE*, ulonglong table_id, bool is_transactional); virtual bool write(Log_event_writer *writer); #endif @@ -5153,7 +5156,7 @@ public: static constexpr Log_event_type TYPE_CODE = DELETE_ROWS_EVENT; #ifdef MYSQL_SERVER - Delete_rows_log_event(THD*, TABLE*, ulong, bool is_transactional); + Delete_rows_log_event(THD*, TABLE*, ulonglong, bool is_transactional); #endif #ifdef HAVE_REPLICATION Delete_rows_log_event(const uchar *buf, uint event_len, @@ -5203,7 +5206,8 @@ class Delete_rows_compressed_log_event : public Delete_rows_log_event { public: #if defined(MYSQL_SERVER) - Delete_rows_compressed_log_event(THD*, TABLE*, ulong, bool is_transactional); + Delete_rows_compressed_log_event(THD*, TABLE*, ulonglong, + bool is_transactional); virtual bool write(Log_event_writer *writer); #endif #ifdef HAVE_REPLICATION diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc index d6cc5beee8c..6b83f159896 100644 --- a/sql/log_event_client.cc +++ b/sql/log_event_client.cc @@ -1578,8 +1578,9 @@ bool Rows_log_event::print_verbose(IO_CACHE *file, if (!(map= print_event_info->m_table_map.get_table(m_table_id)) || !(td= map->create_table_def())) { - return (my_b_printf(file, "### Row event for unknown table #%lu", - (ulong) m_table_id)); + char llbuff[22]; + return (my_b_printf(file, "### Row event for unknown table #%s", + ullstr(m_table_id, llbuff))); } /* If the write rows event contained no values for the AI */ @@ -2479,7 +2480,7 @@ bool User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) } else { - switch (type) { + switch (m_type) { case REAL_RESULT: double real_val; char real_buf[FMT_G_BUFSIZE(14)]; @@ -2491,8 +2492,7 @@ bool User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) break; case INT_RESULT: char int_buf[22]; - longlong10_to_str(uint8korr(val), int_buf, - ((flags & User_var_log_event::UNSIGNED_F) ? 10 : -10)); + longlong10_to_str(uint8korr(val), int_buf, is_unsigned() ? 10 : -10); if (my_b_printf(&cache, ":=%s%s\n", int_buf, print_event_info->delimiter)) goto err; @@ -2547,7 +2547,7 @@ bool User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) people want to mysqlbinlog|mysql into another server not supporting the character set. But there's not much to do about this and it's unlikely. */ - if (!(cs= get_charset(charset_number, MYF(0)))) + if (!(cs= get_charset(m_charset_number, MYF(0)))) { /* Generate an unusable command (=> syntax error) is probably the best thing we can do here. diff --git a/sql/log_event_data_type.h b/sql/log_event_data_type.h new file mode 100644 index 00000000000..e3b2039a63c --- /dev/null +++ b/sql/log_event_data_type.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2024, 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#ifndef LOG_EVENT_DATA_TYPE_H +#define LOG_EVENT_DATA_TYPE_H + +class Log_event_data_type +{ +public: + + enum { + CHUNK_SIGNED= 0, + CHUNK_UNSIGNED= 1, + CHUNK_DATA_TYPE_NAME= 2 + }; + +protected: + LEX_CSTRING m_data_type_name; + Item_result m_type; + uint m_charset_number; + bool m_is_unsigned; + +public: + + Log_event_data_type() + :m_data_type_name({NULL,0}), + m_type(STRING_RESULT), + m_charset_number(my_charset_bin.number), + m_is_unsigned(false) + { } + + Log_event_data_type(const LEX_CSTRING &data_type_name_arg, + Item_result type_arg, + uint charset_number_arg, + bool is_unsigned_arg) + :m_data_type_name(data_type_name_arg), + m_type(type_arg), + m_charset_number(charset_number_arg), + m_is_unsigned(is_unsigned_arg) + { } + + const LEX_CSTRING & data_type_name() const + { + return m_data_type_name; + } + Item_result type() const + { + return m_type; + } + uint charset_number() const + { + return m_charset_number; + } + bool is_unsigned() const + { + return m_is_unsigned; + } + + bool unpack_optional_attributes(const char *str, const char *end); +}; + +#endif // LOG_EVENT_DATA_TYPE_H diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 78af4780311..169f78b5c00 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -790,6 +790,10 @@ int Log_event_writer::write_header(uchar *pos, size_t len) int Log_event_writer::write_data(const uchar *pos, size_t len) { DBUG_ENTER("Log_event_writer::write_data"); + + if (!len) + DBUG_RETURN(0); + if (checksum_len) crc= my_checksum(crc, pos, len); @@ -3780,11 +3784,16 @@ bool XA_prepare_log_event::write(Log_event_writer *writer) #if defined(HAVE_REPLICATION) static bool user_var_append_name_part(THD *thd, String *buf, - const char *name, size_t name_len) + const char *name, size_t name_len, + const LEX_CSTRING &data_type_name) { return buf->append('@') || append_identifier(thd, buf, name, name_len) || - buf->append('='); + buf->append('=') || + (data_type_name.length && + (buf->append(STRING_WITH_LEN("/*")) || + buf->append(data_type_name.str, data_type_name.length) || + buf->append(STRING_WITH_LEN("*/")))); } void User_var_log_event::pack_info(Protocol* protocol) @@ -3794,14 +3803,15 @@ void User_var_log_event::pack_info(Protocol* protocol) char buf_mem[FN_REFLEN+7]; String buf(buf_mem, sizeof(buf_mem), system_charset_info); buf.length(0); - if (user_var_append_name_part(protocol->thd, &buf, name, name_len) || + if (user_var_append_name_part(protocol->thd, &buf, name, name_len, + m_data_type_name) || buf.append(NULL_clex_str)) return; protocol->store(buf.ptr(), buf.length(), &my_charset_bin); } else { - switch (type) { + switch (m_type) { case REAL_RESULT: { double real_val; @@ -3810,7 +3820,8 @@ void User_var_log_event::pack_info(Protocol* protocol) String buf(buf_mem, sizeof(buf_mem), system_charset_info); float8get(real_val, val); buf.length(0); - if (user_var_append_name_part(protocol->thd, &buf, name, name_len) || + if (user_var_append_name_part(protocol->thd, &buf, name, name_len, + m_data_type_name) || buf.append(buf2, my_gcvt(real_val, MY_GCVT_ARG_DOUBLE, MY_GCVT_MAX_FIELD_WIDTH, buf2, NULL))) return; @@ -3823,10 +3834,11 @@ void User_var_log_event::pack_info(Protocol* protocol) char buf_mem[FN_REFLEN + 22]; String buf(buf_mem, sizeof(buf_mem), system_charset_info); buf.length(0); - if (user_var_append_name_part(protocol->thd, &buf, name, name_len) || + if (user_var_append_name_part(protocol->thd, &buf, name, name_len, + m_data_type_name) || buf.append(buf2, longlong10_to_str(uint8korr(val), buf2, - ((flags & User_var_log_event::UNSIGNED_F) ? 10 : -10))-buf2)) + (is_unsigned() ? 10 : -10))-buf2)) return; protocol->store(buf.ptr(), buf.length(), &my_charset_bin); break; @@ -3839,7 +3851,8 @@ void User_var_log_event::pack_info(Protocol* protocol) String str(buf2, sizeof(buf2), &my_charset_bin); buf.length(0); my_decimal((const uchar *) (val + 2), val[0], val[1]).to_string(&str); - if (user_var_append_name_part(protocol->thd, &buf, name, name_len) || + if (user_var_append_name_part(protocol->thd, &buf, name, name_len, + m_data_type_name) || buf.append(str)) return; protocol->store(buf.ptr(), buf.length(), &my_charset_bin); @@ -3855,7 +3868,7 @@ void User_var_log_event::pack_info(Protocol* protocol) String buf(buf_mem, sizeof(buf_mem), system_charset_info); CHARSET_INFO *cs; buf.length(0); - if (!(cs= get_charset(charset_number, MYF(0)))) + if (!(cs= get_charset(m_charset_number, MYF(0)))) { if (buf.append(STRING_WITH_LEN("???"))) return; @@ -3864,7 +3877,8 @@ void User_var_log_event::pack_info(Protocol* protocol) { size_t old_len; char *beg, *end; - if (user_var_append_name_part(protocol->thd, &buf, name, name_len) || + if (user_var_append_name_part(protocol->thd, &buf, name, name_len, + m_data_type_name) || buf.append('_') || buf.append(cs->cs_name) || buf.append(' ')) @@ -3912,10 +3926,10 @@ bool User_var_log_event::write(Log_event_writer *writer) } else { - buf1[1]= type; - int4store(buf1 + 2, charset_number); + buf1[1]= m_type; + int4store(buf1 + 2, m_charset_number); - switch (type) { + switch (m_type) { case REAL_RESULT: float8store(buf2, *(double*) val); break; @@ -3945,15 +3959,30 @@ bool User_var_log_event::write(Log_event_writer *writer) buf1_length= 10; } - /* Length of the whole event */ - event_length= sizeof(buf)+ name_len + buf1_length + val_len + unsigned_len; + uchar data_type_name_chunk_signature= (uchar) CHUNK_DATA_TYPE_NAME; + uint data_type_name_chunk_signature_length= m_data_type_name.length ? 1 : 0; + uchar data_type_name_length_length= m_data_type_name.length ? 1 : 0; + /* Length of the whole event */ + event_length= sizeof(buf)+ name_len + buf1_length + val_len + unsigned_len + + data_type_name_chunk_signature_length + + data_type_name_length_length + + (uint) m_data_type_name.length; + + uchar unsig= m_is_unsigned ? CHUNK_UNSIGNED : CHUNK_SIGNED; + uchar data_type_name_length= (uchar) m_data_type_name.length; return write_header(writer, event_length) || write_data(writer, buf, sizeof(buf)) || write_data(writer, name, name_len) || write_data(writer, buf1, buf1_length) || write_data(writer, pos, val_len) || - write_data(writer, &flags, unsigned_len) || + write_data(writer, &unsig, unsigned_len) || + write_data(writer, &data_type_name_chunk_signature, + data_type_name_chunk_signature_length) || + write_data(writer, &data_type_name_length, + data_type_name_length_length) || + write_data(writer, m_data_type_name.str, + (uint) m_data_type_name.length) || write_footer(writer); } @@ -3977,7 +4006,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) current_thd->query_id= query_id; /* recreating original time context */ } - if (!(charset= get_charset(charset_number, MYF(MY_WME)))) + if (!(charset= get_charset(m_charset_number, MYF(MY_WME)))) { rgi->rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, ER_THD(thd, ER_SLAVE_FATAL_ERROR), @@ -3996,7 +4025,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) } else { - switch (type) { + switch (m_type) { case REAL_RESULT: if (val_len != 8) { @@ -4060,13 +4089,10 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) if (e->fix_fields(thd, 0)) DBUG_RETURN(1); - /* - A variable can just be considered as a table with - a single record and with a single column. Thus, like - a column value, it could always have IMPLICIT derivation. - */ - e->update_hash((void*) val, val_len, type, charset, - (flags & User_var_log_event::UNSIGNED_F)); + const Type_handler *th= Type_handler::handler_by_log_event_data_type(thd, + *this); + e->update_hash((void*) val, val_len, th, charset); + if (!is_deferred()) free_root(thd->mem_root, 0); else @@ -4497,13 +4523,14 @@ bool sql_ex_info::write_data(Log_event_writer *writer) Rows_log_event member functions **************************************************************************/ -Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, +Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, + ulonglong table_id, MY_BITMAP const *cols, bool is_transactional, Log_event_type event_type) : Log_event(thd_arg, 0, is_transactional), m_row_count(0), m_table(tbl_arg), - m_table_id(tid), + m_table_id(table_id), m_width(tbl_arg ? tbl_arg->s->fields : 1), m_rows_buf(0), m_rows_cur(0), m_rows_end(0), m_flags(0), m_type(event_type), m_extra_row_data(0) @@ -4515,12 +4542,13 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, { /* We allow a special form of dummy event when the table, and cols - are null and the table id is ~0UL. This is a temporary + are null and the table id is UINT32_MAX. This is a temporary solution, to be able to terminate a started statement in the binary log: the extraneous events will be removed in the future. */ - DBUG_ASSERT((tbl_arg && tbl_arg->s && tid != ~0UL) || - (!tbl_arg && !cols && tid == ~0UL)); + DBUG_ASSERT((tbl_arg && tbl_arg->s && + (table_id & MAX_TABLE_MAP_ID) != UINT32_MAX) || + (!tbl_arg && !cols && (table_id & MAX_TABLE_MAP_ID) == UINT32_MAX)); if (thd_arg->variables.option_bits & OPTION_NO_FOREIGN_KEY_CHECKS) set_flags(NO_FOREIGN_KEY_CHECKS_F); @@ -4668,12 +4696,12 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) LEX *lex= thd->lex; uint8 new_trg_event_map= get_trg_event_map(); /* - If m_table_id == ~0ULL, then we have a dummy event that does not + If m_table_id == UINT32_MAX, then we have a dummy event that does not contain any data. In that case, we just remove all tables in the tables_to_lock list, close the thread tables, and return with success. */ - if (m_table_id == ~0ULL) + if (m_table_id == UINT32_MAX) { /* This one is supposed to be set: just an extra check so that @@ -5346,10 +5374,10 @@ Rows_log_event::do_update_pos(rpl_group_info *rgi) bool Rows_log_event::write_data_header(Log_event_writer *writer) { uchar buf[ROWS_HEADER_LEN_V2]; // No need to init the buffer - DBUG_ASSERT(m_table_id != ~0ULL); + DBUG_ASSERT(m_table_id != UINT32_MAX); DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", { - int4store(buf + 0, m_table_id); + int4store(buf + 0, (ulong) m_table_id); int2store(buf + 4, m_flags); return (write_data(writer, buf, 6)); }); @@ -5554,7 +5582,7 @@ int Table_map_log_event::save_field_metadata() Mats says tbl->s lives longer than this event so it's ok to copy pointers (tbl->s->db etc) and not pointer content. */ -Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, +Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulonglong tid, bool is_transactional) : Log_event(thd, 0, is_transactional), m_table(tbl), @@ -5577,7 +5605,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, uchar cbuf[MAX_INT_WIDTH]; uchar *cbuf_end; DBUG_ENTER("Table_map_log_event::Table_map_log_event(TABLE)"); - DBUG_ASSERT(m_table_id != ~0ULL); + DBUG_ASSERT(m_table_id != UINT32_MAX); /* In TABLE_SHARE, "db" and "table_name" are 0-terminated (see this comment in table.cc / alloc_table_share(): @@ -5863,7 +5891,7 @@ int Table_map_log_event::do_apply_event(rpl_group_info *rgi) char buf[256]; my_snprintf(buf, sizeof(buf), - "Found table map event mapping table id %u which " + "Found table map event mapping table id %llu which " "was already mapped but with different settings.", table_list->table_id); @@ -5905,11 +5933,11 @@ int Table_map_log_event::do_update_pos(rpl_group_info *rgi) bool Table_map_log_event::write_data_header(Log_event_writer *writer) { - DBUG_ASSERT(m_table_id != ~0ULL); + DBUG_ASSERT(m_table_id != UINT32_MAX); uchar buf[TABLE_MAP_HEADER_LEN]; DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", { - int4store(buf + 0, m_table_id); + int4store(buf + 0, (ulong) m_table_id); int2store(buf + 4, m_flags); return (write_data(writer, buf, 6)); }); @@ -6345,7 +6373,7 @@ void Table_map_log_event::pack_info(Protocol *protocol) { char buf[256]; size_t bytes= my_snprintf(buf, sizeof(buf), - "table_id: %llu (%s.%s)", + "table_id: %llu (%s.%s)", m_table_id, m_dbnam, m_tblnam); protocol->store(buf, bytes, &my_charset_bin); } @@ -6360,7 +6388,7 @@ void Table_map_log_event::pack_info(Protocol *protocol) Constructor used to build an event for writing to the binary log. */ Write_rows_log_event::Write_rows_log_event(THD *thd_arg, TABLE *tbl_arg, - ulong tid_arg, + ulonglong tid_arg, bool is_transactional) :Rows_log_event(thd_arg, tbl_arg, tid_arg, tbl_arg->rpl_write_set, is_transactional, WRITE_ROWS_EVENT_V1) @@ -6370,7 +6398,7 @@ Write_rows_log_event::Write_rows_log_event(THD *thd_arg, TABLE *tbl_arg, Write_rows_compressed_log_event::Write_rows_compressed_log_event( THD *thd_arg, TABLE *tbl_arg, - ulong tid_arg, + ulonglong tid_arg, bool is_transactional) : Write_rows_log_event(thd_arg, tbl_arg, tid_arg, is_transactional) { @@ -6456,7 +6484,7 @@ Write_rows_log_event::do_before_row_operations(const rpl_group_info *) indexed and it cannot have a DEFAULT value). */ m_table->auto_increment_field_not_null= FALSE; - m_table->mark_auto_increment_column(); + m_table->mark_auto_increment_column(true); } return error; @@ -7634,7 +7662,8 @@ end: */ Delete_rows_log_event::Delete_rows_log_event(THD *thd_arg, TABLE *tbl_arg, - ulong tid, bool is_transactional) + ulonglong tid, + bool is_transactional) : Rows_log_event(thd_arg, tbl_arg, tid, tbl_arg->read_set, is_transactional, DELETE_ROWS_EVENT_V1) { @@ -7642,7 +7671,7 @@ Delete_rows_log_event::Delete_rows_log_event(THD *thd_arg, TABLE *tbl_arg, Delete_rows_compressed_log_event::Delete_rows_compressed_log_event( THD *thd_arg, TABLE *tbl_arg, - ulong tid_arg, + ulonglong tid_arg, bool is_transactional) : Delete_rows_log_event(thd_arg, tbl_arg, tid_arg, is_transactional) { @@ -7771,7 +7800,7 @@ uint8 Delete_rows_log_event::get_trg_event_map() const Constructor used to build an event for writing to the binary log. */ Update_rows_log_event::Update_rows_log_event(THD *thd_arg, TABLE *tbl_arg, - ulong tid, + ulonglong tid, bool is_transactional) : Rows_log_event(thd_arg, tbl_arg, tid, tbl_arg->read_set, is_transactional, UPDATE_ROWS_EVENT_V1) @@ -7779,9 +7808,9 @@ Update_rows_log_event::Update_rows_log_event(THD *thd_arg, TABLE *tbl_arg, init(tbl_arg->rpl_write_set); } -Update_rows_compressed_log_event::Update_rows_compressed_log_event(THD *thd_arg, TABLE *tbl_arg, - ulong tid, - bool is_transactional) +Update_rows_compressed_log_event:: +Update_rows_compressed_log_event(THD *thd_arg, TABLE *tbl_arg, + ulonglong tid, bool is_transactional) : Update_rows_log_event(thd_arg, tbl_arg, tid, is_transactional) { m_type = UPDATE_ROWS_COMPRESSED_EVENT_V1; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 33f76aa0e78..80a1e5a2c24 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5147,6 +5147,14 @@ static int init_server_components() us_to_ms(global_system_variables.optimizer_scan_setup_cost); } + /* + Plugins may not be completed because system table DDLs are only + run after the ddl recovery done. Therefore between the + plugin_init() call and the ha_signal_ddl_recovery_done() call + below only things related to preparation for recovery should be + done and nothing else, and definitely not anything assuming that + all plugins have been initialised. + */ if (plugin_init(&remaining_argc, remaining_argv, (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) | (opt_abort ? PLUGIN_INIT_SKIP_INITIALIZATION : 0))) @@ -5492,6 +5500,15 @@ static int init_server_components() #else locked_in_memory= 0; #endif +#ifdef PR_SET_THP_DISABLE + /* + Engine page buffers are now allocated. + Disable transparent huge pages for all + future allocations as these causes memory + leaks. + */ + prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0); +#endif ft_init_stopwords(); @@ -5739,8 +5756,6 @@ int mysqld_main(int argc, char **argv) SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size); } - (void) thr_setconcurrency(concurrency); // 10 by default - select_thread=pthread_self(); select_thread_in_use=1; @@ -6806,8 +6821,8 @@ struct my_option my_long_options[]= #endif }; -static int show_queries(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_queries(THD *thd, SHOW_VAR *var, void *, + system_status_var *, enum_var_type) { var->type= SHOW_LONGLONG; var->value= &thd->query_id; @@ -6815,16 +6830,16 @@ static int show_queries(THD *thd, SHOW_VAR *var, char *buff, } -static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_net_compression(THD *thd, SHOW_VAR *var, void *, + system_status_var *, enum_var_type) { var->type= SHOW_MY_BOOL; var->value= &thd->net.compress; return 0; } -static int show_starttime(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_starttime(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -6833,8 +6848,8 @@ static int show_starttime(THD *thd, SHOW_VAR *var, char *buff, } #ifdef ENABLED_PROFILING -static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_flushstatustime(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -6844,32 +6859,28 @@ static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff, #endif #ifdef HAVE_REPLICATION -static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_rpl_status(THD *, SHOW_VAR *var, void *, system_status_var *, + enum_var_type) { var->type= SHOW_CHAR; var->value= const_cast(rpl_status_type[(int)rpl_status]); return 0; } -static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_slave_running(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { - Master_info *mi= NULL; - bool UNINIT_VAR(tmp); - - var->type= SHOW_MY_BOOL; - var->value= buff; - - if ((mi= get_master_info(&thd->variables.default_master_connection, - Sql_condition::WARN_LEVEL_NOTE))) + if (Master_info *mi= + get_master_info(&thd->variables.default_master_connection, + Sql_condition::WARN_LEVEL_NOTE)) { - tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_READING && - mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN); + *((my_bool*) buff)= + (mi->slave_running == MYSQL_SLAVE_RUN_READING && + mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN); mi->release(); + var->type= SHOW_MY_BOOL; + var->value= buff; } - if (mi) - *((my_bool *)buff)= tmp; else var->type= SHOW_UNDEF; return 0; @@ -6879,7 +6890,8 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff, /* How many masters this slave is connected to */ -static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff) +static int show_slaves_running(THD *, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONGLONG; var->value= buff; @@ -6890,19 +6902,17 @@ static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff) } -static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { - Master_info *mi; - - var->type= SHOW_LONGLONG; - var->value= buff; - - if ((mi= get_master_info(&thd->variables.default_master_connection, - Sql_condition::WARN_LEVEL_NOTE))) + if (Master_info *mi= + get_master_info(&thd->variables.default_master_connection, + Sql_condition::WARN_LEVEL_NOTE)) { *((longlong *)buff)= mi->received_heartbeats; mi->release(); + var->type= SHOW_LONGLONG; + var->value= buff; } else var->type= SHOW_UNDEF; @@ -6910,19 +6920,17 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff, } -static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_heartbeat_period(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { - Master_info *mi; - - var->type= SHOW_CHAR; - var->value= buff; - - if ((mi= get_master_info(&thd->variables.default_master_connection, - Sql_condition::WARN_LEVEL_NOTE))) + if (Master_info *mi= + get_master_info(&thd->variables.default_master_connection, + Sql_condition::WARN_LEVEL_NOTE)) { - sprintf(buff, "%.3f", mi->heartbeat_period); + sprintf(static_cast(buff), "%.3f", mi->heartbeat_period); mi->release(); + var->type= SHOW_CHAR; + var->value= buff; } else var->type= SHOW_UNDEF; @@ -6932,19 +6940,20 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff, #endif /* HAVE_REPLICATION */ -static int show_max_used_connections_time(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_max_used_connections_time(THD *, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_CHAR; var->value= buff; - get_date(buff, GETDATE_DATE_TIME | GETDATE_FIXEDLENGTH, max_used_connections_time); + get_date(static_cast(buff), + GETDATE_DATE_TIME | GETDATE_FIXEDLENGTH, max_used_connections_time); return 0; } -static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_open_tables(THD *, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -6952,8 +6961,8 @@ static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_prepared_stmt_count(THD *, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -6963,8 +6972,8 @@ static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_table_definitions(THD *, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -6983,8 +6992,8 @@ static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff, inside an Event. */ -static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_ssl_get_version(THD *thd, SHOW_VAR *var, void *, + system_status_var *, enum_var_type) { var->type= SHOW_CHAR; if( thd->vio_ok() && thd->net.vio->ssl_arg ) @@ -6994,8 +7003,8 @@ static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -7006,8 +7015,8 @@ static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -7022,8 +7031,8 @@ static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_LONG; var->value= buff; @@ -7035,8 +7044,8 @@ static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_CHAR; if( thd->vio_ok() && thd->net.vio->ssl_arg ) @@ -7046,9 +7055,10 @@ static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, void *buf, + system_status_var *, enum_var_type) { + char *buff= static_cast(buf); var->type= SHOW_CHAR; var->value= buff; if (thd->vio_ok() && thd->net.vio->ssl_arg) @@ -7133,8 +7143,8 @@ end: */ static int -show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_CHAR; if(thd->vio_ok() && thd->net.vio->ssl_arg) @@ -7143,7 +7153,7 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff, X509 *cert= SSL_get_certificate(ssl); const ASN1_TIME *not_before= X509_get0_notBefore(cert); - var->value= my_asn1_time_to_string(not_before, buff, + var->value= my_asn1_time_to_string(not_before, static_cast(buff), SHOW_VAR_FUNC_BUFF_SIZE); if (!var->value) return 1; @@ -7167,8 +7177,8 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff, */ static int -show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_CHAR; if(thd->vio_ok() && thd->net.vio->ssl_arg) @@ -7177,7 +7187,7 @@ show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff, X509 *cert= SSL_get_certificate(ssl); const ASN1_TIME *not_after= X509_get0_notAfter(cert); - var->value= my_asn1_time_to_string(not_after, buff, + var->value= my_asn1_time_to_string(not_after, static_cast(buff), SHOW_VAR_FUNC_BUFF_SIZE); if (!var->value) return 1; @@ -7231,7 +7241,7 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, void *buff, } -static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff, +static int show_memory_used(THD *thd, SHOW_VAR *var, void *buff, struct system_status_var *status_var, enum enum_var_type scope) { @@ -7301,8 +7311,8 @@ static int debug_status_func(THD *thd, SHOW_VAR *var, void *buff, #endif #ifdef HAVE_POOL_OF_THREADS -static int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_threadpool_idle_threads(THD *, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_INT; var->value= buff; @@ -7311,8 +7321,8 @@ static int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff, } -static int show_threadpool_threads(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_threadpool_threads(THD *, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { var->type= SHOW_INT; var->value= buff; @@ -7470,7 +7480,7 @@ SHOW_VAR status_vars[]= { SHOW_FUNC_ENTRY("Rpl_semi_sync_master_net_avg_wait_time", &SHOW_FNAME(avg_net_wait_time)), {"Rpl_semi_sync_master_request_ack", (char*) &rpl_semi_sync_master_request_ack, SHOW_LONGLONG}, {"Rpl_semi_sync_master_get_ack", (char*)&rpl_semi_sync_master_get_ack, SHOW_LONGLONG}, - {"Rpl_semi_sync_slave_status", (char*) &rpl_semi_sync_slave_status, SHOW_BOOL}, + SHOW_FUNC_ENTRY("Rpl_semi_sync_slave_status", &rpl_semi_sync_enabled), {"Rpl_semi_sync_slave_send_ack", (char*) &rpl_semi_sync_slave_send_ack, SHOW_LONGLONG}, #endif /* HAVE_REPLICATION */ #ifdef HAVE_QUERY_CACHE diff --git a/sql/net_serv.cc b/sql/net_serv.cc index eff03efb858..bcbf9c6a36c 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -138,6 +138,7 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) net->where_b = net->remain_in_buf=0; net->net_skip_rest_factor= 0; net->last_errno=0; + net->pkt_nr_can_be_reset= 0; net->thread_specific_malloc= MY_TEST(my_flags & MY_THREAD_SPECIFIC); net->thd= 0; net->extension= NULL; diff --git a/sql/opt_rewrite_date_cmp.cc b/sql/opt_rewrite_date_cmp.cc index 5a6410414da..e115c94d3ca 100644 --- a/sql/opt_rewrite_date_cmp.cc +++ b/sql/opt_rewrite_date_cmp.cc @@ -233,91 +233,67 @@ void Date_cmp_func_rewriter::rewrite_le_gt_lt_ge() } -Item *Date_cmp_func_rewriter::create_start_bound() +Item *Date_cmp_func_rewriter::create_bound(uint month, uint day, + const TimeOfDay6 &td) const { - Item_datetime *res; - MYSQL_TIME const_arg_ts; - memset(&const_arg_ts, 0, sizeof(const_arg_ts)); - const_arg_ts.time_type= MYSQL_TIMESTAMP_DATETIME; + /* + We could always create Item_datetime with Item_datetime::decimals==6 here. + But this would not be efficient in some cases. + + Let's create an Item_datetime with Item_datetime::decimals + equal to field_ref->decimals, so if: + + (1) the original statement: + + SELECT ts3 FROM t1 WHERE DATE(ts3) <= '2024-01-23'; + + gets rewritten to: + + (2) a statement with DATETIME comparison + with an Item_datetime on the right side: + + SELECT ts3 FROM t1 + WHERE ts3 <= '2024-01-23 23:59.59.999'; -- Item_datetime + + and then gets further rewritten with help of convert_item_for_comparison() + to: + + (3) a statement with TIMESTAMP comparison + with an Item_timestamp_literal on the right side + + SELECT ts3 FROM t1 + WHERE ts3 <= '2024-01-23 23:59:59.999'; -- Item_timestamp_literal + + then we have an efficent statement calling + Type_handler_timestamp_common::cmp_native() for comparison, + which has a faster execution path when both sides have equal + fractional precision. + */ switch (argument_func_type) { case Item_func::YEAR_FUNC: - const_arg_ts.year= static_cast(const_arg_value->val_int()); - const_arg_ts.month= 1; - const_arg_ts.day= 1; - if (check_datetime_range(&const_arg_ts)) - return nullptr; - res= new (thd->mem_root) Item_datetime(thd); - res->set(&const_arg_ts); - break; + { + longlong year= const_arg_value->val_int(); + const Datetime bound(static_cast(year), month, day, td); + if (!bound.is_valid_datetime()) + return nullptr; // "year" was out of the supported range + return new (thd->mem_root) Item_datetime(thd, bound, field_ref->decimals); + } case Item_func::DATE_FUNC: if (field_ref->field->type() == MYSQL_TYPE_DATE) return const_arg_value; else { - Datetime const_arg_dt(current_thd, const_arg_value); + const Datetime const_arg_dt(current_thd, const_arg_value); if (!const_arg_dt.is_valid_datetime()) - return nullptr; - res= new (thd->mem_root) Item_datetime(thd); - const_arg_dt.copy_to_mysql_time(&const_arg_ts); - const_arg_ts.second_part= const_arg_ts.second= - const_arg_ts.minute= const_arg_ts.hour= 0; - const_arg_ts.time_type= MYSQL_TIMESTAMP_DATETIME; - res->set(&const_arg_ts); + return nullptr; // SQL NULL datetime + const Datetime bound(const_arg_dt.time_of_day(td)); + return new (thd->mem_root) Item_datetime(thd, bound, field_ref->decimals); } - break; default: DBUG_ASSERT(0); - res= nullptr; break; } - return res; -} - - -Item *Date_cmp_func_rewriter::create_end_bound() -{ - Item_datetime *res; - MYSQL_TIME const_arg_ts; - memset(&const_arg_ts, 0, sizeof(const_arg_ts)); - const_arg_ts.time_type= MYSQL_TIMESTAMP_DATETIME; - switch (argument_func_type) { - case Item_func::YEAR_FUNC: - const_arg_ts.year= static_cast(const_arg_value->val_int()); - const_arg_ts.month= 12; - const_arg_ts.day= 31; - const_arg_ts.hour= 23; - const_arg_ts.minute= TIME_MAX_MINUTE; - const_arg_ts.second= TIME_MAX_SECOND; - const_arg_ts.second_part= TIME_MAX_SECOND_PART; - if (check_datetime_range(&const_arg_ts)) - return nullptr; - res= new (thd->mem_root) Item_datetime(thd); - res->set(&const_arg_ts); - break; - case Item_func::DATE_FUNC: - if (field_ref->field->type() == MYSQL_TYPE_DATE) - return const_arg_value; - else - { - res= new (thd->mem_root) Item_datetime(thd); - Datetime const_arg_dt(current_thd, const_arg_value); - if (!const_arg_dt.is_valid_datetime()) - return nullptr; - const_arg_dt.copy_to_mysql_time(&const_arg_ts); - const_arg_ts.hour= 23; - const_arg_ts.minute= TIME_MAX_MINUTE; - const_arg_ts.second= TIME_MAX_SECOND; - const_arg_ts.second_part=TIME_MAX_SECOND_PART; - const_arg_ts.time_type= MYSQL_TIMESTAMP_DATETIME; - res->set(&const_arg_ts); - } - break; - default: - DBUG_ASSERT(0); - res= nullptr; - break; - } - return res; + return nullptr; } diff --git a/sql/opt_rewrite_date_cmp.h b/sql/opt_rewrite_date_cmp.h index 9f6e1d74ffa..6c2e499ffc7 100644 --- a/sql/opt_rewrite_date_cmp.h +++ b/sql/opt_rewrite_date_cmp.h @@ -82,8 +82,15 @@ private: const Type_handler *comparison_type, Item_func::Functype *out_func_type) const; void rewrite_le_gt_lt_ge(); - Item *create_start_bound(); - Item *create_end_bound(); + Item *create_bound(uint month, uint day, const TimeOfDay6 &td) const; + Item *create_start_bound() const + { + return create_bound(1, 1, TimeOfDay6()); + } + Item *create_end_bound() const + { + return create_bound(12, 31, TimeOfDay6::end_of_day(field_ref->decimals)); + } Item *create_cmp_func(Item_func::Functype func_type, Item *arg1, Item *arg2); THD *thd= nullptr; diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index 1008690ccaa..93090acfb96 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -103,7 +103,8 @@ inline bool sql_command_can_be_traced(enum enum_sql_command sql_command) sql_command == SQLCOM_UPDATE || sql_command == SQLCOM_DELETE || sql_command == SQLCOM_DELETE_MULTI || - sql_command == SQLCOM_UPDATE_MULTI; + sql_command == SQLCOM_UPDATE_MULTI || + sql_command == SQLCOM_INSERT_SELECT; } void opt_trace_print_expanded_query(THD *thd, SELECT_LEX *select_lex, diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index f64f0fd1c93..89a35129a2d 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -43,7 +43,8 @@ Master_info::Master_info(LEX_CSTRING *connection_name_arg, gtid_reconnect_event_skip_count(0), gtid_event_seen(false), in_start_all_slaves(0), in_stop_all_slaves(0), in_flush_all_relay_logs(0), users(0), killed(0), - total_ddl_groups(0), total_non_trans_groups(0), total_trans_groups(0) + total_ddl_groups(0), total_non_trans_groups(0), total_trans_groups(0), + semi_sync_reply_enabled(0) { char *tmp; host[0] = 0; user[0] = 0; password[0] = 0; diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index b25c0790e2a..7f2e4c50a1b 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -376,6 +376,12 @@ class Master_info : public Slave_reporting_capability it must be ignored similarly to the replicate-same-server-id rule. */ bool do_accept_own_server_id= false; + /* + Set to 1 when semi_sync is enabled. Set to 0 if there is any transmit + problems to the slave, in which case any furter semi-sync reply is + ignored + */ + bool semi_sync_reply_enabled; List start_alter_list; MEM_ROOT mem_root; /* diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc index 24ff7b9e8fe..cfe9b8c3a99 100644 --- a/sql/semisync_master.cc +++ b/sql/semisync_master.cc @@ -91,7 +91,9 @@ Active_tranx::Active_tranx(mysql_mutex_t *lock, for (int idx = 0; idx < m_num_entries; ++idx) m_trx_htb[idx] = NULL; +#ifdef EXTRA_DEBUG sql_print_information("Semi-sync replication initialized for transactions."); +#endif } Active_tranx::~Active_tranx() @@ -352,8 +354,7 @@ Repl_semi_sync_master::Repl_semi_sync_master() m_state(0), m_wait_point(0) { - strcpy(m_reply_file_name, ""); - strcpy(m_wait_file_name, ""); + m_reply_file_name[0]= m_wait_file_name[0]= 0; } int Repl_semi_sync_master::init_object() @@ -379,20 +380,10 @@ int Repl_semi_sync_master::init_object() { result = enable_master(); if (!result) - { result= ack_receiver.start(); /* Start the ACK thread. */ - /* - If rpl_semi_sync_master_wait_no_slave is disabled, let's temporarily - switch off semisync to avoid hang if there's none active slave. - */ - if (!rpl_semi_sync_master_wait_no_slave) - switch_off(); - } } else - { disable_master(); - } return result; } @@ -441,7 +432,7 @@ void Repl_semi_sync_master::disable_master() */ switch_off(); - assert(m_active_tranxs != NULL); + DBUG_ASSERT(m_active_tranxs != NULL); delete m_active_tranxs; m_active_tranxs = NULL; @@ -450,7 +441,6 @@ void Repl_semi_sync_master::disable_master() m_commit_file_name_inited = false; set_master_enabled(false); - sql_print_information("Semi-sync replication disabled on the master."); } unlock(); @@ -537,31 +527,34 @@ void Repl_semi_sync_master::add_slave() void Repl_semi_sync_master::remove_slave() { lock(); - rpl_semi_sync_master_clients--; - - /* Only switch off if semi-sync is enabled and is on */ - if (get_master_enabled() && is_on()) + if (!(--rpl_semi_sync_master_clients) && !rpl_semi_sync_master_wait_no_slave) { - /* If user has chosen not to wait if no semi-sync slave available - and the last semi-sync slave exits, turn off semi-sync on master - immediately. - */ - if (!rpl_semi_sync_master_wait_no_slave && - rpl_semi_sync_master_clients == 0) - switch_off(); + /* + Signal transactions waiting in commit_trx() that they do not have to + wait anymore. + */ + cond_broadcast(); } unlock(); } + +/* + Check report package + + @retval 0 ok + @retval 1 Error + @retval -1 Slave is going down (ok) +*/ + int Repl_semi_sync_master::report_reply_packet(uint32 server_id, const uchar *packet, ulong packet_len) { - int result= -1; + int result= 1; // Assume error char log_file_name[FN_REFLEN+1]; my_off_t log_file_pos; ulong log_file_len = 0; - DBUG_ENTER("Repl_semi_sync_master::report_reply_packet"); DBUG_EXECUTE_IF("semisync_corrupt_magic", @@ -569,7 +562,14 @@ int Repl_semi_sync_master::report_reply_packet(uint32 server_id, if (unlikely(packet[REPLY_MAGIC_NUM_OFFSET] != Repl_semi_sync_master::k_packet_magic_num)) { - sql_print_error("Read semi-sync reply magic number error"); + if (packet[0] == COM_QUIT && packet_len == 1) + { + /* Slave sent COM_QUIT as part of IO thread going down */ + sql_print_information("slave IO thread has stopped"); + DBUG_RETURN(-1); + } + else + sql_print_error("Read semi-sync reply magic number error"); goto l_end; } @@ -597,14 +597,13 @@ int Repl_semi_sync_master::report_reply_packet(uint32 server_id, rpl_semi_sync_master_get_ack++; report_reply_binlog(server_id, log_file_name, log_file_pos); - result= 0; + DBUG_RETURN(0); l_end: - if (result == -1) { char buf[256]; - octet2hex(buf, packet, std::min(static_cast(sizeof(buf)-1), - packet_len)); + octet2hex(buf, (const unsigned char*) packet, + MY_MIN(sizeof(buf)-1, (size_t) packet_len)); sql_print_information("First bytes of the packet from semisync slave " "server-id %d: %s", server_id, buf); @@ -668,7 +667,7 @@ int Repl_semi_sync_master::report_reply_binlog(uint32 server_id, m_reply_file_name_inited = true; /* Remove all active transaction nodes before this point. */ - assert(m_active_tranxs != NULL); + DBUG_ASSERT(m_active_tranxs != NULL); m_active_tranxs->clear_active_tranx_nodes(log_file_name, log_file_pos); DBUG_PRINT("semisync", ("%s: Got reply at (%s, %lu)", @@ -809,6 +808,8 @@ int Repl_semi_sync_master::dump_start(THD* thd, (long) thd->variables.server_id, log_file, (ulong) log_pos); + /* Mark that semi-sync net->pkt_nr is not reliable */ + thd->net.pkt_nr_can_be_reset= 1; return 0; } @@ -827,8 +828,15 @@ void Repl_semi_sync_master::dump_end(THD* thd) int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, my_off_t trx_wait_binlog_pos) { + bool success= 0; DBUG_ENTER("Repl_semi_sync_master::commit_trx"); + if (!rpl_semi_sync_master_clients && !rpl_semi_sync_master_wait_no_slave) + { + rpl_semi_sync_master_no_transactions++; + DBUG_RETURN(0); + } + if (get_master_enabled() && trx_wait_binlog_name) { struct timespec start_ts; @@ -836,7 +844,7 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, int wait_result; PSI_stage_info old_stage; THD *thd= current_thd; - + bool aborted= 0; set_timespec(start_ts, 0); DEBUG_SYNC(thd, "rpl_semisync_master_commit_trx_before_lock"); @@ -859,6 +867,13 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, while (is_on() && !thd_killed(thd)) { + /* We have to check these again as things may have changed */ + if (!rpl_semi_sync_master_clients && !rpl_semi_sync_master_wait_no_slave) + { + aborted= 1; + break; + } + if (m_reply_file_name_inited) { int cmp = Active_tranx::compare(m_reply_file_name, m_reply_file_pos, @@ -873,6 +888,7 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, "Repl_semi_sync_master::commit_trx", m_reply_file_name, (ulong)m_reply_file_pos)); + success= 1; break; } } @@ -973,13 +989,13 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, m_active_tranxs may be NULL if someone disabled semi sync during cond_timewait() */ - assert(thd_killed(thd) || !m_active_tranxs || - !m_active_tranxs->is_tranx_end_pos(trx_wait_binlog_name, - trx_wait_binlog_pos)); + DBUG_ASSERT(thd_killed(thd) || !m_active_tranxs || aborted || + !m_active_tranxs->is_tranx_end_pos(trx_wait_binlog_name, + trx_wait_binlog_pos)); l_end: /* Update the status counter. */ - if (is_on()) + if (success) rpl_semi_sync_master_yes_transactions++; else rpl_semi_sync_master_no_transactions++; @@ -1014,18 +1030,20 @@ void Repl_semi_sync_master::switch_off() { DBUG_ENTER("Repl_semi_sync_master::switch_off"); - m_state = false; + if (m_state) + { + m_state = false; - /* Clear the active transaction list. */ - assert(m_active_tranxs != NULL); - m_active_tranxs->clear_active_tranx_nodes(NULL, 0); - - rpl_semi_sync_master_off_times++; - m_wait_file_name_inited = false; - m_reply_file_name_inited = false; - sql_print_information("Semi-sync replication switched OFF."); - cond_broadcast(); /* wake up all waiting threads */ + /* Clear the active transaction list. */ + DBUG_ASSERT(m_active_tranxs != NULL); + m_active_tranxs->clear_active_tranx_nodes(NULL, 0); + rpl_semi_sync_master_off_times++; + m_wait_file_name_inited = false; + m_reply_file_name_inited = false; + sql_print_information("Semi-sync replication switched OFF."); + } + cond_broadcast(); /* wake up all waiting threads */ DBUG_VOID_RETURN; } @@ -1072,9 +1090,10 @@ int Repl_semi_sync_master::reserve_sync_header(String* packet) { DBUG_ENTER("Repl_semi_sync_master::reserve_sync_header"); - /* Set the magic number and the sync status. By default, no sync - * is required. - */ + /* + Set the magic number and the sync status. By default, no sync + is required. + */ packet->append(reinterpret_cast(k_sync_header), sizeof(k_sync_header)); DBUG_RETURN(0); @@ -1087,7 +1106,6 @@ int Repl_semi_sync_master::update_sync_header(THD* thd, unsigned char *packet, { int cmp = 0; bool sync = false; - DBUG_ENTER("Repl_semi_sync_master::update_sync_header"); /* If the semi-sync master is not enabled, or the slave is not a semi-sync @@ -1103,16 +1121,11 @@ int Repl_semi_sync_master::update_sync_header(THD* thd, unsigned char *packet, /* This is the real check inside the mutex. */ if (!get_master_enabled()) - { - assert(sync == false); goto l_end; - } if (is_on()) { /* semi-sync is ON */ - sync = false; /* No sync unless a transaction is involved. */ - if (m_reply_file_name_inited) { cmp = Active_tranx::compare(log_file_name, log_file_pos, @@ -1126,15 +1139,10 @@ int Repl_semi_sync_master::update_sync_header(THD* thd, unsigned char *packet, } } + cmp = 1; if (m_wait_file_name_inited) - { cmp = Active_tranx::compare(log_file_name, log_file_pos, m_wait_file_name, m_wait_file_pos); - } - else - { - cmp = 1; - } /* If we are already waiting for some transaction replies which * are later in binlog, do not wait for this one event. @@ -1144,7 +1152,7 @@ int Repl_semi_sync_master::update_sync_header(THD* thd, unsigned char *packet, /* * We only wait if the event is a transaction's ending event. */ - assert(m_active_tranxs != NULL); + DBUG_ASSERT(m_active_tranxs != NULL); sync = m_active_tranxs->is_tranx_end_pos(log_file_name, log_file_pos); } @@ -1172,13 +1180,12 @@ int Repl_semi_sync_master::update_sync_header(THD* thd, unsigned char *packet, l_end: unlock(); - /* We do not need to clear sync flag because we set it to 0 when we - * reserve the packet header. - */ + /* + We do not need to clear sync flag in packet because we set it to 0 when we + reserve the packet header. + */ if (sync) - { - (packet)[2] = k_packet_flag_sync; - } + packet[2]= k_packet_flag_sync; DBUG_RETURN(0); } @@ -1225,7 +1232,7 @@ int Repl_semi_sync_master::write_tranx_in_binlog(const char* log_file_name, if (is_on()) { - assert(m_active_tranxs != NULL); + DBUG_ASSERT(m_active_tranxs != NULL); if(m_active_tranxs->insert_tranx_node(log_file_name, log_file_pos)) { /* @@ -1256,7 +1263,7 @@ int Repl_semi_sync_master::flush_net(THD *thd, DBUG_ENTER("Repl_semi_sync_master::flush_net"); - assert((unsigned char)event_buf[1] == k_packet_magic_num); + DBUG_ASSERT((unsigned char)event_buf[1] == k_packet_magic_num); if ((unsigned char)event_buf[2] != k_packet_flag_sync) { /* current event does not require reply */ @@ -1274,6 +1281,11 @@ int Repl_semi_sync_master::flush_net(THD *thd, goto l_end; } + /* + We have to do a net_clear() as with semi-sync the slave_reply's are + interleaved with data from the master and then the net->pkt_nr + cannot be kept in sync. Better to start pkt_nr from 0 again. + */ net_clear(net, 0); net->pkt_nr++; net->compress_pkt_nr++; @@ -1300,11 +1312,7 @@ int Repl_semi_sync_master::after_reset_master() lock(); - if (rpl_semi_sync_master_clients == 0 && - !rpl_semi_sync_master_wait_no_slave) - m_state = 0; - else - m_state = get_master_enabled()? 1 : 0; + m_state = get_master_enabled() ? 1 : 0; m_wait_file_name_inited = false; m_reply_file_name_inited = false; @@ -1338,18 +1346,6 @@ int Repl_semi_sync_master::before_reset_master() DBUG_RETURN(result); } -void Repl_semi_sync_master::check_and_switch() -{ - lock(); - if (get_master_enabled() && is_on()) - { - if (!rpl_semi_sync_master_wait_no_slave - && rpl_semi_sync_master_clients == 0) - switch_off(); - } - unlock(); -} - void Repl_semi_sync_master::set_export_stats() { lock(); @@ -1363,7 +1359,6 @@ void Repl_semi_sync_master::set_export_stats() ((rpl_semi_sync_master_net_wait_num) ? (ulong)((double)rpl_semi_sync_master_net_wait_time / ((double)rpl_semi_sync_master_net_wait_num)) : 0); - unlock(); } diff --git a/sql/semisync_master.h b/sql/semisync_master.h index 5451ad512c6..99f46869354 100644 --- a/sql/semisync_master.h +++ b/sql/semisync_master.h @@ -633,8 +633,6 @@ class Repl_semi_sync_master /*called before reset master*/ int before_reset_master(); - void check_and_switch(); - /* Determines if the given thread is currently awaiting a semisync_ack. Note that the thread's value is protected by this class's LOCK_binlog, so this diff --git a/sql/semisync_master_ack_receiver.cc b/sql/semisync_master_ack_receiver.cc index 559f939c42c..a311599c54b 100644 --- a/sql/semisync_master_ack_receiver.cc +++ b/sql/semisync_master_ack_receiver.cc @@ -24,7 +24,8 @@ extern PSI_cond_key key_COND_ack_receiver; #ifdef HAVE_PSI_THREAD_INTERFACE extern PSI_thread_key key_thread_ack_receiver; #endif -extern Repl_semi_sync_master repl_semisync; + +my_socket global_ack_signal_fd= -1; /* Callback function of ack receive thread */ pthread_handler_t ack_receive_handler(void *arg) @@ -45,6 +46,7 @@ Ack_receiver::Ack_receiver() m_status= ST_DOWN; mysql_mutex_init(key_LOCK_ack_receiver, &m_mutex, NULL); mysql_cond_init(key_COND_ack_receiver, &m_cond, NULL); + mysql_cond_init(key_COND_ack_receiver, &m_cond_reply, NULL); m_pid= 0; DBUG_VOID_RETURN; @@ -57,6 +59,7 @@ void Ack_receiver::cleanup() stop(); mysql_mutex_destroy(&m_mutex); mysql_cond_destroy(&m_cond); + mysql_cond_destroy(&m_cond_reply); DBUG_VOID_RETURN; } @@ -104,6 +107,7 @@ void Ack_receiver::stop() if (m_status == ST_UP) { m_status= ST_STOPPING; + signal_listener(); // Signal listener thread to stop mysql_cond_broadcast(&m_cond); while (m_status == ST_STOPPING) @@ -118,6 +122,21 @@ void Ack_receiver::stop() DBUG_VOID_RETURN; } +#ifndef DBUG_OFF +void static dbug_verify_no_duplicate_slaves(Slave_ilist *m_slaves, THD *thd) +{ + I_List_iterator it(*m_slaves); + Slave *slave; + while ((slave= it++)) + { + DBUG_ASSERT(slave->thd->variables.server_id != thd->variables.server_id); + } +} +#else +#define dbug_verify_no_duplicate_slaves(A,B) do {} while(0) +#endif + + bool Ack_receiver::add_slave(THD *thd) { Slave *slave; @@ -126,17 +145,23 @@ bool Ack_receiver::add_slave(THD *thd) if (!(slave= new Slave)) DBUG_RETURN(true); + slave->active= 0; slave->thd= thd; slave->vio= *thd->net.vio; slave->vio.mysql_socket.m_psi= NULL; slave->vio.read_timeout= 1; mysql_mutex_lock(&m_mutex); + + dbug_verify_no_duplicate_slaves(&m_slaves, thd); + m_slaves.push_back(slave); m_slaves_changed= true; mysql_cond_broadcast(&m_cond); mysql_mutex_unlock(&m_mutex); + signal_listener(); // Inform listener that there are new slaves + DBUG_RETURN(false); } @@ -144,6 +169,7 @@ void Ack_receiver::remove_slave(THD *thd) { I_List_iterator it(m_slaves); Slave *slave; + bool slaves_changed= 0; DBUG_ENTER("Ack_receiver::remove_slave"); mysql_mutex_lock(&m_mutex); @@ -153,10 +179,23 @@ void Ack_receiver::remove_slave(THD *thd) if (slave->thd == thd) { delete slave; - m_slaves_changed= true; + slaves_changed= true; break; } } + if (slaves_changed) + { + m_slaves_changed= true; + mysql_cond_broadcast(&m_cond); + /* + Wait until Ack_receiver::run() acknowledges remove of slave + As this is only sent under the mutex and after listners has + been collected, we know that listener has ignored the found + slave. + */ + if (m_status != ST_DOWN) + mysql_cond_wait(&m_cond_reply, &m_mutex); + } mysql_mutex_unlock(&m_mutex); DBUG_VOID_RETURN; @@ -167,10 +206,15 @@ inline void Ack_receiver::set_stage_info(const PSI_stage_info &stage) (void)MYSQL_SET_STAGE(stage.m_key, __FILE__, __LINE__); } -inline void Ack_receiver::wait_for_slave_connection() +void Ack_receiver::wait_for_slave_connection(THD *thd) { - set_stage_info(stage_waiting_for_semi_sync_slave); - mysql_cond_wait(&m_cond, &m_mutex); + thd->enter_cond(&m_cond, &m_mutex, &stage_waiting_for_semi_sync_slave, + 0, __func__, __FILE__, __LINE__); + + while (m_status == ST_UP && m_slaves.is_empty()) + mysql_cond_wait(&m_cond, &m_mutex); + + thd->exit_cond(0, __func__, __FILE__, __LINE__); } /* Auxilary function to initialize a NET object with given net buffer. */ @@ -188,17 +232,23 @@ void Ack_receiver::run() THD *thd= new THD(next_thread_id()); NET net; unsigned char net_buff[REPLY_MESSAGE_MAX_LENGTH]; + DBUG_ENTER("Ack_receiver::run"); my_thread_init(); - DBUG_ENTER("Ack_receiver::run"); - #ifdef HAVE_POLL Poll_socket_listener listener(m_slaves); #else Select_socket_listener listener(m_slaves); #endif //HAVE_POLL + if (listener.got_error()) + { + sql_print_error("Got error %M starting ack receiver thread", + listener.got_error()); + return; + } + sql_print_information("Starting ack receiver thread"); thd->system_thread= SYSTEM_THREAD_SEMISYNC_MASTER_BACKGROUND; thd->thread_stack= (char*) &thd; @@ -207,64 +257,79 @@ void Ack_receiver::run() thd->set_command(COM_DAEMON); init_net(&net, net_buff, REPLY_MESSAGE_MAX_LENGTH); - mysql_mutex_lock(&m_mutex); + /* + Mark that we have to setup the listener. Note that only this functions can + set m_slaves_changed to false + */ m_slaves_changed= true; - mysql_mutex_unlock(&m_mutex); while (1) { - int ret; - uint slave_count __attribute__((unused))= 0; + int ret, slave_count= 0; Slave *slave; mysql_mutex_lock(&m_mutex); - if (unlikely(m_status == ST_STOPPING)) + if (unlikely(m_status != ST_UP)) goto end; - set_stage_info(stage_waiting_for_semi_sync_ack_from_slave); if (unlikely(m_slaves_changed)) { if (unlikely(m_slaves.is_empty())) { - wait_for_slave_connection(); - mysql_mutex_unlock(&m_mutex); + m_slaves_changed= false; + mysql_cond_broadcast(&m_cond_reply); // Signal remove_slave + wait_for_slave_connection(thd); + /* Wait for slave unlocks m_mutex */ continue; } + set_stage_info(stage_waiting_for_semi_sync_ack_from_slave); if ((slave_count= listener.init_slave_sockets()) == 0) + { + mysql_mutex_unlock(&m_mutex); + m_slaves_changed= true; + continue; // Retry + } + if (slave_count < 0) goto end; m_slaves_changed= false; + mysql_cond_broadcast(&m_cond_reply); // Signal remove_slave + } + #ifdef HAVE_POLL DBUG_PRINT("info", ("fd count %u", slave_count)); #else DBUG_PRINT("info", ("fd count %u, max_fd %d", slave_count, (int) listener.get_max_fd())); #endif - } + mysql_mutex_unlock(&m_mutex); ret= listener.listen_on_sockets(); + if (ret <= 0) { - mysql_mutex_unlock(&m_mutex); ret= DBUG_IF("rpl_semisync_simulate_select_error") ? -1 : ret; if (ret == -1 && errno != EINTR) sql_print_information("Failed to wait on semi-sync sockets, " "error: errno=%d", socket_errno); - /* Sleep 1us, so other threads can catch the m_mutex easily. */ - my_sleep(1); continue; } + listener.clear_signal(); + mysql_mutex_lock(&m_mutex); set_stage_info(stage_reading_semi_sync_ack); Slave_ilist_iterator it(m_slaves); while ((slave= it++)) { - if (listener.is_socket_active(slave)) + if (slave->active && + ((slave->vio.read_pos < slave->vio.read_end) || + listener.is_socket_active(slave))) { ulong len; + /* Semi-sync packets will always be sent with pkt_nr == 1 */ net_clear(&net, 0); net.vio= &slave->vio; /* @@ -275,29 +340,42 @@ void Ack_receiver::run() len= my_net_read(&net); if (likely(len != packet_error)) - repl_semisync_master.report_reply_packet(slave->server_id(), - net.read_pos, len); - else { - if (net.last_errno == ER_NET_READ_ERROR) + int res; + res= repl_semisync_master.report_reply_packet(slave->server_id(), + net.read_pos, len); + if (unlikely(res < 0)) { - listener.clear_socket_info(slave); + /* + Slave has sent COM_QUIT or other failure. + Delete it from listener + */ + it.remove(); + m_slaves_changed= true; } + } + else if (net.last_errno == ER_NET_READ_ERROR) + { if (net.last_errno > 0 && global_system_variables.log_warnings > 2) sql_print_warning("Semisync ack receiver got error %d \"%s\" " "from slave server-id %d", net.last_errno, ER_DEFAULT(net.last_errno), slave->server_id()); + it.remove(); + m_slaves_changed= true; } } } mysql_mutex_unlock(&m_mutex); } + end: sql_print_information("Stopping ack receiver thread"); m_status= ST_DOWN; - delete thd; mysql_cond_broadcast(&m_cond); + mysql_cond_broadcast(&m_cond_reply); mysql_mutex_unlock(&m_mutex); + + delete thd; DBUG_VOID_RETURN; } diff --git a/sql/semisync_master_ack_receiver.h b/sql/semisync_master_ack_receiver.h index d869bd2e6d4..eacb4b200c0 100644 --- a/sql/semisync_master_ack_receiver.h +++ b/sql/semisync_master_ack_receiver.h @@ -20,6 +20,7 @@ #include "my_pthread.h" #include "sql_class.h" #include "semisync.h" +#include "socketpair.h" #include struct Slave :public ilink @@ -29,6 +30,7 @@ struct Slave :public ilink #ifdef HAVE_POLL uint m_fds_index; #endif + bool active; my_socket sock_fd() const { return vio.mysql_socket.fd; } uint server_id() const { return thd->variables.server_id; } }; @@ -46,6 +48,7 @@ typedef I_List_iterator Slave_ilist_iterator; add_slave: maintain a new semisync slave's information remove_slave: remove a semisync slave's information */ + class Ack_receiver : public Repl_semi_sync_base { public: @@ -96,15 +99,20 @@ public: { m_trace_level= trace_level; } + bool running() + { + return m_status != ST_DOWN; + } + private: enum status {ST_UP, ST_DOWN, ST_STOPPING}; - uint8 m_status; + enum status m_status; /* Protect m_status, m_slaves_changed and m_slaves. ack thread and other session may access the variables at the same time. */ mysql_mutex_t m_mutex; - mysql_cond_t m_cond; + mysql_cond_t m_cond, m_cond_reply; /* If slave list is updated(add or remove). */ bool m_slaves_changed; @@ -116,25 +124,103 @@ private: Ack_receiver& operator=(const Ack_receiver &ack_receiver); void set_stage_info(const PSI_stage_info &stage); - void wait_for_slave_connection(); + void wait_for_slave_connection(THD *thd); }; -#ifdef HAVE_POLL -#include -#include +extern my_socket global_ack_signal_fd; -class Poll_socket_listener +class Ack_listener { public: - Poll_socket_listener(const Slave_ilist &slaves) - :m_slaves(slaves) + my_socket local_read_signal; + const Slave_ilist &m_slaves; + int error; + + Ack_listener(const Slave_ilist &slaves) + :local_read_signal(-1), m_slaves(slaves), error(0) { + my_socket pipes[2]; +#ifdef _WIN32 + error= create_socketpair(pipes); +#else + if (!pipe(pipes)) + { + fcntl(pipes[0], F_SETFL, O_NONBLOCK); + fcntl(pipes[1], F_SETFL, O_NONBLOCK); + } + else + { + pipes[0]= pipes[1]= -1; + } +#endif /* _WIN32 */ + local_read_signal= pipes[0]; + global_ack_signal_fd= pipes[1]; } + virtual ~Ack_listener() + { +#ifdef _WIN32 + my_socket pipes[2]; + pipes[0]= local_read_signal; + pipes[1]= global_ack_signal_fd; + close_socketpair(pipes); +#else + if (global_ack_signal_fd >= 0) + close(global_ack_signal_fd); + if (local_read_signal >= 0) + close(local_read_signal); +#endif /* _WIN32 */ + global_ack_signal_fd= local_read_signal= -1; + } + + int got_error() { return error; } + + virtual bool has_signal_data()= 0; + + /* Clear data sent by signal_listener() to abort read */ + void clear_signal() + { + if (has_signal_data()) + { + char buff[100]; + /* Clear the signal message */ +#ifndef _WIN32 + read(local_read_signal, buff, sizeof(buff)); +#else + recv(local_read_signal, buff, sizeof(buff), 0); +#endif /* _WIN32 */ + } + } +}; + +static inline void signal_listener() +{ +#ifndef _WIN32 + my_write(global_ack_signal_fd, (uchar*) "a", 1, MYF(0)); +#else + send(global_ack_signal_fd, "a", 1, 0); +#endif /* _WIN32 */ +} + +#ifdef HAVE_POLL +#include + +class Poll_socket_listener final : public Ack_listener +{ +private: + std::vector m_fds; + +public: + Poll_socket_listener(const Slave_ilist &slaves) + :Ack_listener(slaves) + {} + + virtual ~Poll_socket_listener() = default; + bool listen_on_sockets() { - return poll(m_fds.data(), m_fds.size(), 1000 /*1 Second timeout*/); + return poll(m_fds.data(), m_fds.size(), -1); } bool is_socket_active(const Slave *slave) @@ -148,15 +234,29 @@ public: m_fds[slave->m_fds_index].events= 0; } - uint init_slave_sockets() + bool has_signal_data() override + { + /* The signal fd is always first */ + return (m_fds[0].revents & POLLIN); + } + + int init_slave_sockets() { Slave_ilist_iterator it(const_cast(m_slaves)); Slave *slave; uint fds_index= 0; + pollfd poll_fd; m_fds.clear(); + /* First put in the signal socket */ + poll_fd.fd= local_read_signal; + poll_fd.events= POLLIN; + m_fds.push_back(poll_fd); + fds_index++; + while ((slave= it++)) { + slave->active= 1; pollfd poll_fd; poll_fd.fd= slave->sock_fd(); poll_fd.events= POLLIN; @@ -165,29 +265,30 @@ public: } return fds_index; } - -private: - const Slave_ilist &m_slaves; - std::vector m_fds; }; #else //NO POLL -class Select_socket_listener +class Select_socket_listener final : public Ack_listener { +private: + my_socket m_max_fd; + fd_set m_init_fds; + fd_set m_fds; + public: Select_socket_listener(const Slave_ilist &slaves) - :m_slaves(slaves), m_max_fd(INVALID_SOCKET) - { - } + :Ack_listener(slaves), m_max_fd(INVALID_SOCKET) + {} + + virtual ~Select_socket_listener() = default; bool listen_on_sockets() { /* Reinitialize the fds with active fds before calling select */ m_fds= m_init_fds; - struct timeval tv= {1,0}; /* select requires max fd + 1 for the first argument */ - return select((int) m_max_fd+1, &m_fds, NULL, NULL, &tv); + return select((int) m_max_fd+1, &m_fds, NULL, NULL, NULL); } bool is_socket_active(const Slave *slave) @@ -195,43 +296,61 @@ public: return FD_ISSET(slave->sock_fd(), &m_fds); } + bool has_signal_data() override + { + return FD_ISSET(local_read_signal, &m_fds); + } + void clear_socket_info(const Slave *slave) { FD_CLR(slave->sock_fd(), &m_init_fds); } - uint init_slave_sockets() + int init_slave_sockets() { Slave_ilist_iterator it(const_cast(m_slaves)); Slave *slave; uint fds_index= 0; FD_ZERO(&m_init_fds); + m_max_fd= -1; + + /* First put in the signal socket */ + FD_SET(local_read_signal, &m_init_fds); + fds_index++; + set_if_bigger(m_max_fd, local_read_signal); +#ifndef _WIN32 + if (local_read_signal > FD_SETSIZE) + { + int socket_id= local_read_signal; + sql_print_error("Semisync slave socket fd is %u. " + "select() cannot handle if the socket fd is " + "greater than %u (FD_SETSIZE).", socket_id, FD_SETSIZE); + return -1; + } +#endif + while ((slave= it++)) { my_socket socket_id= slave->sock_fd(); - m_max_fd= (socket_id > m_max_fd ? socket_id : m_max_fd); + set_if_bigger(m_max_fd, socket_id); #ifndef _WIN32 if (socket_id > FD_SETSIZE) { sql_print_error("Semisync slave socket fd is %u. " "select() cannot handle if the socket fd is " "greater than %u (FD_SETSIZE).", socket_id, FD_SETSIZE); - return 0; + it.remove(); + continue; } #endif //_WIN32 FD_SET(socket_id, &m_init_fds); fds_index++; + slave->active= 1; } return fds_index; } my_socket get_max_fd() { return m_max_fd; } - -private: - const Slave_ilist &m_slaves; - my_socket m_max_fd; - fd_set m_init_fds; - fd_set m_fds; }; #endif //HAVE_POLL diff --git a/sql/semisync_slave.cc b/sql/semisync_slave.cc index 788aab78911..4314b116287 100644 --- a/sql/semisync_slave.cc +++ b/sql/semisync_slave.cc @@ -20,20 +20,9 @@ Repl_semi_sync_slave repl_semisync_slave; -my_bool rpl_semi_sync_slave_enabled= 0; - +my_bool global_rpl_semi_sync_slave_enabled= 0; char rpl_semi_sync_slave_delay_master; -my_bool rpl_semi_sync_slave_status= 0; ulong rpl_semi_sync_slave_trace_level; - -/* - indicate whether or not the slave should send a reply to the master. - - This is set to true in repl_semi_slave_read_event if the current - event read is the last event of a transaction. And the value is - checked in repl_semi_slave_queue_event. -*/ -bool semi_sync_need_reply= false; unsigned int rpl_semi_sync_slave_kill_conn_timeout; unsigned long long rpl_semi_sync_slave_send_ack = 0; @@ -44,14 +33,26 @@ int Repl_semi_sync_slave::init_object() m_init_done = true; /* References to the parameter works after set_options(). */ - set_slave_enabled(rpl_semi_sync_slave_enabled); + set_slave_enabled(global_rpl_semi_sync_slave_enabled); set_trace_level(rpl_semi_sync_slave_trace_level); set_delay_master(rpl_semi_sync_slave_delay_master); set_kill_conn_timeout(rpl_semi_sync_slave_kill_conn_timeout); - return result; } +static bool local_semi_sync_enabled; + +int rpl_semi_sync_enabled(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *status_var, + enum_var_type scope) +{ + local_semi_sync_enabled= repl_semisync_slave.get_slave_enabled(); + var->type= SHOW_BOOL; + var->value= (char*) &local_semi_sync_enabled; + return 0; +} + + int Repl_semi_sync_slave::slave_read_sync_header(const uchar *header, unsigned long total_len, int *semi_flags, @@ -61,12 +62,12 @@ int Repl_semi_sync_slave::slave_read_sync_header(const uchar *header, int read_res = 0; DBUG_ENTER("Repl_semi_sync_slave::slave_read_sync_header"); - if (rpl_semi_sync_slave_status) + if (get_slave_enabled()) { if (!DBUG_IF("semislave_corrupt_log") && header[0] == k_packet_magic_num) { - semi_sync_need_reply = (header[1] & k_packet_flag_sync); + bool semi_sync_need_reply = (header[1] & k_packet_flag_sync); *payload_len = total_len - 2; *payload = header + 2; @@ -85,7 +86,9 @@ int Repl_semi_sync_slave::slave_read_sync_header(const uchar *header, "len: %lu", total_len); read_res = -1; } - } else { + } + else + { *payload= header; *payload_len= total_len; } @@ -93,9 +96,23 @@ int Repl_semi_sync_slave::slave_read_sync_header(const uchar *header, DBUG_RETURN(read_res); } -int Repl_semi_sync_slave::slave_start(Master_info *mi) +/* + Set default semisync variables and print some replication info to the log + + Note that the main setup is done in request_transmit() +*/ + +void Repl_semi_sync_slave::slave_start(Master_info *mi) { - bool semi_sync= get_slave_enabled(); + + /* + Set semi_sync_enabled at slave start. This is not changed until next + slave start or reconnect. + */ + bool semi_sync= global_rpl_semi_sync_slave_enabled; + + set_slave_enabled(semi_sync); + mi->semi_sync_reply_enabled= 0; sql_print_information("Slave I/O thread: Start %s replication to\ master '%s@%s:%d' in log '%s' at position %lu", @@ -104,30 +121,29 @@ int Repl_semi_sync_slave::slave_start(Master_info *mi) const_cast(mi->master_log_name), (unsigned long)(mi->master_log_pos)); - if (semi_sync && !rpl_semi_sync_slave_status) - rpl_semi_sync_slave_status= 1; - /*clear the counter*/ rpl_semi_sync_slave_send_ack= 0; - return 0; } -int Repl_semi_sync_slave::slave_stop(Master_info *mi) +void Repl_semi_sync_slave::slave_stop(Master_info *mi) { if (get_slave_enabled()) kill_connection(mi->mysql); - if (rpl_semi_sync_slave_status) - rpl_semi_sync_slave_status= 0; - - return 0; + set_slave_enabled(0); } -int Repl_semi_sync_slave::reset_slave(Master_info *mi) +void Repl_semi_sync_slave::slave_reconnect(Master_info *mi) { - return 0; + /* + Start semi-sync either if it globally enabled or if was enabled + before the reconnect. + */ + if (global_rpl_semi_sync_slave_enabled || get_slave_enabled()) + slave_start(mi); } + void Repl_semi_sync_slave::kill_connection(MYSQL *mysql) { if (!mysql) @@ -194,33 +210,43 @@ int Repl_semi_sync_slave::request_transmit(Master_info *mi) !(res= mysql_store_result(mysql))) { sql_print_error("Execution failed on master: %s, error :%s", query, mysql_error(mysql)); + set_slave_enabled(0); return 1; } row= mysql_fetch_row(res); - if (DBUG_IF("master_not_support_semisync") || !row) + if (DBUG_IF("master_not_support_semisync") || (!row || ! row[1])) { /* Master does not support semi-sync */ - sql_print_warning("Master server does not support semi-sync, " - "fallback to asynchronous replication"); - rpl_semi_sync_slave_status= 0; + if (!row) + sql_print_warning("Master server does not support semi-sync, " + "fallback to asynchronous replication"); + set_slave_enabled(0); mysql_free_result(res); return 0; } + if (strcmp(row[1], "ON")) + sql_print_information("Slave has semi-sync enabled but master server does " + "not. Semi-sync will be activated when master " + "enables it"); mysql_free_result(res); /* Tell master dump thread that we want to do semi-sync - replication + replication. This is done by setting a thread local variable in + the master connection. */ query= "SET @rpl_semi_sync_slave= 1"; if (mysql_real_query(mysql, query, (ulong)strlen(query))) { - sql_print_error("Set 'rpl_semi_sync_slave=1' on master failed"); + sql_print_error("%s on master failed", query); + set_slave_enabled(0); return 1; } + mi->semi_sync_reply_enabled= 1; + /* Inform net_server that pkt_nr can come out of order */ + mi->mysql->net.pkt_nr_can_be_reset= 1; mysql_free_result(mysql_store_result(mysql)); - rpl_semi_sync_slave_status= 1; return 0; } @@ -230,46 +256,40 @@ int Repl_semi_sync_slave::slave_reply(Master_info *mi) MYSQL* mysql= mi->mysql; const char *binlog_filename= const_cast(mi->master_log_name); my_off_t binlog_filepos= mi->master_log_pos; - NET *net= &mysql->net; uchar reply_buffer[REPLY_MAGIC_NUM_LEN + REPLY_BINLOG_POS_LEN + REPLY_BINLOG_NAME_LEN]; int reply_res = 0; size_t name_len = strlen(binlog_filename); - DBUG_ENTER("Repl_semi_sync_slave::slave_reply"); + DBUG_ASSERT(get_slave_enabled() && mi->semi_sync_reply_enabled); - if (rpl_semi_sync_slave_status && semi_sync_need_reply) + /* Prepare the buffer of the reply. */ + reply_buffer[REPLY_MAGIC_NUM_OFFSET] = k_packet_magic_num; + int8store(reply_buffer + REPLY_BINLOG_POS_OFFSET, binlog_filepos); + memcpy(reply_buffer + REPLY_BINLOG_NAME_OFFSET, + binlog_filename, + name_len + 1 /* including trailing '\0' */); + + DBUG_PRINT("semisync", ("%s: reply (%s, %lu)", + "Repl_semi_sync_slave::slave_reply", + binlog_filename, (ulong)binlog_filepos)); + + /* + We have to do a net_clear() as with semi-sync the slave_reply's are + interleaved with data from the master and then the net->pkt_nr + cannot be kept in sync. Better to start pkt_nr from 0 again. + */ + net_clear(net, 0); + /* Send the reply. */ + reply_res = my_net_write(net, reply_buffer, + name_len + REPLY_BINLOG_NAME_OFFSET); + if (!reply_res) { - /* Prepare the buffer of the reply. */ - reply_buffer[REPLY_MAGIC_NUM_OFFSET] = k_packet_magic_num; - int8store(reply_buffer + REPLY_BINLOG_POS_OFFSET, binlog_filepos); - memcpy(reply_buffer + REPLY_BINLOG_NAME_OFFSET, - binlog_filename, - name_len + 1 /* including trailing '\0' */); - - DBUG_PRINT("semisync", ("%s: reply (%s, %lu)", - "Repl_semi_sync_slave::slave_reply", - binlog_filename, (ulong)binlog_filepos)); - - net_clear(net, 0); - /* Send the reply. */ - reply_res = my_net_write(net, reply_buffer, - name_len + REPLY_BINLOG_NAME_OFFSET); + reply_res= DBUG_IF("semislave_failed_net_flush") || net_flush(net); if (!reply_res) - { - reply_res = (DBUG_IF("semislave_failed_net_flush") || net_flush(net)); - if (reply_res) - sql_print_error("Semi-sync slave net_flush() reply failed"); rpl_semi_sync_slave_send_ack++; - } - else - { - sql_print_error("Semi-sync slave send reply failed: %s (%d)", - net->last_error, net->last_errno); - } } - DBUG_RETURN(reply_res); } diff --git a/sql/semisync_slave.h b/sql/semisync_slave.h index a8229245ab1..6811584c9c8 100644 --- a/sql/semisync_slave.h +++ b/sql/semisync_slave.h @@ -33,7 +33,7 @@ class Master_info; class Repl_semi_sync_slave :public Repl_semi_sync_base { public: - Repl_semi_sync_slave() :m_slave_enabled(false) {} + Repl_semi_sync_slave() :m_slave_enabled(false) {} ~Repl_semi_sync_slave() = default; void set_trace_level(unsigned long trace_level) { @@ -45,7 +45,7 @@ public: */ int init_object(); - bool get_slave_enabled() { + inline bool get_slave_enabled() { return m_slave_enabled; } @@ -53,7 +53,7 @@ public: m_slave_enabled = enabled; } - bool is_delay_master(){ + inline bool is_delay_master(){ return m_delay_master; } @@ -88,24 +88,23 @@ public: * binlog position. */ int slave_reply(Master_info* mi); - int slave_start(Master_info *mi); - int slave_stop(Master_info *mi); - int request_transmit(Master_info*); + void slave_start(Master_info *mi); + void slave_stop(Master_info *mi); + void slave_reconnect(Master_info *mi); + int request_transmit(Master_info *mi); void kill_connection(MYSQL *mysql); - int reset_slave(Master_info *mi); private: /* True when init_object has been called */ bool m_init_done; - bool m_slave_enabled; /* semi-sycn is enabled on the slave */ + bool m_slave_enabled; /* semi-sync is enabled on the slave */ bool m_delay_master; unsigned int m_kill_conn_timeout; }; /* System and status variables for the slave component */ -extern my_bool rpl_semi_sync_slave_enabled; -extern my_bool rpl_semi_sync_slave_status; +extern my_bool global_rpl_semi_sync_slave_enabled; extern ulong rpl_semi_sync_slave_trace_level; extern Repl_semi_sync_slave repl_semisync_slave; @@ -113,4 +112,7 @@ extern char rpl_semi_sync_slave_delay_master; extern unsigned int rpl_semi_sync_slave_kill_conn_timeout; extern unsigned long long rpl_semi_sync_slave_send_ack; +extern int rpl_semi_sync_enabled(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *status_var, + enum_var_type scope); #endif /* SEMISYNC_SLAVE_H */ diff --git a/sql/slave.cc b/sql/slave.cc index fe92db88ffe..a6858b428bd 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4454,6 +4454,15 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, { Gtid_log_event *gev= static_cast(ev); +#ifdef ENABLED_DEBUG_SYNC + DBUG_EXECUTE_IF( + "pause_sql_thread_on_relay_fde_after_trans", + { + DBUG_SET("-d,pause_sql_thread_on_relay_fde_after_trans"); + DBUG_SET("+d,pause_sql_thread_on_next_relay_fde"); + }); +#endif + /* For GTID, allocate a new sub_id for the given domain_id. The sub_id must be allocated in increasing order of binlog order. @@ -4606,12 +4615,14 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, #endif /* WITH_WSREP */ #ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF( - "pause_sql_thread_on_fde", - if (ev && typ == FORMAT_DESCRIPTION_EVENT) { + "pause_sql_thread_on_next_relay_fde", + if (ev && typ == FORMAT_DESCRIPTION_EVENT && + ((Format_description_log_event *) ev)->is_relay_log_event()) { DBUG_ASSERT(!debug_sync_set_action( thd, STRING_WITH_LEN( "now SIGNAL paused_on_fde WAIT_FOR sql_thread_continue"))); + DBUG_SET("-d,pause_sql_thread_on_next_relay_fde"); }); #endif @@ -4728,6 +4739,7 @@ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi, sql_print_information("%s", messages[SLAVE_RECON_MSG_KILLED_AFTER]); return 1; } + repl_semisync_slave.slave_reconnect(mi); return 0; } @@ -4816,14 +4828,7 @@ pthread_handler_t handle_slave_io(void *arg) } thd->variables.wsrep_on= 0; - if (DBUG_IF("failed_slave_start") - || repl_semisync_slave.slave_start(mi)) - { - mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL, - ER_THD(thd, ER_SLAVE_FATAL_ERROR), - "Failed to run 'thread_start' hook"); - goto err; - } + repl_semisync_slave.slave_start(mi); if (!(mi->mysql = mysql = mysql_init(NULL))) { @@ -4917,6 +4922,7 @@ connected: if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, reconnect_messages[SLAVE_RECON_ACT_REG])) goto err; + goto connected; } @@ -4977,6 +4983,15 @@ connected: we're in fact receiving nothing. */ THD_STAGE_INFO(thd, stage_waiting_for_master_to_send_event); + +#ifdef ENABLED_DEBUG_SYNC + DBUG_EXECUTE_IF("pause_before_io_read_event", + { + DBUG_ASSERT(!debug_sync_set_action( thd, STRING_WITH_LEN( + "now signal io_thread_at_read_event wait_for io_thread_continue_read_event"))); + DBUG_SET("-d,pause_before_io_read_event"); + };); +#endif event_len= read_event(mysql, mi, &suppress_warnings, &network_read_len); if (check_io_slave_killed(mi, NullS)) goto err; @@ -5076,17 +5091,36 @@ 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)) + if (repl_semisync_slave.get_slave_enabled() && + mi->semi_sync_reply_enabled && + (mi->semi_ack & SEMI_SYNC_NEED_ACK)) { - /* - 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. - */ - DBUG_EXECUTE_IF("simulate_delay_semisync_slave_reply", my_sleep(800000);); - (void)repl_semisync_slave.slave_reply(mi); - } + DBUG_EXECUTE_IF("simulate_delay_semisync_slave_reply", + my_sleep(800000);); + if (repl_semisync_slave.slave_reply(mi)) + { + /* + Master is not responding (gone away?) or it has turned semi sync + off. Turning off semi-sync responses as there is no point in sending + data to the master if the master not receiving the messages. + This also stops the logs from getting filled with + "Semi-sync slave net_flush() reply failed" messages. + On reconnect semi sync will be turned on again, if the + master has semi-sync enabled. + We check mi->abort_slave to see if the io thread was + killed and in this case we do not need an error message as + we know what is going on. + */ + if (!mi->abort_slave) + sql_print_error("Master server does not read semi-sync messages " + "last_error: %s (%d). " + "Fallback to asynchronous replication", + mi->mysql->net.last_error, + mi->mysql->net.last_errno); + mi->semi_sync_reply_enabled= 0; + } + } if (mi->using_gtid == Master_info::USE_GTID_NO && /* If rpl_semi_sync_slave_delay_master is enabled, we will flush @@ -6629,7 +6663,7 @@ dbug_gtid_accept: */ mi->do_accept_own_server_id= (s_id == global_system_variables.server_id && - rpl_semi_sync_slave_enabled && opt_gtid_strict_mode && + repl_semisync_slave.get_slave_enabled() && opt_gtid_strict_mode && mi->using_gtid != Master_info::USE_GTID_NO && !mysql_bin_log.check_strict_gtid_sequence(event_gtid.domain_id, event_gtid.server_id, diff --git a/sql/socketpair.c b/sql/socketpair.c new file mode 100644 index 00000000000..ef89fa0446b --- /dev/null +++ b/sql/socketpair.c @@ -0,0 +1,156 @@ +/* socketpair.c +Copyright 2007, 2010 by Nathan C. Myers +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + The name of the author must not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Changes: + * 2023-12-25 Addopted for MariaDB usage + * 2014-02-12: merge David Woodhouse, Ger Hobbelt improvements + * git.infradead.org/users/dwmw2/openconnect.git/commitdiff/bdeefa54 + * github.com/GerHobbelt/selectable-socketpair + * always init the socks[] to -1/INVALID_SOCKET on error, both on Win32/64 + * and UNIX/other platforms + * 2013-07-18: Change to BSD 3-clause license + * 2010-03-31: + * set addr to 127.0.0.1 because win32 getsockname does not always set it. + * 2010-02-25: + * set SO_REUSEADDR option to avoid leaking some windows resource. + * Windows System Error 10049, "Event ID 4226 TCP/IP has reached + * the security limit imposed on the number of concurrent TCP connect + * attempts." Bleah. + * 2007-04-25: + * preserve value of WSAGetLastError() on all error returns. + * 2007-04-22: (Thanks to Matthew Gregan ) + * s/EINVAL/WSAEINVAL/ fix trivial compile failure + * s/socket/WSASocket/ enable creation of sockets suitable as stdin/stdout + * of a child process. + * add argument make_overlapped + */ + +#include +#ifdef _WIN32 +#include /* socklen_t, et al (MSVC20xx) */ +#include +#include +#include "socketpair.h" + +#define safe_errno (errno != 0) ? errno : -1 + +/** + create_socketpair() + + @param socks[2] Will be filled by 2 SOCKET entries (similar to pipe()) + socks[0] for reading + socks[1] for writing + + @return: 0 ok + # System error code. -1 if unknown + */ + +int create_socketpair(SOCKET socks[2]) +{ + union + { + struct sockaddr_in inaddr; + struct sockaddr addr; + } a; + SOCKET listener= -1; + int reuse = 1; + int last_error; + socklen_t addrlen = sizeof(a.inaddr); + + socks[0]= socks[1]= -1; + + if ((listener= socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) + return safe_errno; + + memset(&a, 0, sizeof(a)); + a.inaddr.sin_family = AF_INET; + a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + a.inaddr.sin_port = 0; + + for (;;) /* Avoid using goto */ + { + if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, + (char*) &reuse, (socklen_t) sizeof(reuse)) == -1) + break; + if (bind(listener, &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR) + break; + + memset(&a, 0, sizeof(a)); + if (getsockname(listener, &a.addr, &addrlen) == SOCKET_ERROR) + break; + // win32 getsockname may only set the port number, p=0.0005. + // ( http://msdn.microsoft.com/library/ms738543.aspx ): + a.inaddr.sin_addr.s_addr= htonl(INADDR_LOOPBACK); + a.inaddr.sin_family= AF_INET; + + if (listen(listener, 1) == SOCKET_ERROR) + break; + + socks[1]= socket(AF_INET, SOCK_STREAM, 0); + if (socks[1] == -1) + break; + if (connect(socks[1], &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR) + break; + + socks[0]= accept(listener, NULL, NULL); + if (socks[0] == -1) + break; + + closesocket(listener); + + { + /* Make both sockets non blocking */ + ulong arg= 1; + ioctlsocket(socks[0], FIONBIO,(void*) &arg); + ioctlsocket(socks[1], FIONBIO,(void*) &arg); + } + return 0; + } + /* Error handling */ + last_error= WSAGetLastError(); + if (listener != -1) + closesocket(listener); + close_socketpair(socks); + WSASetLastError(last_error); + + return last_error; +} + +/* + Free socketpair +*/ + +void close_socketpair(SOCKET socks[2]) +{ + if (socks[0] != -1) + closesocket(socks[0]); + if (socks[1] != -1) + closesocket(socks[1]); + socks[0]= socks[1]= -1; +} + +#endif /*_WIN32 */ diff --git a/sql/socketpair.h b/sql/socketpair.h new file mode 100644 index 00000000000..d9f89c84ffa --- /dev/null +++ b/sql/socketpair.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2023, MariaDB Plc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifdef _WIN32 +C_MODE_START + int create_socketpair(SOCKET socks[2]); + void close_socketpair(SOCKET socks[2]); +C_MODE_END +#endif /* _WIN32 */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index d9c8c030f44..846b6dd27cf 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -8385,11 +8385,6 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables, INSERT_ACL : SELECT_ACL); } - if (tl->with || !tl->db.str || - (tl->select_lex && - (tl->with= tl->select_lex->find_table_def_in_with_clauses(tl)))) - continue; - const ACL_internal_table_access *access= get_cached_table_access(&t_ref->grant.m_internal, t_ref->get_db_name(), @@ -12172,8 +12167,8 @@ static my_bool count_column_grants(void *grant_table, This must be performed under the mutex in order to make sure the iteration does not fail. */ -static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_column_grants(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum enum_var_type scope) { var->type= SHOW_ULONG; var->value= buff; @@ -12189,8 +12184,8 @@ static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff, return 0; } -static int show_database_grants(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +static int show_database_grants(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum enum_var_type scope) { var->type= SHOW_UINT; var->value= buff; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index fcbd8a55c15..a3b9bbd4f7e 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -818,7 +818,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (lock_type == TL_WRITE && table->mdl_request.type > MDL_SHARED_WRITE) { if (table->table->s->tmp_table) - thd->close_unused_temporary_table_instances(tables); + thd->close_unused_temporary_table_instances(table); else { /* Store information about table for ddl log */ diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 4c853689504..93b0dbb3ac7 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -953,7 +953,8 @@ void field_longlong::get_opt_type(String *answer, UINT_MAX24 : INT_MAX24)) snprintf(buff, sizeof(buff), "MEDIUMINT(%d)", (int) max_length); else if (min_arg >= INT_MIN32 && max_arg <= (min_arg >= 0 ? - UINT_MAX32 : INT_MAX32)) + (longlong) UINT_MAX32 : + (longlong) INT_MAX32)) snprintf(buff, sizeof(buff), "INT(%d)", (int) max_length); else snprintf(buff, sizeof(buff), "BIGINT(%d)", (int) max_length); diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index e71c7015238..118b361eb79 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -137,7 +137,7 @@ int binlog_defragment(THD *thd) entry[k]= (user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name[k].str, name[k].length); - if (!entry[k] || entry[k]->type != STRING_RESULT) + if (!entry[k] || entry[k]->type_handler()->result_type() != STRING_RESULT) { my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), name[k].str); return -1; @@ -162,7 +162,8 @@ int binlog_defragment(THD *thd) gathered_length += entry[k]->length; } for (uint k=0; k < 2; k++) - update_hash(entry[k], true, NULL, 0, STRING_RESULT, &my_charset_bin, 0); + update_hash(entry[k], true, NULL, 0, + &type_handler_long_blob, &my_charset_bin); DBUG_ASSERT(gathered_length == thd->lex->comment.length); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 00161d19a9b..aa22aa73ada 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -729,7 +729,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) wsrep_wfc() #endif /*WITH_WSREP */ { - ulong tmp; bzero(&variables, sizeof(variables)); /* @@ -880,14 +879,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) tablespace_op=FALSE; - /* - Initialize the random generator. We call my_rnd() without a lock as - it's not really critical if two threads modifies the structure at the - same time. We ensure that we have an unique number foreach thread - by adding the address of the stack. - */ - tmp= (ulong) (my_rnd(&sql_rand) * 0xffffffff); - my_rnd_init(&rand, tmp + (ulong)((size_t) &rand), tmp + (ulong) ::global_query_id); substitute_null_with_insert_id = FALSE; lock_info.mysql_thd= (void *)this; @@ -1206,6 +1197,63 @@ void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t) } +/* + @brief + Convert a non-zero DATETIME to its safe timeval based representation, + which guarantees a safe roundtrip DATETIME->timeval->DATETIME, + e.g. to optimize: + + WHERE timestamp_arg0 = datetime_arg1 + + in the way that we replace "datetime_arg1" to its TIMESTAMP equivalent + "timestamp_arg1" and switch from DATETIME comparison to TIMESTAMP comparison: + + WHERE timestamp_arg0 = timestamp_arg1 + + This helps to avoid slow TIMESTAMP->DATETIME data type conversion + for timestamp_arg0 per row. + + @detail + Round trip is possible if the input "YYYY-MM-DD hh:mm:ss" value + satisfies the following conditions: + + 1. TIME_to_gmt_sec() returns no errors or warnings, + which means the input value + a. has no zeros in YYYYMMDD + b. fits into the TIMESTAMP range + c. does not fall into the spring forward gap + (because values inside gaps get adjusted to the beginning of the gap) + + 2. The my_time_t value returned by TIME_to_gmt_sec() must not be + near a DST change or near a leap second, to avoid anomalies: + - "YYYY-MM-DD hh:mm:ss" has more than one matching my_time_t values + - "YYYY-MM-DD hh:mm:ss" has no matching my_time_t values + (e.g. fall into the spring forward gap) + + @param dt The DATETIME value to convert. + Must not be zero '0000-00-00 00:00:00.000000'. + (The zero value must be handled by the caller). + + @return The conversion result + @retval If succeeded, non-NULL Timeval value. + @retval Timeval_null value representing SQL NULL if the argument + does not have a safe replacement. +*/ +Timeval_null +THD::safe_timeval_replacement_for_nonzero_datetime(const Datetime &dt) +{ + used|= THD::TIME_ZONE_USED; + DBUG_ASSERT(non_zero_date(dt.get_mysql_time())); + uint error= 0; + const MYSQL_TIME *ltime= dt.get_mysql_time(); + my_time_t sec= variables.time_zone->TIME_to_gmt_sec(ltime, &error); + if (error /* (1) */ || + !variables.time_zone->is_monotone_continuous_around(sec) /* (2) */) + return Timeval_null(); + return Timeval_null(sec, ltime->second_part); +} + + #ifdef _WIN32 extern "C" my_thread_id next_thread_id_noinline() { @@ -1311,6 +1359,17 @@ void THD::init() /* Set to handle counting of aborted connections */ userstat_running= opt_userstat_running; last_global_update_time= current_connect_time= time(NULL); + + /* + Initialize the random generator. We call my_rnd() without a lock as + it's not really critical if two threads modify the structure at the + same time. We ensure that we have a unique number for each thread + by adding the address of this THD. + */ + ulong tmp= (ulong) (my_rnd(&sql_rand) * 0xffffffff); + my_rnd_init(&rand, tmp + (ulong)(intptr) this, + (ulong)(my_timer_cycles() + global_query_id)); + #ifndef EMBEDDED_LIBRARY session_tracker.enable(this); #endif //EMBEDDED_LIBRARY @@ -1856,14 +1915,6 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, */ } -#define SECONDS_TO_WAIT_FOR_KILL 2 -#if !defined(_WIN32) && defined(HAVE_SELECT) -/* my_sleep() can wait for sub second times */ -#define WAIT_FOR_KILL_TRY_TIMES 20 -#else -#define WAIT_FOR_KILL_TRY_TIMES 2 -#endif - /** Awake a thread. diff --git a/sql/sql_class.h b/sql/sql_class.h index 5c75c9655e3..12e3e856cca 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -291,9 +291,8 @@ typedef struct st_user_var_events user_var_entry *user_var_event; char *value; size_t length; - Item_result type; + const Type_handler *th; uint charset_number; - bool unsigned_flag; } BINLOG_USER_VAR_EVENT; /* @@ -667,6 +666,15 @@ enum killed_type KILL_TYPE_QUERY }; +#define SECONDS_TO_WAIT_FOR_KILL 2 +#define SECONDS_TO_WAIT_FOR_DUMP_THREAD_KILL 10 +#if !defined(_WIN32) && defined(HAVE_SELECT) +/* my_sleep() can wait for sub second times */ +#define WAIT_FOR_KILL_TRY_TIMES 20 +#else +#define WAIT_FOR_KILL_TRY_TIMES 2 +#endif + #include "sql_lex.h" /* Must be here */ class Delayed_insert; @@ -770,9 +778,10 @@ typedef struct system_variables ulong optimizer_search_depth; ulong optimizer_selectivity_sampling_limit; ulong optimizer_use_condition_selectivity; - ulong optimizer_trace_max_mem_size; ulong optimizer_max_sel_arg_weight; ulong optimizer_max_sel_args; + ulong optimizer_trace_max_mem_size; + ulong optimizer_adjust_secondary_key_costs; ulong use_stat_tables; ulong histogram_size; ulong histogram_type; @@ -4291,6 +4300,8 @@ public: utime_after_query= current_utime(); } + Timeval_null safe_timeval_replacement_for_nonzero_datetime(const Datetime &); + /** Update server status after execution of a top level statement. Currently only checks if a query was slow, and assigns @@ -7273,7 +7284,7 @@ public: // this is needed for user_vars hash -class user_var_entry +class user_var_entry: public Type_handler_hybrid_field_type { CHARSET_INFO *m_charset; public: @@ -7282,8 +7293,6 @@ class user_var_entry char *value; size_t length; query_id_t update_query_id, used_query_id; - Item_result type; - bool unsigned_flag; double val_real(bool *null_value); longlong val_int(bool *null_value) const; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index c55f2999c71..b4decefc47f 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -779,6 +779,10 @@ void update_global_user_stats(THD *thd, bool create_user, time_t now) bool thd_init_client_charset(THD *thd, uint cs_number) { CHARSET_INFO *cs; + + // Test a non-default collation ID. See also comments in this function below. + DBUG_EXECUTE_IF("thd_init_client_charset_utf8mb3_bin", cs_number= 83;); + /* Use server character set and collation if - opt_character_set_client_handshake is not set @@ -801,9 +805,25 @@ bool thd_init_client_charset(THD *thd, uint cs_number) cs->cs_name.str); return true; } - Sql_used used; - cs= global_system_variables.character_set_collations. - get_collation_for_charset(&used, cs); + /* + Some connectors (e.g. JDBC, Node.js) can send non-default collation IDs + in the handshake packet, to set @@collation_connection right during + handshake. Although this is a non-documenting feature, + for better backward compatibility with such connectors let's: + a. resolve only default collations according to @@character_set_collations + b. preserve non-default collations as is + + Perhaps eventually we should change (b) also to resolve non-default + collations accoding to @@character_set_collations. Clients that used to + send a non-default collation ID in the handshake packet will have to set + @@character_set_collations instead. + */ + if (cs->state & MY_CS_PRIMARY) + { + Sql_used used; + cs= global_system_variables.character_set_collations. + get_collation_for_charset(&used, cs); + } thd->org_charset= cs; thd->update_charset(cs,cs,cs); } diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index 1dbb265452a..5b3db9bca1d 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -106,6 +106,7 @@ bool LEX::check_dependencies_in_with_clauses() @param tables Points to the beginning of the sub-chain @param tables_last Points to the address with the sub-chain barrier + @param excl_spec Ignore the definition with this spec @details The method resolves tables references to CTE from the chain of @@ -147,7 +148,8 @@ bool LEX::check_dependencies_in_with_clauses() */ bool LEX::resolve_references_to_cte(TABLE_LIST *tables, - TABLE_LIST **tables_last) + TABLE_LIST **tables_last, + st_select_lex_unit *excl_spec) { With_element *with_elem= 0; @@ -156,7 +158,8 @@ bool LEX::resolve_references_to_cte(TABLE_LIST *tables, if (tbl->derived) continue; if (!tbl->db.str && !tbl->with) - tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl); + tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl, + excl_spec); if (!tbl->with) // no CTE matches table reference tbl { if (only_cte_resolution) @@ -244,7 +247,7 @@ LEX::check_cte_dependencies_and_resolve_references() return true; if (!with_cte_resolution) return false; - if (resolve_references_to_cte(query_tables, query_tables_last)) + if (resolve_references_to_cte(query_tables, query_tables_last, NULL)) return true; return false; } @@ -388,6 +391,7 @@ bool With_element::check_dependencies_in_spec() @param table The reference to the table that is looked for @param barrier The barrier with element for the search + @param excl_spec Ignore the definition with this spec @details The function looks through the elements of this with clause trying to find @@ -401,12 +405,15 @@ bool With_element::check_dependencies_in_spec() */ With_element *With_clause::find_table_def(TABLE_LIST *table, - With_element *barrier) + With_element *barrier, + st_select_lex_unit *excl_spec) { for (With_element *with_elem= with_list.first; with_elem != barrier; with_elem= with_elem->next) { + if (excl_spec && with_elem->spec == excl_spec) + continue; if (my_strcasecmp(system_charset_info, with_elem->get_name_str(), table->table_name.str) == 0 && !table->is_fqtn) @@ -466,7 +473,7 @@ With_element *find_table_def_in_with_clauses(TABLE_LIST *tbl, top_unit->with_element && top_unit->with_element->get_owner() == with_clause) barrier= top_unit->with_element; - found= with_clause->find_table_def(tbl, barrier); + found= with_clause->find_table_def(tbl, barrier, NULL); if (found) break; } @@ -521,10 +528,11 @@ void With_element::check_dependencies_in_select(st_select_lex *sl, { With_clause *with_clause= sl->master_unit()->with_clause; if (with_clause) - tbl->with= with_clause->find_table_def(tbl, NULL); + tbl->with= with_clause->find_table_def(tbl, NULL, NULL); if (!tbl->with) tbl->with= owner->find_table_def(tbl, - owner->with_recursive ? NULL : this); + owner->with_recursive ? NULL : this, + NULL); } if (!tbl->with) tbl->with= find_table_def_in_with_clauses(tbl, ctxt); @@ -1101,7 +1109,8 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex, */ lex->only_cte_resolution= old_lex->only_cte_resolution; if (lex->resolve_references_to_cte(lex->query_tables, - lex->query_tables_last)) + lex->query_tables_last, + spec)) { res= NULL; goto err; @@ -1304,6 +1313,7 @@ bool With_element::is_anchor(st_select_lex *sel) Search for the definition of the given table referred in this select node @param table reference to the table whose definition is searched for + @param excl_spec ignore the definition with this spec @details The method looks for the definition of the table whose reference is occurred @@ -1316,7 +1326,8 @@ bool With_element::is_anchor(st_select_lex *sel) NULL - otherwise */ -With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) +With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table, + st_select_lex_unit *excl_spec) { With_element *found= NULL; With_clause *containing_with_clause= NULL; @@ -1333,7 +1344,7 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) With_clause *attached_with_clause= sl->get_with_clause(); if (attached_with_clause && attached_with_clause != containing_with_clause && - (found= attached_with_clause->find_table_def(table, NULL))) + (found= attached_with_clause->find_table_def(table, NULL, excl_spec))) break; master_unit= sl->master_unit(); outer_sl= master_unit->outer_select(); @@ -1343,7 +1354,8 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) containing_with_clause= with_elem->get_owner(); With_element *barrier= containing_with_clause->with_recursive ? NULL : with_elem; - if ((found= containing_with_clause->find_table_def(table, barrier))) + if ((found= containing_with_clause->find_table_def(table, barrier, + excl_spec))) break; if (outer_sl && !outer_sl->get_with_element()) break; diff --git a/sql/sql_cte.h b/sql/sql_cte.h index 6a1f67d3258..1da7c6c323a 100644 --- a/sql/sql_cte.h +++ b/sql/sql_cte.h @@ -325,7 +325,8 @@ public: friend bool LEX::resolve_references_to_cte(TABLE_LIST *tables, - TABLE_LIST **tables_last); + TABLE_LIST **tables_last, + st_select_lex_unit *excl_spec); }; const uint max_number_of_elements_in_with_clause= sizeof(table_map)*8; @@ -425,7 +426,8 @@ public: void move_anchors_ahead(); - With_element *find_table_def(TABLE_LIST *table, With_element *barrier); + With_element *find_table_def(TABLE_LIST *table, With_element *barrier, + st_select_lex_unit *excl_spec); With_element *find_table_def_in_with_clauses(TABLE_LIST *table); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 01d9f77427f..ccb5a7de1eb 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -96,7 +96,8 @@ static void end_delayed_insert(THD *thd); pthread_handler_t handle_delayed_insert(void *arg); static void unlink_blobs(TABLE *table); #endif -static bool check_view_insertability(THD *thd, TABLE_LIST *view); +static bool check_view_insertability(THD *thd, TABLE_LIST *view, + List &fields); static int binlog_show_create_table_(THD *thd, TABLE *table, Table_specification_st *create_info); @@ -311,7 +312,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, if (check_key_in_view(thd, table_list) || (table_list->view && - check_view_insertability(thd, table_list))) + check_view_insertability(thd, table_list, fields))) { my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT"); DBUG_RETURN(-1); @@ -1423,6 +1424,7 @@ abort: check_view_insertability() thd - thread handler view - reference on VIEW + fields - fields used in insert IMPLEMENTATION A view is insertable if the folloings are true: @@ -1438,7 +1440,8 @@ abort: TRUE - can't be used for insert */ -static bool check_view_insertability(THD * thd, TABLE_LIST *view) +static bool check_view_insertability(THD *thd, TABLE_LIST *view, + List &fields) { uint num= view->view->first_select_lex()->item_list.elements; TABLE *table= view->table; @@ -1449,6 +1452,8 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view) uint32 *used_fields_buff= (uint32*)thd->alloc(used_fields_buff_size); MY_BITMAP used_fields; enum_column_usage saved_column_usage= thd->column_usage; + List_iterator_fast it(fields); + Item *ex; DBUG_ENTER("check_key_in_view"); if (!used_fields_buff) @@ -1477,6 +1482,17 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view) /* simple SELECT list entry (field without expression) */ if (!(field= trans->item->field_for_view_update())) { + // Do not check fields which we are not inserting into + while((ex= it++)) + { + // The field used in the INSERT + if (ex->real_item()->field_for_view_update() == + trans->item->field_for_view_update()) + break; + } + it.rewind(); + if (!ex) + continue; thd->column_usage= saved_column_usage; DBUG_RETURN(TRUE); } @@ -1491,11 +1507,12 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view) } thd->column_usage= saved_column_usage; /* unique test */ - for (trans= trans_start; trans != trans_end; trans++) + while((ex= it++)) { /* Thanks to test above, we know that all columns are of type Item_field */ - Item_field *field= (Item_field *)trans->item; - /* check fields belong to table in which we are inserting */ + DBUG_ASSERT(ex->real_item()->field_for_view_update()->type() == + Item::FIELD_ITEM); + Item_field *field= (Item_field *)ex->real_item()->field_for_view_update(); if (field->field->table == table && bitmap_fast_test_and_set(&used_fields, field->field->field_index)) DBUG_RETURN(TRUE); @@ -1779,7 +1796,7 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, /* Check if there is more uniq keys after field */ -static int last_uniq_key(TABLE *table,uint keynr) +static int last_uniq_key(TABLE *table, const KEY *key, uint keynr) { /* When an underlying storage engine informs that the unique key @@ -1799,7 +1816,7 @@ static int last_uniq_key(TABLE *table,uint keynr) return 0; while (++keynr < table->s->keys) - if (table->key_info[keynr].flags & HA_NOSAME) + if (key[keynr].flags & HA_NOSAME) return 0; return 1; } @@ -2114,8 +2131,27 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink) tables which have ON UPDATE but have no ON DELETE triggers, we just should not expose this fact to users by invoking ON UPDATE triggers. + + Note, TABLE_SHARE and TABLE see long uniques differently: + - TABLE_SHARE sees as HA_KEY_ALG_LONG_HASH and HA_NOSAME + - TABLE sees as usual non-unique indexes */ - if (last_uniq_key(table,key_nr) && + bool is_long_unique= table->s->key_info && + table->s->key_info[key_nr].algorithm == + HA_KEY_ALG_LONG_HASH; + if ((is_long_unique ? + /* + We have a long unique. Test that there are no in-engine + uniques and the current long unique is the last long unique. + */ + !(table->key_info[0].flags & HA_NOSAME) && + last_uniq_key(table, table->s->key_info, key_nr) : + /* + We have a normal key - not a long unique. + Test is the current normal key is unique and + it is the last normal unique. + */ + last_uniq_key(table, table->key_info, key_nr)) && !table->file->referenced_by_foreign_key() && (!table->triggers || !table->triggers->has_delete_triggers())) { diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 76c03439158..22eb8834492 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4800,9 +4800,12 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds, { Query_arena_stmt on_stmt_arena(thd); changed_elements|= TOUCHED_SEL_COND; + /* + TODO: return after MDEV-33218 fix DBUG_ASSERT( active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS); + */ if (group_list.first) { if (!group_list_ptrs) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 74f47782bc3..ca8bf7e940c 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1596,7 +1596,8 @@ public: master_unit()->cloned_from->with_element : master_unit()->with_element; } - With_element *find_table_def_in_with_clauses(TABLE_LIST *table); + With_element *find_table_def_in_with_clauses(TABLE_LIST *table, + st_select_lex_unit * excl_spec); bool check_unrestricted_recursive(bool only_standard_compliant); bool check_subqueries_with_recursive_references(); void collect_grouping_fields_for_derived(THD *thd, ORDER *grouping_list); @@ -4951,7 +4952,8 @@ public: bool check_dependencies_in_with_clauses(); bool check_cte_dependencies_and_resolve_references(); bool resolve_references_to_cte(TABLE_LIST *tables, - TABLE_LIST **tables_last); + TABLE_LIST **tables_last, + st_select_lex_unit *excl_spec); /** Turn on the SELECT_DESCRIBE flag for every SELECT_LEX involved into diff --git a/sql/sql_list.h b/sql/sql_list.h index 5a57c86ef9d..faec566ccdc 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -799,7 +799,9 @@ public: class base_ilist_iterator { base_ilist *list; - struct ilink **el,*current; + struct ilink **el; +protected: + struct ilink *current; public: base_ilist_iterator(base_ilist &list_par) :list(&list_par), el(&list_par.first),current(0) {} @@ -811,6 +813,13 @@ public: el= ¤t->next; return current; } + /* Unlink element returned by last next() call */ + inline void unlink(void) + { + struct ilink **tmp= current->prev; + current->unlink(); + el= tmp; + } }; @@ -840,6 +849,13 @@ template class I_List_iterator :public base_ilist_iterator public: I_List_iterator(I_List &a) : base_ilist_iterator(a) {} inline T* operator++(int) { return (T*) base_ilist_iterator::next(); } + /* Remove element returned by last next() call */ + inline void remove(void) + { + unlink(); + delete (T*) current; + current= 0; // Safety + } }; /** diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6557f1c5ecd..db99dfe6d21 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2123,7 +2123,6 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * { ulong pos; ushort flags; - uint32 slave_server_id; status_var_increment(thd->status_var.com_other); @@ -2134,10 +2133,26 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * /* TODO: The following has to be changed to an 8 byte integer */ pos = uint4korr(packet); flags = uint2korr(packet + 4); - thd->variables.server_id=0; /* avoid suicide */ - if ((slave_server_id= uint4korr(packet+6))) // mysqlbinlog.server_id==0 - kill_zombie_dump_threads(slave_server_id); - thd->variables.server_id = slave_server_id; + if ((thd->variables.server_id= uint4korr(packet+6))) + { + bool got_error; + + got_error= kill_zombie_dump_threads(thd, + thd->variables.server_id); + if (got_error || thd->killed) + { + if (!thd->killed) + my_printf_error(ER_MASTER_FATAL_ERROR_READING_BINLOG, + "Could not start dump thread for slave: %u as " + "it has already a running dump thread", + MYF(0), (uint) thd->variables.server_id); + else if (! thd->get_stmt_da()->is_set()) + thd->send_kill_message(); + error= TRUE; + thd->unregister_slave(); // todo: can be extraneous + break; + } + } const char *name= packet + 10; size_t nlen= strlen(name); @@ -2145,6 +2160,8 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * general_log_print(thd, command, "Log: '%s' Pos: %lu", name, pos); if (nlen < FN_REFLEN) mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags); + if (thd->killed && ! thd->get_stmt_da()->is_set()) + thd->send_kill_message(); thd->unregister_slave(); // todo: can be extraneous /* fake COM_QUIT -- if we get here, the thread needs to terminate */ error = TRUE; @@ -9067,11 +9084,13 @@ kill_one_thread(THD *thd, my_thread_id id, killed_state kill_signal, killed_type struct kill_threads_callback_arg { - kill_threads_callback_arg(THD *thd_arg, LEX_USER *user_arg): - thd(thd_arg), user(user_arg) {} + kill_threads_callback_arg(THD *thd_arg, LEX_USER *user_arg, + killed_state kill_signal_arg): + thd(thd_arg), user(user_arg), kill_signal(kill_signal_arg), counter(0) {} THD *thd; LEX_USER *user; - List threads_to_kill; + killed_state kill_signal; + uint counter; }; @@ -9094,11 +9113,12 @@ static my_bool kill_threads_callback(THD *thd, kill_threads_callback_arg *arg) { return MY_TEST(arg->thd->security_ctx->master_access & PROCESS_ACL); } - if (!arg->threads_to_kill.push_back(thd, arg->thd->mem_root)) - { - mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete - mysql_mutex_lock(&thd->LOCK_thd_data); - } + arg->counter++; + mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete + mysql_mutex_lock(&thd->LOCK_thd_data); + thd->awake_no_mutex(arg->kill_signal); + mysql_mutex_unlock(&thd->LOCK_thd_data); + mysql_mutex_unlock(&thd->LOCK_thd_kill); } } return 0; @@ -9108,42 +9128,17 @@ static my_bool kill_threads_callback(THD *thd, kill_threads_callback_arg *arg) static uint kill_threads_for_user(THD *thd, LEX_USER *user, killed_state kill_signal, ha_rows *rows) { - kill_threads_callback_arg arg(thd, user); + kill_threads_callback_arg arg(thd, user, kill_signal); DBUG_ENTER("kill_threads_for_user"); - - *rows= 0; - - if (unlikely(thd->is_fatal_error)) // If we run out of memory - DBUG_RETURN(ER_OUT_OF_RESOURCES); - DBUG_PRINT("enter", ("user: %s signal: %u", user->user.str, (uint) kill_signal)); + *rows= 0; + if (server_threads.iterate(kill_threads_callback, &arg)) DBUG_RETURN(ER_KILL_DENIED_ERROR); - if (!arg.threads_to_kill.is_empty()) - { - List_iterator_fast it2(arg.threads_to_kill); - THD *next_ptr; - THD *ptr= it2++; - do - { - ptr->awake_no_mutex(kill_signal); - /* - Careful here: The list nodes are allocated on the memroots of the - THDs to be awakened. - But those THDs may be terminated and deleted as soon as we release - LOCK_thd_kill, which will make the list nodes invalid. - Since the operation "it++" dereferences the "next" pointer of the - previous list node, we need to do this while holding LOCK_thd_kill. - */ - next_ptr= it2++; - mysql_mutex_unlock(&ptr->LOCK_thd_kill); - mysql_mutex_unlock(&ptr->LOCK_thd_data); - (*rows)++; - } while ((ptr= next_ptr)); - } + *rows= arg.counter; DBUG_RETURN(0); } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 008aa2b5de1..fca16ffa369 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1505,7 +1505,7 @@ static int plugin_initialize(MEM_ROOT *tmp_root, struct st_plugin_int *plugin, else ret= plugin_do_initialize(plugin, state); - if (ret) + if (ret && ret != HA_ERR_RETRY_INIT) plugin_variables_deinit(plugin); mysql_mutex_lock(&LOCK_plugin); @@ -1786,6 +1786,7 @@ int plugin_init(int *argc, char **argv, int flags) uint state= plugin_ptr->state; mysql_mutex_unlock(&LOCK_plugin); error= plugin_do_initialize(plugin_ptr, state); + DBUG_EXECUTE_IF("fail_spider_init_retry", error= 1;); mysql_mutex_lock(&LOCK_plugin); plugin_ptr->state= state; if (error == HA_ERR_RETRY_INIT) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index baed0888279..fb470cbcbb9 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -512,7 +512,7 @@ static enum_binlog_checksum_alg get_binlog_checksum_value_at_connect(THD * thd) } else { - DBUG_ASSERT(entry->type == STRING_RESULT); + DBUG_ASSERT(entry->type_handler()->result_type() == STRING_RESULT); String str; uint dummy_errors; str.copy(entry->value, entry->length, &my_charset_bin, &my_charset_bin, @@ -2266,7 +2266,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type, } if (need_sync && repl_semisync_master.flush_net(info->thd, - packet->c_ptr_safe())) + packet->c_ptr())) { info->error= ER_UNKNOWN_ERROR; return "Failed to run hook 'after_send_event'"; @@ -3264,8 +3264,13 @@ err: if (info->thd->killed == KILL_SLAVE_SAME_ID) { - info->errmsg= "A slave with the same server_uuid/server_id as this slave " - "has connected to the master"; + /* + Note that the text is limited to 64 characters in errmsg-utf8 in + ER_ABORTING_CONNECTION. + */ + info->errmsg= + "A slave with the same server_uuid/server_id is already " + "connected"; info->error= ER_SLAVE_SAME_ID; } @@ -3639,6 +3644,7 @@ int stop_slave(THD* thd, Master_info* mi, bool net_report ) @retval 0 success @retval 1 error */ + int reset_slave(THD *thd, Master_info* mi) { MY_STAT stat_area; @@ -3736,8 +3742,6 @@ int reset_slave(THD *thd, Master_info* mi) else if (global_system_variables.log_warnings > 1) sql_print_information("Deleted Master_info file '%s'.", fname); - if (rpl_semi_sync_slave_enabled) - repl_semisync_slave.reset_slave(mi); err: mi->unlock_slave_threads(); if (unlikely(error)) @@ -3765,43 +3769,89 @@ err: struct kill_callback_arg { - kill_callback_arg(uint32 id): slave_server_id(id), thd(0) {} - uint32 slave_server_id; + kill_callback_arg(THD *thd_arg, uint32 id): + thd(thd_arg), slave_server_id(id), counter(0) {} THD *thd; + uint32 slave_server_id; + uint counter; }; -static my_bool kill_callback(THD *thd, kill_callback_arg *arg) + +/* + Collect all active dump threads +*/ + +static my_bool kill_callback_collect(THD *thd, kill_callback_arg *arg) { if (thd->get_command() == COM_BINLOG_DUMP && - thd->variables.server_id == arg->slave_server_id) + thd->variables.server_id == arg->slave_server_id && + thd != arg->thd) { - arg->thd= thd; + arg->counter++; mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete mysql_mutex_lock(&thd->LOCK_thd_data); - return 1; + thd->awake_no_mutex(KILL_SLAVE_SAME_ID); // Mark killed + /* + Remover the thread from ack_receiver to ensure it is not + sending acks to the master anymore. + */ + ack_receiver.remove_slave(thd); + + mysql_mutex_unlock(&thd->LOCK_thd_data); + mysql_mutex_unlock(&thd->LOCK_thd_kill); } return 0; } -void kill_zombie_dump_threads(uint32 slave_server_id) -{ - kill_callback_arg arg(slave_server_id); - server_threads.iterate(kill_callback, &arg); +/* + Check if there are any active dump threads +*/ - if (arg.thd) - { - /* - Here we do not call kill_one_thread() as - it will be slow because it will iterate through the list - again. We just to do kill the thread ourselves. - */ - arg.thd->awake_no_mutex(KILL_SLAVE_SAME_ID); - mysql_mutex_unlock(&arg.thd->LOCK_thd_kill); - mysql_mutex_unlock(&arg.thd->LOCK_thd_data); - } +static my_bool kill_callback_check(THD *thd, kill_callback_arg *arg) +{ + return (thd->get_command() == COM_BINLOG_DUMP && + thd->variables.server_id == arg->slave_server_id && + thd != arg->thd); } + +/** + Try to kill running dump threads on the master + + @result 0 ok + @result 1 old slave thread exists and does not want to die + + There should not be more than one dump thread with the same server id + this code has however in the past has several issues. To ensure that + things works in all cases (now and in the future), this code is collecting + all matching server id's and killing all of them. +*/ + +bool kill_zombie_dump_threads(THD *thd, uint32 slave_server_id) +{ + kill_callback_arg arg(thd, slave_server_id); + server_threads.iterate(kill_callback_collect, &arg); + + if (!arg.counter) + return 0; + + /* + Wait up to SECONDS_TO_WAIT_FOR_DUMP_THREAD_KILL for kill + of all dump thread, trying every 1/10 of second. + */ + for (uint i= 10 * SECONDS_TO_WAIT_FOR_DUMP_THREAD_KILL ; + --i > 0 && !thd->killed; + i++) + { + if (!server_threads.iterate(kill_callback_check, &arg)) + return 0; // All dump thread are killed + my_sleep(1000000L / 10); // Wait 1/10 of a second + } + return 1; +} + + /** Get value for a string parameter with error checking diff --git a/sql/sql_repl.h b/sql/sql_repl.h index fcf9ec1c37c..51b6a599d5f 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -43,7 +43,7 @@ void adjust_linfo_offsets(my_off_t purge_offset); void show_binlogs_get_fields(THD *thd, List *field_list); bool show_binlogs(THD* thd); extern int init_master_info(Master_info* mi); -void kill_zombie_dump_threads(uint32 slave_server_id); +bool kill_zombie_dump_threads(THD *thd, uint32 slave_server_id); int check_binlog_magic(IO_CACHE* log, const char** errmsg); int compare_log_name(const char *log_1, const char *log_2); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d56b6052447..6f2797b6b39 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -30551,7 +30551,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, bool distinct,const char *message) { THD *thd=join->thd; - select_result *result=join->result; DBUG_ENTER("select_describe"); if (join->select_lex->pushdown_select) @@ -30586,7 +30585,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (unit->explainable()) { - if (mysql_explain_union(thd, unit, result)) + if (mysql_explain_union(thd, unit, unit->result)) DBUG_VOID_RETURN; } } diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index f5652bd8886..f6d7c310a2f 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -921,6 +921,7 @@ bool Sql_cmd_alter_sequence::execute(THD *thd) TABLE_LIST *first_table= lex->query_tables; TABLE *table; sequence_definition *new_seq= lex->create_info.seq_create_info; + uint saved_used_fields= new_seq->used_fields; SEQUENCE *seq; No_such_table_error_handler no_such_table_handler; DBUG_ENTER("Sql_cmd_alter_sequence::execute"); @@ -1042,5 +1043,6 @@ bool Sql_cmd_alter_sequence::execute(THD *thd) my_ok(thd); end: + new_seq->used_fields= saved_used_fields; DBUG_RETURN(error); } diff --git a/sql/sql_test.cc b/sql/sql_test.cc index e332d524e16..cf34c996eba 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -28,14 +28,17 @@ #include #include "sql_connect.h" #include "thread_cache.h" -#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) + #if defined(HAVE_MALLOC_H) #include -#elif defined(HAVE_SYS_MALLOC_H) -#include -#elif defined(HAVE_MALLOC_ZONE) -#include #endif + +#if defined(HAVE_SYS_MALLOC_H) +#include +#endif + +#if defined(HAVE_MALLOC_ZONE) +#include #endif #ifdef HAVE_EVENT_SCHEDULER diff --git a/sql/sql_type.cc b/sql/sql_type.cc index c68809ec784..bd807db4bf7 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -2242,6 +2242,34 @@ Type_handler::get_handler_by_real_type(enum_field_types type) } +const Type_handler * +Type_handler::handler_by_log_event_data_type(THD *thd, + const Log_event_data_type &type) +{ + if (type.data_type_name().length) + { + const Type_handler *th= handler_by_name(thd, type.data_type_name()); + if (th) + return th; + } + switch (type.type()) { + case STRING_RESULT: + case ROW_RESULT: + case TIME_RESULT: + break; + case REAL_RESULT: + return &type_handler_double; + case INT_RESULT: + if (type.is_unsigned()) + return &type_handler_ulonglong; + return &type_handler_slonglong; + case DECIMAL_RESULT: + return &type_handler_newdecimal; + } + return &type_handler_long_blob; +} + + /** Create a DOUBLE field by default. */ @@ -7686,6 +7714,104 @@ Item *Type_handler_row:: return NULL; } +/***************************************************************************/ + +/* + Check if in a predicate like: + + WHERE timestamp_arg=datetime_arg + + we can replace DATETIME comparison to TIMESTAMP comparison, + to avoid slow TIMESTAMP->DATETIME data type conversion per row. + + TIMESTAMP and DATETIME are compared as DATETIME historically. + This may be inefficient, because involves a conversion of + the TIMESTAMP side to DATETIME per row. + The conversion happens in Timezone::gmt_sec_to_TIME(). + E.g. in case of the SYSTEM timezone, it calls localtime_r(), + which is known to be slow. + + It's generally not possible to compare TIMESTAMP and DATETIME + as TIMESTAMP without behavior change, because: + - DATETIME has a wider range. + - Two different TIMESTAMP values can have the same DATETIME value + near the "fall back" DST change, as well as for leap seconds. + - There are DATETIME gaps during the "spring forward" DST switch. + + However, if the DATETIME side is a constant, then we can compare + it to TIMESTAMP as TIMESTAMP in many cases. The DATETIME argument can + be converted once to TIMESTAMP, so no data type conversion will + happen per row. This is faster for big tables. + + The comparison predicates must satisfy the following conditions: + 1. There must be a proper data type combination: + - other must be of the TIMESTAMP data type + - subject must be of the DATETIME data type, + or can convert to DATETIME. + 2. subject must be a constant + 3. subject must convert to TIMESTAMP safely + (without time zone anomalies near its value) +*/ + +Item * +Type_handler_datetime_common::convert_item_for_comparison( + THD *thd, + Item *subject, + const Item *counterpart) + const +{ + if (!dynamic_cast( + counterpart->type_handler()) || + !subject->type_handler()->can_return_date()) + return subject; + + struct Count_handler : public Internal_error_handler + { + uint hit= 0; + bool handle_condition(THD *thd, + uint sql_errno, + const char *sqlstate, + Sql_condition::enum_warning_level *level, + const char *msg, + Sql_condition **cond_hdl) + { + hit++; + return *level == Sql_condition::WARN_LEVEL_WARN; + } + } cnt_handler; + + // Suppress and count warnings + thd->push_internal_handler(&cnt_handler); + Datetime dt(thd, subject, Timestamp::DatetimeOptions(thd)); + thd->pop_internal_handler(); + + if (!dt.is_valid_datetime() || cnt_handler.hit) + { + /* + SQL NULL DATETIME, or a DATETIME with zeros in YYYYMMDD, + or warnings during DATETIME evaluation. + */ + return subject; + } + + // '0000-00-00 00:00:00' is a special valid MariaDB TIMESTAMP value + if (!non_zero_date(dt.get_mysql_time())) + return new (thd->mem_root) Item_timestamp_literal(thd, + Timestamp_or_zero_datetime::zero(), + subject->datetime_precision(thd)); + + const Timeval_null tv(thd->safe_timeval_replacement_for_nonzero_datetime(dt)); + if (tv.is_null()) + return subject; // Time zone anomalies found around "dt" + + // Should be safe to convert + const Timestamp_or_zero_datetime ts(Timestamp(tv.to_timeval())); + return new (thd->mem_root) Item_timestamp_literal(thd, + ts, + subject->datetime_precision(thd)); +} + + /***************************************************************************/ static const char* item_name(Item *a, String *str) @@ -8686,6 +8812,43 @@ Type_handler_temporal_result::Item_const_eq(const Item_const *a, b->get_type_all_attributes_from_const()->decimals); } + +/* + @brief + Check if two costant timestamp values are identical. + + @return + true <=> *a and *b are identical +*/ +bool +Type_handler_timestamp_common::Item_const_eq(const Item_const *a, + const Item_const *b, + bool binary_cmp) const +{ + /* + In a condition like: + WHERE IF(a='2001-01-01 00:00:00',1,0)=IF(a='2001-01-01 00:00:00',1,0); + Item_func_eq::fix_length_and_dec() calls get_timestamp_item_for_comparison() + which replaces string literals '2001-01-01 00:00:00' with + Item_timestamp_literal instances, which later during remove_eq_conds() + come to here. + + Note, Item_param bound to TIMESTAMP is not detected here, + so trivial conditions of this kind do not get eliminated: + DECLARE ts TIMESTAMP DEFAULT (SELECT MAX(ts_col) FROM t1); + EXECUTE IMMEDIATE + 'SELECT * FROM t1 WHERE COALESCE(ts_col,?)<=>COALESCE(ts_col,?)' + USING ts, ts; + It should be fixed by MDEV-14271. + */ + const Item_timestamp_literal *ta, *tb; + if (!(ta= dynamic_cast(a)) || + !(tb= dynamic_cast(b))) + return false; + return !ta->value().cmp(tb->value()); +} + + /***************************************************************************/ const Type_handler * diff --git a/sql/sql_type.h b/sql/sql_type.h index 8215a3ee759..45e94c0dbd6 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -24,12 +24,15 @@ #include "mysqld.h" #include "lex_string.h" +#include "sql_type_timeofday.h" #include "sql_array.h" #include "sql_const.h" #include "sql_time.h" #include "sql_type_string.h" #include "sql_type_real.h" #include "compat56.h" +#include "log_event_data_type.h" + C_MODE_START #include C_MODE_END @@ -2520,6 +2523,20 @@ public: } Datetime(my_time_t unix_time, ulong second_part, const Time_zone* time_zone); + Datetime(uint year_arg, uint month_arg, uint day_arg, const TimeOfDay6 &td) + { + neg= 0; + year= year_arg; + month= month_arg; + day= day_arg; + hour= td.hour(); + minute= td.minute(); + second= td.second(); + second_part= td.usecond(); + time_type= MYSQL_TIMESTAMP_DATETIME; + if (!is_valid_datetime_slow()) + time_type= MYSQL_TIMESTAMP_NONE; + } bool is_valid_datetime() const { @@ -2665,6 +2682,12 @@ public: return Temporal::fraction_remainder(dec); } + Datetime time_of_day(const TimeOfDay6 &td) const + { + DBUG_ASSERT(is_valid_datetime()); // not SQL NULL + return Datetime(year, month, day, td); + } + Datetime &trunc(uint dec) { if (is_valid_datetime()) @@ -2837,6 +2860,11 @@ public: class Timestamp_or_zero_datetime: protected Timestamp { bool m_is_zero_datetime; +public: + static Timestamp_or_zero_datetime zero() + { + return Timestamp_or_zero_datetime(Timestamp(0, 0), true); + } public: Timestamp_or_zero_datetime() :Timestamp(0,0), m_is_zero_datetime(true) @@ -2845,7 +2873,7 @@ public: :Timestamp(native.length() ? Timestamp(native) : Timestamp(0,0)), m_is_zero_datetime(native.length() == 0) { } - Timestamp_or_zero_datetime(const Timestamp &tm, bool is_zero_datetime) + Timestamp_or_zero_datetime(const Timestamp &tm, bool is_zero_datetime= false) :Timestamp(tm), m_is_zero_datetime(is_zero_datetime) { } Timestamp_or_zero_datetime(THD *thd, const MYSQL_TIME *ltime, uint *err_code); @@ -2869,6 +2897,11 @@ public: return 1; return Timestamp::cmp(other); } + const Timestamp &to_timestamp() const + { + DBUG_ASSERT(!is_zero_datetime()); + return *this; + } bool to_TIME(THD *thd, MYSQL_TIME *to, date_mode_t fuzzydate) const; /* Convert to native format: @@ -3673,6 +3706,9 @@ public: static const Type_handler *handler_by_name(THD *thd, const LEX_CSTRING &name); static const Type_handler *handler_by_name_or_error(THD *thd, const LEX_CSTRING &name); + static const Type_handler *handler_by_log_event_data_type( + THD *thd, + const Log_event_data_type &type); static const Type_handler *odbc_literal_type_handler(const LEX_CSTRING *str); static const Type_handler *blob_type_handler(uint max_octet_length); static const Type_handler *string_type_handler(uint max_octet_length); @@ -3957,6 +3993,12 @@ public: { return false; } + + virtual Log_event_data_type user_var_log_event_data_type(uint charset_nr) const + { + return Log_event_data_type({NULL,0}/*data type name*/, result_type(), + charset_nr, is_unsigned()); + } virtual uint Column_definition_gis_options_image(uchar *buff, const Column_definition &def) const @@ -4206,6 +4248,33 @@ public: virtual Item *make_const_item_for_comparison(THD *thd, Item *src, const Item *cmp) const= 0; + /** + When aggregating function arguments for comparison + (e.g. for =, <, >, <=, >=, NULLIF), in some cases we rewrite + arguments. For example, if the predicate + timestamp_expr0 = datetime_const_expr1 + decides to compare arguments as DATETIME, + we can try to rewrite datetime_const_expr1 to a TIMESTAMP constant + and perform the comparison as TIMESTAMP, which is faster because + does not have to perform TIMESTAMP->DATETIME data type conversion per row. + + "this" is the type handler that is used to compare + "subject" and "counterpart" (DATETIME in the above example). + @param thd the current thread + @param subject the comparison side that we want try to rewrite + @param counterpart the other comparison side + @retval subject, if the subject does not need to be rewritten + @retval NULL in case of error (e.g. EOM) + @retval Otherwise, a pointer to a new Item which can + be used as a replacement for the subject. + */ + virtual Item *convert_item_for_comparison(THD *thd, + Item *subject, + const Item *counterpart) const + { + return subject; + } + virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const= 0; virtual Item *make_constructor_item(THD *thd, List *args) const { @@ -6524,6 +6593,9 @@ public: } String *print_item_value(THD *thd, Item *item, String *str) const override; Item_cache *Item_get_cache(THD *thd, const Item *item) const override; + Item *convert_item_for_comparison(THD *thd, + Item *subject, + const Item *counterpart) const override; String *Item_func_min_max_val_str(Item_func_min_max *, String *) const override; double Item_func_min_max_val_real(Item_func_min_max *) const override; longlong Item_func_min_max_val_int(Item_func_min_max *) const override; @@ -6695,6 +6767,8 @@ public: my_decimal *Item_func_min_max_val_decimal(Item_func_min_max *, my_decimal *) const override; bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override; + bool Item_const_eq(const Item_const *a, const Item_const *b, + bool binary_cmp) const override; bool Item_hybrid_func_fix_attributes(THD *thd, const LEX_CSTRING &name, Type_handler_hybrid_field_type *, diff --git a/sql/sql_type_geom.h b/sql/sql_type_geom.h index d86d1181187..14d3d062ef9 100644 --- a/sql/sql_type_geom.h +++ b/sql/sql_type_geom.h @@ -82,6 +82,13 @@ public: Field *make_conversion_table_field(MEM_ROOT *root, TABLE *table, uint metadata, const Field *target) const override; + Log_event_data_type user_var_log_event_data_type(uint charset_nr) + const override + { + return Log_event_data_type(name().lex_cstring(), result_type(), + charset_nr, false/*unsigned*/); + } + uint Column_definition_gis_options_image(uchar *buff, const Column_definition &def) const override; diff --git a/sql/sql_type_timeofday.h b/sql/sql_type_timeofday.h new file mode 100644 index 00000000000..202c98e9c09 --- /dev/null +++ b/sql/sql_type_timeofday.h @@ -0,0 +1,67 @@ +/* Copyright (c) 2024, 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#ifndef SQL_TYPE_TIMEOFDAY_INCLUDED +#define SQL_TYPE_TIMEOFDAY_INCLUDED + +#include "my_time.h" // TIME_MAX_MINUTE + +/* + This class stores a time of the day with + fractional precision up to 6 digits. +*/ +class TimeOfDay6 +{ + uint m_hour; // 0..23 + uint m_minute; // 0..59 + uint m_second; // 0..59 + uint m_usecond; // 0..999999 + bool is_valid_time_of_day6() const + { + return m_hour <= 23 && + m_minute <= TIME_MAX_MINUTE && + m_second <= TIME_MAX_SECOND && + m_usecond <= TIME_MAX_SECOND_PART; + } +public: + TimeOfDay6() + :m_hour(0), m_minute(0), m_second(0), m_usecond(0) + { } + // This constructor assumes the caller passes valid 'hh:mm:ss.ff' values + TimeOfDay6(uint hour, uint minute, uint second, uint usecond) + :m_hour(hour), m_minute(minute), m_second(second), m_usecond(usecond) + { + DBUG_ASSERT(is_valid_time_of_day6()); + } + uint hour() const { return m_hour; } + uint minute() const { return m_minute; } + uint second() const { return m_second; } + uint usecond() const { return m_usecond; } + /* + Return the last time of the day for the given precision, e.g.: + - '23:59:59.000000' for decimals==0 + - '23:59:59.999000' for decimals==3 + - '23:59:59.999999' for decimals==6 + */ + static TimeOfDay6 end_of_day(decimal_digits_t decimals) + { + long rem= my_time_fraction_remainder(TIME_MAX_SECOND_PART, decimals); + DBUG_ASSERT(rem >= 0 && rem <= TIME_MAX_SECOND_PART); + return TimeOfDay6(23, TIME_MAX_MINUTE, TIME_MAX_SECOND, + (uint) (TIME_MAX_SECOND_PART - (uint) rem)); + } +}; + +#endif // SQL_TYPE_TIMEOFDAY_INCLUDED diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 790fa1a7d1f..e6181b98627 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -2139,7 +2139,8 @@ loop_end: group.direction= ORDER::ORDER_ASC; group.item= (Item**) temp_fields.head_ref(); - tmp_param->quick_group= 1; + tmp_param->init(); + tmp_param->tmp_name="update"; tmp_param->field_count= temp_fields.elements; tmp_param->func_count= temp_fields.elements - 1; calc_group_buffer(tmp_param, &group); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 25fa92cdafc..cb39ef001fc 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -297,7 +297,8 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view, for (tbl= sl->get_table_list(); tbl; tbl= tbl->next_local) { if (!tbl->with && tbl->select_lex) - tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl); + tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl, + NULL); /* Ensure that we have some privileges on this table, more strict check will be done on column level after preparation, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b01d369bb10..5977e309ae4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -741,7 +741,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token ACTION /* SQL-2003-N */ %token ADMIN_SYM /* SQL-2003-N */ %token ADDDATE_SYM /* MYSQL-FUNC */ -%token ADD_MONTHS_SYM /* Oracle FUNC*/ %token AFTER_SYM /* SQL-2003-N */ %token AGAINST %token AGGREGATE_SYM @@ -817,7 +816,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DATAFILE_SYM %token DATA_SYM /* SQL-2003-N */ %token DATETIME -%token DATE_FORMAT_SYM /* MYSQL-FUNC */ %token DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */ %token DAY_SYM /* SQL-2003-R */ %token DEALLOCATE_SYM /* SQL-2003-R */ @@ -969,7 +967,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token NATIONAL_SYM /* SQL-2003-R */ %token NCHAR_SYM /* SQL-2003-R */ %token NEVER_SYM /* MySQL */ -%token NEW_SYM /* SQL-2003-R */ %token NEXT_SYM /* SQL-2003-N */ %token NEXTVAL_SYM /* PostgreSQL sequence function */ %token NOCACHE_SYM @@ -1134,7 +1131,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token TRIGGERS_SYM %token TRIM_ORACLE %token TRUNCATE_SYM -%token TYPES_SYM %token TYPE_SYM /* SQL-2003-N */ %token UDF_RETURNS_SYM %token UNBOUNDED_SYM /* SQL-2011-N */ @@ -1329,6 +1325,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type IDENT_sys + ident_func ident label_ident sp_decl_ident @@ -1354,6 +1351,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); IDENT_cli ident_cli ident_cli_set_usual_case + ident_cli_func %type ident_sys_alloc @@ -1369,6 +1367,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); keyword_sp_block_section keyword_sp_decl keyword_sp_head + keyword_func_sp_var_and_label + keyword_func_sp_var_not_label keyword_sp_var_and_label keyword_sp_var_not_label keyword_sysvar_name @@ -10312,14 +10312,7 @@ substring_operands_special: discouraged. */ function_call_nonkeyword: - ADD_MONTHS_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, - INTERVAL_MONTH, 0); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | ADDDATE_SYM '(' expr ',' expr ')' + ADDDATE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, INTERVAL_DAY, 0); @@ -10358,18 +10351,6 @@ function_call_nonkeyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | DATE_FORMAT_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | DATE_FORMAT_SYM '(' expr ',' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5, $7); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | EXTRACT_SYM '(' interval FROM expr ')' { $$=new (thd->mem_root) Item_extract(thd, $3, $5); @@ -10494,13 +10475,6 @@ function_call_nonkeyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | - COLUMN_CHECK_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_dyncol_check(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | COLUMN_CREATE_SYM '(' dyncall_create_list ')' { @@ -10536,43 +10510,12 @@ function_call_conflict: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | COALESCE '(' expr_list ')' - { - $$= new (thd->mem_root) Item_func_coalesce(thd, *$3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | COLLATION_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_collation(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | DATABASE '(' ')' - { - $$= new (thd->mem_root) Item_func_database(thd); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - Lex->safe_to_cache_query=0; - } | IF_SYM '(' expr ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_if(thd, $3, $5, $7); if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | FORMAT_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_format(thd, $3, $5); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | FORMAT_SYM '(' expr ',' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_format(thd, $3, $5, $7); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } /* LAST_VALUE here conflicts with the definition for window functions. We have these 2 separate rules to remove the shift/reduce conflict. */ @@ -10594,25 +10537,12 @@ function_call_conflict: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | MICROSECOND_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_microsecond(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | MOD_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_mod(thd, $3, $5); if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | OLD_PASSWORD_SYM '(' expr ')' - { - $$= new (thd->mem_root) - Item_func_password(thd, $3, Item_func_password::OLD); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | PASSWORD_SYM '(' expr ')' { Item* i1; @@ -10621,12 +10551,6 @@ function_call_conflict: MYSQL_YYABORT; $$= i1; } - | QUARTER_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_quarter(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | REPEAT_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_repeat(thd, $3, $5); @@ -10639,38 +10563,12 @@ function_call_conflict: make_item_func_replace(thd, $3, $5, $7)))) MYSQL_YYABORT; } - | REVERSE_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_reverse(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | ROW_COUNT_SYM '(' ')' - { - $$= new (thd->mem_root) Item_func_row_count(thd); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); - Lex->safe_to_cache_query= 0; - } | TRUNCATE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_round(thd, $3, $5, 1); if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | WEEK_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_week(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | WEEK_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_week(thd, $3, $5); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | WEIGHT_STRING_SYM '(' expr opt_ws_levels ')' { $$= new (thd->mem_root) Item_func_weight_string(thd, $3, 0, 0, $4); @@ -10716,7 +10614,7 @@ function_call_conflict: in sql/item_create.cc */ function_call_generic: - IDENT_sys '(' + ident_func '(' { #ifdef HAVE_DLOPEN udf_func *udf= 0; @@ -15641,6 +15539,22 @@ IDENT_sys: } ; +ident_cli_func: + IDENT + | IDENT_QUOTED + | keyword_func_sp_var_and_label { $$= $1; } + | keyword_func_sp_var_not_label { $$= $1; } + ; + +ident_func: + ident_cli_func + { + if (unlikely(thd->to_ident_sys_alloc(&$$, &$1))) + MYSQL_YYABORT; + } + ; + + TEXT_STRING_sys: TEXT_STRING { @@ -15864,7 +15778,8 @@ non_reserved_keyword_udt: TODO: check if some of them can migrate to keyword_sp_var_and_label. */ keyword_sp_var_not_label: - ASCII_SYM + keyword_func_sp_var_not_label + | ASCII_SYM | BACKUP_SYM | BINLOG_SYM | BYTE_SYM @@ -15872,7 +15787,6 @@ keyword_sp_var_not_label: | CHECKSUM_SYM | CHECKPOINT_SYM | COLUMN_ADD_SYM - | COLUMN_CHECK_SYM | COLUMN_CREATE_SYM | COLUMN_DELETE_SYM | COLUMN_GET_SYM @@ -15884,7 +15798,6 @@ keyword_sp_var_not_label: | EXECUTE_SYM | FLUSH_SYM | FOLLOWING_SYM - | FORMAT_SYM | GET_SYM | HELP_SYM | HOST_SYM @@ -16038,21 +15951,15 @@ keyword_cast_type: ; -/* - These keywords are fine for both SP variable names and SP labels. -*/ -keyword_sp_var_and_label: - ACTION +keyword_func_sp_var_and_label: + ACTION | ACCOUNT_SYM - | ADDDATE_SYM - | ADD_MONTHS_SYM | ADMIN_SYM | AFTER_SYM | AGAINST | AGGREGATE_SYM | ALGORITHM_SYM | ALWAYS_SYM - | ANY_SYM | AT_SYM | ATOMIC_SYM | AUTHORS_SYM @@ -16060,7 +15967,6 @@ keyword_sp_var_and_label: | AUTOEXTEND_SIZE_SYM | AUTO_SYM | AVG_ROW_LENGTH - | AVG_SYM | BLOCK_SYM | BODY_MARIADB_SYM | BTREE_SYM @@ -16073,7 +15979,6 @@ keyword_sp_var_and_label: | CLIENT_SYM | CLASS_ORIGIN_SYM | COALESCE - | CODE_SYM | COLLATION_SYM | COLUMN_NAME_SYM | COLUMNS @@ -16099,16 +16004,15 @@ keyword_sp_var_and_label: | CURSOR_NAME_SYM | CYCLE_SYM | DATA_SYM + | DATABASE | DATAFILE_SYM - | DATE_FORMAT_SYM - | DAY_SYM | DEFINER_SYM | DELAY_KEY_WRITE_SYM | DES_KEY_FILE | DIAGNOSTICS_SYM + | DISCARD | DIRECTORY_SYM | DISABLE_SYM - | DISCARD | DISK_SYM | DUMPFILE | DUPLICATE_SYM @@ -16116,6 +16020,11 @@ keyword_sp_var_and_label: | ELSEIF_ORACLE_SYM | ELSIF_MARIADB_SYM | EMPTY_SYM + | EXPIRE_SYM + | EXPORT_SYM + | EXTENDED_SYM + | EXTENT_SIZE_SYM + | ENABLE_SYM | ENDS_SYM | ENGINE_SYM | ENGINES_SYM @@ -16128,29 +16037,21 @@ keyword_sp_var_and_label: | EXCEPTION_MARIADB_SYM | EXCHANGE_SYM | EXPANSION_SYM - | EXPIRE_SYM - | EXPORT_SYM - | EXTENDED_SYM - | EXTENT_SIZE_SYM | FAULTS_SYM | FAST_SYM - | FOUND_SYM - | ENABLE_SYM | FEDERATED_SYM - | FULL | FILE_SYM | FIRST_SYM + | FOUND_SYM + | FULL | GENERAL | GENERATED_SYM - | GET_FORMAT | GRANTS | GOTO_MARIADB_SYM | HASH_SYM | HARD_SYM | HISTORY_SYM | HOSTS_SYM - | HOUR_SYM - | ID_SYM | IDENTIFIED_SYM | IGNORE_SERVER_IDS_SYM | INCREMENT_SYM @@ -16168,9 +16069,7 @@ keyword_sp_var_and_label: | INVISIBLE_SYM | JSON_TABLE_SYM | KEY_BLOCK_SIZE - | LAST_VALUE | LAST_SYM - | LASTVAL_SYM | LEAVES | LESS_SYM | LEVEL_SYM @@ -16212,7 +16111,6 @@ keyword_sp_var_and_label: | MESSAGE_TEXT_SYM | MICROSECOND_SYM | MIGRATE_SYM - | MINUTE_SYM %ifdef MARIADB | MINUS_ORACLE_SYM %endif @@ -16221,7 +16119,6 @@ keyword_sp_var_and_label: | MODIFY_SYM | MODE_SYM | MONITOR_SYM - | MONTH_SYM | MUTEX_SYM | MYSQL_SYM | MYSQL_ERRNO_SYM @@ -16229,8 +16126,6 @@ keyword_sp_var_and_label: | NESTED_SYM | NEVER_SYM | NEXT_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 - | NEXTVAL_SYM - | NEW_SYM | NOCACHE_SYM | NOCYCLE_SYM | NOMINVALUE_SYM @@ -16246,7 +16141,6 @@ keyword_sp_var_and_label: | ONLINE_SYM | ONLY_SYM | ORDINALITY_SYM - | OVERLAPS_SYM | PACKAGE_MARIADB_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | PACK_KEYS_SYM | PAGE_SYM @@ -16278,10 +16172,10 @@ keyword_sp_var_and_label: | REDOFILE_SYM | REDUNDANT_SYM | RELAY - | RELAYLOG_SYM | RELAY_LOG_FILE_SYM | RELAY_LOG_POS_SYM | RELAY_THREAD + | RELAYLOG_SYM | RELOAD | REORGANIZE_SYM | REPEATABLE_SYM @@ -16296,20 +16190,15 @@ keyword_sp_var_and_label: | REVERSE_SYM | ROLLUP_SYM | ROUTINE_SYM + | ROW_COUNT_SYM | ROWCOUNT_SYM | ROWTYPE_MARIADB_SYM - | ROW_COUNT_SYM | ROW_FORMAT_SYM -%ifdef MARIADB - | ROWNUM_SYM -%endif | RTREE_SYM | SCHEDULE_SYM | SCHEMA_NAME_SYM - | SECOND_SYM | SEQUENCE_SYM | SERIALIZABLE_SYM - | SETVAL_SYM | SIMPLE_SYM | SHARE_SYM | SKIP_SYM @@ -16317,7 +16206,6 @@ keyword_sp_var_and_label: | SLOW | SNAPSHOT_SYM | SOFT_SYM - | SOUNDS_SYM | SOURCE_SYM | SQL_CACHE_SYM | SQL_BUFFER_RESULT @@ -16330,7 +16218,6 @@ keyword_sp_var_and_label: | STORAGE_SYM | STRING_SYM | SUBCLASS_ORIGIN_SYM - | SUBDATE_SYM | SUBJECT_SYM | SUBPARTITION_SYM | SUBPARTITIONS_SYM @@ -16338,9 +16225,6 @@ keyword_sp_var_and_label: | SUSPEND_SYM | SWAPS_SYM | SWITCHES_SYM -%ifdef MARIADB - | SYSDATE -%endif | SYSTEM | SYSTEM_TIME_SYM | TABLE_NAME_SYM @@ -16354,10 +16238,6 @@ keyword_sp_var_and_label: | TRANSACTIONAL_SYM | THREADS_SYM | TRIGGERS_SYM - | TRIM_ORACLE - | TIMESTAMP_ADD - | TIMESTAMP_DIFF - | TYPES_SYM | TYPE_SYM | UDF_RETURNS_SYM | UNCOMMITTED_SYM @@ -16366,7 +16246,6 @@ keyword_sp_var_and_label: | UNDOFILE_SYM | UNKNOWN_SYM | UNTIL_SYM - | USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | USE_FRM | VARIABLES | VERSIONING_SYM @@ -16374,16 +16253,55 @@ keyword_sp_var_and_label: | VIRTUAL_SYM | VISIBLE_SYM | VALIDATION_SYM - | VALUE_SYM | WARNINGS | WAIT_SYM - | WEEK_SYM - | WEIGHT_STRING_SYM | WITHOUT | WORK_SYM | X509_SYM | XML_SYM | VIA_SYM + | WEEK_SYM + ; + +keyword_func_sp_var_not_label: + FORMAT_SYM + | COLUMN_CHECK_SYM + ; +/* + These keywords are fine for both SP variable names and SP labels. +*/ +keyword_sp_var_and_label: + keyword_func_sp_var_and_label + | ADDDATE_SYM + | ANY_SYM + | AVG_SYM + | CODE_SYM + | DAY_SYM + | GET_FORMAT + | HOUR_SYM + | ID_SYM + | LAST_VALUE + | LASTVAL_SYM + | MINUTE_SYM + | MONTH_SYM + | NEXTVAL_SYM + | OVERLAPS_SYM +%ifdef MARIADB + | ROWNUM_SYM +%endif + | SECOND_SYM + | SETVAL_SYM + | SOUNDS_SYM + | SUBDATE_SYM +%ifdef MARIADB + | SYSDATE +%endif + | TRIM_ORACLE + | TIMESTAMP_ADD + | TIMESTAMP_DIFF + | USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 + | VALUE_SYM + | WEIGHT_STRING_SYM ; @@ -16424,7 +16342,6 @@ reserved_keyword_udt_not_param_type: | CURRENT_USER | CURRENT_ROLE | CURTIME - | DATABASE | DATABASES | DATE_ADD_INTERVAL | DATE_SUB_INTERVAL diff --git a/sql/structs.h b/sql/structs.h index c8351efd8bf..029543ceb01 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -1035,4 +1035,29 @@ public: }; +/* + A value that's either a Timeval or SQL NULL +*/ + +class Timeval_null: protected Timeval +{ + bool m_is_null; +public: + Timeval_null() + :Timeval(0, 0), + m_is_null(true) + { } + Timeval_null(const my_time_t sec, ulong usec) + :Timeval(sec, usec), + m_is_null(false) + { } + const Timeval & to_timeval() const + { + DBUG_ASSERT(!m_is_null); + return *this; + } + bool is_null() const { return m_is_null; } +}; + + #endif /* STRUCTS_INCLUDED */ diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index efa46fa083e..b7d81fe07bd 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2987,6 +2987,14 @@ static Sys_var_ulong Sys_optimizer_trace_max_mem_size( SESSION_VAR(optimizer_trace_max_mem_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, ULONG_MAX), DEFAULT(1024 * 1024), BLOCK_SIZE(1)); +static Sys_var_ulong Sys_optimizer_adjust_secondary_key_costs( + "optimizer_adjust_secondary_key_costs", + "Unused, will be removed.", + SESSION_VAR(optimizer_adjust_secondary_key_costs), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, 2), DEFAULT(0), BLOCK_SIZE(1), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), + DEPRECATED(1100, "")); + static Sys_var_charptr_fscs Sys_pid_file( "pid_file", "Pid file used by safe_mysqld", READ_ONLY GLOBAL_VAR(pidfile_name_ptr), CMD_LINE(REQUIRED_ARG), @@ -3661,13 +3669,6 @@ static bool fix_rpl_semi_sync_master_wait_point(sys_var *self, THD *thd, return false; } -static bool fix_rpl_semi_sync_master_wait_no_slave(sys_var *self, THD *thd, - enum_var_type type) -{ - repl_semisync_master.check_and_switch(); - return false; -} - static Sys_var_on_access_global Sys_semisync_master_enabled( @@ -3694,12 +3695,11 @@ static Sys_var_on_access_global Sys_semisync_master_wait_no_slave( "rpl_semi_sync_master_wait_no_slave", - "Wait until timeout when no semi-synchronous replication slave " - "available (enabled by default).", + "Wait until timeout when no semi-synchronous replication slave is " + "available.", GLOBAL_VAR(rpl_semi_sync_master_wait_no_slave), CMD_LINE(OPT_ARG), DEFAULT(TRUE), - NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), - ON_UPDATE(fix_rpl_semi_sync_master_wait_no_slave)); + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0)); static Sys_var_on_access_global @@ -3726,13 +3726,6 @@ Sys_semisync_master_wait_point( NO_MUTEX_GUARD, NOT_IN_BINLOG,ON_CHECK(0), ON_UPDATE(fix_rpl_semi_sync_master_wait_point)); -static bool fix_rpl_semi_sync_slave_enabled(sys_var *self, THD *thd, - enum_var_type type) -{ - repl_semisync_slave.set_slave_enabled(rpl_semi_sync_slave_enabled != 0); - return false; -} - static bool fix_rpl_semi_sync_slave_trace_level(sys_var *self, THD *thd, enum_var_type type) { @@ -3760,10 +3753,9 @@ static Sys_var_on_access_global diff --git a/sql/table.cc b/sql/table.cc index 2b95cf25911..ca4b4e40014 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -53,6 +53,7 @@ #ifdef WITH_WSREP #include "wsrep_schema.h" #endif +#include "log_event.h" // MAX_TABLE_MAP_ID /* For MySQL 5.7 virtual fields */ #define MYSQL57_GENERATED_FIELD 128 @@ -112,7 +113,7 @@ LEX_CSTRING MYSQL_PROC_NAME= {STRING_WITH_LEN("proc")}; */ static LEX_CSTRING parse_vcol_keyword= { STRING_WITH_LEN("PARSE_VCOL_EXPR ") }; -static std::atomic last_table_id; +static std::atomic last_table_id; /* Functions defined in this file */ @@ -388,17 +389,20 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name, DBUG_EXECUTE_IF("simulate_big_table_id", if (last_table_id < UINT_MAX32) - last_table_id= UINT_MAX32 - 1;); + last_table_id= UINT_MAX32-1;); /* - There is one reserved number that cannot be used. Remember to - change this when 6-byte global table id's are introduced. + Replication is using 6 bytes as table_map_id. Ensure that + the 6 lowest bytes are not 0. + We also have to ensure that we do not use the special value + UINT_MAX32 as this is used to mark a dummy event row event. See + comments in Rows_log_event::Rows_log_event(). */ do { share->table_map_id= last_table_id.fetch_add(1, std::memory_order_relaxed); - } while (unlikely(share->table_map_id == ~0UL || - share->table_map_id == 0)); + } while (unlikely((share->table_map_id & MAX_TABLE_MAP_ID) == 0) || + unlikely((share->table_map_id & MAX_TABLE_MAP_ID) == UINT_MAX32)); } DBUG_RETURN(share); } @@ -461,7 +465,7 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key, table_map_id is also used for MERGE tables to suppress repeated compatibility checks. */ - share->table_map_id= (ulong) thd->query_id; + share->table_map_id= (ulonglong) thd->query_id; DBUG_VOID_RETURN; } @@ -1288,12 +1292,11 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, if (keypart->key_part_flag & HA_PART_KEY_SEG) { int length= keypart->length/keypart->field->charset()->mbmaxlen; + Field *kpf= table->field[keypart->field->field_index]; list_item= new (mem_root) Item_func_left(thd, - new (mem_root) Item_field(thd, keypart->field), + new (mem_root) Item_field(thd, kpf), new (mem_root) Item_int(thd, length)); list_item->fix_fields(thd, NULL); - keypart->field->vcol_info= - table->field[keypart->field->field_index]->vcol_info; } else list_item= new (mem_root) Item_field(thd, keypart->field); @@ -7661,7 +7664,7 @@ inline void TABLE::mark_index_columns_for_read(uint index) always set and sometimes read. */ -void TABLE::mark_auto_increment_column() +void TABLE::mark_auto_increment_column(bool is_insert) { DBUG_ASSERT(found_next_number_field); /* @@ -7669,7 +7672,8 @@ void TABLE::mark_auto_increment_column() store() to check overflow of auto_increment values */ bitmap_set_bit(read_set, found_next_number_field->field_index); - bitmap_set_bit(write_set, found_next_number_field->field_index); + if (is_insert) + bitmap_set_bit(write_set, found_next_number_field->field_index); if (s->next_number_keypart) mark_index_columns_for_read(s->next_number_index); file->column_bitmaps_signal(); @@ -7805,7 +7809,7 @@ void TABLE::mark_columns_needed_for_update() else { if (found_next_number_field) - mark_auto_increment_column(); + mark_auto_increment_column(false); } if (file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) @@ -7892,7 +7896,7 @@ void TABLE::mark_columns_needed_for_insert() triggers->mark_fields_used(TRG_EVENT_INSERT); } if (found_next_number_field) - mark_auto_increment_column(); + mark_auto_increment_column(true); if (default_field) mark_default_fields_for_write(TRUE); if (s->versioned) diff --git a/sql/table.h b/sql/table.h index 4cfcb9ae41a..7d6eba07831 100644 --- a/sql/table.h +++ b/sql/table.h @@ -877,7 +877,7 @@ struct TABLE_SHARE bool keep_original_mysql_version; bool optimizer_costs_inited; - ulong table_map_id; /* for row-based replication */ + ulonglong table_map_id; /* for row-based replication */ /* Things that are incompatible between the stored version and the @@ -1043,7 +1043,7 @@ struct TABLE_SHARE return (table_category == TABLE_CATEGORY_LOG); } - inline ulong get_table_def_version() + inline ulonglong get_table_def_version() { return table_map_id; } @@ -1122,7 +1122,7 @@ struct TABLE_SHARE @sa TABLE_LIST::is_the_same_definition() */ - ulong get_table_ref_version() const + ulonglong get_table_ref_version() const { return (tmp_table == SYSTEM_TMP_TABLE) ? 0 : table_map_id; } @@ -1616,7 +1616,7 @@ public: void mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap); void mark_index_columns_for_read(uint index); void restore_column_maps_after_keyread(MY_BITMAP *backup); - void mark_auto_increment_column(void); + void mark_auto_increment_column(bool insert_fl); void mark_columns_needed_for_update(void); void mark_columns_needed_for_delete(void); void mark_columns_needed_for_insert(void); @@ -2908,7 +2908,7 @@ struct TABLE_LIST { set_table_ref_id(s->get_table_ref_type(), s->get_table_ref_version()); } inline void set_table_ref_id(enum_table_ref_type table_ref_type_arg, - ulong table_ref_version_arg) + ulonglong table_ref_version_arg) { m_table_ref_type= table_ref_type_arg; m_table_ref_version= table_ref_version_arg; @@ -3063,7 +3063,7 @@ private: /** See comments for set_table_ref_id() */ enum enum_table_ref_type m_table_ref_type; /** See comments for set_table_ref_id() */ - ulong m_table_ref_version; + ulonglong m_table_ref_version; }; class Item; diff --git a/sql/table_cache.cc b/sql/table_cache.cc index 0039c96a001..91292e18d72 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -1213,8 +1213,8 @@ int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument, } -int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope) +int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum enum_var_type scope) { var->type= SHOW_UINT; var->value= buff; diff --git a/sql/table_cache.h b/sql/table_cache.h index 433df5e0328..71704ff2ed0 100644 --- a/sql/table_cache.h +++ b/sql/table_cache.h @@ -87,8 +87,8 @@ extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument, bool no_dups= false); extern uint tc_records(void); -int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff, - enum enum_var_type scope); +int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum enum_var_type scope); extern void tc_purge(); extern void tc_add_table(THD *thd, TABLE *table); extern void tc_release_table(TABLE *table); diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index d236f0b863f..4a226df0e0b 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1592,6 +1592,11 @@ void THD::close_unused_temporary_table_instances(const TABLE_LIST *tl) { /* Note: removing current list element doesn't invalidate iterator. */ share->all_tmp_tables.remove(table); + /* + At least one instance should be left (guaratead by calling this + function for table which is opened and the table is under processing) + */ + DBUG_ASSERT(share->all_tmp_tables.front()); free_temporary_table(table); } } diff --git a/sql/tztime.cc b/sql/tztime.cc index fa50fcb87d6..1e919140660 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2391,6 +2391,59 @@ void Time_zone::adjust_leap_second(MYSQL_TIME *t) t->second= 59; } + +/* + @brief + Check if timestamp<->datetime conversion is guaranteed to be reversible + around the given time value. +*/ + +bool Time_zone::is_monotone_continuous_around(my_time_t sec) const +{ + const my_time_t width= 24 * 60 * 60; + /* + Let's check that the TIMESTAMP range [sec - width, sec + width] + converts back to a DATETIME range [dtmin, dtmax], and the difference + (dtmax-dtmin), calculated using DATETIME arithmetics, + is also equal to exactly 2*width. + + This should almost guarantee that the TIMESTAMP range around sec + is monotone and continuous and thus has no DST changes or leap seconds. + + It's still possible that there are two or more timezone offset changes + in the given range. But there are no such time zones according to + our knowledge. + Note, DST changes and leap seconds do not interfere on a short time_t range: + - Leap seconds happen in winter and summer + - DST changes happen in spring and fall + + The largest time zone change that ever happened in a single place + was 24 hours: + - from SST (UTC-11) - the American Samoa Time Zone + - to WST (UTC+13) - the Independent State of Samoa Time Zone + The Independent State of Samoa used SST until it moved across + the International Date Line at the end of 29 December 2011, to WST. + It is now 24 hours ahead of American Samoa + (and 25 hours in Southern hemisphere summer). + Let's use 24 hours as width (48 hours range total). + */ + + if (sec < width || sec > TIMESTAMP_MAX_VALUE - width) + return false; + + MYSQL_TIME dtmin, dtmax; + gmt_sec_to_TIME(&dtmin, sec - width); + gmt_sec_to_TIME(&dtmax, sec + width); + + ulonglong seconds; + ulong useconds; + if (calc_time_diff(&dtmax, &dtmin, 1, &seconds, &useconds)) + return false; // dtmax is smaller than dtmin, should not happen. + if (seconds != (ulonglong) width * 2) + return false; // Anomalies found (DST changes or leap seconds) + return true; +} + #endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */ diff --git a/sql/tztime.h b/sql/tztime.h index 5910e8d0d1c..7c96f8b9ad9 100644 --- a/sql/tztime.h +++ b/sql/tztime.h @@ -71,6 +71,13 @@ public: */ virtual ~Time_zone() = default; + /** + Check if the time zone does not have any anomalies around "sec", such as: + - DST changes (spring forward, fall back) + - leap seconds (the 60-th second) + */ + bool is_monotone_continuous_around(my_time_t sec) const; + protected: static inline void adjust_leap_second(MYSQL_TIME *t); }; diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index 00d8a56acba..8a6c592257e 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -88,8 +88,8 @@ class ha_archive final : public handler public: ha_archive(handlerton *hton, TABLE_SHARE *table_arg); ~ha_archive() = default; - const char *index_type(uint inx) { return "NONE"; } - ulonglong table_flags() const + const char *index_type(uint inx) override { return "NONE"; } + ulonglong table_flags() const override { return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | @@ -97,70 +97,74 @@ public: HA_HAS_RECORDS | HA_CAN_REPAIR | HA_SLOW_RND_POS | HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY); } - ulong index_flags(uint idx, uint part, bool all_parts) const + ulong index_flags(uint idx, uint part, bool all_parts) const override { return HA_ONLY_WHOLE_INDEX; } virtual void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, - ulonglong *nb_reserved_values); - uint max_supported_keys() const { return 1; } - uint max_supported_key_length() const { return sizeof(ulonglong); } - uint max_supported_key_part_length() const { return sizeof(ulonglong); } - ha_rows records() { return share->rows_recorded; } + ulonglong *nb_reserved_values) override; + uint max_supported_keys() const override { return 1; } + uint max_supported_key_length() const override { return sizeof(ulonglong); } + uint max_supported_key_part_length() const override + { return sizeof(ulonglong); } + ha_rows records() override { return share->rows_recorded; } IO_AND_CPU_COST scan_time() override; IO_AND_CPU_COST keyread_time(uint index, ulong ranges, ha_rows rows, ulonglong blocks) override; IO_AND_CPU_COST rnd_pos_time(ha_rows rows) override; - int index_init(uint keynr, bool sorted); + int index_init(uint keynr, bool sorted) override; virtual int index_read(uchar * buf, const uchar * key, - uint key_len, enum ha_rkey_function find_flag); + uint key_len, enum ha_rkey_function find_flag) + override; virtual int index_read_idx(uchar * buf, uint index, const uchar * key, uint key_len, enum ha_rkey_function find_flag); - int index_next(uchar * buf); - int open(const char *name, int mode, uint test_if_locked); - int close(void); - int write_row(const uchar * buf); + int index_next(uchar * buf) override; + int open(const char *name, int mode, uint test_if_locked) override; + int close(void) override; + int write_row(const uchar * buf) override; int real_write_row(const uchar *buf, azio_stream *writer); - int truncate(); - int rnd_init(bool scan=1); - int rnd_next(uchar *buf); - int rnd_pos(uchar * buf, uchar *pos); + int truncate() override; + int rnd_init(bool scan=1) override; + int rnd_next(uchar *buf) override; + int rnd_pos(uchar * buf, uchar *pos) override; int get_row(azio_stream *file_to_read, uchar *buf); int get_row_version2(azio_stream *file_to_read, uchar *buf); int get_row_version3(azio_stream *file_to_read, uchar *buf); Archive_share *get_share(const char *table_name, int *rc); int init_archive_reader(); // Always try auto_repair in case of HA_ERR_CRASHED_ON_USAGE - bool auto_repair(int error) const + bool auto_repair(int error) const override { return error == HA_ERR_CRASHED_ON_USAGE; } int read_data_header(azio_stream *file_to_read); - void position(const uchar *record); - int info(uint); - int extra(enum ha_extra_function operation); - void update_create_info(HA_CREATE_INFO *create_info); - int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); - int optimize(THD* thd, HA_CHECK_OPT* check_opt); - int repair(THD* thd, HA_CHECK_OPT* check_opt); - int check_for_upgrade(HA_CHECK_OPT *check_opt); - void start_bulk_insert(ha_rows rows, uint flags); - int end_bulk_insert(); - enum row_type get_row_type() const + void position(const uchar *record) override; + int info(uint) override; + int extra(enum ha_extra_function operation) override; + void update_create_info(HA_CREATE_INFO *create_info) override; + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info) + override; + int optimize(THD* thd, HA_CHECK_OPT* check_opt) override; + int repair(THD* thd, HA_CHECK_OPT* check_opt) override; + int check_for_upgrade(HA_CHECK_OPT *check_opt) override; + void start_bulk_insert(ha_rows rows, uint flags) override; + int end_bulk_insert() override; + enum row_type get_row_type() const override { return ROW_TYPE_COMPRESSED; } THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, - enum thr_lock_type lock_type); - bool is_crashed() const; - int check(THD* thd, HA_CHECK_OPT* check_opt); - bool check_and_repair(THD *thd); + enum thr_lock_type lock_type) override; + bool is_crashed() const override; + int check(THD* thd, HA_CHECK_OPT* check_opt) override; + bool check_and_repair(THD *thd) override; uint32 max_row_length(const uchar *buf); bool fix_rec_buff(unsigned int length); int unpack_row(azio_stream *file_to_read, uchar *record); unsigned int pack_row(const uchar *record, azio_stream *writer); - bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); - int external_lock(THD *thd, int lock_type); + bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) + override; + int external_lock(THD *thd, int lock_type) override; private: void flush_and_clear_pending_writes(); }; diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp index 9cf5f41d1fe..f5710688d3c 100644 --- a/storage/connect/tabvct.cpp +++ b/storage/connect/tabvct.cpp @@ -71,11 +71,6 @@ #include "tabvct.h" #include "valblk.h" -#if defined(UNIX) -//add dummy strerror (NGC) -char *strerror(int num); -#endif // UNIX - /***********************************************************************/ /* External function. */ /***********************************************************************/ diff --git a/storage/connect/zip.c b/storage/connect/zip.c index f6a10601968..3d3d4caddef 100644 --- a/storage/connect/zip.c +++ b/storage/connect/zip.c @@ -14,8 +14,8 @@ Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data - It is used when recreting zip archive with RAW when deleting items from a zip. - ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed. + It is used when recreating zip archive with RAW when deleting items from a zip. + ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed. Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer @@ -25,15 +25,13 @@ #include #include #include +#include #include #include "zlib.h" #include "zip.h" -#include "my_attribute.h" #ifdef STDC # include -# include -# include #endif #ifdef NO_ERRNO_H extern int errno; @@ -48,7 +46,7 @@ /* compile with -Dlocal if your debugger can't find static symbols */ #ifndef VERSIONMADEBY -# define VERSIONMADEBY (0x0) /* platform depedent */ +# define VERSIONMADEBY (0x0) /* platform dependent */ #endif #ifndef Z_BUFSIZE @@ -62,9 +60,6 @@ #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif /* #define SIZECENTRALDIRITEM (0x2e) @@ -117,7 +112,7 @@ typedef struct linkedlist_datablock_internal_s struct linkedlist_datablock_internal_s* next_datablock; uLong avail_in_this_block; uLong filled_in_this_block; - uLong unused; /* for future use and alignement */ + uLong unused; /* for future use and alignment */ unsigned char data[SIZEDATA_INDATABLOCK]; } linkedlist_datablock_internal; @@ -139,40 +134,40 @@ typedef struct uInt pos_in_buffered_data; /* last written byte in buffered_data */ ZPOS64_T pos_local_header; /* offset of the local header of the file - currenty writing */ + currently writing */ char* central_header; /* central header data for the current file */ uLong size_centralExtra; uLong size_centralheader; /* size of the central header for cur file */ uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ uLong flag; /* flag of the file currently writing */ - int method; /* compression method of file currenty wr.*/ + int method; /* compression method of file currently wr.*/ int raw; /* 1 for directly writing raw data */ Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ uLong dosDate; uLong crc32; int encrypt; - int zip64; /* Add ZIP64 extened information in the extra field */ + int zip64; /* Add ZIP64 extended information in the extra field */ ZPOS64_T pos_zip64extrainfo; ZPOS64_T totalCompressedData; ZPOS64_T totalUncompressedData; #ifndef NOCRYPT unsigned long keys[3]; /* keys defining the pseudo-random sequence */ const z_crc_t* pcrc_32_tab; - int crypt_header_size; + unsigned crypt_header_size; #endif } curfile64_info; typedef struct { zlib_filefunc64_32_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ + voidpf filestream; /* io structure of the zipfile */ linkedlist_data central_dir;/* datablock with central dir in construction*/ int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile64_info ci; /* info on the file curretly writing */ + curfile64_info ci; /* info on the file currently writing */ ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ - ZPOS64_T add_position_when_writting_offset; + ZPOS64_T add_position_when_writing_offset; ZPOS64_T number_entry; #ifndef NO_ADDFILEINEXISTINGZIP @@ -187,8 +182,7 @@ typedef struct #include "crypt.h" #endif -local linkedlist_datablock_internal* allocate_new_datablock() -{ +local linkedlist_datablock_internal* allocate_new_datablock(void) { linkedlist_datablock_internal* ldi; ldi = (linkedlist_datablock_internal*) ALLOC(sizeof(linkedlist_datablock_internal)); @@ -201,30 +195,26 @@ local linkedlist_datablock_internal* allocate_new_datablock() return ldi; } -local void free_datablock(linkedlist_datablock_internal* ldi) -{ +local void free_datablock(linkedlist_datablock_internal* ldi) { while (ldi!=NULL) { linkedlist_datablock_internal* ldinext = ldi->next_datablock; - TRYFREE(ldi); + free(ldi); ldi = ldinext; } } -local void init_linkedlist(linkedlist_data* ll) -{ +local void init_linkedlist(linkedlist_data* ll) { ll->first_block = ll->last_block = NULL; } -local void free_linkedlist(linkedlist_data* ll) -{ +local void free_linkedlist(linkedlist_data* ll) { free_datablock(ll->first_block); ll->first_block = ll->last_block = NULL; } -local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) -{ +local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) { linkedlist_datablock_internal* ldi; const unsigned char* from_copy; @@ -239,7 +229,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) } ldi = ll->last_block; - from_copy = (unsigned char*)buf; + from_copy = (const unsigned char*)buf; while (len>0) { @@ -284,9 +274,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) */ -local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); -local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) -{ +local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) { unsigned char buf[8]; int n; for (n = 0; n < nbByte; n++) @@ -302,15 +290,13 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, } } - if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) + if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,(uLong)nbByte)!=(uLong)nbByte) return ZIP_ERRNO; else return ZIP_OK; } -local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); -local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) -{ +local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) { unsigned char* buf=(unsigned char*)dest; int n; for (n = 0; n < nbByte; n++) { @@ -330,25 +316,21 @@ local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) /****************************************************************************/ -local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) -{ +local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) { uLong year = (uLong)ptm->tm_year; if (year>=1980) year-=1980; else if (year>=80) year-=80; return - (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | - ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); + (uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) | + (((uLong)ptm->tm_sec/2) + (32 * (uLong)ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); } /****************************************************************************/ -local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); - -local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi) -{ +local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) { unsigned char c; int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); if (err==1) @@ -369,10 +351,7 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,vo /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ -local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); - -local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) -{ +local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { uLong x ; int i = 0; int err; @@ -391,10 +370,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, return err; } -local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); - -local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) -{ +local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { uLong x ; int i = 0; int err; @@ -421,11 +397,8 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, return err; } -local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); - -local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) -{ +local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) { ZPOS64_T x; int i = 0; int err; @@ -476,10 +449,7 @@ local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def Locate the Central directory of a zipfile (at the end, just before the global comment) */ -local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); - -local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ +local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; @@ -519,18 +489,18 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) break; - for (i=(int)uReadSize-3; (i--)>0;) { + for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { - uPosFound = uReadPos+i; + uPosFound = uReadPos+(unsigned)i; break; } - } + if (uPosFound!=0) break; } - TRYFREE(buf); + free(buf); return uPosFound; } @@ -538,10 +508,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before the global comment) */ -local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); - -local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ +local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; @@ -587,7 +554,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib // Signature "0x07064b50" Zip64 end of central directory locater if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) { - uPosFound = uReadPos+i; + uPosFound = uReadPos+(unsigned)i; break; } } @@ -596,7 +563,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib break; } - TRYFREE(buf); + free(buf); if (uPosFound == 0) return 0; @@ -638,8 +605,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib return relativeOffset; } -static int LoadCentralDirectoryRecord(zip64_internal* pziinit) -{ +local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { int err=ZIP_OK; ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ @@ -649,9 +615,9 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit) uLong uL; uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ + spanning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ + for spanning ZIP, unsupported, always 0*/ ZPOS64_T number_entry; ZPOS64_T number_entry_CD; /* total number of entries in the central dir @@ -808,7 +774,7 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit) } byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir); - pziinit->add_position_when_writting_offset = byte_before_the_zipfile; + pziinit->add_position_when_writing_offset = byte_before_the_zipfile; { ZPOS64_T size_central_dir_to_read = size_central_dir; @@ -831,7 +797,7 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit) size_central_dir_to_read-=read_this; } - TRYFREE(buf_read); + free(buf_read); } pziinit->begin_pos = byte_before_the_zipfile; pziinit->number_entry = number_entry_CD; @@ -847,8 +813,7 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit) /************************************************************/ -static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) -{ +extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) { zip64_internal ziinit; zip64_internal* zi; int err=ZIP_OK; @@ -876,7 +841,7 @@ static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomm ziinit.in_opened_file_inzip = 0; ziinit.ci.stream_initialised = 0; ziinit.number_entry = 0; - ziinit.add_position_when_writting_offset = 0; + ziinit.add_position_when_writing_offset = 0; init_linkedlist(&(ziinit.central_dir)); @@ -906,9 +871,9 @@ static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomm if (err != ZIP_OK) { # ifndef NO_ADDFILEINEXISTINGZIP - TRYFREE(ziinit.globalcomment); + free(ziinit.globalcomment); # endif /* !NO_ADDFILEINEXISTINGZIP*/ - TRYFREE(zi); + free(zi); return NULL; } else @@ -918,8 +883,7 @@ static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomm } } -extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) -{ +extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) { if (pzlib_filefunc32_def != NULL) { zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; @@ -930,8 +894,7 @@ extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* gl return zipOpen3(pathname, append, globalcomment, NULL); } -extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) -{ +extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) { if (pzlib_filefunc_def != NULL) { zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; @@ -946,18 +909,15 @@ extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* -extern zipFile ZEXPORT zipOpen (const char* pathname, int append) -{ +extern zipFile ZEXPORT zipOpen(const char* pathname, int append) { return zipOpen3((const void*)pathname,append,NULL,NULL); } -extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) -{ +extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) { return zipOpen3(pathname,append,NULL,NULL); } -static int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) -{ +local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) { /* write the local header */ int err; uInt size_filename = (uInt)strlen(filename); @@ -1035,8 +995,8 @@ static int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2); - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8); @@ -1053,24 +1013,24 @@ static int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize unnecessary allocations. */ -extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting __attribute__((unused)), - uLong versionMadeBy, uLong flagBase, int zip64) -{ +extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase, int zip64) { zip64_internal* zi; uInt size_filename; uInt size_comment; uInt i; int err = ZIP_OK; -#ifdef NOCRYPT +# ifdef NOCRYPT + (crcForCrypting); if (password != NULL) return ZIP_PARAMERROR; -#endif +# endif if (file == NULL) return ZIP_PARAMERROR; @@ -1164,7 +1124,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, if(zi->ci.pos_local_header >= 0xffffffff) zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4); else - zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writting_offset,4); + zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writing_offset,4); for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); @@ -1262,35 +1222,33 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, return err; } -extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, - uLong versionMadeBy, uLong flagBase) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, versionMadeBy, flagBase, 0); +extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, versionMadeBy, flagBase, 0); } -extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, VERSIONMADEBY, 0, 0); +extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, 0); } extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, @@ -1298,70 +1256,64 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c const void* extrafield_global, uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, VERSIONMADEBY, 0, zip64); + const char* password, uLong crcForCrypting, int zip64) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, zip64); } extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, 0); + const char* comment, int method, int level, int raw) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, 0); } extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, zip64); + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, int zip64) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); } -extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void*extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, zip64); +extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int zip64) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); } -extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void*extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, 0); +extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, 0); } -local int zip64FlushWriteBuffer(zip64_internal* zi) -{ +local int zip64FlushWriteBuffer(zip64_internal* zi) { int err=ZIP_OK; if (zi->ci.encrypt != 0) @@ -1399,8 +1351,7 @@ local int zip64FlushWriteBuffer(zip64_internal* zi) return err; } -extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) -{ +extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) { zip64_internal* zi; int err=ZIP_OK; @@ -1450,7 +1401,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in else #endif { - zi->ci.stream.next_in = (Bytef*)buf; + zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf; zi->ci.stream.avail_in = len; while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) @@ -1501,17 +1452,15 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in return err; } -extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) -{ +extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) { return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); } -extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) -{ +extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) { zip64_internal* zi; ZPOS64_T compressed_size; uLong invalidValue = 0xffffffff; - short datasize = 0; + unsigned datasize = 0; int err=ZIP_OK; if (file == NULL) @@ -1742,15 +1691,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s return err; } -extern int ZEXPORT zipCloseFileInZip (zipFile file) -{ +extern int ZEXPORT zipCloseFileInZip(zipFile file) { return zipCloseFileInZipRaw (file,0,0); } -static int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) -{ +local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) { int err = ZIP_OK; - ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; + ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); @@ -1769,8 +1716,7 @@ static int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T return err; } -static int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) -{ +local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { int err = ZIP_OK; uLong Zip64DataSize = 44; @@ -1803,13 +1749,13 @@ static int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ { - ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; + ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); } return err; } -static int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) -{ + +local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { int err = ZIP_OK; /*signature*/ @@ -1844,20 +1790,19 @@ static int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_cent if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ { - ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; + ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; if(pos >= 0xffffffff) { err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); } else - err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset),4); } return err; } -static int Write_GlobalComment(zip64_internal* zi, const char* global_comment) -{ +local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) { int err = ZIP_OK; uInt size_global_comment = 0; @@ -1874,8 +1819,7 @@ static int Write_GlobalComment(zip64_internal* zi, const char* global_comment) return err; } -extern int ZEXPORT zipClose (zipFile file, const char* global_comment) -{ +extern int ZEXPORT zipClose(zipFile file, const char* global_comment) { zip64_internal* zi; int err = 0; uLong size_centraldir = 0; @@ -1916,7 +1860,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment) } free_linkedlist(&(zi->central_dir)); - pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; + pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) { ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); @@ -1936,15 +1880,14 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment) err = ZIP_ERRNO; #ifndef NO_ADDFILEINEXISTINGZIP - TRYFREE(zi->globalcomment); + free(zi->globalcomment); #endif - TRYFREE(zi); + free(zi); return err; } -extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) -{ +extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) { char* p = pData; int size = 0; char* pNewHeader; @@ -1954,10 +1897,10 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe int retVal = ZIP_OK; - if(pData == NULL || *dataLen < 4) + if(pData == NULL || dataLen == NULL || *dataLen < 4) return ZIP_PARAMERROR; - pNewHeader = (char*)ALLOC(*dataLen); + pNewHeader = (char*)ALLOC((unsigned)*dataLen); pTmp = pNewHeader; while(p < (pData + *dataLen)) @@ -1996,7 +1939,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe else retVal = ZIP_ERRNO; - TRYFREE(pNewHeader); + free(pNewHeader); return retVal; } diff --git a/storage/connect/zip.h b/storage/connect/zip.h index 8aaebb62343..5fc08413241 100644 --- a/storage/connect/zip.h +++ b/storage/connect/zip.h @@ -88,12 +88,12 @@ typedef voidp zipFile; /* tm_zip contain date/time info */ typedef struct tm_zip_s { - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years - [1980..2044] */ } tm_zip; typedef struct @@ -113,8 +113,8 @@ typedef const char* zipcharpc; #define APPEND_STATUS_CREATEAFTER (1) #define APPEND_STATUS_ADDINZIP (2) -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); -extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); +extern zipFile ZEXPORT zipOpen(const char *pathname, int append); +extern zipFile ZEXPORT zipOpen64(const void *pathname, int append); /* Create a zipfile. pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on @@ -131,41 +131,46 @@ extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); /* Note : there is no delete function into a zipfile. If you want delete file into a zipfile, you must open a zipfile, and create another - Of couse, you can use RAW reading and writing to copy the file you did not want delte + Of course, you can use RAW reading and writing to copy the file you did not want delete */ -extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, +extern zipFile ZEXPORT zipOpen2(const char *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc_def* pzlib_filefunc_def); + +extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, - zlib_filefunc_def* pzlib_filefunc_def)); + zlib_filefunc64_def* pzlib_filefunc_def); -extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc64_def* pzlib_filefunc_def)); +extern zipFile ZEXPORT zipOpen3(const void *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc64_32_def* pzlib_filefunc64_32_def); -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); +extern int ZEXPORT zipOpenNewFileInZip(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level); -extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int zip64)); +extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int zip64); /* Open a file in the ZIP for writing. @@ -184,70 +189,69 @@ extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, */ -extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw)); +extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw); -extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int zip64)); +extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int zip64); /* Same than zipOpenNewFileInZip, except if raw=1, we write raw file */ -extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting)); +extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting); -extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - int zip64 - )); +extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + int zip64); /* Same than zipOpenNewFileInZip2, except @@ -256,47 +260,45 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, crcForCrypting : crc of file to compress (needed for crypting) */ -extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - uLong versionMadeBy, - uLong flagBase - )); +extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase); -extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - uLong versionMadeBy, - uLong flagBase, - int zip64 - )); +extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase, + int zip64); /* Same than zipOpenNewFileInZip4, except versionMadeBy : value for Version made by field @@ -304,25 +306,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, */ -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const void* buf, - unsigned len)); +extern int ZEXPORT zipWriteInFileInZip(zipFile file, + const void* buf, + unsigned len); /* Write data in the zipfile */ -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); +extern int ZEXPORT zipCloseFileInZip(zipFile file); /* Close the current file in the zipfile */ -extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, - uLong uncompressed_size, - uLong crc32)); +extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, + uLong uncompressed_size, + uLong crc32); -extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, - ZPOS64_T uncompressed_size, - uLong crc32)); +extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, + ZPOS64_T uncompressed_size, + uLong crc32); /* Close the current file in the zipfile, for file opened with @@ -330,14 +332,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, uncompressed_size and crc32 are value for the uncompressed size */ -extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); +extern int ZEXPORT zipClose(zipFile file, + const char* global_comment); /* Close the zipfile */ -extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); +extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader); /* zipRemoveExtraInfoBlock - Added by Mathias Svensson diff --git a/storage/federatedx/federatedx_io_mysql.cc b/storage/federatedx/federatedx_io_mysql.cc index 7512f8b16f0..72b902987b5 100644 --- a/storage/federatedx/federatedx_io_mysql.cc +++ b/storage/federatedx/federatedx_io_mysql.cc @@ -448,11 +448,14 @@ int federatedx_io_mysql::actual_query(const char *buffer, size_t length) get_password(), get_database(), get_port(), get_socket(), 0)) DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + + if ((error= mysql_real_query(&mysql, STRING_WITH_LEN("set time_zone='+00:00'")))) + DBUG_RETURN(error); + mysql.reconnect= 1; } - if (!(error= mysql_real_query(&mysql, STRING_WITH_LEN("set time_zone='+00:00'")))) - error= mysql_real_query(&mysql, buffer, (ulong)length); + error= mysql_real_query(&mysql, buffer, (ulong)length); DBUG_RETURN(error); } diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index 868d97ca74b..b9ea48af9f8 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -51,6 +51,7 @@ PageBulk::init() if (m_page_no == FIL_NULL) { mtr_t alloc_mtr; + dberr_t err= DB_SUCCESS; /* We commit redo log for allocation by a separate mtr, because we don't guarantee pages are committed following @@ -59,27 +60,14 @@ PageBulk::init() alloc_mtr.start(); m_index->set_modified(alloc_mtr); - uint32_t n_reserved; - dberr_t err = fsp_reserve_free_extents( - &n_reserved, m_index->table->space, 1, FSP_NORMAL, - &alloc_mtr); - if (UNIV_UNLIKELY(err != DB_SUCCESS)) { -oom: - alloc_mtr.commit(); - m_mtr.commit(); - return err; - } - /* Allocate a new page. */ new_block = btr_page_alloc(m_index, 0, FSP_UP, m_level, &alloc_mtr, &m_mtr, &err); - if (!new_block) { - goto oom; - } - - m_index->table->space->release_free_extents(n_reserved); - alloc_mtr.commit(); + if (!new_block) { + m_mtr.commit(); + return err; + } new_page = buf_block_get_frame(new_block); m_page_no = new_block->page.id().page_no(); diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index e9aea35533b..e2702adc880 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -336,11 +336,14 @@ func_exit: os_file_flush(file); } else - for (ulint i= 0; i < size * 2; i++, page += srv_page_size) - if (mach_read_from_8(my_assume_aligned<8>(page + FIL_PAGE_LSN))) - /* Each valid page header must contain a nonzero FIL_PAGE_LSN field. */ + { + alignas(8) char checkpoint[8]; + mach_write_to_8(checkpoint, log_sys.next_checkpoint_lsn); + for (auto i= size * 2; i--; page += srv_page_size) + if (memcmp_aligned<8>(page + FIL_PAGE_LSN, checkpoint, 8) >= 0) + /* Valid pages are not older than the log checkpoint. */ recv_sys.dblwr.add(page); - + } err= DB_SUCCESS; goto func_exit; } diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 80469caf86b..d0a0f0dce4b 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -180,7 +180,7 @@ static void buf_dump_generate_path(char *path, size_t path_size) char buf[FN_REFLEN]; mysql_mutex_lock(&LOCK_global_system_variables); - snprintf(buf, sizeof buf, "%s/%s", get_buf_dump_dir(), + snprintf(buf, sizeof buf, "%s" FN_ROOTDIR "%s", get_buf_dump_dir(), srv_buf_dump_filename); mysql_mutex_unlock(&LOCK_global_system_variables); @@ -214,7 +214,7 @@ static void buf_dump_generate_path(char *path, size_t path_size) format = "%s%s"; break; default: - format = "%s/%s"; + format = "%s" FN_ROOTDIR "%s"; } snprintf(path, path_size, format, diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index ebcf430d532..bd43429eb5d 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1758,6 +1758,28 @@ ulint buf_flush_LRU(ulint max_n, bool evict) buf_pool.try_LRU_scan= true; pthread_cond_broadcast(&buf_pool.done_free); } + else if (!pages && !buf_pool.try_LRU_scan && + !buf_pool.LRU_warned.test_and_set(std::memory_order_acquire)) + { + /* For example, with the minimum innodb_buffer_pool_size=5M and + the default innodb_page_size=16k there are only a little over 316 + pages in the buffer pool. The buffer pool can easily be exhausted + by a workload of some dozen concurrent connections. The system could + reach a deadlock like the following: + + (1) Many threads are waiting in buf_LRU_get_free_block() + for buf_pool.done_free. + (2) Some threads are waiting for a page latch which is held by + another thread that is waiting in buf_LRU_get_free_block(). + (3) This thread is the only one that could make progress, but + we fail to do so because all the pages that we scanned are + buffer-fixed or latched by some thread. */ + sql_print_warning("InnoDB: Could not free any blocks in the buffer pool!" + " %zu blocks are in use and %zu free." + " Consider increasing innodb_buffer_pool_size.", + UT_LIST_GET_LEN(buf_pool.LRU), + UT_LIST_GET_LEN(buf_pool.free)); + } return pages; } @@ -2378,11 +2400,19 @@ func_exit: goto func_exit; } +TPOOL_SUPPRESS_TSAN +bool buf_pool_t::need_LRU_eviction() const +{ + /* try_LRU_scan==false means that buf_LRU_get_free_block() is waiting + for buf_flush_page_cleaner() to evict some blocks */ + return UNIV_UNLIKELY(!try_LRU_scan || + (UT_LIST_GET_LEN(LRU) > BUF_LRU_MIN_LEN && + UT_LIST_GET_LEN(free) < srv_LRU_scan_depth / 2)); +} + #if defined __aarch64__&&defined __GNUC__&&__GNUC__==4&&!defined __clang__ -/* Avoid GCC 4.8.5 internal compiler error "could not split insn". -We would only need this for buf_flush_page_cleaner(), -but GCC 4.8.5 does not support pop_options. */ -# pragma GCC optimize ("O0") +/* Avoid GCC 4.8.5 internal compiler error "could not split insn". */ +__attribute__((optimize(0))) #endif /** page_cleaner thread tasked with flushing dirty pages from the buffer pools. As of now we'll have only one coordinator. */ @@ -2416,21 +2446,24 @@ static void buf_flush_page_cleaner() } mysql_mutex_lock(&buf_pool.flush_list_mutex); - if (buf_pool.ran_out()) - goto no_wait; - else if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) - break; + if (!buf_pool.need_LRU_eviction()) + { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) + break; - if (buf_pool.page_cleaner_idle() && - (!UT_LIST_GET_LEN(buf_pool.flush_list) || - srv_max_dirty_pages_pct_lwm == 0.0)) - /* We are idle; wait for buf_pool.page_cleaner_wakeup() */ - my_cond_wait(&buf_pool.do_flush_list, - &buf_pool.flush_list_mutex.m_mutex); - else - my_cond_timedwait(&buf_pool.do_flush_list, - &buf_pool.flush_list_mutex.m_mutex, &abstime); - no_wait: + if (buf_pool.page_cleaner_idle() && + (!UT_LIST_GET_LEN(buf_pool.flush_list) || + srv_max_dirty_pages_pct_lwm == 0.0)) + { + buf_pool.LRU_warned.clear(std::memory_order_release); + /* We are idle; wait for buf_pool.page_cleaner_wakeup() */ + my_cond_wait(&buf_pool.do_flush_list, + &buf_pool.flush_list_mutex.m_mutex); + } + else + my_cond_timedwait(&buf_pool.do_flush_list, + &buf_pool.flush_list_mutex.m_mutex, &abstime); + } set_timespec(abstime, 1); lsn_limit= buf_flush_sync_lsn; @@ -2462,7 +2495,7 @@ static void buf_flush_page_cleaner() } while (false); - if (!buf_pool.ran_out()) + if (!buf_pool.need_LRU_eviction()) continue; mysql_mutex_lock(&buf_pool.flush_list_mutex); oldest_lsn= buf_pool.get_oldest_modification(0); @@ -2491,7 +2524,7 @@ static void buf_flush_page_cleaner() if (oldest_lsn >= soft_lsn_limit) buf_flush_async_lsn= soft_lsn_limit= 0; } - else if (buf_pool.ran_out()) + else if (buf_pool.need_LRU_eviction()) { buf_pool.page_cleaner_set_idle(false); buf_pool.n_flush_inc(); @@ -2606,9 +2639,13 @@ static void buf_flush_page_cleaner() MONITOR_FLUSH_ADAPTIVE_PAGES, n_flushed); } - else if (buf_flush_async_lsn <= oldest_lsn) + else if (buf_flush_async_lsn <= oldest_lsn && + !buf_pool.need_LRU_eviction()) goto check_oldest_and_set_idle; + else + mysql_mutex_lock(&buf_pool.mutex); + n= srv_max_io_capacity; n= n >= n_flushed ? n - n_flushed : 0; goto LRU_flush; } diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 34776d1033c..8301d10b75f 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -60,10 +60,6 @@ static constexpr ulint BUF_LRU_OLD_TOLERANCE = 20; frames in the buffer pool, we set this to TRUE */ static bool buf_lru_switched_on_innodb_mon = false; -/** True if diagnostic message about difficult to find free blocks -in the buffer bool has already printed. */ -static bool buf_lru_free_blocks_error_printed; - /******************************************************************//** These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O and page_zip_decompress() operations. Based on the statistics, @@ -409,6 +405,7 @@ got_mutex: buf_LRU_check_size_of_non_data_objects(); buf_block_t* block; + IF_DBUG(static bool buf_lru_free_blocks_error_printed,); DBUG_EXECUTE_IF("ib_lru_force_no_free_page", if (!buf_lru_free_blocks_error_printed) { n_iterations = 21; @@ -419,9 +416,25 @@ retry: /* If there is a block in the free list, take it */ if ((block = buf_LRU_get_free_only()) != nullptr) { got_block: + const ulint LRU_size = UT_LIST_GET_LEN(buf_pool.LRU); + const ulint available = UT_LIST_GET_LEN(buf_pool.free); + const ulint scan_depth = srv_LRU_scan_depth / 2; + ut_ad(LRU_size <= BUF_LRU_MIN_LEN || available >= scan_depth + || buf_pool.need_LRU_eviction()); + if (UNIV_LIKELY(get != have_mutex)) { mysql_mutex_unlock(&buf_pool.mutex); } + + if (UNIV_UNLIKELY(available < scan_depth) + && LRU_size > BUF_LRU_MIN_LEN) { + mysql_mutex_lock(&buf_pool.flush_list_mutex); + if (!buf_pool.page_cleaner_active()) { + buf_pool.page_cleaner_wakeup(true); + } + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + } + block->page.zip.clear(); return block; } @@ -452,10 +465,11 @@ got_block: if ((block = buf_LRU_get_free_only()) != nullptr) { goto got_block; } + const bool wake = buf_pool.need_LRU_eviction(); mysql_mutex_unlock(&buf_pool.mutex); mysql_mutex_lock(&buf_pool.flush_list_mutex); const auto n_flush = buf_pool.n_flush(); - if (!buf_pool.try_LRU_scan) { + if (wake && !buf_pool.page_cleaner_active()) { buf_pool.page_cleaner_wakeup(true); } mysql_mutex_unlock(&buf_pool.flush_list_mutex); @@ -474,9 +488,10 @@ not_found: MONITOR_INC( MONITOR_LRU_GET_FREE_WAITS ); } - if (n_iterations == 21 && !buf_lru_free_blocks_error_printed - && srv_buf_pool_old_size == srv_buf_pool_size) { - buf_lru_free_blocks_error_printed = true; + if (n_iterations == 21 + && srv_buf_pool_old_size == srv_buf_pool_size + && buf_pool.LRU_warned.test_and_set(std::memory_order_acquire)) { + IF_DBUG(buf_lru_free_blocks_error_printed = true,); mysql_mutex_unlock(&buf_pool.mutex); ib::warn() << "Difficult to find free blocks in the buffer pool" " (" << n_iterations << " search iterations)! " diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 2e47a059f37..c93fc9f814a 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -958,12 +958,11 @@ void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) if (latch_ex_wait_start.compare_exchange_strong (old, now, std::memory_order_relaxed, std::memory_order_relaxed)) { -#ifdef UNIV_DEBUG - latch.x_lock(SRW_LOCK_ARGS(file, line)); -#else latch.wr_lock(SRW_LOCK_ARGS(file, line)); -#endif latch_ex_wait_start.store(0, std::memory_order_relaxed); + ut_ad(!latch_readers); + ut_ad(!latch_ex); + ut_d(latch_ex= pthread_self()); return; } @@ -978,39 +977,33 @@ void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) if (waited > threshold / 4) ib::warn() << "A long wait (" << waited << " seconds) was observed for dict_sys.latch"; -#ifdef UNIV_DEBUG - latch.x_lock(SRW_LOCK_ARGS(file, line)); -#else latch.wr_lock(SRW_LOCK_ARGS(file, line)); -#endif + ut_ad(!latch_readers); + ut_ad(!latch_ex); + ut_d(latch_ex= pthread_self()); } #ifdef UNIV_PFS_RWLOCK ATTRIBUTE_NOINLINE void dict_sys_t::unlock() { -# ifdef UNIV_DEBUG - latch.x_unlock(); -# else + ut_ad(latch_ex == pthread_self()); + ut_ad(!latch_readers); + ut_d(latch_ex= 0); latch.wr_unlock(); -# endif } ATTRIBUTE_NOINLINE void dict_sys_t::freeze(const char *file, unsigned line) { -# ifdef UNIV_DEBUG - latch.s_lock(file, line); -# else latch.rd_lock(file, line); -# endif + ut_ad(!latch_ex); + ut_d(latch_readers++); } ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze() { -# ifdef UNIV_DEBUG - latch.s_unlock(); -# else + ut_ad(!latch_ex); + ut_ad(latch_readers--); latch.rd_unlock(); -# endif } #endif /* UNIV_PFS_RWLOCK */ @@ -4515,11 +4508,7 @@ void dict_sys_t::close() temp_id_hash.free(); unlock(); -#ifdef UNIV_DEBUG - latch.free(); -#else latch.destroy(); -#endif mysql_mutex_destroy(&dict_foreign_err_mutex); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 842651360fe..0ce54df6574 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -341,8 +341,9 @@ static bool fil_node_open_file_low(fil_node_t *node) ut_ad(!node->is_open()); ut_ad(node->space->is_closing()); mysql_mutex_assert_owner(&fil_system.mutex); - ulint type; static_assert(((UNIV_ZIP_SIZE_MIN >> 1) << 3) == 4096, "compatibility"); +#if defined _WIN32 || defined HAVE_FCNTL_DIRECT + ulint type; switch (FSP_FLAGS_GET_ZIP_SSIZE(node->space->flags)) { case 1: case 2: @@ -351,6 +352,9 @@ static bool fil_node_open_file_low(fil_node_t *node) default: type= OS_DATA_FILE; } +#else + constexpr auto type= OS_DATA_FILE; +#endif for (;;) { @@ -2028,9 +2032,10 @@ fil_ibd_create( mtr.flag_wr_unlock(); log_write_up_to(lsn, true); - ulint type; static_assert(((UNIV_ZIP_SIZE_MIN >> 1) << 3) == 4096, "compatibility"); +#if defined _WIN32 || defined HAVE_FCNTL_DIRECT + ulint type; switch (FSP_FLAGS_GET_ZIP_SSIZE(flags)) { case 1: case 2: @@ -2039,6 +2044,9 @@ fil_ibd_create( default: type = OS_DATA_FILE; } +#else + constexpr auto type = OS_DATA_FILE; +#endif file = os_file_create( innodb_data_file_key, path, diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index 9fa7a5a6c88..baa4aca1b71 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -48,11 +48,6 @@ Updated 14/02/2015 #include "row0mysql.h" #include "buf0lru.h" #include "zlib.h" -#ifdef __linux__ -#include -#include -#include -#endif #include "row0mysql.h" #include "lz4.h" #include "lzo/lzo1x.h" diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index cafff419b05..1c20efcdca2 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -435,12 +435,22 @@ Datafile::validate_for_recovery() return(err); } + if (!m_space_id) { + m_space_id = recv_sys.dblwr.find_first_page( + m_filepath, m_handle); + if (m_space_id) { + m_defer= false; + goto free_first_page; + } else return err; + } + if (!m_defer) { err = find_space_id(); if (err != DB_SUCCESS || m_space_id == 0) { - ib::error() << "Datafile '" << m_filepath - << "' is corrupted. Cannot determine " - "the space ID from the first 64 pages."; + sql_print_error( + "InnoDB: Datafile '%s' is corrupted." + " Cannot determine the space ID from" + " the first 64 pages.", m_filepath); return(err); } } @@ -453,7 +463,7 @@ Datafile::validate_for_recovery() m_space_id, m_filepath, m_handle)) { return m_defer ? err : DB_CORRUPTION; } - +free_first_page: /* Free the previously read first page and then re-validate. */ free_first_page(); m_defer = false; @@ -492,11 +502,11 @@ err_exit: return DB_SUCCESS; } - ib::info() << error_txt << " in datafile: " << m_filepath - << ", Space ID:" << m_space_id << ", Flags: " - << m_flags; + sql_print_error("InnoDB: %s in datafile: %s, Space ID: " + UINT32PF ", " "Flags: " UINT32PF, + error_txt, m_filepath, m_space_id, m_flags); m_is_valid = false; - return(DB_CORRUPTION); + return DB_CORRUPTION; } /* Check if the whole page is blank. */ diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc index 5bea4596491..be52e7e4743 100644 --- a/storage/innobase/fsp/fsp0sysspace.cc +++ b/storage/innobase/fsp/fsp0sysspace.cc @@ -33,6 +33,7 @@ Refactored 2013-7-26 by Kevin Lewis #include "os0file.h" #include "row0mysql.h" #include "buf0dblwr.h" +#include "log.h" /** The server header file is included to access opt_initialize global variable. If server passes the option for create/open DB to SE, we should remove such @@ -581,7 +582,7 @@ inline dberr_t SysTablespace::read_lsn_and_check_flags() } err = it->read_first_page( - m_ignore_read_only ? false : srv_read_only_mode); + m_ignore_read_only && srv_read_only_mode); if (err != DB_SUCCESS) { return(err); @@ -595,47 +596,62 @@ inline dberr_t SysTablespace::read_lsn_and_check_flags() /* Check the contents of the first page of the first datafile. */ - for (int retry = 0; retry < 2; ++retry) { + err = it->validate_first_page(); - err = it->validate_first_page(); - - if (err != DB_SUCCESS - && (retry == 1 - || recv_sys.dblwr.restore_first_page( + if (err != DB_SUCCESS) { + if (recv_sys.dblwr.restore_first_page( it->m_space_id, it->m_filepath, - it->handle()))) { - + it->handle())) { it->close(); - return(err); } + err = it->read_first_page( + m_ignore_read_only && srv_read_only_mode); } /* Make sure the tablespace space ID matches the space ID on the first page of the first datafile. */ - if (space_id() != it->m_space_id) { - - ib::error() - << "The data file '" << it->filepath() - << "' has the wrong space ID. It should be " - << space_id() << ", but " << it->m_space_id - << " was found"; - + if (err != DB_SUCCESS || space_id() != it->m_space_id) { + sql_print_error("InnoDB: The data file '%s'" + " has the wrong space ID." + " It should be " UINT32PF ", but " UINT32PF + " was found", it->filepath(), + space_id(), it->m_space_id); it->close(); - - return(err); + return err; } - if (srv_operation == SRV_OPERATION_NORMAL) { + if (srv_force_recovery != 6 + && srv_operation == SRV_OPERATION_NORMAL + && !log_sys.next_checkpoint_lsn + && log_sys.format == log_t::FORMAT_3_23) { + + log_sys.latch.wr_lock(SRW_LOCK_CALL); /* Prepare for possible upgrade from 0-sized ib_logfile0. */ - ut_ad(!log_sys.next_checkpoint_lsn); log_sys.next_checkpoint_lsn = mach_read_from_8( it->m_first_page + 26/*FIL_PAGE_FILE_FLUSH_LSN*/); + if (log_sys.next_checkpoint_lsn < 8204) { + /* Before MDEV-14425, InnoDB had a minimum LSN + of 8192+12=8204. Likewise, mariadb-backup + --prepare would create an empty ib_logfile0 + after applying the log. We will allow an + upgrade from such an empty log. */ + sql_print_error("InnoDB: ib_logfile0 is " + "empty, and LSN is unknown."); + err = DB_CORRUPTION; + } else { + log_sys.last_checkpoint_lsn = + recv_sys.lsn = recv_sys.file_checkpoint = + log_sys.next_checkpoint_lsn; + log_sys.set_recovered_lsn(log_sys.next_checkpoint_lsn); + log_sys.next_checkpoint_no = 0; + } + + log_sys.latch.wr_unlock(); } it->close(); - - return(DB_SUCCESS); + return err; } /** Check if a file can be opened in the correct mode. diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d49ad6af16c..93127bb1c3a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -581,13 +581,7 @@ static PSI_rwlock_info all_innodb_rwlocks[] = # ifdef BTR_CUR_HASH_ADAPT { &btr_search_latch_key, "btr_search_latch", 0 }, # endif - { &dict_operation_lock_key, "dict_operation_lock", -# ifdef UNIV_DEBUG - PSI_RWLOCK_FLAG_SX -# else - 0 -# endif - }, + { &dict_operation_lock_key, "dict_operation_lock", 0 }, { &fil_space_latch_key, "fil_space_latch", 0 }, { &trx_i_s_cache_lock_key, "trx_i_s_cache_lock", 0 }, { &trx_purge_latch_key, "trx_purge_latch", 0 }, @@ -2044,7 +2038,7 @@ all_fail: ut_d(purge_sys.resume_FTS()); } -static void innodb_ddl_recovery_done(handlerton*) +static int innodb_ddl_recovery_done(handlerton*) { ut_ad(!ddl_recovery_done); ut_d(ddl_recovery_done= true); @@ -2055,6 +2049,7 @@ static void innodb_ddl_recovery_done(handlerton*) drop_garbage_tables_after_restore(); srv_init_purge_tasks(); } + return 0; } /********************************************************************//** @@ -3969,7 +3964,7 @@ static int innodb_init_params() } else if (innodb_flush_method >= 4 /* O_DIRECT */ IF_WIN(&& innodb_flush_method < 8 /* normal */,)) { /* O_DIRECT and similar settings do nothing */ -#ifndef _WIN32 +#ifdef HAVE_FCNTL_DIRECT } else if (srv_use_atomic_writes && my_may_have_atomic_write) { /* If atomic writes are enabled, do the same as with innodb_flush_method=O_DIRECT: retain the default settings */ @@ -13479,7 +13474,14 @@ int ha_innobase::delete_table(const char *name) /* FOREIGN KEY constraints cannot exist on partitioned tables. */; #endif else - err= lock_table_children(table, trx); + { + dict_sys.freeze(SRW_LOCK_CALL); + for (const dict_foreign_t* f : table->referenced_set) + if (dict_table_t* child= f->foreign_table) + if ((err= lock_table_for_trx(child, trx, LOCK_X)) != DB_SUCCESS) + break; + dict_sys.unfreeze(); + } } dict_table_t *table_stats= nullptr, *index_stats= nullptr; @@ -13877,7 +13879,14 @@ int ha_innobase::truncate() dict_table_t *table_stats = nullptr, *index_stats = nullptr; MDL_ticket *mdl_table = nullptr, *mdl_index = nullptr; - dberr_t error= lock_table_children(ib_table, trx); + dberr_t error= DB_SUCCESS; + + dict_sys.freeze(SRW_LOCK_CALL); + for (const dict_foreign_t *f : ib_table->referenced_set) + if (dict_table_t *child= f->foreign_table) + if ((error= lock_table_for_trx(child, trx, LOCK_X)) != DB_SUCCESS) + break; + dict_sys.unfreeze(); if (error == DB_SUCCESS) error= lock_table_for_trx(ib_table, trx, LOCK_X); @@ -14068,7 +14077,16 @@ ha_innobase::rename_table( /* There is no need to lock any FOREIGN KEY child tables. */ } else if (dict_table_t *table = dict_table_open_on_name( norm_from, false, DICT_ERR_IGNORE_FK_NOKEY)) { - error = lock_table_children(table, trx); + dict_sys.freeze(SRW_LOCK_CALL); + for (const dict_foreign_t* f : table->referenced_set) { + if (dict_table_t* child = f->foreign_table) { + error = lock_table_for_trx(child, trx, LOCK_X); + if (error != DB_SUCCESS) { + break; + } + } + } + dict_sys.unfreeze(); if (error == DB_SUCCESS) { error = lock_table_for_trx(table, trx, LOCK_X); } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 48bf59fb6f4..4e8e7d26d02 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -11234,7 +11234,16 @@ ha_innobase::commit_inplace_alter_table( fts_optimize_remove_table(ctx->old_table); } - error = lock_table_children(ctx->old_table, trx); + dict_sys.freeze(SRW_LOCK_CALL); + for (auto f : ctx->old_table->referenced_set) { + if (dict_table_t* child = f->foreign_table) { + error = lock_table_for_trx(child, trx, LOCK_X); + if (error != DB_SUCCESS) { + break; + } + } + } + dict_sys.unfreeze(); if (ctx->new_table->fts) { ut_ad(!ctx->new_table->fts->add_wq); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 697903a4f19..4aa7ba93348 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1367,10 +1367,8 @@ public: n_chunks_new / 4 * chunks->size; } - /** @return whether the buffer pool has run out */ - TPOOL_SUPPRESS_TSAN - bool ran_out() const - { return UNIV_UNLIKELY(!try_LRU_scan || !UT_LIST_GET_LEN(free)); } + /** @return whether the buffer pool is running low */ + bool need_LRU_eviction() const; /** @return whether the buffer pool is shrinking */ inline bool is_shrinking() const @@ -1696,6 +1694,9 @@ public: Set whenever the free list grows, along with a broadcast of done_free. Protected by buf_pool.mutex. */ Atomic_relaxed try_LRU_scan; + /** Whether we have warned to be running out of buffer pool */ + std::atomic_flag LRU_warned; + /* @} */ /** @name LRU replacement algorithm fields */ diff --git a/storage/innobase/include/buf0dblwr.h b/storage/innobase/include/buf0dblwr.h index 9932b0e521f..6e7662d9b81 100644 --- a/storage/innobase/include/buf0dblwr.h +++ b/storage/innobase/include/buf0dblwr.h @@ -105,7 +105,8 @@ public: If we are upgrading from a version before MySQL 4.1, then this function performs the necessary update operations to support innodb_file_per_table. If we are in a crash recovery, this function - loads the pages from double write buffer into memory. + loads the pages from double write buffer which are not older than + the checkpoint into memory. @param file File handle @param path Path name of file @return DB_SUCCESS or error code */ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 61c6a3b1bf2..3513f21b5ec 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1311,14 +1311,14 @@ class dict_sys_t /** The my_hrtime_coarse().val of the oldest lock_wait() start, or 0 */ std::atomic latch_ex_wait_start; -#ifdef UNIV_DEBUG - typedef index_lock dict_lock; -#else - typedef srw_lock dict_lock; -#endif - /** the rw-latch protecting the data dictionary cache */ - alignas(CPU_LEVEL1_DCACHE_LINESIZE) dict_lock latch; + alignas(CPU_LEVEL1_DCACHE_LINESIZE) srw_lock latch; +#ifdef UNIV_DEBUG + /** whether latch is being held in exclusive mode (by any thread) */ + Atomic_relaxed latch_ex; + /** number of S-latch holders */ + Atomic_counter latch_readers; +#endif public: /** Indexes of SYS_TABLE[] */ enum @@ -1469,12 +1469,15 @@ public: } #ifdef UNIV_DEBUG - /** @return whether the current thread is holding the latch */ - bool frozen() const { return latch.have_any(); } - /** @return whether the current thread is holding a shared latch */ - bool frozen_not_locked() const { return latch.have_s(); } + /** @return whether any thread (not necessarily the current thread) + is holding the latch; that is, this check may return false + positives */ + bool frozen() const { return latch_readers || latch_ex; } + /** @return whether any thread (not necessarily the current thread) + is holding a shared latch */ + bool frozen_not_locked() const { return latch_readers; } /** @return whether the current thread holds the exclusive latch */ - bool locked() const { return latch.have_x(); } + bool locked() const { return latch_ex == pthread_self(); } #endif private: /** Acquire the exclusive latch */ @@ -1489,12 +1492,13 @@ public: /** Exclusively lock the dictionary cache. */ void lock(SRW_LOCK_ARGS(const char *file, unsigned line)) { -#ifdef UNIV_DEBUG - ut_ad(!latch.have_any()); - if (!latch.x_lock_try()) -#else - if (!latch.wr_lock_try()) -#endif + if (latch.wr_lock_try()) + { + ut_ad(!latch_readers); + ut_ad(!latch_ex); + ut_d(latch_ex= pthread_self()); + } + else lock_wait(SRW_LOCK_ARGS(file, line)); } @@ -1509,30 +1513,24 @@ public: /** Unlock the data dictionary cache. */ void unlock() { -# ifdef UNIV_DEBUG - latch.x_unlock(); -# else + ut_ad(latch_ex == pthread_self()); + ut_ad(!latch_readers); + ut_d(latch_ex= 0); latch.wr_unlock(); -# endif } /** Acquire a shared lock on the dictionary cache. */ void freeze() { -# ifdef UNIV_DEBUG - ut_ad(!latch.have_any()); - latch.s_lock(); -# else latch.rd_lock(); -# endif + ut_ad(!latch_ex); + ut_d(latch_readers++); } /** Release a shared lock on the dictionary cache. */ void unfreeze() { -# ifdef UNIV_DEBUG - latch.s_unlock(); -# else + ut_ad(!latch_ex); + ut_ad(latch_readers--); latch.rd_unlock(); -# endif } #endif diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 8f0da1695ad..eca8c2cb614 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -431,13 +431,6 @@ dberr_t lock_table_for_trx(dict_table_t *table, trx_t *trx, lock_mode mode, bool no_wait= false) MY_ATTRIBUTE((nonnull, warn_unused_result)); -/** Lock the child tables of a table. -@param table parent table -@param trx transaction -@return error code */ -dberr_t lock_table_children(dict_table_t *table, trx_t *trx) - MY_ATTRIBUTE((nonnull, warn_unused_result)); - /** Exclusively lock the data dictionary tables. @param trx dictionary transaction @return error code diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index cdce87384f1..ecc0b91e80f 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -180,9 +180,6 @@ private: /* On ARM, we do more spinning */ typedef srw_spin_lock log_rwlock; typedef pthread_mutex_wrapper log_lsn_lock; -#elif defined _WIN32 - typedef srw_lock log_rwlock; - typedef pthread_mutex_wrapper log_lsn_lock; #else typedef srw_lock log_rwlock; typedef srw_mutex log_lsn_lock; diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 583aa36269f..9321a8b80d5 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -44,6 +44,11 @@ ATTRIBUTE_COLD MY_ATTRIBUTE((nonnull, warn_unused_result)) @return whether the page was recovered correctly */ bool recv_recover_page(fil_space_t* space, buf_page_t* bpage); +/** Read the latest checkpoint information from log file +and store it in log_sys.next_checkpoint and recv_sys.file_checkpoint +@return error code or DB_SUCCESS */ +dberr_t recv_recovery_read_checkpoint(); + /** Start recovering from a redo log checkpoint. of first system tablespace page @return error code or DB_SUCCESS */ @@ -114,7 +119,19 @@ struct recv_dblwr_t @param name tablespace filepath @param file tablespace file handle @return whether the operation failed */ - bool restore_first_page(uint32_t space_id, const char *name, os_file_t file); + bool restore_first_page(uint32_t space_id, const char *name, + pfs_os_file_t file); + + /** Restore the first page of the given tablespace from + doublewrite buffer. + 1) Find the page which has page_no as 0 + 2) Read first 3 pages from tablespace file + 3) Compare the space_ids from the pages with page0 which + was retrieved from doublewrite buffer + @param name tablespace filepath + @param file tablespace file handle + @return space_id or 0 in case of error */ + uint32_t find_first_page(const char *name, pfs_os_file_t file); typedef std::deque > list; diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index c9db6a1fb09..c8374515859 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -142,9 +142,11 @@ static const ulint OS_FILE_NORMAL = 62; /* @} */ /** Types for file create @{ */ -static const ulint OS_DATA_FILE = 100; -static const ulint OS_LOG_FILE = 101; -static const ulint OS_DATA_FILE_NO_O_DIRECT = 103; +static constexpr ulint OS_DATA_FILE = 100; +static constexpr ulint OS_LOG_FILE = 101; +#if defined _WIN32 || defined HAVE_FCNTL_DIRECT +static constexpr ulint OS_DATA_FILE_NO_O_DIRECT = 103; +#endif /* @} */ /** Error codes from os_file_get_last_error @{ */ @@ -373,7 +375,7 @@ os_file_create_simple_no_error_handling_func( bool* success) MY_ATTRIBUTE((warn_unused_result)); -#ifdef _WIN32 +#ifndef HAVE_FCNTL_DIRECT #define os_file_set_nocache(fd, file_name, operation_name) do{}while(0) #else /** Tries to disable OS caching on an opened file descriptor. diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index 3ddd2e98fee..0f4f8afa15b 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -140,6 +140,15 @@ private: bool m_initialized{false}; /** whether purge is enabled; protected by latch and std::atomic */ std::atomic m_enabled{false}; + /** The primary candidate for iterator::free_history() is + rseg=trx_sys.rseg_array[skipped_rseg]. This field may be changed + after invoking rseg.set_skip_allocation() and rseg.clear_skip_allocation() + and while holding the exclusive rseg.latch. + + This may only be 0 if innodb_undo_tablespaces=0, because rollback segment + 0 always resides in the system tablespace and would never be used when + dedicated undo tablespaces are in use. */ + Atomic_relaxed skipped_rseg; public: /** whether purge is active (may hold table handles) */ std::atomic m_active{false}; @@ -197,6 +206,11 @@ public: return undo_no <= other.undo_no; } + /** Remove unnecessary history data from a rollback segment. + @param rseg rollback segment + @return error code */ + inline dberr_t free_history_rseg(trx_rseg_t &rseg) const; + /** Free the undo pages up to this. */ dberr_t free_history() const; @@ -240,14 +254,15 @@ public: by the pq_mutex */ mysql_mutex_t pq_mutex; /*!< Mutex protecting purge_queue */ - /** Undo tablespace file truncation (only accessed by the - srv_purge_coordinator_thread) */ - struct { - /** The undo tablespace that is currently being truncated */ - fil_space_t* current; - /** The undo tablespace that was last truncated */ - fil_space_t* last; - } truncate; + /** innodb_undo_log_truncate=ON state; + only modified by purge_coordinator_callback() */ + struct { + /** The undo tablespace that is currently being truncated */ + Atomic_relaxed current; + /** The number of the undo tablespace that was last truncated, + relative from srv_undo_space_id_start */ + uint32_t last; + } truncate_undo_space; /** Create the instance */ void create(); @@ -357,6 +372,26 @@ public: typically via purge_sys_t::view_guard. */ return view.sees(id); } + +private: + /** Enable the use of a rollback segment and advance skipped_rseg, + after iterator::free_history_rseg() had invoked + rseg.set_skip_allocation(). */ + inline void rseg_enable(trx_rseg_t &rseg); + + /** Try to start truncating a tablespace. + @param id undo tablespace identifier + @param size the maximum desired undo tablespace size, in pages + @return undo tablespace whose truncation was started + @retval nullptr if truncation is not currently possible */ + inline fil_space_t *undo_truncate_try(uint32_t id, uint32_t size); +public: + /** Check if innodb_undo_log_truncate=ON needs to be handled. + This is only to be called by purge_coordinator_callback(). + @return undo tablespace chosen by innodb_undo_log_truncate=ON + @retval nullptr if truncation is not currently possible */ + fil_space_t *truncating_tablespace(); + /** A wrapper around trx_sys_t::clone_oldest_view(). */ template void clone_oldest_view() diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 43e0c290d63..7fa43047b18 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -73,14 +73,15 @@ private: /** Reference counter to track is_persistent() transactions, with SKIP flag. */ std::atomic ref; - +public: /** Whether undo tablespace truncation is pending */ static constexpr uint32_t SKIP= 1; /** Transaction reference count multiplier */ static constexpr uint32_t REF= 2; + /** @return the reference count and flags */ uint32_t ref_load() const { return ref.load(std::memory_order_relaxed); } - +private: /** Set the SKIP bit */ void ref_set_skip() { diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 7a62c9f0167..e6e8eb6b156 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -1190,6 +1190,11 @@ public: return count; } + /** Disable further allocation of transactions in a rollback segment + that are subject to innodb_undo_log_truncate=ON + @param space undo tablespace that will be truncated */ + inline void undo_truncate_start(fil_space_t &space); + /** Set the undo log empty value */ void set_undo_non_empty(bool val) { diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 0f2d5380935..101735b5d6a 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -3940,8 +3940,6 @@ static void lock_table_dequeue(lock_t *in_lock, bool owns_wait_mutex) dberr_t lock_table_for_trx(dict_table_t *table, trx_t *trx, lock_mode mode, bool no_wait) { - ut_ad(!dict_sys.frozen()); - mem_heap_t *heap= mem_heap_create(512); sel_node_t *node= sel_node_create(heap); que_thr_t *thr= pars_complete_graph_for_exec(node, trx, heap, nullptr); @@ -3978,36 +3976,6 @@ run_again: return err; } -/** Lock the child tables of a table. -@param table parent table -@param trx transaction -@return error code */ -dberr_t lock_table_children(dict_table_t *table, trx_t *trx) -{ - dict_sys.freeze(SRW_LOCK_CALL); - std::vector children; - - for (auto f : table->referenced_set) - if (dict_table_t *child= f->foreign_table) - { - child->acquire(); - children.emplace_back(child); - } - dict_sys.unfreeze(); - - dberr_t err= DB_SUCCESS; - - for (auto child : children) - if ((err= lock_table_for_trx(child, trx, LOCK_X)) != DB_SUCCESS) - break; - - for (auto child : children) - child->release(); - - return err; -} - - /** Exclusively lock the data dictionary tables. @param trx dictionary transaction @return error code diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 5880ae56670..ef31a4d00c1 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1673,20 +1673,6 @@ dberr_t recv_sys_t::find_checkpoint() { if (wrong_size) return DB_CORRUPTION; - if (log_sys.next_checkpoint_lsn < 8204) - { - /* Before MDEV-14425, InnoDB had a minimum LSN of 8192+12=8204. - Likewise, mariadb-backup --prepare would create an empty - ib_logfile0 after applying the log. We will allow an upgrade - from such an empty log. - - If a user replaces the redo log with an empty file and the - FIL_PAGE_FILE_FLUSH_LSN field was zero in the system - tablespace (see SysTablespace::read_lsn_and_check_flags()) we - must refuse to start up. */ - sql_print_error("InnoDB: ib_logfile0 is empty, and LSN is unknown."); - return DB_CORRUPTION; - } lsn= log_sys.next_checkpoint_lsn; log_sys.format= log_t::FORMAT_3_23; goto upgrade; @@ -4483,12 +4469,36 @@ done: return err; } +dberr_t recv_recovery_read_checkpoint() +{ + ut_ad(srv_operation <= SRV_OPERATION_EXPORT_RESTORED || + srv_operation == SRV_OPERATION_RESTORE || + srv_operation == SRV_OPERATION_RESTORE_EXPORT); + ut_d(mysql_mutex_lock(&buf_pool.mutex)); + ut_ad(UT_LIST_GET_LEN(buf_pool.LRU) == 0); + ut_ad(UT_LIST_GET_LEN(buf_pool.unzip_LRU) == 0); + ut_d(mysql_mutex_unlock(&buf_pool.mutex)); + + if (srv_force_recovery >= SRV_FORCE_NO_LOG_REDO) + { + sql_print_information("InnoDB: innodb_force_recovery=6" + " skips redo log apply"); + return DB_SUCCESS; + } + + log_sys.latch.wr_lock(SRW_LOCK_CALL); + dberr_t err= recv_sys.find_checkpoint(); + log_sys.latch.wr_unlock(); + return err; +} + /** Start recovering from a redo log checkpoint. of first system tablespace page @return error code or DB_SUCCESS */ dberr_t recv_recovery_from_checkpoint_start() { - bool rescan = false; + bool rescan = false; + dberr_t err = DB_SUCCESS; ut_ad(srv_operation <= SRV_OPERATION_EXPORT_RESTORED || srv_operation == SRV_OPERATION_RESTORE @@ -4501,20 +4511,12 @@ dberr_t recv_recovery_from_checkpoint_start() if (srv_force_recovery >= SRV_FORCE_NO_LOG_REDO) { sql_print_information("InnoDB: innodb_force_recovery=6" " skips redo log apply"); - return(DB_SUCCESS); + return err; } recv_sys.recovery_on = true; log_sys.latch.wr_lock(SRW_LOCK_CALL); - - dberr_t err = recv_sys.find_checkpoint(); - if (err != DB_SUCCESS) { -early_exit: - log_sys.latch.wr_unlock(); - return err; - } - log_sys.set_capacity(); /* Start reading the log from the checkpoint lsn. The variable @@ -4524,7 +4526,9 @@ early_exit: ut_ad(recv_sys.pages.empty()); if (log_sys.format == log_t::FORMAT_3_23) { - goto early_exit; +early_exit: + log_sys.latch.wr_unlock(); + return err; } if (log_sys.is_latest()) { @@ -4818,7 +4822,7 @@ byte *recv_dblwr_t::find_page(const page_id_t page_id, } bool recv_dblwr_t::restore_first_page(uint32_t space_id, const char *name, - os_file_t file) + pfs_os_file_t file) { const page_id_t page_id(space_id, 0); const byte* page= find_page(page_id); @@ -4826,10 +4830,10 @@ bool recv_dblwr_t::restore_first_page(uint32_t space_id, const char *name, { /* If the first page of the given user tablespace is not there in the doublewrite buffer, then the recovery is going to fail - now. Hence this is treated as error. */ - ib::error() - << "Corrupted page " << page_id << " of datafile '" - << name <<"' could not be found in the doublewrite buffer."; + now. Report error only when doublewrite buffer is not empty */ + if (pages.size()) + ib::error() << "Corrupted page " << page_id << " of datafile '" + << name << "' could not be found in the doublewrite buffer."; return true; } @@ -4843,3 +4847,58 @@ bool recv_dblwr_t::restore_first_page(uint32_t space_id, const char *name, IORequestWrite, name, file, page, 0, physical_size) != DB_SUCCESS; } + +uint32_t recv_dblwr_t::find_first_page(const char *name, pfs_os_file_t file) +{ + os_offset_t file_size= os_file_get_size(file); + if (file_size != (os_offset_t) -1) + { + for (const page_t *page : pages) + { + uint32_t space_id= page_get_space_id(page); + byte *read_page= nullptr; + if (page_get_page_no(page) > 0 || space_id == 0) + { +next_page: + aligned_free(read_page); + continue; + } + uint32_t flags= mach_read_from_4( + FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); + page_id_t page_id(space_id, 0); + size_t page_size= fil_space_t::physical_size(flags); + if (file_size < 4 * page_size) + goto next_page; + read_page= + static_cast(aligned_malloc(3 * page_size, page_size)); + /* Read 3 pages from the file and match the space id + with the space id which is stored in + doublewrite buffer page. */ + if (os_file_read(IORequestRead, file, read_page, page_size, + 3 * page_size, nullptr) != DB_SUCCESS) + goto next_page; + for (ulint j= 0; j <= 2; j++) + { + byte *cur_page= read_page + j * page_size; + if (buf_is_zeroes(span(cur_page, page_size))) + { + space_id= 0; + goto early_exit; + } + if (mach_read_from_4(cur_page + FIL_PAGE_OFFSET) != j + 1 || + memcmp(cur_page + FIL_PAGE_SPACE_ID, + page + FIL_PAGE_SPACE_ID, 4) || + buf_page_is_corrupted(false, cur_page, flags)) + goto next_page; + } + if (!restore_first_page(space_id, name, file)) + { +early_exit: + aligned_free(read_page); + return space_id; + } + break; + } + } + return 0; +} diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 86ff9c549bd..bd9ed24f14b 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1130,7 +1130,7 @@ os_file_create_func( ); int create_flag = O_RDONLY | O_CLOEXEC; -#ifdef O_DIRECT +#ifdef HAVE_FCNTL_DIRECT const char* mode_str = "OPEN"; #endif @@ -1148,12 +1148,12 @@ os_file_create_func( || create_mode == OS_FILE_OPEN_RETRY) { create_flag = O_RDWR | O_CLOEXEC; } else if (create_mode == OS_FILE_CREATE) { -#ifdef O_DIRECT +#ifdef HAVE_FCNTL_DIRECT mode_str = "CREATE"; #endif create_flag = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC; } else if (create_mode == OS_FILE_OVERWRITE) { -#ifdef O_DIRECT +#ifdef HAVE_FCNTL_DIRECT mode_str = "OVERWRITE"; #endif create_flag = O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC; @@ -1165,19 +1165,19 @@ os_file_create_func( return(OS_FILE_CLOSED); } - ut_a(type == OS_LOG_FILE - || type == OS_DATA_FILE - || type == OS_DATA_FILE_NO_O_DIRECT); - ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL); create_flag |= O_CLOEXEC; -#ifdef O_DIRECT +#ifdef HAVE_FCNTL_DIRECT + ut_a(type == OS_LOG_FILE + || type == OS_DATA_FILE + || type == OS_DATA_FILE_NO_O_DIRECT); int direct_flag = type == OS_DATA_FILE && create_mode != OS_FILE_CREATE && !fil_system.is_buffered() ? O_DIRECT : 0; #else + ut_a(type == OS_LOG_FILE || type == OS_DATA_FILE); constexpr int direct_flag = 0; #endif @@ -1194,7 +1194,7 @@ os_file_create_func( file = open(name, create_flag | direct_flag, os_innodb_umask); if (file == -1) { -#ifdef O_DIRECT +#ifdef HAVE_FCNTL_DIRECT if (direct_flag && errno == EINVAL) { direct_flag = 0; continue; @@ -1224,7 +1224,7 @@ os_file_create_func( } } -#if (defined __sun__ && defined DIRECTIO_ON) || defined O_DIRECT +#ifdef HAVE_FCNTL_DIRECT if (type == OS_DATA_FILE && create_mode == OS_FILE_CREATE && !fil_system.is_buffered()) { # ifdef __linux__ @@ -3012,30 +3012,15 @@ os_file_handle_error_cond_exit( return(false); } -#ifndef _WIN32 +#ifdef HAVE_FCNTL_DIRECT /** Tries to disable OS caching on an opened file descriptor. @param[in] fd file descriptor to alter @param[in] file_name file name, used in the diagnostic message @param[in] name "open" or "create"; used in the diagnostic message */ void -os_file_set_nocache( - int fd MY_ATTRIBUTE((unused)), - const char* file_name MY_ATTRIBUTE((unused)), - const char* operation_name MY_ATTRIBUTE((unused))) +os_file_set_nocache(int fd, const char *file_name, const char *operation_name) { - /* some versions of Solaris may not have DIRECTIO_ON */ -#if defined(__sun__) && defined(DIRECTIO_ON) - if (directio(fd, DIRECTIO_ON) == -1) { - int errno_save = errno; - - ib::error() - << "Failed to set DIRECTIO_ON on file " - << file_name << "; " << operation_name << ": " - << strerror(errno_save) << "," - " continuing anyway."; - } -#elif defined(O_DIRECT) if (fcntl(fd, F_SETFL, O_DIRECT) == -1) { int errno_save = errno; static bool warning_message_printed = false; @@ -3054,10 +3039,8 @@ os_file_set_nocache( << ", continuing anyway."; } } -#endif /* defined(__sun__) && defined(DIRECTIO_ON) */ } - -#endif /* _WIN32 */ +#endif /* HAVE_FCNTL_DIRECT */ /** Check if the file system supports sparse files. @param fh file handle @@ -3147,8 +3130,18 @@ fallback: return true; } current_size &= ~4095ULL; +# ifdef __linux__ + if (!fallocate(file, 0, current_size, + size - current_size)) { + err = 0; + break; + } + + err = errno; +# else err = posix_fallocate(file, current_size, size - current_size); +# endif } } while (err == EINTR && srv_shutdown_state <= SRV_SHUTDOWN_INITIATED); @@ -3427,7 +3420,7 @@ static void write_io_callback(void *c) if (UNIV_UNLIKELY(cb->m_err != 0)) ib::info () << "IO Error: " << cb->m_err - << "during write of " + << " during write of " << cb->m_len << " bytes, for file " << request.node->name << "(" << cb->m_fh << "), returned " << cb->m_ret_len; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index b74227aa792..f95e97fb6b5 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -4411,13 +4411,14 @@ row_merge_file_create( merge_file->fd = row_merge_file_create_low(path); merge_file->offset = 0; merge_file->n_rec = 0; - +#ifdef HAVE_FCNTL_DIRECT if (merge_file->fd != OS_FILE_CLOSED) { if (srv_disable_sort_file_cache) { os_file_set_nocache(merge_file->fd, "row0merge.cc", "sort"); } } +#endif return(merge_file->fd); } diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index d1ea843e521..ceb739d8508 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1418,7 +1418,8 @@ inline void purge_coordinator_state::do_purge() ulint n_pages_handled= trx_purge(n_threads, history_size); if (!trx_sys.history_exists()) goto no_history; - if (purge_sys.truncate.current || srv_shutdown_state != SRV_SHUTDOWN_NONE) + if (purge_sys.truncating_tablespace() || + srv_shutdown_state != SRV_SHUTDOWN_NONE) { purge_truncation_task.wait(); trx_purge_truncate_history(); diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index b8b5231eeb8..55e5c5d0e7f 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1368,6 +1368,10 @@ dberr_t srv_start(bool create_new_db) ut_ad(buf_page_cleaner_is_active); } + if (innodb_encrypt_temporary_tables && !log_crypt_init()) { + return srv_init_abort(DB_ERROR); + } + /* Check if undo tablespaces and redo log files exist before creating a new system tablespace */ if (create_new_db) { @@ -1376,6 +1380,11 @@ dberr_t srv_start(bool create_new_db) return(srv_init_abort(DB_ERROR)); } recv_sys.debug_free(); + } else { + err = recv_recovery_read_checkpoint(); + if (err != DB_SUCCESS) { + return srv_init_abort(err); + } } /* Open or create the data files. */ @@ -1400,12 +1409,9 @@ dberr_t srv_start(bool create_new_db) " old data files which contain your precious data!"; /* fall through */ default: - /* Other errors might come from Datafile::validate_first_page() */ - return(srv_init_abort(err)); - } - - if (innodb_encrypt_temporary_tables && !log_crypt_init()) { - return srv_init_abort(DB_ERROR); + /* Other errors might be flagged by + Datafile::validate_first_page() */ + return srv_init_abort(err); } if (create_new_db) { @@ -1421,10 +1427,10 @@ dberr_t srv_start(bool create_new_db) return srv_init_abort(err); } - srv_undo_space_id_start= 1; + srv_undo_space_id_start = 1; } - /* Open log file and data files in the systemtablespace: we keep + /* Open data files in the system tablespace: we keep them open until database shutdown */ ut_d(fil_system.sys_space->recv_size = srv_sys_space_size_debug); diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index add4db962d5..9a295e0b2c1 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -169,10 +169,15 @@ void purge_sys_t::create() ut_ad(this == &purge_sys); ut_ad(!m_initialized); ut_ad(!enabled()); + ut_ad(!m_active); + /* If innodb_undo_tablespaces>0, the rollback segment 0 + (which always resides in the system tablespace) will + never be used; @see trx_assign_rseg_low() */ + skipped_rseg= srv_undo_tablespaces > 0; m_paused= 0; query= purge_graph_build(); next_stored= false; - rseg= NULL; + rseg= nullptr; page_no= 0; offset= 0; hdr_page_no= 0; @@ -180,8 +185,8 @@ void purge_sys_t::create() latch.SRW_LOCK_INIT(trx_purge_latch_key); end_latch.init(); mysql_mutex_init(purge_sys_pq_mutex_key, &pq_mutex, nullptr); - truncate.current= NULL; - truncate.last= NULL; + truncate_undo_space.current= nullptr; + truncate_undo_space.last= 0; m_initialized= true; } @@ -385,17 +390,50 @@ static void trx_purge_free_segment(buf_block_t *rseg_hdr, buf_block_t *block, block->page.frame, &mtr)); } +void purge_sys_t::rseg_enable(trx_rseg_t &rseg) +{ + ut_ad(this == &purge_sys); +#ifndef SUX_LOCK_GENERIC + ut_ad(rseg.latch.is_write_locked()); +#endif + uint8_t skipped= skipped_rseg; + ut_ad(skipped < TRX_SYS_N_RSEGS); + if (&rseg == &trx_sys.rseg_array[skipped]) + { + /* If this rollback segment is subject to innodb_undo_log_truncate=ON, + we must not clear the flag. But we will advance purge_sys.skipped_rseg + to be able to choose another candidate for this soft truncation, and + to prevent the following scenario: + + (1) purge_sys_t::iterator::free_history_rseg() had invoked + rseg.set_skip_allocation() + (2) undo log truncation had completed on this rollback segment + (3) SET GLOBAL innodb_undo_log_truncate=OFF + (4) purge_sys_t::iterator::free_history_rseg() would not be able to + invoke rseg.set_skip_allocation() on any other rollback segment + before this rseg has grown enough */ + if (truncate_undo_space.current != rseg.space) + rseg.clear_skip_allocation(); + skipped++; + /* If innodb_undo_tablespaces>0, the rollback segment 0 + (which always resides in the system tablespace) will + never be used; @see trx_assign_rseg_low() */ + if (!(skipped&= (TRX_SYS_N_RSEGS - 1)) && srv_undo_tablespaces) + skipped++; + skipped_rseg= skipped; + } +} + /** Remove unnecessary history data from a rollback segment. @param rseg rollback segment @param limit truncate anything before this -@param all whether everything can be truncated @return error code */ -static dberr_t -trx_purge_truncate_rseg_history(trx_rseg_t &rseg, - const purge_sys_t::iterator &limit, bool all) +inline dberr_t purge_sys_t::iterator::free_history_rseg(trx_rseg_t &rseg) const { fil_addr_t hdr_addr; mtr_t mtr; + bool freed= false; + uint32_t rseg_ref= 0; mtr.start(); @@ -405,6 +443,8 @@ trx_purge_truncate_rseg_history(trx_rseg_t &rseg, { func_exit: mtr.commit(); + if (freed && (rseg.SKIP & rseg_ref)) + purge_sys.rseg_enable(rseg); return err; } @@ -426,16 +466,40 @@ loop: const trx_id_t undo_trx_no= mach_read_from_8(b->page.frame + hdr_addr.boffset + TRX_UNDO_TRX_NO); - if (undo_trx_no >= limit.trx_no) + if (undo_trx_no >= trx_no) { - if (undo_trx_no == limit.trx_no) - err = trx_undo_truncate_start(&rseg, hdr_addr.page, - hdr_addr.boffset, limit.undo_no); + if (undo_trx_no == trx_no) + err= trx_undo_truncate_start(&rseg, hdr_addr.page, + hdr_addr.boffset, undo_no); goto func_exit; } + else + { + rseg_ref= rseg.ref_load(); + if (rseg_ref >= rseg.REF || !purge_sys.sees(rseg.needs_purge)) + { + /* We cannot clear this entire rseg because trx_assign_rseg_low() + has already chosen it for a future trx_undo_assign(), or + because some recently started transaction needs purging. - if (!all) - goto func_exit; + If this invocation could not reduce rseg.history_size at all + (!freed), we will try to ensure progress and prevent our + starvation by disabling one rollback segment for future + trx_assign_rseg_low() invocations until a future invocation has + made progress and invoked purge_sys_t::rseg_enable(rseg) on that + rollback segment. */ + + if (!(rseg.SKIP & rseg_ref) && !freed && + ut_d(!trx_rseg_n_slots_debug &&) + &rseg == &trx_sys.rseg_array[purge_sys.skipped_rseg]) + /* If rseg.space == purge_sys.truncate_undo_space.current + the following will be a no-op. A possible conflict + with innodb_undo_log_truncate=ON will be handled in + purge_sys_t::rseg_enable(). */ + rseg.set_skip_allocation(); + goto func_exit; + } + } fil_addr_t prev_hdr_addr= flst_get_prev_addr(b->page.frame + hdr_addr.boffset + @@ -498,6 +562,7 @@ loop: mtr.commit(); ut_ad(rseg.history_size > 0); rseg.history_size--; + freed= true; mtr.start(); rseg_hdr->page.lock.x_lock(); ut_ad(rseg_hdr->page.id() == rseg.page_id()); @@ -552,9 +617,7 @@ dberr_t purge_sys_t::iterator::free_history() const ut_ad(rseg.is_persistent()); log_free_check(); rseg.latch.wr_lock(SRW_LOCK_CALL); - dberr_t err= - trx_purge_truncate_rseg_history(rseg, *this, !rseg.is_referenced() && - purge_sys.sees(rseg.needs_purge)); + dberr_t err= free_history_rseg(rseg); rseg.latch.wr_unlock(); if (err) return err; @@ -562,6 +625,62 @@ dberr_t purge_sys_t::iterator::free_history() const return DB_SUCCESS; } +inline void trx_sys_t::undo_truncate_start(fil_space_t &space) +{ + ut_ad(this == &trx_sys); + /* Undo tablespace always are a single file. */ + ut_a(UT_LIST_GET_LEN(space.chain) == 1); + fil_node_t *file= UT_LIST_GET_FIRST(space.chain); + /* The undo tablespace files are never closed. */ + ut_ad(file->is_open()); + sql_print_information("InnoDB: Starting to truncate %s", file->name); + + for (auto &rseg : rseg_array) + if (rseg.space == &space) + { + /* Prevent a race with purge_sys_t::iterator::free_history_rseg() */ + rseg.latch.rd_lock(SRW_LOCK_CALL); + /* Once set, this rseg will not be allocated to subsequent + transactions, but we will wait for existing active + transactions to finish. */ + rseg.set_skip_allocation(); + rseg.latch.rd_unlock(); + } +} + +inline fil_space_t *purge_sys_t::undo_truncate_try(uint32_t id, uint32_t size) +{ + ut_ad(srv_is_undo_tablespace(id)); + fil_space_t *space= fil_space_get(id); + if (space && space->get_size() > size) + { + truncate_undo_space.current= space; + trx_sys.undo_truncate_start(*space); + return space; + } + return nullptr; +} + +fil_space_t *purge_sys_t::truncating_tablespace() +{ + ut_ad(this == &purge_sys); + + fil_space_t *space= truncate_undo_space.current; + if (space || srv_undo_tablespaces_active < 2 || !srv_undo_log_truncate) + return space; + + const uint32_t size= uint32_t(srv_max_undo_log_size >> srv_page_size_shift); + for (uint32_t i= truncate_undo_space.last, j= i;; ) + { + if (fil_space_t *s= undo_truncate_try(srv_undo_space_id_start + i, size)) + return s; + ++i; + i%= srv_undo_tablespaces_active; + if (i == j) + return nullptr; + } +} + #if defined __GNUC__ && __GNUC__ == 4 && !defined __clang__ # if defined __arm__ || defined __aarch64__ /* Work around an internal compiler error in GCC 4.8.5 */ @@ -587,55 +706,14 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history() head.undo_no= 0; } - if (head.free_history() != DB_SUCCESS || srv_undo_tablespaces_active < 2) + if (head.free_history() != DB_SUCCESS) return; - while (srv_undo_log_truncate) + while (fil_space_t *space= purge_sys.truncating_tablespace()) { - if (!purge_sys.truncate.current) - { - const ulint threshold= - ulint(srv_max_undo_log_size >> srv_page_size_shift); - for (uint32_t i= purge_sys.truncate.last - ? purge_sys.truncate.last->id - srv_undo_space_id_start : 0, - j= i;; ) - { - const uint32_t space_id= srv_undo_space_id_start + i; - ut_ad(srv_is_undo_tablespace(space_id)); - fil_space_t *space= fil_space_get(space_id); - ut_a(UT_LIST_GET_LEN(space->chain) == 1); - - if (space && space->get_size() > threshold) - { - purge_sys.truncate.current= space; - break; - } - - ++i; - i %= srv_undo_tablespaces_active; - if (i == j) - return; - } - } - - fil_space_t &space= *purge_sys.truncate.current; - /* Undo tablespace always are a single file. */ - fil_node_t *file= UT_LIST_GET_FIRST(space.chain); - /* The undo tablespace files are never closed. */ - ut_ad(file->is_open()); - - DBUG_LOG("undo", "marking for truncate: " << file->name); - - for (auto &rseg : trx_sys.rseg_array) - if (rseg.space == &space) - /* Once set, this rseg will not be allocated to subsequent - transactions, but we will wait for existing active - transactions to finish. */ - rseg.set_skip_allocation(); - for (auto &rseg : trx_sys.rseg_array) { - if (rseg.space != &space) + if (rseg.space != space) continue; rseg.latch.rd_lock(SRW_LOCK_CALL); @@ -668,8 +746,9 @@ not_free: rseg.latch.rd_unlock(); } - sql_print_information("InnoDB: Truncating %s", file->name); - trx_purge_cleanse_purge_queue(space); + const char *file_name= UT_LIST_GET_FIRST(space->chain)->name; + sql_print_information("InnoDB: Truncating %s", file_name); + trx_purge_cleanse_purge_queue(*space); /* Lock all modified pages of the tablespace. @@ -686,12 +765,12 @@ not_free: /* Adjust the tablespace metadata. */ mysql_mutex_lock(&fil_system.mutex); - if (space.crypt_data) + if (space->crypt_data) { - space.reacquire(); + space->reacquire(); mysql_mutex_unlock(&fil_system.mutex); - fil_space_crypt_close_tablespace(&space); - space.release(); + fil_space_crypt_close_tablespace(space); + space->release(); } else mysql_mutex_unlock(&fil_system.mutex); @@ -703,17 +782,17 @@ not_free: mtr_t mtr; mtr.start(); - mtr.x_lock_space(&space); + mtr.x_lock_space(space); /* Associate the undo tablespace with mtr. During mtr::commit_shrink(), InnoDB can use the undo tablespace object to clear all freed ranges */ - mtr.set_named_space(&space); - mtr.trim_pages(page_id_t(space.id, size)); - ut_a(fsp_header_init(&space, size, &mtr) == DB_SUCCESS); + mtr.set_named_space(space); + mtr.trim_pages(page_id_t(space->id, size)); + ut_a(fsp_header_init(space, size, &mtr) == DB_SUCCESS); for (auto &rseg : trx_sys.rseg_array) { - if (rseg.space != &space) + if (rseg.space != space) continue; ut_ad(!rseg.is_referenced()); @@ -722,7 +801,7 @@ not_free: possibly before this server had been started up. */ dberr_t err; - buf_block_t *rblock= trx_rseg_header_create(&space, + buf_block_t *rblock= trx_rseg_header_create(space, &rseg - trx_sys.rseg_array, trx_sys.get_max_trx_id(), &mtr, &err); @@ -735,7 +814,7 @@ not_free: rseg.reinit(rblock->page.id().page_no()); } - mtr.commit_shrink(space, size); + mtr.commit_shrink(*space, size); /* No mutex; this is only updated by the purge coordinator. */ export_vars.innodb_undo_truncations++; @@ -757,10 +836,10 @@ not_free: log_buffer_flush_to_disk(); DBUG_SUICIDE();); - sql_print_information("InnoDB: Truncated %s", file->name); - purge_sys.truncate.last= purge_sys.truncate.current; - ut_ad(&space == purge_sys.truncate.current); - purge_sys.truncate.current= nullptr; + sql_print_information("InnoDB: Truncated %s", file_name); + ut_ad(space == purge_sys.truncate_undo_space.current); + purge_sys.truncate_undo_space.current= nullptr; + purge_sys.truncate_undo_space.last= space->id - srv_undo_space_id_start; } } diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index d17f84248f1..566a753fe9e 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -902,15 +902,13 @@ trx_undo_truncate_start( trx_undo_rec_t* last_rec; mtr_t mtr; + ut_ad(rseg->is_persistent()); + if (!limit) { return DB_SUCCESS; } loop: - mtr_start(&mtr); - - if (!rseg->is_persistent()) { - mtr.set_log_mode(MTR_LOG_NO_REDO); - } + mtr.start(); dberr_t err; const buf_block_t* undo_page; diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c index ff4a2bcb33a..938e5b102c9 100644 --- a/storage/maria/unittest/ma_pagecache_consist.c +++ b/storage/maria/unittest/ma_pagecache_consist.c @@ -403,10 +403,6 @@ int main(int argc __attribute__((unused)), exit(1); } -#ifdef HAVE_THR_SETCONCURRENCY - thr_setconcurrency(2); -#endif - if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, TEST_PAGE_SIZE, 0, 0)) == 0) { diff --git a/storage/maria/unittest/ma_pagecache_rwconsist.c b/storage/maria/unittest/ma_pagecache_rwconsist.c index 24c30245bac..e059ac45511 100644 --- a/storage/maria/unittest/ma_pagecache_rwconsist.c +++ b/storage/maria/unittest/ma_pagecache_rwconsist.c @@ -272,10 +272,6 @@ int main(int argc __attribute__((unused)), exit(1); } -#ifdef HAVE_THR_SETCONCURRENCY - thr_setconcurrency(2); -#endif - if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, TEST_PAGE_SIZE, 0, 0)) == 0) { diff --git a/storage/maria/unittest/ma_pagecache_rwconsist2.c b/storage/maria/unittest/ma_pagecache_rwconsist2.c index c92bec3ca41..28d3bb8dcb8 100644 --- a/storage/maria/unittest/ma_pagecache_rwconsist2.c +++ b/storage/maria/unittest/ma_pagecache_rwconsist2.c @@ -268,10 +268,6 @@ int main(int argc __attribute__((unused)), exit(1); } -#ifdef HAVE_THR_SETCONCURRENCY - thr_setconcurrency(2); -#endif - if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, TEST_PAGE_SIZE, 0, 0)) == 0) { diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index de2ecaecfc4..9009e59c245 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -795,10 +795,6 @@ int main(int argc __attribute__((unused)), exit(1); } -#ifdef HAVE_THR_SETCONCURRENCY - thr_setconcurrency(2); -#endif - if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, TEST_PAGE_SIZE, 0, MYF(MY_WME))) == 0) { diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c index ec097ede036..be6046abab4 100644 --- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c @@ -331,10 +331,6 @@ int main(int argc __attribute__((unused)), exit(1); } -#ifdef HAVE_THR_SETCONCURRENCY - thr_setconcurrency(2); -#endif - if (ma_control_file_open(TRUE, TRUE, TRUE)) { fprintf(stderr, "Can't init control file (%d)\n", errno); diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h index 0435f7d6bd6..12189b79dc9 100644 --- a/storage/myisammrg/ha_myisammrg.h +++ b/storage/myisammrg/ha_myisammrg.h @@ -34,7 +34,7 @@ class Mrg_child_def: public Sql_alloc { /* Remembered MERGE child def version. See top comment in ha_myisammrg.cc */ enum_table_ref_type m_child_table_ref_type; - ulong m_child_def_version; + ulonglong m_child_def_version; public: LEX_STRING db; LEX_STRING name; @@ -44,12 +44,12 @@ public: { return m_child_table_ref_type; } - inline ulong get_child_def_version() + inline ulonglong get_child_def_version() { return m_child_def_version; } inline void set_child_def_version(enum_table_ref_type child_table_ref_type, - ulong version) + ulonglong version) { m_child_table_ref_type= child_table_ref_type; m_child_def_version= version; diff --git a/storage/perfschema/CMakeLists.txt b/storage/perfschema/CMakeLists.txt index b4f5e96b607..e703e43fe50 100644 --- a/storage/perfschema/CMakeLists.txt +++ b/storage/perfschema/CMakeLists.txt @@ -24,7 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_BINARY_DIR}/sql ${CMAKE_CURRENT_BINARY_DIR} - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS}) ADD_DEFINITIONS(-DMYSQL_SERVER) diff --git a/storage/perfschema/unittest/CMakeLists.txt b/storage/perfschema/unittest/CMakeLists.txt index 2a22990f807..600795c78fc 100644 --- a/storage/perfschema/unittest/CMakeLists.txt +++ b/storage/perfschema/unittest/CMakeLists.txt @@ -22,7 +22,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/mysql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${SSL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/unittest/mytap diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 3c5b23f559f..103ce50dd63 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -3541,7 +3541,8 @@ CSphSEStats * sphinx_get_stats ( THD * thd, SHOW_VAR * out ) return 0; } -int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, char * ) +static int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, void *, + system_status_var *, enum_var_type ) { CSphSEStats * pStats = sphinx_get_stats ( thd, out ); if ( pStats ) @@ -3552,7 +3553,8 @@ int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, char * ) return 0; } -int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, char * ) +static int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, void *, + system_status_var *, enum_var_type ) { CSphSEStats * pStats = sphinx_get_stats ( thd, out ); if ( pStats ) @@ -3563,7 +3565,8 @@ int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, char * ) return 0; } -int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, char * ) +static int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, void *, + system_status_var *, enum_var_type ) { CSphSEStats * pStats = sphinx_get_stats ( thd, out ); if ( pStats ) @@ -3574,7 +3577,8 @@ int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, char * ) return 0; } -int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, char * ) +static int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, void *, + system_status_var *, enum_var_type ) { CSphSEStats * pStats = sphinx_get_stats ( thd, out ); if ( pStats ) @@ -3585,9 +3589,11 @@ int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, char * ) return 0; } -int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, char * sBuffer ) +static int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, void * buf, + system_status_var *, enum_var_type ) { #if MYSQL_VERSION_ID>50100 + char *sBuffer = static_cast(buf); if ( sphinx_hton_ptr ) { CSphTLS * pTls = (CSphTLS *) thd_get_ha_data ( thd, sphinx_hton_ptr ); @@ -3642,7 +3648,8 @@ int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, char * sBuffer ) return 0; } -int sphinx_showfunc_error ( THD * thd, SHOW_VAR * out, char * ) +static int sphinx_showfunc_error ( THD * thd, SHOW_VAR * out, void *, + system_status_var *, enum_var_type ) { CSphSEStats * pStats = sphinx_get_stats ( thd, out ); out->type = SHOW_CHAR; diff --git a/storage/sphinx/ha_sphinx.h b/storage/sphinx/ha_sphinx.h index f5651fc6eb5..db41b7bd2fb 100644 --- a/storage/sphinx/ha_sphinx.h +++ b/storage/sphinx/ha_sphinx.h @@ -178,12 +178,6 @@ private: bool sphinx_show_status ( THD * thd ); #endif -int sphinx_showfunc_total_found ( THD *, SHOW_VAR *, char * ); -int sphinx_showfunc_total ( THD *, SHOW_VAR *, char * ); -int sphinx_showfunc_time ( THD *, SHOW_VAR *, char * ); -int sphinx_showfunc_word_count ( THD *, SHOW_VAR *, char * ); -int sphinx_showfunc_words ( THD *, SHOW_VAR *, char * ); - // // $Id: ha_sphinx.h 4818 2014-09-24 08:53:38Z tomat $ // diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 05fff7201df..046567724d9 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -6222,7 +6222,7 @@ int ha_spider::ft_read_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } } else { - uint dbton_id = share->use_sql_dbton_ids[roop_count]; + uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; SPIDER_CONN *conn = conns[roop_count]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); @@ -8506,7 +8506,10 @@ int ha_spider::create( if ( thd->lex->create_info.or_replace() && (error_num = spider_delete_tables( - table_tables, tmp_share.table_name, &dummy)) + table_tables, tmp_share.table_name, &dummy)) && + /* In this context, no key found in mysql.spider_tables means + the Spider table does not exist */ + error_num != HA_ERR_KEY_NOT_FOUND ) { goto error; } @@ -8913,6 +8916,10 @@ int ha_spider::delete_table( (error_num = spider_delete_tables( table_tables, name, &old_link_count)) ) { + /* In this context, no key found in mysql.spider_tables means + the Spider table does not exist */ + if (error_num == HA_ERR_KEY_NOT_FOUND) + error_num= HA_ERR_NO_SUCH_TABLE; goto error; } spider_sys_close_table(current_thd, &open_tables_backup); @@ -9731,7 +9738,7 @@ int ha_spider::drop_tmp_tables() ) { if (spider_bit_is_set(result_list.tmp_table_created, roop_count)) { - uint dbton_id = share->use_sql_dbton_ids[roop_count]; + uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; SPIDER_CONN *conn = conns[roop_count]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); diff --git a/storage/spider/mysql-test/spider/bugfix/disabled.def b/storage/spider/mysql-test/spider/bugfix/disabled.def index c171d4b60eb..9009cd2565d 100644 --- a/storage/spider/mysql-test/spider/bugfix/disabled.def +++ b/storage/spider/mysql-test/spider/bugfix/disabled.def @@ -1,4 +1,5 @@ wait_timeout : MDEV-26045 mdev_29676 : MDEV-31138 -mdev_29904 : MDEV-31101 mdev_27239: MDEV-32046 +mdev_27575 : MDEV-32997 +mdev_28739_simple : MDEV-33343 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_26151.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_26151.result index 867da33a603..10fec21da9d 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_26151.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_26151.result @@ -6,6 +6,9 @@ for child2 for child3 set @old_spider_bgs_mode= @@spider_bgs_mode; set session spider_bgs_mode=1; +set spider_same_server_link=1; +set @old_spider_same_server_link=@@global.spider_same_server_link; +set global spider_same_server_link=1; CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table td (a int, PRIMARY KEY (a)); create table ts (a int, PRIMARY KEY (a)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_26151",TABLE "td", casual_read "3"'; @@ -32,6 +35,7 @@ min(a) drop table td, ts; drop server srv_mdev_26151; set session spider_bgs_mode=@old_spider_bgs_mode; +set global spider_same_server_link=@old_spider_same_server_link; for master_1 for child2 for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_26541.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_26541.result index 34d561f46d1..35a9d9167a6 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_26541.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_26541.result @@ -2,18 +2,3 @@ # MDEV-26541 Undefined symbol: _ZTI12ha_partition when attempting to use ha_spider.so in UBSAN builds # INSTALL SONAME 'ha_spider.so'; -DROP FUNCTION spider_flush_table_mon_cache; -DROP FUNCTION spider_copy_tables; -DROP FUNCTION spider_ping_table; -DROP FUNCTION spider_bg_direct_sql; -DROP FUNCTION spider_direct_sql; -UNINSTALL SONAME IF EXISTS 'ha_spider'; -DROP TABLE IF EXISTS mysql.spider_xa; -DROP TABLE IF EXISTS mysql.spider_xa_member; -DROP TABLE IF EXISTS mysql.spider_xa_failed_log; -DROP TABLE IF EXISTS mysql.spider_tables; -DROP TABLE IF EXISTS mysql.spider_link_mon_servers; -DROP TABLE IF EXISTS mysql.spider_link_failed_log; -DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery; -DROP TABLE IF EXISTS mysql.spider_table_sts; -DROP TABLE IF EXISTS mysql.spider_table_crd; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_27575.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_27575.result index 5890a4e8a74..3b137eaabcf 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_27575.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_27575.result @@ -4,8 +4,6 @@ for master_1 for child2 for child3 -call mtr.add_suppression("\\[ERROR\\] Table 'mysql.spider_table_sts' doesn't exist"); -call mtr.add_suppression("\\[ERROR\\] Server shutdown in progress"); SET GLOBAL default_tmp_storage_engine=spider; ERROR HY000: Table storage engine 'SPIDER' does not support the create option 'TEMPORARY' # restart diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_28739_simple.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_28739_simple.result index a8b128e25cc..685a58e9d89 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_28739_simple.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_28739_simple.result @@ -5,6 +5,7 @@ for master_1 for child2 for child3 set global query_cache_type= on; +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t2 (c int); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result index b5f780d5c9c..7c66fa79f6c 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); # testing monitoring_* diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_28998.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_28998.result index e22736d793d..7dd03cca939 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_28998.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_28998.result @@ -4,8 +4,7 @@ for master_1 for child2 for child3 -set @old_spider_disable_group_by_handler=@@spider_disable_group_by_handler; -set spider_disable_group_by_handler=1; +set spider_same_server_link=1; CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); @@ -19,7 +18,6 @@ a 2 DROP TABLE t2, t1_SPIDER, t1; drop server s; -set spider_disable_group_by_handler=@old_spider_disable_group_by_handler; for master_1 for child2 for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29002.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29002.result new file mode 100644 index 00000000000..94f441d65d6 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29002.result @@ -0,0 +1,44 @@ +for master_1 +for child2 +for child3 +SET spider_same_server_link= on; +CREATE SERVER s FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +CREATE TABLE t (a INT); +CREATE TABLE t1_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'"; +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +CREATE TABLE t2_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'"; +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +SELECT * FROM t1_spider, t2_spider; +a a +SELECT table_name, index_name, cardinality FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name IN ('t1_spider','t2_spider'); +table_name index_name cardinality +RENAME TABLE t1_spider TO t3_spider; +SELECT * FROM t3_spider; +a +DROP TABLE t3_spider, t2_spider, t; +drop server s; +CREATE TABLE t1 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"'; +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"'; +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +CREATE TABLE t3 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"'; +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +SHOW TABLE STATUS; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +t1 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0 +t2 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0 +t3 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0 +Warnings: +Warning 1429 Unable to connect to foreign data source: srv +Warning 1429 Unable to connect to foreign data source: srv +Warning 1429 Unable to connect to foreign data source: srv +drop table t1, t2, t3; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29163.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29163.result index 03058a44057..126c8591e0c 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_29163.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29163.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 (a INT); CREATE TABLE t2 (b INT); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29456.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29456.result index bb5ddfe5006..5f64908de73 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_29456.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29456.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t1 (c int); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29502.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29502.result index 6adeecc9a3e..0d0ad383d8f 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_29502.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29502.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t (a INT); INSERT INTO t VALUES (23),(48); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29963.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29963.result index e8fa46ebc20..52a923eb8c7 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_29963.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29963.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t (a INT) ENGINE=Spider; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_30014.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_30014.result index e5551bc5b2b..94fdcd2033c 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_30014.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_30014.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t1 (c int); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_30170.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_30170.result new file mode 100644 index 00000000000..2183447bfa3 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_30170.result @@ -0,0 +1,7 @@ +install soname 'ha_spider'; +DROP TABLE non_existing_table; +ERROR 42S02: Unknown table 'test.non_existing_table' +create or replace table non_existing_table (c int) engine=Spider; +drop table non_existing_table; +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_30392.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_30392.result index 11fb9bd469b..6f569dd2418 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_30392.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_30392.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_31338.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_31338.result index 9abc0bb269e..ccd9125600d 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_31338.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_31338.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t (c BLOB) ENGINE=InnoDB; CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_31645.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_31645.result index 338f2cbdf4e..5bfee3b18e3 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_31645.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_31645.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)); CREATE TABLE t2 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)) ENGINE=SPIDER COMMENT='srv "srv", WRAPPER "mysql", TABLE "t1"'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_31996.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_31996.result index 3302c38820b..0f8915d4c50 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_31996.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_31996.result @@ -1,6 +1,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); set session spider_delete_all_rows_type=0; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_32986.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_32986.result index 9baaee7a8db..e3b4da296b4 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_32986.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_32986.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t2 (c varchar(16)); diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_32999.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_32999.result index 1f0f5f1bf6b..42288a2f708 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_32999.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_32999.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=on; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t ENGINE=Spider COMMENT='srv "srv",table "t1"'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33008.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33008.result new file mode 100644 index 00000000000..3bcb4bb038a --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33008.result @@ -0,0 +1,25 @@ +for master_1 +for child2 +for child3 +set spider_same_server_link=on; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`code` varchar(10) DEFAULT NULL, +PRIMARY KEY (`id`) +); +create table t1 ENGINE=Spider +COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"' +drop table t1, t2; +drop server srv; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33191.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33191.result new file mode 100644 index 00000000000..d4c5a74a58a --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33191.result @@ -0,0 +1,16 @@ +INSTALL SONAME 'ha_spider'; +set spider_same_server_link=on; +CREATE TABLE t2(c INT); +CREATE TABLE t1(c INT) ENGINE=Spider COMMENT='socket "$SOCKET", user "root", table "t2 t3"'; +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +Warning 138 The high availability feature of Spider has been deprecated and will be removed in a future release +ALTER TABLE t1 ENGINE=Spider; +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +Warning 138 The high availability feature of Spider has been deprecated and will be removed in a future release +TRUNCATE TABLE t1; +ERROR 42S02: Table 'test.t3' doesn't exist +drop table t1, t2; +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33441.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33441.result new file mode 100644 index 00000000000..b19194f13b5 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33441.result @@ -0,0 +1,7 @@ +# +# MDEV-33441 No spider variables available is Spider is loaded upon server startup +# +set spider_same_server_link=0; +# +# end of test mdev_33441 +# diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33441_fail.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33441_fail.result new file mode 100644 index 00000000000..e6123ed429b --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33441_fail.result @@ -0,0 +1,10 @@ +# +# MDEV-33441 No spider variables available is Spider is loaded upon server startup +# +select * from mysql.plugin; +name dl +show variables like 'spider%'; +Variable_name Value +# +# end of test mdev_33441_fail +# diff --git a/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result b/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result index db755c8b0b1..043cd95dc44 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result +++ b/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result @@ -4,6 +4,9 @@ for child3 MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever +set spider_same_server_link=1; +set @old_spider_same_server_link=@@global.spider_same_server_link; +set global spider_same_server_link=1; CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t2 (c int); create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_self_reference_multi",TABLE "t2"'; @@ -23,6 +26,7 @@ select * from t2; ERROR HY000: An infinite loop is detected when opening table test.t0 drop table t0, t1, t2; drop server srv_self_reference_multi; +set global spider_same_server_link=@old_spider_same_server_link; for master_1 for child2 for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/r/signal_ddl_fail.result b/storage/spider/mysql-test/spider/bugfix/r/signal_ddl_fail.result new file mode 100644 index 00000000000..c86e600b2c1 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/signal_ddl_fail.result @@ -0,0 +1,8 @@ +# +# MDEV-32559 Move alter table statements in spider init queries to be executed in the signal_ddl_recovery_done callback +# +select * from mysql.plugin; +name dl +# +# end of test signal_ddl_fail +# diff --git a/storage/spider/mysql-test/spider/bugfix/r/spider_join_with_non_spider.result b/storage/spider/mysql-test/spider/bugfix/r/spider_join_with_non_spider.result index affd3ce7ef9..b537f142295 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/spider_join_with_non_spider.result +++ b/storage/spider/mysql-test/spider/bugfix/r/spider_join_with_non_spider.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t1 (c int); create table t2 (d int); diff --git a/storage/spider/mysql-test/spider/bugfix/r/subquery.result b/storage/spider/mysql-test/spider/bugfix/r/subquery.result index 5c54365c757..2bc55e0ce92 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/subquery.result +++ b/storage/spider/mysql-test/spider/bugfix/r/subquery.result @@ -4,6 +4,7 @@ for master_1 for child2 for child3 +set spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t1 (c1 int); create table t2 (c2 int); diff --git a/storage/spider/mysql-test/spider/bugfix/r/sysvar_params.result b/storage/spider/mysql-test/spider/bugfix/r/sysvar_params.result index c5fe7e680ec..dae04be498c 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/sysvar_params.result +++ b/storage/spider/mysql-test/spider/bugfix/r/sysvar_params.result @@ -5,6 +5,7 @@ for master_1 for child2 for child3 SET @old_spider_read_only_mode = @@session.spider_read_only_mode; +set spider_same_server_link=on; CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); # Cases where table params/options are not set set session spider_read_only_mode = default; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_26151.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_26151.test index 79eb209cbaf..d458a12e6db 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_26151.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_26151.test @@ -14,6 +14,10 @@ --let $srv=srv_mdev_26151 set @old_spider_bgs_mode= @@spider_bgs_mode; set session spider_bgs_mode=1; +set spider_same_server_link=1; +set @old_spider_same_server_link=@@global.spider_same_server_link; +set global spider_same_server_link=1; + evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); # casual_read != 0 && casual_read != 1 @@ -46,6 +50,7 @@ drop table td, ts; eval drop server $srv; set session spider_bgs_mode=@old_spider_bgs_mode; +set global spider_same_server_link=@old_spider_same_server_link; --disable_query_log --disable_result_log diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_26541.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_26541.test index bf6cb255d02..add5f621441 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_26541.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_26541.test @@ -2,10 +2,7 @@ --echo # MDEV-26541 Undefined symbol: _ZTI12ha_partition when attempting to use ha_spider.so in UBSAN builds --echo # -if (`select not(count(*)) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like "%UBSAN%"`) -{ ---skip test needs to be run with UBSAN -} +# this test should be checked with ubsan # init spider @@ -20,4 +17,5 @@ while (!$PLUGIN_EXIST) `SELECT COUNT(*) FROM mysql.func WHERE name = '$PLUGIN_NAME'`; } +--disable_query_log --source ../../include/clean_up_spider.inc diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27575.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_27575.test index cc9b68ad115..79a08489bae 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_27575.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27575.test @@ -7,11 +7,6 @@ --enable_result_log --enable_query_log -# These suppressions are a workaround and should not be needed once -# MDEV-29870 is done. -call mtr.add_suppression("\\[ERROR\\] Table 'mysql.spider_table_sts' doesn't exist"); -call mtr.add_suppression("\\[ERROR\\] Server shutdown in progress"); ---error ER_ILLEGAL_HA_CREATE_OPTION SET GLOBAL default_tmp_storage_engine=spider; --source include/restart_mysqld.inc diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_28739_simple.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_28739_simple.test index fddca792030..29825536a8e 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_28739_simple.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_28739_simple.test @@ -13,6 +13,7 @@ --enable_prepare_warnings set global query_cache_type= on; +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t2 (c int); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test index f23fcdd6c9c..62f59766aae 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test @@ -9,6 +9,7 @@ # This test covers some table params under consideration for inclusion # in the engine-defined options to be implemented in MDEV-28856. +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_28998.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_28998.test index b070fe698cd..04d084b2627 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_28998.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_28998.test @@ -2,19 +2,14 @@ --echo # MDEV-28998 ASAN errors in spider_fields::free_conn_holder or spider_create_group_by_handler --echo # -if (`select not(count(*)) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like "%ASAN%"`) -{ ---skip test needs to be run with ASAN -} +# this test should be checked with ubsan --disable_query_log --disable_result_log --source ../../t/test_init.inc --enable_result_log --enable_query_log -# FIXME: this is a workaround. -set @old_spider_disable_group_by_handler=@@spider_disable_group_by_handler; -set spider_disable_group_by_handler=1; +set spider_same_server_link=1; evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 (a INT); @@ -29,7 +24,6 @@ SELECT * FROM t2; # Cleanup DROP TABLE t2, t1_SPIDER, t1; drop server s; -set spider_disable_group_by_handler=@old_spider_disable_group_by_handler; --disable_query_log --disable_result_log diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29002.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29002.test new file mode 100644 index 00000000000..51620a5a23c --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29002.test @@ -0,0 +1,32 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log +SET spider_same_server_link= on; +evalp CREATE SERVER s FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); + +CREATE TABLE t (a INT); +CREATE TABLE t1_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'"; +CREATE TABLE t2_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'"; +SELECT * FROM t1_spider, t2_spider; +SELECT table_name, index_name, cardinality FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name IN ('t1_spider','t2_spider'); +RENAME TABLE t1_spider TO t3_spider; +SELECT * FROM t3_spider; + +DROP TABLE t3_spider, t2_spider, t; +drop server s; + +# case by roel +CREATE TABLE t1 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"'; +CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"'; +CREATE TABLE t3 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"'; +SHOW TABLE STATUS; +drop table t1, t2, t3; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29163.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29163.test index b2d062c73f1..a4e8d080677 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29163.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29163.test @@ -6,6 +6,7 @@ --source ../../t/test_init.inc --enable_result_log --enable_query_log +set spider_same_server_link=1; evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 (a INT); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29456.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29456.test index 16291f82075..89d53227c6c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29456.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29456.test @@ -8,6 +8,7 @@ --enable_result_log --enable_query_log +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test index f7d67172443..246c405d935 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test @@ -8,6 +8,7 @@ --enable_result_log --enable_query_log +set spider_same_server_link=1; --let $srv=srv_mdev_29502 evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29963.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29963.test index ab7a4ded07c..93b38c7963c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29963.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29963.test @@ -7,6 +7,7 @@ --enable_result_log --enable_query_log +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30014.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30014.test index 4dc3dafab24..9c59adc80dd 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30014.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30014.test @@ -7,6 +7,7 @@ --enable_result_log --enable_query_log +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30170.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30170.test new file mode 100644 index 00000000000..690268432d3 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30170.test @@ -0,0 +1,8 @@ +install soname 'ha_spider'; +--error ER_BAD_TABLE_ERROR +DROP TABLE non_existing_table; +# Test that create or replace a non existing spider table work +create or replace table non_existing_table (c int) engine=Spider; +drop table non_existing_table; +--disable_query_log +--source ../../include/clean_up_spider.inc diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30392.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30392.test index 39401164532..a664c7ecfae 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30392.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30392.test @@ -6,6 +6,7 @@ --source ../../t/test_init.inc --enable_result_log --enable_query_log +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 (a INT); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30981.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30981.test index cc24ce82ce4..ca3f000c819 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30981.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30981.test @@ -2,21 +2,18 @@ --echo # MDEV-30981 Spider UBSAN: null pointer passed as argument 2, which is declared to never be null in spider_create_trx_alter_table on ALTER --echo # -if (`select not(count(*)) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like "%UBSAN%"`) -{ ---skip test needs to be run with UBSAN -} - +# this test should be checked with ubsan + --disable_query_log --disable_result_log --source ../../t/test_init.inc --enable_result_log --enable_query_log - + CREATE TABLE t (c INT) ENGINE=Spider PARTITION BY LIST (c) (PARTITION p VALUES IN (1,2)); ALTER TABLE t ENGINE=InnoDB; drop table t; - + --disable_query_log --disable_result_log --source ../t/test_deinit.inc diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_31338.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_31338.test index 9306c9692a4..6185990230b 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_31338.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_31338.test @@ -9,6 +9,7 @@ --enable_result_log --enable_query_log +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t (c BLOB) ENGINE=InnoDB; CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"'; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_31645.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_31645.test index bc90716e660..b0883f8fd90 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_31645.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_31645.test @@ -8,6 +8,7 @@ --enable_query_log --enable_prepare_warnings +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_31996.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_31996.test index e4fd14c126c..7dfa5af9678 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_31996.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_31996.test @@ -5,6 +5,7 @@ --enable_query_log --enable_prepare_warnings +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_32753_after_start.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_32753_after_start.test index 281d2adce64..de2ab789a28 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_32753_after_start.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_32753_after_start.test @@ -4,6 +4,7 @@ # This test tests spider init after startup under global ORACLE mode install soname 'ha_spider'; +--replace_regex /\.dll/.so/ select * from mysql.plugin; create table t (c int) Engine=SPIDER; drop table t; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_32986.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_32986.test index 94081d24ad8..144387452f7 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_32986.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_32986.test @@ -6,6 +6,7 @@ --source ../../t/test_init.inc --enable_result_log --enable_query_log +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_32999.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_32999.test index 807c70b2f92..b85fe76eb15 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_32999.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_32999.test @@ -6,6 +6,7 @@ --source ../../t/test_init.inc --enable_result_log --enable_query_log +set spider_same_server_link=on; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); --error 12702 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33008.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33008.test new file mode 100644 index 00000000000..48d9a4f01ec --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33008.test @@ -0,0 +1,24 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log +set spider_same_server_link=on; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +); +create table t1 ENGINE=Spider +COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +show create table t1; +drop table t1, t2; + +drop server srv; +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33191.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33191.test new file mode 100644 index 00000000000..90709127f46 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33191.test @@ -0,0 +1,11 @@ +INSTALL SONAME 'ha_spider'; +set spider_same_server_link=on; +CREATE TABLE t2(c INT); +--let $SOCKET=`SELECT @@global.socket` +evalp CREATE TABLE t1(c INT) ENGINE=Spider COMMENT='socket "$SOCKET", user "root", table "t2 t3"'; +ALTER TABLE t1 ENGINE=Spider; +--error ER_NO_SUCH_TABLE +TRUNCATE TABLE t1; +drop table t1, t2; +--disable_query_log +--source ../../include/clean_up_spider.inc diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33441.opt b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441.opt new file mode 100644 index 00000000000..924ea4e31ef --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441.opt @@ -0,0 +1 @@ +--plugin-load-add=ha_spider diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33441.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441.test new file mode 100644 index 00000000000..a2e0ddafe01 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441.test @@ -0,0 +1,10 @@ +--echo # +--echo # MDEV-33441 No spider variables available is Spider is loaded upon server startup +--echo # + +# We test that at least one spider variable exists. +set spider_same_server_link=0; + +--echo # +--echo # end of test mdev_33441 +--echo # diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33441_fail.opt b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441_fail.opt new file mode 100644 index 00000000000..28f1ce4825b --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441_fail.opt @@ -0,0 +1,2 @@ +--plugin-load-add=ha_spider +--debug-dbug=d,fail_spider_init_retry diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33441_fail.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441_fail.test new file mode 100644 index 00000000000..6734b477583 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33441_fail.test @@ -0,0 +1,10 @@ +--source include/have_debug.inc +--echo # +--echo # MDEV-33441 No spider variables available is Spider is loaded upon server startup +--echo # +# We test that when retry fails, spider variables are deleted. +select * from mysql.plugin; +show variables like 'spider%'; +--echo # +--echo # end of test mdev_33441_fail +--echo # diff --git a/storage/spider/mysql-test/spider/bugfix/t/perfschema.opt b/storage/spider/mysql-test/spider/bugfix/t/perfschema.opt index 611d08f0c78..d2ed32ddf34 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/perfschema.opt +++ b/storage/spider/mysql-test/spider/bugfix/t/perfschema.opt @@ -1 +1 @@ ---performance-schema +--loose-performance-schema diff --git a/storage/spider/mysql-test/spider/bugfix/t/perfschema.test b/storage/spider/mysql-test/spider/bugfix/t/perfschema.test index 2f1a961a513..9346d2b5aa3 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/perfschema.test +++ b/storage/spider/mysql-test/spider/bugfix/t/perfschema.test @@ -1,3 +1,4 @@ +source include/have_perfschema.inc; disable_query_log; source ../../include/init_spider.inc; enable_query_log; diff --git a/storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test b/storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test index 2ac927d99b3..4263560baa1 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test +++ b/storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test @@ -8,6 +8,9 @@ --echo MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever --echo +set spider_same_server_link=1; +set @old_spider_same_server_link=@@global.spider_same_server_link; +set global spider_same_server_link=1; --let $srv=srv_self_reference_multi evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t2 (c int); @@ -22,6 +25,7 @@ select * from t1; select * from t2; drop table t0, t1, t2; eval drop server $srv; +set global spider_same_server_link=@old_spider_same_server_link; --disable_query_log --disable_result_log diff --git a/storage/spider/mysql-test/spider/bugfix/t/signal_ddl_fail.opt b/storage/spider/mysql-test/spider/bugfix/t/signal_ddl_fail.opt new file mode 100644 index 00000000000..d883df7bed2 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/signal_ddl_fail.opt @@ -0,0 +1,2 @@ +--plugin-load-add=ha_spider +--debug-dbug=d,fail_spider_ddl_recovery_done diff --git a/storage/spider/mysql-test/spider/bugfix/t/signal_ddl_fail.test b/storage/spider/mysql-test/spider/bugfix/t/signal_ddl_fail.test new file mode 100644 index 00000000000..f13eae3a062 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/signal_ddl_fail.test @@ -0,0 +1,10 @@ +--source include/have_debug.inc +--echo # +--echo # MDEV-32559 Move alter table statements in spider init queries to be executed in the signal_ddl_recovery_done callback +--echo # +# This test tests that failure in ddl_recovery callback causes the +# plugin to be deinitialized. +select * from mysql.plugin; +--echo # +--echo # end of test signal_ddl_fail +--echo # diff --git a/storage/spider/mysql-test/spider/bugfix/t/spider_join_with_non_spider.test b/storage/spider/mysql-test/spider/bugfix/t/spider_join_with_non_spider.test index 59c3f7a73a4..349da90a9e7 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/spider_join_with_non_spider.test +++ b/storage/spider/mysql-test/spider/bugfix/t/spider_join_with_non_spider.test @@ -9,6 +9,7 @@ --enable_query_log --enable_prepare_warnings +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t1 (c int); create table t2 (d int); diff --git a/storage/spider/mysql-test/spider/bugfix/t/subquery.test b/storage/spider/mysql-test/spider/bugfix/t/subquery.test index 3c2823812c0..d40b459702e 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/subquery.test +++ b/storage/spider/mysql-test/spider/bugfix/t/subquery.test @@ -8,6 +8,7 @@ --enable_query_log --enable_prepare_warnings +set spider_same_server_link=1; evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); create table t1 (c1 int); create table t2 (c2 int); diff --git a/storage/spider/mysql-test/spider/bugfix/t/sysvar_params.test b/storage/spider/mysql-test/spider/bugfix/t/sysvar_params.test index f01c6c11ad6..96c0338f80a 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/sysvar_params.test +++ b/storage/spider/mysql-test/spider/bugfix/t/sysvar_params.test @@ -12,6 +12,7 @@ # including a mix of different levels (partition vs table), see # spider/features.engine_defined_attributes. SET @old_spider_read_only_mode = @@session.spider_read_only_mode; +set spider_same_server_link=on; evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); --echo # Cases where table params/options are not set diff --git a/storage/spider/mysql-test/spider/include/clean_up_spider.inc b/storage/spider/mysql-test/spider/include/clean_up_spider.inc index 249606ec774..1c977bfb66f 100644 --- a/storage/spider/mysql-test/spider/include/clean_up_spider.inc +++ b/storage/spider/mysql-test/spider/include/clean_up_spider.inc @@ -3,6 +3,7 @@ DROP FUNCTION spider_copy_tables; DROP FUNCTION spider_ping_table; DROP FUNCTION spider_bg_direct_sql; DROP FUNCTION spider_direct_sql; +--replace_regex /\.dll/.so/ UNINSTALL SONAME IF EXISTS 'ha_spider'; DROP TABLE IF EXISTS mysql.spider_xa; DROP TABLE IF EXISTS mysql.spider_xa_member; diff --git a/storage/spider/mysql-test/spider/r/timestamp.result b/storage/spider/mysql-test/spider/r/timestamp.result index 50603a9a1ed..3eb4d1dab1c 100644 --- a/storage/spider/mysql-test/spider/r/timestamp.result +++ b/storage/spider/mysql-test/spider/r/timestamp.result @@ -261,7 +261,7 @@ select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timest select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (_latin1'2018-10-28 01:30:00' > t0.`col_ts`) select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00')) -select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00') +select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2018-03-25 01:00:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01') SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; @@ -348,7 +348,7 @@ select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timest select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (_latin1'2018-10-28 01:30:00' > t0.`col_ts`) select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00')) -select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00') +select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2018-03-25 01:00:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01') SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; diff --git a/storage/spider/mysql-test/spider/r/variable_deprecation.result b/storage/spider/mysql-test/spider/r/variable_deprecation.result index d832722ed4e..2ef96e93d09 100644 --- a/storage/spider/mysql-test/spider/r/variable_deprecation.result +++ b/storage/spider/mysql-test/spider/r/variable_deprecation.result @@ -79,8 +79,6 @@ Warning 1287 '@@spider_load_crd_at_startup' is deprecated and will be removed in SHOW VARIABLES LIKE "spider_load_crd_at_startup"; Variable_name Value spider_load_crd_at_startup 0 -DROP TABLE tbl_a; -DROP TABLE tbl_b; # MDEV-28008 Deprecate spider_crd_mode and spider_sts_mode SET spider_crd_mode = 1; Warnings: diff --git a/storage/spider/mysql-test/spider/t/variable_deprecation.test b/storage/spider/mysql-test/spider/t/variable_deprecation.test index 3ed8dcf5ec6..6159b25b053 100644 --- a/storage/spider/mysql-test/spider/t/variable_deprecation.test +++ b/storage/spider/mysql-test/spider/t/variable_deprecation.test @@ -47,9 +47,6 @@ SHOW VARIABLES LIKE "spider_load_sts_at_startup"; SET GLOBAL spider_load_crd_at_startup = 0; SHOW VARIABLES LIKE "spider_load_crd_at_startup"; -DROP TABLE tbl_a; -DROP TABLE tbl_b; - --echo # MDEV-28008 Deprecate spider_crd_mode and spider_sts_mode SET spider_crd_mode = 1; SHOW VARIABLES LIKE "spider_crd_mode"; diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index d8288ef1383..b2079f5286f 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -1199,13 +1199,7 @@ int spider_conn_queue_and_merge_loop_check( lcptr->flag = SPIDER_LOP_CHK_MERAGED; lcptr->next = NULL; if (!conn->loop_check_meraged_first) - { conn->loop_check_meraged_first = lcptr; - conn->loop_check_meraged_last = lcptr; - } else { - conn->loop_check_meraged_last->next = lcptr; - conn->loop_check_meraged_last = lcptr; - } } DBUG_RETURN(0); @@ -1298,7 +1292,7 @@ int spider_conn_queue_loop_check( loop_check_buf[lex_str.length] = '\0'; DBUG_PRINT("info", ("spider param name=%s", lex_str.str)); loop_check = get_variable(&thd->user_vars, &lex_str, FALSE); - if (!loop_check || loop_check->type != STRING_RESULT) + if (!loop_check || loop_check->type_handler()->result_type() != STRING_RESULT) { DBUG_PRINT("info", ("spider client is not Spider")); lex_str.str = ""; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index f9cf8a9c294..c786bd42746 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -6522,7 +6522,7 @@ int spider_db_delete_all_rows( spider->conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { - uint dbton_id = share->use_sql_dbton_ids[roop_count]; + uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[dbton_id]; conn = spider->conns[roop_count]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 92e8ae208ef..d384e54ff6f 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -1640,6 +1640,12 @@ static const LEX_CSTRING maturity_name[] = { STRING_WITH_LEN("Stable") } }; +/* + Type of singletons based on the type of the remote database. + + All such singletons are stored in the array `spider_dbton', see + `spider_db_init()'. +*/ typedef struct st_spider_dbton { /** The index of this dbton in `spider_dbton` */ diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index c156a0ededc..45ff1e1d480 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -1531,10 +1531,13 @@ int spider_db_mbase_result::fetch_index_for_discover_table_structure( } DBUG_RETURN(0); } - if (num_fields() != 13) + if (num_fields() < 13) { - DBUG_PRINT("info",("spider num_fields != 13")); - my_printf_error(ER_SPIDER_UNKNOWN_NUM, ER_SPIDER_UNKNOWN_STR, MYF(0)); + DBUG_PRINT("info",("spider num_fields < 13")); + my_printf_error(ER_SPIDER_CANT_NUM, ER_SPIDER_CANT_STR1, MYF(0), + "fetch index for table structure discovery because of " + "wrong number of columns in SHOW INDEX FROM output: ", + num_fields()); DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); } bool first = TRUE; @@ -1929,7 +1932,7 @@ int spider_db_mbase::connect( if (!spider_param_same_server_link(thd)) { - if (!strcmp(tgt_host, my_localhost)) + if (!strcmp(tgt_host, my_localhost) || !tgt_host || !tgt_host[0]) { if (!strcmp(tgt_socket, *spd_mysqld_unix_port)) { @@ -1939,7 +1942,7 @@ int spider_db_mbase::connect( DBUG_RETURN(ER_SPIDER_SAME_SERVER_LINK_NUM); } } else if (!strcmp(tgt_host, "127.0.0.1") || - !strcmp(tgt_host, glob_hostname)) + !strcmp(tgt_host, glob_hostname) || !tgt_host || !tgt_host[0]) { if (tgt_port == (long) *spd_mysqld_port) { diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 8ce18e401b0..b46a593f391 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -793,7 +793,6 @@ typedef struct st_spider_conn SPIDER_CONN_LOOP_CHECK *loop_check_ignored_first; SPIDER_CONN_LOOP_CHECK *loop_check_ignored_last; SPIDER_CONN_LOOP_CHECK *loop_check_meraged_first; - SPIDER_CONN_LOOP_CHECK *loop_check_meraged_last; } SPIDER_CONN; typedef struct st_spider_lgtm_tblhnd_share @@ -1230,6 +1229,7 @@ typedef struct st_spider_share uint *tgt_pk_names_lengths; uint *tgt_sequence_names_lengths; uint *conn_keys_lengths; + /* The index in `spider_dbton' of each data node link. */ uint *sql_dbton_ids; uint server_names_charlen; @@ -1305,10 +1305,16 @@ typedef struct st_spider_share /* Number of `SPIDER_DBTON`s used */ uint use_dbton_count; /* Index of each `SPIDER_DBTON` in `spider_dbton` to use */ + /* Actual size is `use_dbton_count'. Values are the indices of item + in `spider_dbton'. */ uint use_dbton_ids[SPIDER_DBTON_SIZE]; + /* Inverse map of `use_dbton_ids'. */ uint dbton_id_to_seq[SPIDER_DBTON_SIZE]; uint use_sql_dbton_count; + /* Actual size is `use_sql_dbton_count'. Values are the indices of + item in `spider_dbton'. */ uint use_sql_dbton_ids[SPIDER_DBTON_SIZE]; + /* Inverse map of `use_sql_dbton_ids'. */ uint sql_dbton_id_to_seq[SPIDER_DBTON_SIZE]; SPIDER_ALTER_TABLE alter_table; diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 4e217fcc577..f05c08de12b 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -110,7 +110,7 @@ extern volatile ulonglong spider_mon_table_cache_version_req; } extern handlerton *spider_hton_ptr; -static void spider_trx_status_var(THD *thd, SHOW_VAR *var, char *buff, +static void spider_trx_status_var(THD *thd, SHOW_VAR *var, void *buff, ulonglong SPIDER_TRX::*counter) { DBUG_ENTER("spider_direct_update"); @@ -126,35 +126,40 @@ static void spider_trx_status_var(THD *thd, SHOW_VAR *var, char *buff, } -static int spider_direct_update(THD *thd, SHOW_VAR *var, char *buff) +static int spider_direct_update(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { DBUG_ENTER("spider_direct_update"); spider_trx_status_var(thd, var, buff, &SPIDER_TRX::direct_update_count); DBUG_RETURN(0); } -static int spider_direct_delete(THD *thd, SHOW_VAR *var, char *buff) +static int spider_direct_delete(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { DBUG_ENTER("spider_direct_delete"); spider_trx_status_var(thd, var, buff, &SPIDER_TRX::direct_delete_count); DBUG_RETURN(0); } -static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, char *buff) +static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { DBUG_ENTER("spider_direct_order_limit"); spider_trx_status_var(thd, var, buff, &SPIDER_TRX::direct_order_limit_count); DBUG_RETURN(0); } -static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, char *buff) +static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { DBUG_ENTER("spider_direct_aggregate"); spider_trx_status_var(thd, var, buff, &SPIDER_TRX::direct_aggregate_count); DBUG_RETURN(0); } -static int spider_parallel_search(THD *thd, SHOW_VAR *var, char *buff) +static int spider_parallel_search(THD *thd, SHOW_VAR *var, void *buff, + system_status_var *, enum_var_type) { DBUG_ENTER("spider_parallel_search"); spider_trx_status_var(thd, var, buff, &SPIDER_TRX::parallel_search_count); diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index af3371cd040..08eea15a76e 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -1764,6 +1764,16 @@ int spider_delete_xa_member( DBUG_RETURN(0); } +/** + Delete a Spider table from mysql.spider_tables. + + @param table The table mysql.spider_tables + @param name The name of the Spider table to delete + @param old_link_count The number of links in the deleted table + + @retval 0 Success + @retval nonzero Failure +*/ int spider_delete_tables( TABLE *table, const char *name, @@ -1779,10 +1789,20 @@ int spider_delete_tables( { spider_store_tables_link_idx(table, roop_count); if ((error_num = spider_check_sys_table(table, table_key))) - break; + { + /* There's a problem with finding the first record for the + spider table, likely because it does not exist. Fail */ + if (roop_count == 0) + DBUG_RETURN(error_num); + /* At least one row has been deleted for the Spider table. + Success */ + else + break; + } else { if ((error_num = spider_delete_sys_table_row(table))) { + /* There's a problem deleting the row. Fail */ DBUG_RETURN(error_num); } } diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index ce3f01a17fa..f2682e8b39d 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -4973,7 +4973,7 @@ int spider_check_for_self_reference(THD *thd, const TABLE_SHARE *share) DBUG_PRINT("info",("spider loop check param name=%s", target.c_ptr())); key = target.to_lex_cstring(); const user_var_entry *loop_check= get_variable(&thd->user_vars, &key, FALSE); - if (loop_check && loop_check->type == STRING_RESULT) + if (loop_check && loop_check->type_handler()->result_type() == STRING_RESULT) { String expected(0); expected.append(spider_unique_id); @@ -6544,9 +6544,10 @@ bool spider_init_system_tables() Spider is typically loaded before ddl_recovery, but DDL statements cannot be executed before ddl_recovery, so we delay system table creation. */ -static void spider_after_ddl_recovery(handlerton *) +static int spider_after_ddl_recovery(handlerton *) { - spider_init_system_tables(); + DBUG_EXECUTE_IF("fail_spider_ddl_recovery_done", return 1;); + return spider_init_system_tables(); } int spider_db_init( @@ -6568,16 +6569,6 @@ int spider_db_init( #ifdef HTON_CAN_READ_CONNECT_STRING_IN_PARTITION spider_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION; #endif - /* spider_hton->db_type = DB_TYPE_SPIDER; */ - /* - spider_hton->savepoint_offset; - spider_hton->savepoint_set = spider_savepoint_set; - spider_hton->savepoint_rollback = spider_savepoint_rollback; - spider_hton->savepoint_release = spider_savepoint_release; - spider_hton->create_cursor_read_view = spider_create_cursor_read_view; - spider_hton->set_cursor_read_view = spider_set_cursor_read_view; - spider_hton->close_cursor_read_view = spider_close_cursor_read_view; - */ spider_hton->panic = spider_panic; spider_hton->signal_ddl_recovery_done= spider_after_ddl_recovery; spider_hton->close_connection = spider_close_connection; @@ -6636,10 +6627,6 @@ int spider_db_init( if (pthread_attr_init(&spider_pt_attr)) goto error_pt_attr_init; -/* - if (pthread_attr_setdetachstate(&spider_pt_attr, PTHREAD_CREATE_DETACHED)) - goto error_pt_attr_setstate; -*/ if (mysql_mutex_init(spd_key_mutex_tbl, &spider_tbl_mutex, MY_MUTEX_INIT_FAST)) diff --git a/strings/json_lib.c b/strings/json_lib.c index 47e0843d627..e1203296f6d 100644 --- a/strings/json_lib.c +++ b/strings/json_lib.c @@ -482,12 +482,12 @@ enum json_num_states { static int json_num_states[NS_NUM_STATES][N_NUM_CLASSES]= { -/* - + 0 1..9 POINT E END_OK ERROR */ +/* - + 0 1..9 POINT E END_OK ERROR */ /*OK*/ { JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_BAD_CHR }, /*GO*/ { NS_GO1, JE_SYN, NS_Z, NS_INT, JE_SYN, JE_SYN, JE_SYN, JE_BAD_CHR }, /*GO1*/ { JE_SYN, JE_SYN, NS_Z1, NS_INT, JE_SYN, JE_SYN, JE_SYN, JE_BAD_CHR }, -/*ZERO*/ { JE_SYN, JE_SYN, JE_SYN, JE_SYN, NS_FRAC, JE_SYN, NS_OK, JE_BAD_CHR }, -/*ZE1*/ { JE_SYN, JE_SYN, JE_SYN, JE_SYN, NS_FRAC, JE_SYN, NS_OK, JE_BAD_CHR }, +/*ZERO*/ { JE_SYN, JE_SYN, JE_SYN, JE_SYN, NS_FRAC, NS_EX, NS_OK, JE_BAD_CHR }, +/*ZE1*/ { JE_SYN, JE_SYN, JE_SYN, JE_SYN, NS_FRAC, NS_EX, NS_OK, JE_BAD_CHR }, /*INT*/ { JE_SYN, JE_SYN, NS_INT, NS_INT, NS_FRAC, NS_EX, NS_OK, JE_BAD_CHR }, /*FRAC*/ { JE_SYN, JE_SYN, NS_FRAC, NS_FRAC,JE_SYN, NS_EX, NS_OK, JE_BAD_CHR }, /*EX*/ { NS_EX, NS_EX, NS_EX1, NS_EX1, JE_SYN, JE_SYN, JE_SYN, JE_BAD_CHR }, diff --git a/unittest/embedded/CMakeLists.txt b/unittest/embedded/CMakeLists.txt index cf48550c377..428bb811de6 100644 --- a/unittest/embedded/CMakeLists.txt +++ b/unittest/embedded/CMakeLists.txt @@ -1,7 +1,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${MY_READLINE_INCLUDE_DIR} )