diff --git a/CMakeLists.txt b/CMakeLists.txt index 40023f28cf5..56975f82b32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ ENDIF() # in RPM's: #set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true") -FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0056 CMP0067 CMP0074 CMP0075 CMP0069 CMP0135) +FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0056 CMP0067 CMP0074 CMP0075 CMP0069 CMP0135 CMP0091) IF(POLICY ${p}) CMAKE_POLICY(SET ${p} NEW) ENDIF() diff --git a/appveyor.yml b/appveyor.yml index a0b1d132394..cf220c17862 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,42 @@ version: build-{build}~branch-{branch} -clone_depth: 1 +clone_depth: 10 + +skip_branch_with_pr: true +before_build: + - ps: | + function Get-Remote-Ref($ref) { + try { + $result = git ls-remote origin $ref 2>$null + if (-not $result) { + "Warning: Could not fetch remote ref '$ref'" + return $null + } + return ($result -split "`t")[0] + } catch { + "Warning: Exception while running git ls-remote for '$ref': $_" + return $null + } + } + Get-ChildItem Env: | Where-Object { $_.Name -like 'APPVEYOR*COMMIT' } | ForEach-Object { "$($_.Name)=$($_.Value)" } + $commit = $env:APPVEYOR_REPO_COMMIT + $commit2 = $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT + $branch = $env:APPVEYOR_REPO_BRANCH + $latest = $null + $mainBranch = $branch -match '^(main|\d+\.\d+)$' + if ($env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null) { + "Branch build detected" + $latest = Get-Remote-Ref "refs/heads/$branch" + } else { + $pr = $env:APPVEYOR_PULL_REQUEST_NUMBER + $latest = Get-Remote-Ref "refs/pull/$pr/head" + $mainBranch = $False + "Pull Request build detected" + } + if ($latest -and ($commit -ne $latest) -and ($commit2 -ne $latest) -and (-not $mainBranch)) { + "Skipping outdated commit (latest is $latest)" + Exit-AppVeyorBuild + } environment: OPENSSL_ROOT_DIR: C:/OpenSSL-v32-Win64 diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d16358166fc..13a9b76f4f7 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -162,7 +162,13 @@ static Server_gtid_event_filter *server_id_gtid_filter= NULL; static char *start_datetime_str, *stop_datetime_str; static my_time_t start_datetime= 0, stop_datetime= MY_TIME_T_MAX; -static my_time_t last_processed_datetime= MY_TIME_T_MAX; + +typedef struct _last_processed_ev_t +{ + ulonglong position; + my_time_t datetime; +} last_processed_ev_t; +static last_processed_ev_t last_processed_ev= {0, MY_TIME_T_MAX}; static ulonglong rec_count= 0; static MYSQL* mysql = NULL; @@ -1370,7 +1376,19 @@ err: end: rec_count++; end_skip_count: - last_processed_datetime= ev_when; + /* + Update the last_processed_ev, unless the event is a fake event (i.e. format + description (ev pointer is reset to 0) or rotate event (ev->when is 0)), or + the event is encrypted (i.e. type is Unknown). + */ + if (ev && + !(ev_type == UNKNOWN_EVENT && + ((Unknown_log_event *) ev)->what == Unknown_log_event::ENCRYPTED) && + !(ev_type == ROTATE_EVENT && !ev->when)) + { + last_processed_ev.position= pos + ev->data_written; + last_processed_ev.datetime= ev_when; + } DBUG_PRINT("info", ("end event processing")); /* @@ -2654,6 +2672,9 @@ static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info, if (old_off != BIN_LOG_HEADER_SIZE) *len= 1; // fake event, don't increment old_off } + DBUG_ASSERT(old_off + ev->data_written == old_off + (*len - 1) || + (*len == 1 && + (type == ROTATE_EVENT || type == FORMAT_DESCRIPTION_EVENT))); Exit_status retval= process_event(print_event_info, ev, old_off, logname); if (retval != OK_CONTINUE) DBUG_RETURN(retval); @@ -3028,6 +3049,8 @@ static Exit_status check_header(IO_CACHE* file, the new one, so we should not do it ourselves in this case. */ + DBUG_ASSERT(tmp_pos + new_description_event->data_written == + my_b_tell(file)); Exit_status retval= process_event(print_event_info, new_description_event, tmp_pos, logname); @@ -3181,20 +3204,17 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, } // else read_error == 0 means EOF, that's OK, we break in this case - /* - Emit a warning in the event that we finished processing input - before reaching the boundary indicated by --stop-position. - */ - if (((longlong)stop_position != stop_position_default) && - stop_position > my_b_tell(file)) - { - retval = OK_STOP; - warning("Did not reach stop position %llu before " - "end of input", stop_position); - } - goto end; } + + /* + The real location that we have read up to in the file should align with + the size of the event, unless the event is encrypted. + */ + DBUG_ASSERT( + ((ev->get_type_code() == UNKNOWN_EVENT && + ((Unknown_log_event *) ev)->what == Unknown_log_event::ENCRYPTED)) || + old_off + ev->data_written == my_b_tell(file)); if ((retval= process_event(print_event_info, ev, old_off, logname)) != OK_CONTINUE) goto end; @@ -3373,10 +3393,18 @@ int main(int argc, char** argv) start_position= BIN_LOG_HEADER_SIZE; } + /* + Emit a warning if we finished processing input before reaching the stop + boundaries indicated by --stop-datetime or --stop-position. + */ if (stop_datetime != MY_TIME_T_MAX && - stop_datetime > last_processed_datetime) + stop_datetime > last_processed_ev.datetime) warning("Did not reach stop datetime '%s' before end of input", stop_datetime_str); + if ((static_cast(stop_position) != stop_position_default) && + stop_position > last_processed_ev.position) + warning("Did not reach stop position %llu before end of input", + stop_position); /* If enable flashback, need to print the events from the end to the diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index cde918d7089..9ef59bf20e5 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -265,7 +265,7 @@ IF(WITH_WSREP) "galera-4" "rsync" "grep" "gawk" "iproute" "coreutils" "findutils" "tar") SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof" "socat" "pv") - SETA(CPACK_RPM_test_PACKAGE_REQUIRES "socat") + SETA(CPACK_RPM_test_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}" "socat") ENDIF() SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh) @@ -312,7 +312,7 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7") ALTERNATIVE_NAME("server" "mariadb-server") ALTERNATIVE_NAME("server" "mysql-compat-server") ALTERNATIVE_NAME("test" "mariadb-test") -ELSEIF(RPM MATCHES "(rhel|centos|rocky)[89]") +ELSEIF(RPM MATCHES "(rhel|centos|rocky)") SET(epoch 3:) ALTERNATIVE_NAME("backup" "mariadb-backup") ALTERNATIVE_NAME("client" "mariadb") diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 510413d915c..cdb16cde468 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -15,372 +15,212 @@ # This file includes Windows specific hacks, mostly around compiler flags -INCLUDE (CheckCSourceCompiles) -INCLUDE (CheckCXXSourceCompiles) -INCLUDE (CheckStructHasMember) -INCLUDE (CheckLibraryExists) -INCLUDE (CheckFunctionExists) -INCLUDE (CheckCSourceRuns) -INCLUDE (CheckSymbolExists) -INCLUDE (CheckTypeSize) -IF(MSVC) - IF(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL ARM64) - SET(MSVC_ARM64 1) - SET(MSVC_INTEL 0) - ELSE() - SET(MSVC_INTEL 1) - ENDIF() -ENDIF() +if(MSVC) + if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL ARM64) + set(MSVC_ARM64 1) + set(MSVC_INTEL 0) + else() + set(MSVC_INTEL 1) + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL Clang) + set(CLANG_CL TRUE) + endif() +endif() # avoid running system checks by using pre-cached check results # system checks are expensive on VS since every tiny program is to be compiled in # a VC solution. -GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake) - +get_filename_component(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +include(${_SCRIPT_DIR}/WindowsCache.cmake) # OS display name (version_compile_os etc). -# Used by the test suite to ignore bugs on some platforms, -IF(CMAKE_SIZEOF_VOID_P MATCHES 8) - SET(SYSTEM_TYPE "Win64") -ELSE() - SET(SYSTEM_TYPE "Win32") -ENDIF() +# Used by the test suite to ignore bugs on some platforms +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(SYSTEM_TYPE "Win64") +else() + set(SYSTEM_TYPE "Win32") +endif() -# Intel compiler is almost Visual C++ -# (same compile flags etc). Set MSVC flag -IF(CMAKE_C_COMPILER MATCHES "icl") - SET(MSVC TRUE) -ENDIF() +function(find_asan_runtime result_list) + set(${result_list} "" PARENT_SCOPE) + if(CMAKE_C_COMPILER_VERSION) + set(CLANG_VERSION "${CMAKE_C_COMPILER_VERSION}") + else() + return() + endif() -IF(MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang) - SET(CLANG_CL TRUE) -ENDIF() + get_filename_component(CLANG_BIN_DIR "${CMAKE_C_COMPILER}" DIRECTORY) + get_filename_component(LLVM_ROOT "${CLANG_BIN_DIR}" DIRECTORY) -ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) -ADD_DEFINITIONS(-D_WIN32_WINNT=0x0A00) -# We do not want the windows.h , or winsvc.h macros min/max -ADD_DEFINITIONS(-DNOMINMAX -DNOSERVICE) -# Speed up build process excluding unused header files -ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN) - -# Adjust compiler and linker flags -IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4) - # mininal architecture flags, i486 enables GCC atomics - ADD_DEFINITIONS(-march=i486) -ENDIF() - -MACRO(ENABLE_SANITIZERS) - IF(NOT MSVC) - MESSAGE(FATAL_ERROR "clang-cl or MSVC necessary to enable asan/ubsan") - ENDIF() - # currently, asan is broken with static CRT. - IF(CLANG_CL AND NOT(MSVC_CRT_TYPE STREQUAL "/MD")) - SET(MSVC_CRT_TYPE "/MD" CACHE INTERNAL "" FORCE) - ENDIF() - IF(CMAKE_SIZEOF_VOID_P EQUAL 4) - SET(ASAN_ARCH i386) - ELSE() - SET(ASAN_ARCH x86_64) - ENDIF() - - # After installation, clang lib directory should be added to PATH - # (e.g C:/Program Files/LLVM/lib/clang/5.0.1/lib/windows) - SET(SANITIZER_LIBS) - SET(SANITIZER_LINK_LIBRARIES) - SET(SANITIZER_COMPILE_FLAGS) - IF(WITH_ASAN) - IF(CLANG_CL) - LIST(APPEND SANITIZER_LIBS - clang_rt.asan_dynamic-${ASAN_ARCH}.lib clang_rt.asan_dynamic_runtime_thunk-${ASAN_ARCH}.lib) - ENDIF() - STRING(APPEND SANITIZER_COMPILE_FLAGS " -fsanitize=address") - ENDIF() - IF(WITH_UBSAN) - STRING(APPEND SANITIZER_COMPILE_FLAGS " -fsanitize=undefined -fno-sanitize=alignment") - ENDIF() - FOREACH(lib ${SANITIZER_LIBS}) - FIND_LIBRARY(${lib}_fullpath ${lib}) - IF(NOT ${lib}_fullpath) - MESSAGE(FATAL_ERROR "Can't enable sanitizer : missing ${lib}") - ENDIF() - LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${${lib}_fullpath}) - STRING(APPEND CMAKE_C_STANDARD_LIBRARIES " \"${${lib}_fullpath}\" ") - STRING(APPEND CMAKE_CXX_STANDARD_LIBRARIES " \"${${lib}_fullpath}\" ") - ENDFOREACH() - STRING(APPEND CMAKE_C_FLAGS ${SANITIZER_COMPILE_FLAGS}) - STRING(APPEND CMAKE_CXX_FLAGS ${SANITIZER_COMPILE_FLAGS}) -ENDMACRO() - - -IF(MSVC) - IF(MSVC_VERSION LESS 1920) - MESSAGE(FATAL_ERROR "Visual Studio 2019 or later is required") - ENDIF() - # Disable mingw based pkg-config found in Strawberry perl - SET(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "") - - SET(MSVC_CRT_TYPE /MD CACHE STRING - "Runtime library - specify runtime library for linking (/MT,/MTd,/MD,/MDd)" + # Determine target architecture + execute_process( + COMMAND "${CMAKE_C_COMPILER}" --version + OUTPUT_VARIABLE CLANG_VERSION_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) - SET(VALID_CRT_TYPES /MTd /MDd /MD /MT) - IF (NOT ";${VALID_CRT_TYPES};" MATCHES ";${MSVC_CRT_TYPE};") - MESSAGE(FATAL_ERROR "Invalid value ${MSVC_CRT_TYPE} for MSVC_CRT_TYPE, choose one of /MT,/MTd,/MD,/MDd ") - ENDIF() - # CMake version 3.15 and later uses CMAKE_MSVC_RUNTIME_LIBRARY - # variable for our MSVC_CRT_TYPE. - # Set CMAKE_MSVC_RUNTIME_LIBRARY and pass to external projects - # it is important to keep the same CRT type when linking - # - # Translation rules MSVC_CRT_TYPE -> CMAKE_MSVC_RUNTIME_LIBRARY - # /MT -> MultiThreaded - # /MTd -> MultiThreadedDebug - # /MD -> MultiThreadedDLL - # /MDd -> MultiThreadedDebugDLL + if(CLANG_VERSION_OUTPUT MATCHES "x86_64") + set(ARCH_SUFFIX "x86_64") + elseif(CLANG_VERSION_OUTPUT MATCHES "i686|i386") + set(ARCH_SUFFIX "i386") + elseif(CLANG_VERSION_OUTPUT MATCHES "aarch64") + set(ARCH_SUFFIX "aarch64") + else() + message(FATAL_ERROR "unknown arch") + endif() - SET(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) - IF(MSVC_CRT_TYPE MATCHES "d$") - STRING(APPEND CMAKE_MSVC_RUNTIME_LIBRARY Debug) - ENDIF() - IF(MSVC_CRT_TYPE MATCHES "D") - STRING(APPEND CMAKE_MSVC_RUNTIME_LIBRARY DLL) - ENDIF() + string(REGEX MATCH "^[0-9]+" CLANG_MAJOR_VERSION "${CMAKE_C_COMPILER_VERSION}") + set(CLANG_VERSION_DIR "${LLVM_ROOT}/lib/clang/${CLANG_MAJOR_VERSION}") - IF(MSVC_CRT_TYPE MATCHES "/MD") - # Dynamic runtime (DLLs), need to install CRT libraries. - SET(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT VCCRT) - SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS TRUE) - IF(MSVC_CRT_TYPE STREQUAL "/MDd") - SET (CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE) - ENDIF() - INCLUDE(InstallRequiredSystemLibraries) - ENDIF() - - IF(WITH_ASAN AND (NOT CLANG_CL)) - SET(DYNAMIC_UCRT_LINK_DEFAULT OFF) - ELSE() - SET(DYNAMIC_UCRT_LINK_DEFAULT ON) - ENDIF() - - OPTION(DYNAMIC_UCRT_LINK "Link Universal CRT dynamically, if MSVC_CRT_TYPE=/MT" ${DYNAMIC_UCRT_LINK_DEFAULT}) - SET(DYNAMIC_UCRT_LINKER_OPTION " /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") - - # Enable debug info also in Release build, - # and create PDB to be able to analyze crashes. - FOREACH(type EXE SHARED MODULE) - SET(CMAKE_${type}_LINKER_FLAGS_RELEASE - "${CMAKE_${type}_LINKER_FLAGS_RELEASE} /debug") - SET(CMAKE_${type}_LINKER_FLAGS_MINSIZEREL - "${CMAKE_${type}_LINKER_FLAGS_MINSIZEREL} /debug") - ENDFOREACH() - - # Force runtime libraries - # Compile with /Zi to get debugging information - - FOREACH(lang C CXX) - SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Zi") - ENDFOREACH() - FOREACH(flag - CMAKE_C_FLAGS CMAKE_CXX_FLAGS - CMAKE_C_FLAGS_INIT CMAKE_CXX_FLAGS_INIT - CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT - CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT - CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL - ) - STRING(REGEX REPLACE "/M[TD][d]?" "${MSVC_CRT_TYPE}" "${flag}" "${${flag}}" ) - STRING(REPLACE "/ZI " "/Zi " "${flag}" "${${flag}}") - IF((NOT "${${flag}}" MATCHES "/Zi") AND (NOT "${${flag}}" MATCHES "/Z7")) - STRING(APPEND ${flag} " /Zi") - ENDIF() - # Remove inlining flags, added by CMake, if any. - # Compiler default is fine. - STRING(REGEX REPLACE "/Ob[0-3]" "" "${flag}" "${${flag}}" ) - ENDFOREACH() - - # Allow to overwrite the inlining flag - SET(MSVC_INLINE "" CACHE STRING - "MSVC Inlining option, either empty, or one of /Ob0,/Ob1,/Ob2,/Ob3") - IF(MSVC_INLINE MATCHES "/Ob[0-3]") - ADD_COMPILE_OPTIONS(${MSVC_INLINE}) - ELSEIF(NOT(MSVC_INLINE STREQUAL "")) - MESSAGE(FATAL_ERROR "Invalid option for MSVC_INLINE") - ENDIF() - - IF(WITH_ASAN OR WITH_UBSAN) - # Workaround something Linux specific - SET(SECURITY_HARDENED 0 CACHE INTERNAL "" FORCE) - ENABLE_SANITIZERS() - ENDIF() - - IF(CLANG_CL) - SET(CLANG_CL_FLAGS -"-Wno-unknown-warning-option -Wno-unused-private-field \ --Wno-unused-parameter -Wno-inconsistent-missing-override \ --Wno-unused-command-line-argument -Wno-pointer-sign \ --Wno-deprecated-register -Wno-missing-braces \ --Wno-unused-function -Wno-unused-local-typedef -msse4.2 " - ) - IF(CMAKE_SIZEOF_VOID_P MATCHES 8) - STRING(APPEND CLANG_CL_FLAGS "-mpclmul ") + set(out) + foreach(name clang_rt.asan_dynamic-${ARCH_SUFFIX}.lib + clang_rt.asan_dynamic_runtime_thunk-${ARCH_SUFFIX}.lib) + set(path "${CLANG_VERSION_DIR}/lib/windows/${name}") + if(EXISTS "${path}") + list(APPEND out ${path}) + else() + message(FATAL_ERROR "expected library ${path} not found") ENDIF() - STRING(APPEND CMAKE_C_FLAGS " ${CLANG_CL_FLAGS} ${MSVC_CRT_TYPE}") - STRING(APPEND CMAKE_CXX_FLAGS " ${CLANG_CL_FLAGS} ${MSVC_CRT_TYPE}") - ENDIF() + endforeach() + set(${result_list} ${out} PARENT_SCOPE) +endfunction() - FOREACH(type EXE SHARED MODULE) - STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}") - IF(WITH_ASAN) - SET(build_types RELWITHDEBINFO DEBUG) - ELSE() - SET(build_types RELWITHDEBINFO) - ENDIF() - FOREACH(btype ${build_types}) - STRING(REGEX REPLACE "/INCREMENTAL:([^ ]+)" "/INCREMENTAL:NO" CMAKE_${type}_LINKER_FLAGS_${btype} "${CMAKE_${type}_LINKER_FLAGS_${btype}}") - STRING(REGEX REPLACE "/INCREMENTAL$" "/INCREMENTAL:NO" CMAKE_${type}_LINKER_FLAGS_${btype} "${CMAKE_${type}_LINKER_FLAGS_${btype}}") - ENDFOREACH() - IF(NOT CLANG_CL) - STRING(APPEND CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO " /release /OPT:REF,ICF") - ENDIF() - IF(DYNAMIC_UCRT_LINK AND (MSVC_CRT_TYPE STREQUAL "/MT")) - FOREACH(config RELEASE RELWITHDEBINFO DEBUG MINSIZEREL) - STRING(APPEND CMAKE_${type}_LINKER_FLAGS_${config} ${DYNAMIC_UCRT_LINKER_OPTION}) - ENDFOREACH() - ENDIF() - ENDFOREACH() +macro(enable_sanitizers) + # Remove the runtime checks from the compiler flags + # ASAN does the same thing, in many cases better + foreach(lang C CXX) + foreach(suffix "_DEBUG" "_DEBUG_INIT") + string(REGEX REPLACE "/RTC[1su]" "" CMAKE_${lang}_FLAGS${suffix} "${CMAKE_${lang}_FLAGS${suffix}}") + endforeach() + endforeach() + + if(WITH_ASAN) + add_compile_options($<$:/fsanitize=address>) + endif() + if(WITH_UBSAN) + include(CheckCCompilerFlag) + check_c_compiler_flag(/fsanitize=undefined HAVE_fsanitize_undefined) + if (HAVE_fsanitize_undefined) + add_compile_options($<$:/fsanitize=undefined>) + else() + message(FATAL_ERROR "UBSAN not supported by this compiler yet") + endif() + endif() + if(CLANG_CL) + find_asan_runtime(asan_libs) + foreach(lib ${asan_libs}) + link_libraries(${lib}) + string(APPEND CMAKE_C_STANDARD_LIBRARIES " \"${lib}\"") + string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " \"${lib}\"") + endforeach() + else() + add_link_options(/INCREMENTAL:NO) + endif() +endmacro() + + +if(MSVC) + # Disable mingw based pkg-config found in Strawberry perl + set(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "") + + if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) + endif() + + if(CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL") + # Dynamic runtime (DLLs), need to install CRT libraries. + set(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT VCCRT) + set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS TRUE) + if(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDebugDLL") + set(CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE) + endif() + include(InstallRequiredSystemLibraries) + endif() + + # Compile with /Zi to get debugging information + if (NOT DEFINED CMAKE_MSVC_DEBUG_INFORMATION_FORMAT) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase") + add_link_options(/DEBUG) # Ensure debugging info at link time + endif() + + if(WITH_ASAN OR WITH_UBSAN) + # Workaround something Linux specific + set(SECURITY_HARDENED 0 CACHE INTERNAL "" FORCE) + enable_sanitizers() + endif() + + add_compile_definitions( + _CRT_SECURE_NO_DEPRECATE + _CRT_NONSTDC_NO_WARNINGS + _WIN32_WINNT=0x0A00 + # We do not want the windows.h , or winsvc.h macros min/max + NOMINMAX NOSERVICE + # Speed up build process excluding unused header files + WIN32_LEAN_AND_MEAN + ) + if(CLANG_CL) + add_compile_options( + -Wno-unknown-warning-option + -Wno-unused-private-field + -Wno-unused-parameter + -Wno-inconsistent-missing-override + -Wno-unused-command-line-argument + -Wno-pointer-sign + -Wno-deprecated-register + -Wno-missing-braces + -Wno-unused-function + -Wno-unused-local-typedef + -Wno-microsoft-static-assert + -Wno-c++17-extensions + -msse4.2 + ) + if((CMAKE_SIZEOF_VOID_P MATCHES 8) AND MSVC_INTEL) + add_compile_options(-mpclmul) + endif() + endif() - # Mark 32 bit executables large address aware so they can # use > 2GB address space - IF(CMAKE_SIZEOF_VOID_P MATCHES 4) - STRING(APPEND CMAKE_EXE_LINKER_FLAGS " /LARGEADDRESSAWARE") - ENDIF() - - # Speed up multiprocessor build - IF (NOT CLANG_CL) - STRING(APPEND CMAKE_C_FLAGS " /MP") - STRING(APPEND CMAKE_CXX_FLAGS " /MP") - STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " /Gw") - STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " /Gw") - ENDIF() - - #TODO: update the code and remove the disabled warnings - STRING(APPEND CMAKE_C_FLAGS " /we4700 /we4311 /we4477 /we4302 /we4090") - STRING(APPEND CMAKE_CXX_FLAGS " /we4099 /we4700 /we4311 /we4477 /we4302 /we4090") - IF(MSVC_VERSION GREATER 1910 AND NOT CLANG_CL) - STRING(APPEND CMAKE_CXX_FLAGS " /permissive-") - STRING(APPEND CMAKE_C_FLAGS " /diagnostics:caret") - STRING(APPEND CMAKE_CXX_FLAGS " /diagnostics:caret") - ENDIF() - ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) - IF(MYSQL_MAINTAINER_MODE MATCHES "ERR") - STRING(APPEND CMAKE_C_FLAGS " /WX") - STRING(APPEND CMAKE_CXX_FLAGS " /WX") - FOREACH(type EXE SHARED MODULE) - FOREACH(cfg RELEASE DEBUG RELWITHDEBINFO) - SET(CMAKE_${type}_LINKER_FLAGS_${cfg} "${CMAKE_${type}_LINKER_FLAGS_${cfg}} /WX") - ENDFOREACH() - ENDFOREACH() - ENDIF() + if(CMAKE_SIZEOF_VOID_P MATCHES 4) + add_link_options(/LARGEADDRESSAWARE) + endif() - IF(FAST_BUILD) - STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - ELSEIF (NOT CLANG_CL) - STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " /d2OptimizeHugeFunctions") - STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " /d2OptimizeHugeFunctions") - ENDIF() - ADD_COMPILE_OPTIONS($<$:/utf-8>) -ENDIF() + # RelWithDebInfo is deoptimized wrt inlining. + # Fix it to default + foreach(lang C CXX) + foreach(suffix "_RELWITHDEBINFO" "_RELWITHDEBINFO_INIT") + string(REGEX REPLACE "/Ob[0-1]" "" CMAKE_${lang}_FLAGS${suffix} "${CMAKE_${lang}_FLAGS${suffix}}") + endforeach() + endforeach() -# Always link with socket/synchronization libraries -STRING(APPEND CMAKE_C_STANDARD_LIBRARIES " ws2_32.lib synchronization.lib") -STRING(APPEND CMAKE_CXX_STANDARD_LIBRARIES " ws2_32.lib synchronization.lib") + if(NOT CLANG_CL) + add_link_options("$<$:/INCREMENTAL:NO;/RELEASE;/OPT:REF,ICF>") + add_compile_options($<$:$<$:/Gw>>) + add_compile_options($<$:/MP>) + add_compile_options("$<$:/we4099;/we4700;/we4311;/we4477;/we4302;/we4090>") + add_compile_options($<$:/permissive->) + add_compile_options($<$:/diagnostics:caret>) + add_compile_options($<$:/utf-8>) + if(NOT FAST_BUILD) + add_compile_options($<$:$<$:/d2OptimizeHugeFunctions>>) + endif() + endif() -# System checks -SET(SIGNAL_WITH_VIO_CLOSE 1) # Something that runtime team needs -SET(HAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT 1) + if(MYSQL_MAINTAINER_MODE MATCHES "ERR") + set(CMAKE_COMPILE_WARNING_AS_ERROR ON) + add_link_options(/WX) + endif() +endif() -# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are -# not in headers, to handle dual mode sockets correctly. -CHECK_SYMBOL_EXISTS(IPPROTO_IPV6 "winsock2.h" HAVE_IPPROTO_IPV6) -IF(NOT HAVE_IPPROTO_IPV6) - SET(HAVE_IPPROTO_IPV6 41) -ENDIF() -CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "winsock2.h;ws2ipdef.h" HAVE_IPV6_V6ONLY) -IF(NOT HAVE_IPV6_V6ONLY) - SET(IPV6_V6ONLY 27) -ENDIF() +# avoid running system checks by using pre-cached check results +# system checks are expensive on VS generator +get_filename_component(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +include(${_SCRIPT_DIR}/WindowsCache.cmake) -# Some standard functions exist there under different -# names (e.g popen is _popen or strok_r is _strtok_s) -# If a replacement function exists, HAVE_FUNCTION is -# defined to 1. CMake variable will also -# be defined to the replacement name. -# So for example, CHECK_FUNCTION_REPLACEMENT(popen _popen) -# will define HAVE_POPEN to 1 and set variable named popen -# to _popen. If the header template, one needs to have -# cmakedefine popen @popen@ which will expand to -# define popen _popen after CONFIGURE_FILE +# this is out of place, not really a system check +set(FN_NO_CASE_SENSE 1) +set(USE_SYMDIR 1) +set(HAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT 1) -MACRO(CHECK_FUNCTION_REPLACEMENT function replacement) - STRING(TOUPPER ${function} function_upper) - CHECK_FUNCTION_EXISTS(${function} HAVE_${function_upper}) - IF(NOT HAVE_${function_upper}) - CHECK_FUNCTION_EXISTS(${replacement} HAVE_${replacement}) - IF(HAVE_${replacement}) - SET(HAVE_${function_upper} 1 ) - SET(${function} ${replacement}) - ENDIF() - ENDIF() -ENDMACRO() -MACRO(CHECK_SYMBOL_REPLACEMENT symbol replacement header) - STRING(TOUPPER ${symbol} symbol_upper) - CHECK_SYMBOL_EXISTS(${symbol} ${header} HAVE_${symbol_upper}) - IF(NOT HAVE_${symbol_upper}) - CHECK_SYMBOL_EXISTS(${replacement} ${header} HAVE_${replacement}) - IF(HAVE_${replacement}) - SET(HAVE_${symbol_upper} 1) - SET(${symbol} ${replacement}) - ENDIF() - ENDIF() -ENDMACRO() - -CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h) -CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h) -CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h) -CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h) -CHECK_FUNCTION_REPLACEMENT(popen _popen) -CHECK_FUNCTION_REPLACEMENT(pclose _pclose) -CHECK_FUNCTION_REPLACEMENT(access _access) -CHECK_FUNCTION_REPLACEMENT(strcasecmp _stricmp) -CHECK_FUNCTION_REPLACEMENT(strncasecmp _strnicmp) -CHECK_SYMBOL_REPLACEMENT(snprintf _snprintf stdio.h) -CHECK_FUNCTION_REPLACEMENT(strtok_r strtok_s) -CHECK_FUNCTION_REPLACEMENT(strtoll _strtoi64) -CHECK_FUNCTION_REPLACEMENT(strtoull _strtoui64) -CHECK_FUNCTION_REPLACEMENT(vsnprintf _vsnprintf) -CHECK_TYPE_SIZE(ssize_t SIZE_OF_SSIZE_T) -IF(NOT HAVE_SIZE_OF_SSIZE_T) - SET(ssize_t SSIZE_T) -ENDIF() - -SET(FN_NO_CASE_SENSE 1) -SET(USE_SYMDIR 1) - -# Force static C runtime for targets in current directory -# (useful to get rid of MFC dll's dependency, or in installer) -MACRO(FORCE_STATIC_CRT) - FOREACH(flag - CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT - CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT - CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL - ) - STRING(REGEX REPLACE "/MD[d]?" "/MT" "${flag}" "${${flag}}" ) - STRING(REPLACE "${DYNAMIC_UCRT_LINKER_OPTION}" "" "${flag}" "${${flag}}") - ENDFOREACH() -ENDMACRO() diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index c5c9ac9e8cf..7034dfad5ca 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -202,10 +202,10 @@ SET(HAVE_STRING_H 1 CACHE INTERNAL "") SET(HAVE_STRNDUP CACHE INTERNAL "") SET(HAVE_STRNLEN 1 CACHE INTERNAL "") SET(HAVE_STRPBRK 1 CACHE INTERNAL "") -SET(HAVE_STRTOK_R CACHE INTERNAL "") -SET(HAVE_STRTOLL CACHE INTERNAL "") +SET(HAVE_STRTOK_R 1 CACHE INTERNAL "") +SET(HAVE_STRTOLL 1 CACHE INTERNAL "") SET(HAVE_STRTOUL 1 CACHE INTERNAL "") -SET(HAVE_STRTOULL CACHE INTERNAL "") +SET(HAVE_STRTOULL 1 CACHE INTERNAL "") SET(HAVE_SYNCH_H CACHE INTERNAL "") SET(HAVE_SYSENT_H CACHE INTERNAL "") SET(HAVE_SYS_DIR_H CACHE INTERNAL "") @@ -293,6 +293,7 @@ SET(HAVE_EVENT_H CACHE INTERNAL "") SET(HAVE_LINUX_UNISTD_H CACHE INTERNAL "") SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "") +SET(HAVE_PTHREAD_GETATTR_NP CACHE INTERNAL "") SET(HAVE_SOCKPEERCRED CACHE INTERNAL "") SET(HAVE_ABI_CXA_DEMANGLE CACHE INTERNAL "") SET(HAVE_GCC_C11_ATOMICS CACHE INTERNAL "") @@ -348,4 +349,16 @@ SET(HAVE_SYS_STATVFS_H CACHE INTERNAL "") SET(HAVE_GETPAGESIZES CACHE INTERNAL "") SET(HAVE_LINUX_LIMITS_H CACHE INTERNAL "") SET(HAVE_FILE_UCONTEXT_H CACHE INTERNAL "") +SET(have_C__Werror CACHE INTERNAL "") +SET(HAVE_SIGNAL_H 1 CACHE INTERNAL "") +SET(HAVE_UINT CACHE INTERNAL "") +SET(HAVE_SOCKET_LEN_T CACHE INTERNAL "") +SET(HAVE_GETTHRID CACHE INTERNAL "") +SET(HAVE_THREAD_LOCAL 1 CACHE INTERNAL "") +SET(have_CXX__Wno_unused_but_set_variable CACHE INTERNAL "") +SET(HAVE_UNISTD_H CACHE INTERNAL "") +SET(HAVE_LINUX_UNISTD_H CACHE INTERNAL "") +SET(OFF64_T CACHE INTERNAL "") +SET(Z_HAVE_UNISTD_H CACHE INTERNAL "") +SET(HAVE_OFF64_T CACHE FALSE INTERNAL "") ENDIF(MSVC) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 43b9db15712..008b2562ffb 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -214,6 +214,11 @@ MACRO(MYSQL_ADD_PLUGIN) TARGET_LINK_LIBRARIES (${target} mysqlservices ${ARG_LINK_LIBRARIES}) + IF(WIN32) + # A popular library, turns out many plugins need it for gethostname() + TARGET_LINK_LIBRARIES (${target} ws2_32) + ENDIF() + IF(CMAKE_SYSTEM_NAME MATCHES AIX) TARGET_LINK_OPTIONS(${target} PRIVATE "-Wl,-bE:${CMAKE_SOURCE_DIR}/libservices/mysqlservices_aix.def") ENDIF() diff --git a/config.h.cmake b/config.h.cmake index 57fdb40abcc..87a884c5a61 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -401,38 +401,27 @@ #cmakedefine SIGNAL_WITH_VIO_CLOSE 1 /* Windows stuff, mostly functions, that have Posix analogs but named differently */ -#cmakedefine S_IROTH @S_IROTH@ -#cmakedefine S_IFIFO @S_IFIFO@ -#cmakedefine IPPROTO_IPV6 @IPPROTO_IPV6@ -#cmakedefine IPV6_V6ONLY @IPV6_V6ONLY@ -#cmakedefine sigset_t @sigset_t@ -#cmakedefine mode_t @mode_t@ -#cmakedefine SIGQUIT @SIGQUIT@ -#cmakedefine SIGPIPE @SIGPIPE@ -#cmakedefine popen @popen@ -#cmakedefine pclose @pclose@ -#cmakedefine ssize_t @ssize_t@ -#cmakedefine strcasecmp @strcasecmp@ -#cmakedefine strncasecmp @strncasecmp@ -#cmakedefine snprintf @snprintf@ -#cmakedefine strtok_r @strtok_r@ -#cmakedefine strtoll @strtoll@ -#cmakedefine strtoull @strtoull@ -#cmakedefine vsnprintf @vsnprintf@ -#if defined(_MSC_VER) && (_MSC_VER > 1800) +#ifdef _WIN32 +#define S_IROTH _S_IREAD +#define S_IFIFO _S_IFIFO +#define SIGQUIT SIGTERM +#define SIGPIPE SIGINT +#define sigset_t int +#define mode_t int +#define popen _popen +#define pclose _pclose +#define ssize_t SSIZE_T +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#define strtok_r strtok_s #define tzname _tzname #define P_tmpdir "C:\\TEMP" -#endif -#if defined(_MSC_VER) && (_MSC_VER > 1310) -# define HAVE_SETENV #define setenv(a,b,c) _putenv_s(a,b) -#endif -#define PSAPI_VERSION 1 /* for GetProcessMemoryInfo() */ -/* We don't want the min/max macros */ -#ifdef _WIN32 +#define HAVE_SETENV #define NOMINMAX 1 -#endif +#define PSAPI_VERSION 2 /* for GetProcessMemoryInfo() */ +#endif /* _WIN32 */ /* MySQL features diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index cd24d858957..4ca092872be 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1791,11 +1791,6 @@ uint xb_client_options_count = array_elements(xb_client_options); static const char *dbug_option; #endif -#ifdef HAVE_URING -extern const char *io_uring_may_be_unsafe; -bool innodb_use_native_aio_default(); -#endif - static my_bool innodb_log_checkpoint_now; struct my_option xb_server_options[] = @@ -1943,12 +1938,7 @@ struct my_option xb_server_options[] = "Use native AIO if supported on this platform.", (G_PTR*) &srv_use_native_aio, (G_PTR*) &srv_use_native_aio, 0, GET_BOOL, NO_ARG, -#ifdef HAVE_URING - innodb_use_native_aio_default(), -#else - TRUE, -#endif - 0, 0, 0, 0, 0}, + TRUE, 0, 0, 0, 0, 0}, {"innodb_page_size", OPT_INNODB_PAGE_SIZE, "The universal page size of the database.", (G_PTR*) &innobase_page_size, (G_PTR*) &innobase_page_size, 0, @@ -2527,12 +2517,8 @@ static bool innodb_init_param() msg("InnoDB: Using Linux native AIO"); } #elif defined(HAVE_URING) - if (!srv_use_native_aio) { - } else if (io_uring_may_be_unsafe) { - msg("InnoDB: Using liburing on this kernel %s may cause hangs;" - " see https://jira.mariadb.org/browse/MDEV-26674", - io_uring_may_be_unsafe); - } else { + + if (srv_use_native_aio) { msg("InnoDB: Using liburing"); } #else @@ -2672,7 +2658,7 @@ static bool innodb_init() } recv_sys.lsn= log_sys.next_checkpoint_lsn= - log_sys.get_lsn() - SIZE_OF_FILE_CHECKPOINT; + log_get_lsn() - SIZE_OF_FILE_CHECKPOINT; log_sys.set_latest_format(false); // not encrypted log_hdr_init(); byte *b= &log_hdr_buf[log_t::START_OFFSET]; diff --git a/include/json_lib.h b/include/json_lib.h index d4632788ecc..eecae46ec4c 100644 --- a/include/json_lib.h +++ b/include/json_lib.h @@ -387,7 +387,7 @@ int json_find_paths_next(json_engine_t *je, json_find_paths_t *state); Returns negative integer in the case of an error, the length of the result otherwise. */ -int json_unescape(CHARSET_INFO *json_cs, +int __attribute__((warn_unused_result)) json_unescape(CHARSET_INFO *json_cs, const uchar *json_str, const uchar *json_end, CHARSET_INFO *res_cs, uchar *res, uchar *res_end); @@ -401,7 +401,8 @@ int json_unescape(CHARSET_INFO *json_cs, JSON_ERROR_OUT_OF_SPACE Not enough space in the provided buffer JSON_ERROR_ILLEGAL_SYMBOL Source symbol cannot be represented in JSON */ -int json_escape(CHARSET_INFO *str_cs, const uchar *str, const uchar *str_end, +int __attribute__((warn_unused_result)) json_escape(CHARSET_INFO *str_cs, + const uchar *str, const uchar *str_end, CHARSET_INFO *json_cs, uchar *json, uchar *json_end); diff --git a/include/my_base.h b/include/my_base.h index f7ff053ed40..0817fbe75e4 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -220,7 +220,10 @@ enum ha_extra_function { /** Start writing rows during ALTER TABLE...ALGORITHM=COPY. */ HA_EXTRA_BEGIN_ALTER_COPY, /** Finish writing rows during ALTER TABLE...ALGORITHM=COPY. */ - HA_EXTRA_END_ALTER_COPY + HA_EXTRA_END_ALTER_COPY, + /** Abort of writing rows during ALTER TABLE..ALGORITHM=COPY or + CREATE..SELCT */ + HA_EXTRA_ABORT_ALTER_COPY }; /* Compatible option, to be deleted in 6.0 */ diff --git a/include/my_stack_alloc.h b/include/my_stack_alloc.h index 796bb69f877..59d9c0da57f 100644 --- a/include/my_stack_alloc.h +++ b/include/my_stack_alloc.h @@ -38,6 +38,8 @@ static inline void *my_get_stack_pointer(void *default_stack) #if defined(__GNUC__) || defined(__clang__) /* GCC and Clang compilers */ #if defined(__i386__) /* Intel x86 (32-bit) */ __asm__ volatile ("movl %%esp, %0" : "=r" (stack_ptr)); +#elif defined(__x86_64__) && defined (__ILP32__) /* Intel x86-64 (64-bit), X32 ABI */ + __asm__ volatile ("movl %%esp, %0" : "=r" (stack_ptr)); #elif defined(__x86_64__) /* Intel x86-64 (64-bit) */ __asm__ volatile ("movq %%rsp, %0" : "=r" (stack_ptr)); #elif defined(__powerpc__) /* PowerPC (32-bit) */ diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index e3b46b3709e..3649d207b71 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -138,6 +138,7 @@ sub new { my $error = delete($opts{'error'}); my $verbose = delete($opts{'verbose'}) || $::opt_verbose; my $nocore = delete($opts{'nocore'}); + my $open_files_limit = delete($opts{'open_files_limit'}); my $host = delete($opts{'host'}); my $shutdown = delete($opts{'shutdown'}); my $user_data= delete($opts{'user_data'}); @@ -161,6 +162,8 @@ sub new { push(@safe_args, "--verbose") if $verbose > 0; push(@safe_args, "--nocore") if $nocore; + push(@safe_args, "--open-files-limit=$open_files_limit") if $open_files_limit; + # Point the safe_process at the right parent if running on cygwin push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN; diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index dcf9491d2d6..462e72ed976 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -220,6 +220,7 @@ int main(int argc, char* const argv[] ) pid_t own_pid= getpid(); pid_t parent_pid= getppid(); bool nocore = false; + int open_files_limit = 1024; struct sigaction sa,sa_abort; sa.sa_handler= handle_signal; @@ -268,7 +269,14 @@ int main(int argc, char* const argv[] ) } else if ( strncmp (arg, "--env ", 6) == 0 ) { - putenv(strdup(arg+6)); + putenv(strdup(arg+6)); + } + else if ( strncmp(arg, "--open-files-limit=", 19) == 0 ) + { + const char* start = arg + 19; + open_files_limit = atoi(start); + if (open_files_limit <= 0) + die("Invalid value '%s' passed to --open-files-limit", start); } else die("Unknown option: %s", arg); @@ -318,11 +326,8 @@ int main(int argc, char* const argv[] ) if (nocore) setlimit(RLIMIT_CORE, 0, 0); - /* - mysqld defaults depend on that. make test results stable and independent - from the environment - */ - setlimit(RLIMIT_NOFILE, 1024, 1024); + // Set open files limit + setlimit(RLIMIT_NOFILE, open_files_limit, open_files_limit); // Signal that child is ready buf= 37; diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index c0354efe90c..36f8beb8187 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -12926,9 +12926,8 @@ SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL; EXPLAIN INSERT INTO t1 SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 144 Using where -2 DERIVED ALL NULL NULL NULL NULL 12 -2 DERIVED t1 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) +1 PRIMARY ALL NULL NULL NULL NULL 12 Using temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) 4 DERIVED t1 ALL NULL NULL NULL NULL 12 EXPLAIN FORMAT=JSON INSERT INTO t1 SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL; @@ -12937,71 +12936,54 @@ EXPLAIN "query_block": { "select_id": 1, "cost": "COST_REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "", - "access_type": "ALL", - "loops": 1, - "rows": 144, - "cost": "COST_REPLACED", - "filtered": 100, - "attached_condition": "t.f is not null", - "materialized": { - "query_block": { - "select_id": 2, - "cost": "COST_REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "", - "access_type": "ALL", - "loops": 1, - "rows": 12, - "cost": "COST_REPLACED", - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "cost": "COST_REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "ALL", - "loops": 1, - "rows": 12, - "cost": "COST_REPLACED", - "filtered": 100 - } - } - ] - } - } - } - }, - { - "block-nl-join": { + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "loops": 1, + "rows": 12, + "cost": "COST_REPLACED", + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "cost": "COST_REPLACED", + "nested_loop": [ + { "table": { "table_name": "t1", "access_type": "ALL", - "loops": 12, + "loops": 1, "rows": 12, "cost": "COST_REPLACED", - "filtered": 100, - "attached_condition": "t1.f is not null" - }, - "buffer_type": "flat", - "buffer_size": "64", - "join_type": "BNL" + "filtered": 100 + } } - } - ] + ] + } } } + }, + { + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 12, + "rows": 12, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "t1.f is not null" + }, + "buffer_type": "flat", + "buffer_size": "64", + "join_type": "BNL" + } } - } - ] + ] + } } } SELECT * FROM t1; @@ -13031,72 +13013,55 @@ EXPLAIN "query_block": { "select_id": 1, "cost": "COST_REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "", - "access_type": "ALL", - "loops": 1, - "rows": 8, - "cost": "COST_REPLACED", - "filtered": 100, - "attached_condition": "t.f is not null", - "materialized": { - "query_block": { - "select_id": 2, - "cost": "COST_REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "ALL", - "loops": 1, - "rows": 8, - "cost": "COST_REPLACED", - "filtered": 100, - "attached_condition": "t1.f is not null" - } - }, - { - "table": { - "table_name": "", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "4", - "used_key_parts": ["f"], - "ref": ["test.t1.f"], - "loops": 8, - "rows": 1, - "cost": "COST_REPLACED", - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 4, - "cost": "COST_REPLACED", - "nested_loop": [ - { - "table": { - "table_name": "t1", - "access_type": "ALL", - "loops": 1, - "rows": 8, - "cost": "COST_REPLACED", - "filtered": 100, - "attached_condition": "t1.f is not null" - } - } - ] - } + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 1, + "rows": 8, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "t1.f is not null" + } + }, + { + "table": { + "table_name": "", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "4", + "used_key_parts": ["f"], + "ref": ["test.t1.f"], + "loops": 8, + "rows": 1, + "cost": "COST_REPLACED", + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 4, + "cost": "COST_REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 1, + "rows": 8, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "t1.f is not null" } } - } - ] + ] + } } } } - } - ] + ] + } } } SELECT * FROM t1; @@ -23639,6 +23604,27 @@ FROM cte2 GROUP BY 1 ; ( SELECT 1 FROM ( SELECT 1 FROM cte1) dt GROUP BY x HAVING x= 1 ) 1 +create table t1 (f int); +create view v1 as select f, count(*) c from t1 group by f; +# +# MDEV-25012 Server crash in find_field_in_tables, Assertion `name' failed in find_field_in_table_ref +# +select * from v1 where export_set(1, default(f), 'x', aes_decrypt('secret', f)); +f c +show warnings; +Level Code Message +drop view v1; +drop table t1; +create table t(c3 longtext) ; +with cte1 as +( +select default(c3) as a +from t group by 1 +) +select * from cte1 +where cte1.a >= 1; +a +drop table t; # End of 10.5 tests # # MDEV-28958: condition pushable into view after simplification diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index 30fe1338b48..02fde7ab035 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -4471,6 +4471,28 @@ SELECT FROM cte2 GROUP BY 1 ; +create table t1 (f int); +create view v1 as select f, count(*) c from t1 group by f; + +--echo # +--echo # MDEV-25012 Server crash in find_field_in_tables, Assertion `name' failed in find_field_in_table_ref +--echo # +select * from v1 where export_set(1, default(f), 'x', aes_decrypt('secret', f)); +show warnings; +# cleanup +drop view v1; +drop table t1; + +create table t(c3 longtext) ; +with cte1 as +( + select default(c3) as a + from t group by 1 +) +select * from cte1 +where cte1.a >= 1; +drop table t; + --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index f8f5130c08f..1c2c1d34523 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -2524,6 +2524,8 @@ SELECT * FROM t1; a 1 1 +1 +1 drop table t1,t2; set optimizer_switch=@save968720_optimizer_switch; # diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index c11dd0beda7..0fe8094692e 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1766,6 +1766,43 @@ FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t; data # +# MDEV-35614 JSON_UNQUOTE doesn't work with emojis +# +SELECT HEX(JSON_UNQUOTE('"\\ud83d\\ude0a"')) as hex_smiley; +hex_smiley +F09F988A +set names utf8mb4; +SELECT JSON_UNQUOTE('"\\ud83d\\ude0a"') as smiley; +smiley +😊 +SELECT JSON_UNQUOTE('"\\ud83d\\ude0a"') = JSON_UNQUOTE('"\\ud83d\\ude0a"') as equal_smileys; +equal_smileys +1 +SELECT JSON_UNQUOTE('"\\ud83d\\ude0a"') <= JSON_UNQUOTE('"\\ud83d\\ude0a"') as less_or_equal_smileys; +less_or_equal_smileys +1 +set @v='{ "color":"😊" }'; +select @v as v, collation(@v) as collation_v; +v collation_v +{ "color":"😊" } utf8mb4_general_ci +select json_valid(@v) as valid; +valid +1 +select json_extract(@v,'$.color') as color_extraction, collation(json_extract(@v,'$.color')) as color_extraction_collation; +color_extraction color_extraction_collation +"😊" utf8mb4_general_ci +select json_unquote(json_extract(@v,'$.color')) as unquoted, collation(json_unquote(json_extract(@v,'$.color'))) as unquoted_collation; +unquoted unquoted_collation +😊 utf8mb4_bin +SELECT JSON_UNQUOTE('"\\uc080\\ude0a"') as invalid_utf8mb4; +invalid_utf8mb4 +"\uc080\ude0a" +Warnings: +Warning 4035 Broken JSON string in argument 1 to function 'json_unquote' at position 13 +show warnings; +Level Code Message +Warning 4035 Broken JSON string in argument 1 to function 'json_unquote' at position 13 +# # End of 10.6 tests # # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 5a8ae9f58a4..2c337f8d6ab 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1196,6 +1196,7 @@ SELECT JSON_EXTRACT('{"a": 1,"b": 2}','$.a'); SET @@collation_connection= @save_collation_connection; + --echo # --echo # End of 10.5 tests --echo # @@ -1233,6 +1234,27 @@ SELECT data FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t; + +--echo # +--echo # MDEV-35614 JSON_UNQUOTE doesn't work with emojis +--echo # + +SELECT HEX(JSON_UNQUOTE('"\\ud83d\\ude0a"')) as hex_smiley; +set names utf8mb4; +SELECT JSON_UNQUOTE('"\\ud83d\\ude0a"') as smiley; + +SELECT JSON_UNQUOTE('"\\ud83d\\ude0a"') = JSON_UNQUOTE('"\\ud83d\\ude0a"') as equal_smileys; +SELECT JSON_UNQUOTE('"\\ud83d\\ude0a"') <= JSON_UNQUOTE('"\\ud83d\\ude0a"') as less_or_equal_smileys; + +set @v='{ "color":"😊" }'; +select @v as v, collation(@v) as collation_v; +select json_valid(@v) as valid; +select json_extract(@v,'$.color') as color_extraction, collation(json_extract(@v,'$.color')) as color_extraction_collation; +select json_unquote(json_extract(@v,'$.color')) as unquoted, collation(json_unquote(json_extract(@v,'$.color'))) as unquoted_collation; + +SELECT JSON_UNQUOTE('"\\uc080\\ude0a"') as invalid_utf8mb4; +show warnings; + --echo # --echo # End of 10.6 tests --echo # diff --git a/mysql-test/main/func_like.result b/mysql-test/main/func_like.result index ba053eac877..4cdb5de37fb 100644 --- a/mysql-test/main/func_like.result +++ b/mysql-test/main/func_like.result @@ -424,3 +424,22 @@ Warnings: Note 1003 select 1 like `test`.`t1`.`c1` | `test`.`t1`.`c2` AS `1 LIKE c1|c2`,1 like `test`.`t1`.`c1` & `test`.`t1`.`c2` AS `1 LIKE c1&c2`,1 like `test`.`t1`.`c2` >> `test`.`t1`.`c1` AS `1 LIKE c2>>c1`,2 like `test`.`t1`.`c2` << `test`.`t1`.`c1` AS `2 LIKE c2< 0 AS `1 LIKE c1||c2`,2 like `test`.`t1`.`c1` + `test`.`t1`.`c2` AS `2 LIKE c1+c2`,-1 like `test`.`t1`.`c1` - `test`.`t1`.`c2` AS `-1 LIKE c1-c2`,2 like `test`.`t1`.`c1` * `test`.`t1`.`c2` AS `2 LIKE c1*c2`,0.5000 like `test`.`t1`.`c1` / `test`.`t1`.`c2` AS `0.5000 LIKE c1/c2`,0 like `test`.`t1`.`c1` DIV `test`.`t1`.`c2` AS `0 LIKE c1 DIV c2`,0 like `test`.`t1`.`c1` MOD `test`.`t1`.`c2` AS `0 LIKE c1 MOD c2` from `test`.`t1` order by `test`.`t1`.`c2` DROP VIEW v1; DROP TABLE t1; +# +# MDEV-36211 Incorrect query result for binary_column NOT LIKE binary_column +# +CREATE TABLE t1 (c1 BLOB NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT c1 FROM t1 WHERE c1 NOT LIKE c1; +c1 +SELECT c1 FROM t1 WHERE c1 LIKE c1; +c1 +1 +DROP TABLE t1; +CREATE TABLE t1 (c1 BLOB); +INSERT INTO t1 (c1) VALUES (1); +SELECT c1 FROM t1 WHERE c1 NOT LIKE c1; +c1 +SELECT c1 FROM t1 WHERE c1 LIKE c1; +c1 +1 +DROP TABLE t1; diff --git a/mysql-test/main/func_like.test b/mysql-test/main/func_like.test index 751e9c19e40..fc22ba3a2ee 100644 --- a/mysql-test/main/func_like.test +++ b/mysql-test/main/func_like.test @@ -291,3 +291,18 @@ SELECT * FROM v1; EXPLAIN EXTENDED SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; + +--echo # +--echo # MDEV-36211 Incorrect query result for binary_column NOT LIKE binary_column +--echo # +CREATE TABLE t1 (c1 BLOB NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT c1 FROM t1 WHERE c1 NOT LIKE c1; +SELECT c1 FROM t1 WHERE c1 LIKE c1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 BLOB); +INSERT INTO t1 (c1) VALUES (1); +SELECT c1 FROM t1 WHERE c1 NOT LIKE c1; +SELECT c1 FROM t1 WHERE c1 LIKE c1; +DROP TABLE t1; diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index 0952d45e1bd..90e978d8a0c 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -3010,6 +3010,80 @@ UPDATE t1 SET c=1 ORDER BY (SELECT c); ERROR 42S22: Unknown column 'c' in 'SET' DROP TABLE t1; # +# MDEV-35238: Wrong results from a tables with a single record and an aggregate +# +CREATE OR REPLACE TABLE t1 (a int) ENGINE=myisam; +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +1+0 min(1) +1 NULL +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "message": "Impossible WHERE noticed after reading const tables" + } + } +} +INSERT INTO t1 VALUES (NULL); +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +1+0 min(1) +1 NULL +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "pseudo_bits_condition": "if(uuid_short(),NULL,1)", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } + ] + } +} +DROP TABLE t1; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=myisam; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (a int NOT NULL) ENGINE=myisam; +INSERT INTO t2 VALUES (10); +SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); +1+0 MIN(t1.a) +1 1 +explain format=json SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "pseudo_bits_condition": "10 = rand()", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } + ] + } +} +DROP TABLE t1,t2; +# # End of 10.5 tests # # diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index 9461a14ef0c..3aa9013bc91 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -2162,6 +2162,28 @@ UPDATE t1 SET c=1 ORDER BY (SELECT c); UPDATE t1 SET c=1 ORDER BY (SELECT c); DROP TABLE t1; +--echo # +--echo # MDEV-35238: Wrong results from a tables with a single record and an aggregate +--echo # +CREATE OR REPLACE TABLE t1 (a int) ENGINE=myisam; +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +INSERT INTO t1 VALUES (NULL); +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +DROP TABLE t1; + +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=myisam; +INSERT INTO t1 VALUES (1); + +CREATE TABLE t2 (a int NOT NULL) ENGINE=myisam; +INSERT INTO t2 VALUES (10); + +SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); +explain format=json SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); + +DROP TABLE t1,t2; + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/insert.result b/mysql-test/main/insert.result index 6e526a5f038..ea21d64ce8c 100644 --- a/mysql-test/main/insert.result +++ b/mysql-test/main/insert.result @@ -808,5 +808,75 @@ a 8 drop table t1; # -# End of 10.5 tests +# MDEV-32086 Server crash when inserting from derived table containing insert target table +# (part 2) # +create table t1 (pk int, id int); +insert into t1 values (2,2), (3,3), (4,4); +select * from t1; +pk id +2 2 +3 3 +4 4 +select 101+count(*) +from +( +select dt2.id +from (select id from t1) dt2, t1 t where t.id=dt2.id +) dt +where dt.id<1000; +101+count(*) +104 +prepare s from ' +insert into t1 values( + (select 101+count(*) + from + ( + select dt2.id + from (select id from t1) dt2, t1 t where t.id=dt2.id + ) dt + where dt.id<1000 + ), 123 +) +'; +execute s; +select * from t1; +pk id +2 2 +3 3 +4 4 +104 123 +select 101+count(*) +from +( +select dt2.id +from (select id from t1) dt2, t1 t where t.id=dt2.id +) dt +where dt.id<1000; +101+count(*) +105 +execute s; +select * from t1; +pk id +2 2 +3 3 +4 4 +104 123 +105 123 +drop table t1; +# +# Try this: INSERT INTO t1 VALUES ... reference to t1 +# RETURNING (subquery not touching t1) +create table t1 (a int, b int); +create table t2 (a int, b int); +# This is accepted: +insert into t1 (a) values +(3), +((select max(a) from t1)) +returning +a, b, (select max(a) from t2); +a b (select max(a) from t2) +3 NULL NULL +NULL NULL NULL +drop table t1,t2; +# End of 10.5 tests diff --git a/mysql-test/main/insert.test b/mysql-test/main/insert.test index 4b5a5181f09..ec100cb114e 100644 --- a/mysql-test/main/insert.test +++ b/mysql-test/main/insert.test @@ -675,5 +675,59 @@ select * from t1; drop table t1; --echo # ---echo # End of 10.5 tests +--echo # MDEV-32086 Server crash when inserting from derived table containing insert target table +--echo # (part 2) --echo # + +create table t1 (pk int, id int); +insert into t1 values (2,2), (3,3), (4,4); +select * from t1; +select 101+count(*) + from + ( + select dt2.id + from (select id from t1) dt2, t1 t where t.id=dt2.id + ) dt + where dt.id<1000; +prepare s from ' +insert into t1 values( + (select 101+count(*) + from + ( + select dt2.id + from (select id from t1) dt2, t1 t where t.id=dt2.id + ) dt + where dt.id<1000 + ), 123 +) +'; +execute s; +select * from t1; +select 101+count(*) + from + ( + select dt2.id + from (select id from t1) dt2, t1 t where t.id=dt2.id + ) dt + where dt.id<1000; +execute s; +select * from t1; + +drop table t1; + +--echo # +--echo # Try this: INSERT INTO t1 VALUES ... reference to t1 +--echo # RETURNING (subquery not touching t1) +create table t1 (a int, b int); +create table t2 (a int, b int); + +--echo # This is accepted: +insert into t1 (a) values + (3), + ((select max(a) from t1)) +returning + a, b, (select max(a) from t2); + +drop table t1,t2; + +--echo # End of 10.5 tests diff --git a/mysql-test/main/insert_returning.result b/mysql-test/main/insert_returning.result index 916347b3ecb..9c1233d7fa8 100644 --- a/mysql-test/main/insert_returning.result +++ b/mysql-test/main/insert_returning.result @@ -498,6 +498,8 @@ t1 WHERE id1=1) 5 6 INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT 1 UNION SELECT id2 FROM t2); +ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*; ERROR 42S02: Unknown table 'test.t1' # diff --git a/mysql-test/main/insert_returning.test b/mysql-test/main/insert_returning.test index 250ca55024f..28bc0e495d7 100644 --- a/mysql-test/main/insert_returning.test +++ b/mysql-test/main/insert_returning.test @@ -201,6 +201,8 @@ INSERT INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM t1 WHERE id1=1); --error ER_UPDATE_TABLE_USED INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); +--error ER_UPDATE_TABLE_USED +INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT 1 UNION SELECT id2 FROM t2); --error ER_BAD_TABLE_ERROR INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*; diff --git a/mysql-test/main/insert_select.result b/mysql-test/main/insert_select.result index 07a2bd174d3..0156439b821 100644 --- a/mysql-test/main/insert_select.result +++ b/mysql-test/main/insert_select.result @@ -1030,6 +1030,144 @@ a 3 DROP VIEW v1; DROP TABLE t1; +create table t1 (pk int, id int); +insert into t1 values (2,2), (3,3), (4,4); +insert into t1 +select 1,10 +from +( +select dt2.id from (select id from t1) dt2, t1 t where t.id=dt2.id +) dt +where dt.id=3; +select * from t1; +pk id +2 2 +3 3 +4 4 +1 10 +explain insert into t1 +select 1,10 +from +( +select dt2.id from (select id from t1) dt2, t1 t where t.id=dt2.id +) dt +where dt.id=3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary +1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +explain format=json insert into t1 +select 1,10 +from +( +select dt2.id from (select id from t1) dt2, t1 t where t.id=dt2.id +) dt +where dt.id=3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost": "COST_REPLACED", + "temporary_table": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 1, + "rows": 4, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "t1.`id` = 3" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t", + "access_type": "ALL", + "loops": 4, + "rows": 4, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "t.`id` = 3" + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL" + } + } + ] + } + } +} +prepare stmt from "insert into t1 +select 1,10 +from +( +select dt2.id from (select id from t1) dt2, t1 t where t.id=dt2.id +) dt +where dt.id=3"; +execute stmt; +select * from t1; +pk id +2 2 +3 3 +4 4 +1 10 +1 10 +execute stmt; +select * from t1; +pk id +2 2 +3 3 +4 4 +1 10 +1 10 +1 10 +deallocate prepare stmt; +create procedure p() insert into t1 +select 1,10 +from +( +select dt2.id from (select id from t1) dt2, t1 t where t.id=dt2.id +) dt +where dt.id=3; +call p(); +select * from t1; +pk id +2 2 +3 3 +4 4 +1 10 +1 10 +1 10 +1 10 +call p(); +select * from t1; +pk id +2 2 +3 3 +4 4 +1 10 +1 10 +1 10 +1 10 +1 10 +drop procedure p; +drop table t1; # -# End of 10.5 test +# MDEV-33139: Crash of INSERT SELECT when preparing structures for +# split optimization # +CREATE TABLE v0 ( v1 INT UNIQUE ) ; +INSERT INTO v0 ( v1 ) VALUES +( ( SELECT 1 +FROM +( SELECT v1 +FROM v0 GROUP BY v1 ) AS v6 NATURAL JOIN +v0 AS v2 NATURAL JOIN +v0 AS v4 NATURAL JOIN +v0 AS v3 NATURAL JOIN +( SELECT v1 FROM v0 ) AS v7 ) ) ; +DROP TABLE v0; +# End of 10.5 tests diff --git a/mysql-test/main/insert_select.test b/mysql-test/main/insert_select.test index 0e9bd05a93e..c88011055bf 100644 --- a/mysql-test/main/insert_select.test +++ b/mysql-test/main/insert_select.test @@ -591,6 +591,61 @@ SELECT * FROM t1; DROP VIEW v1; DROP TABLE t1; +# +# MDEV-32086: condition pushdown into two mergeable derived tables, +# one containing the other, when they are forced to be +# materialized in INSERT +# +create table t1 (pk int, id int); +insert into t1 values (2,2), (3,3), (4,4); + +let $q= +insert into t1 + select 1,10 + from + ( + select dt2.id from (select id from t1) dt2, t1 t where t.id=dt2.id + ) dt + where dt.id=3; + +eval $q; +select * from t1; + +eval explain $q; +--source include/explain-no-costs.inc +eval explain format=json $q; + +eval prepare stmt from "$q"; +execute stmt; +select * from t1; +execute stmt; +select * from t1; +deallocate prepare stmt; + +eval create procedure p() $q; +call p(); +select * from t1; +call p(); +select * from t1; +drop procedure p; + +drop table t1; + --echo # ---echo # End of 10.5 test +--echo # MDEV-33139: Crash of INSERT SELECT when preparing structures for +--echo # split optimization --echo # + +CREATE TABLE v0 ( v1 INT UNIQUE ) ; +INSERT INTO v0 ( v1 ) VALUES + ( ( SELECT 1 + FROM + ( SELECT v1 + FROM v0 GROUP BY v1 ) AS v6 NATURAL JOIN + v0 AS v2 NATURAL JOIN + v0 AS v4 NATURAL JOIN + v0 AS v3 NATURAL JOIN + ( SELECT v1 FROM v0 ) AS v7 ) ) ; +DROP TABLE v0; + +--echo # End of 10.5 tests diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result index 99c27a0ecf2..96b6419fbf9 100644 --- a/mysql-test/main/join.result +++ b/mysql-test/main/join.result @@ -3608,6 +3608,35 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref kp1 kp1 5 test.t1.a 1 Using index condition drop table t1,t2; # +# MDEV-36592: If the join_condition is specified via USING (column_list), the query plan depends ... +# +CREATE TABLE t1 ( +id int(11), +f1 char(255), +PRIMARY KEY (id) +); +INSERT INTO t1 (id) VALUES (1),(2),(3); +UPDATE t1 SET f1=REPEAT('a',250); +CREATE TABLE t2 (id int(11), f2 INT NOT NULL); +INSERT INTO t2 select seq, seq from seq_1_to_20; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +# In both queries, t1 should use type=index, not type=ALL: +EXPLAIN SELECT count(*) FROM t2 JOIN t1 USING (id); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 3 Using index +1 SIMPLE t2 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join) +EXPLAIN SELECT count(*) FROM t1 JOIN t2 USING (id); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 3 Using index +1 SIMPLE t2 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join) +DROP TABLE t1,t2; +# End of 10.11 tests +# # MDEV-30256 Wrong result (missing rows) upon join with empty table # CREATE TABLE t1 (a INT); diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test index 695e6d3d296..6c1b84b6c61 100644 --- a/mysql-test/main/join.test +++ b/mysql-test/main/join.test @@ -2005,6 +2005,31 @@ where t2.kp1=t1.a and t2.kp1<=100 and t2.kp2<=20; drop table t1,t2; + +--echo # +--echo # MDEV-36592: If the join_condition is specified via USING (column_list), the query plan depends ... +--echo # +CREATE TABLE t1 ( + id int(11), + f1 char(255), + PRIMARY KEY (id) +); +INSERT INTO t1 (id) VALUES (1),(2),(3); +UPDATE t1 SET f1=REPEAT('a',250); + +CREATE TABLE t2 (id int(11), f2 INT NOT NULL); +INSERT INTO t2 select seq, seq from seq_1_to_20; + +ANALYZE TABLE t1, t2; + +--echo # In both queries, t1 should use type=index, not type=ALL: +EXPLAIN SELECT count(*) FROM t2 JOIN t1 USING (id); +EXPLAIN SELECT count(*) FROM t1 JOIN t2 USING (id); + +DROP TABLE t1,t2; + +--echo # End of 10.11 tests + --echo # --echo # MDEV-30256 Wrong result (missing rows) upon join with empty table --echo # diff --git a/mysql-test/main/lowercase_table2.result b/mysql-test/main/lowercase_table2.result index d89a916611c..5418e57a39c 100644 --- a/mysql-test/main/lowercase_table2.result +++ b/mysql-test/main/lowercase_table2.result @@ -185,7 +185,7 @@ create table myUC (i int); select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA ='mysqltest_LC2'; TABLE_SCHEMA TABLE_NAME -mysqltest_lc2 myUC +mysqltest_LC2 myUC use test; drop database mysqltest_LC2; # diff --git a/mysql-test/main/lowercase_view.result b/mysql-test/main/lowercase_view.result index af53f67869d..845df4d647d 100644 --- a/mysql-test/main/lowercase_view.result +++ b/mysql-test/main/lowercase_view.result @@ -16,29 +16,17 @@ create view v1Aa as select * from t1aA; create view v2aA as select * from v1aA; create view v3Aa as select v2Aa.col1 from v2aA,t2Aa where v2Aa.col1 = t2aA.col1; insert into v2Aa values ((select max(col1) from v1aA)); -ERROR HY000: The definition of table 'v1aA' prevents operation INSERT on table 'v2Aa' insert into t1aA values ((select max(col1) from v1Aa)); -ERROR HY000: The definition of table 'v1Aa' prevents operation INSERT on table 't1aA' insert into v2aA values ((select max(col1) from v1aA)); -ERROR HY000: The definition of table 'v1aA' prevents operation INSERT on table 'v2aA' insert into v2Aa values ((select max(col1) from t1Aa)); -ERROR HY000: The definition of table 'v2Aa' prevents operation INSERT on table 'v2Aa' insert into t1aA values ((select max(col1) from t1Aa)); -ERROR HY000: Table 't1aA' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into v2aA values ((select max(col1) from t1aA)); -ERROR HY000: The definition of table 'v2aA' prevents operation INSERT on table 'v2aA' insert into v2Aa values ((select max(col1) from v2aA)); -ERROR HY000: Table 'v2Aa' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into t1Aa values ((select max(col1) from v2Aa)); -ERROR HY000: The definition of table 'v2Aa' prevents operation INSERT on table 't1Aa' insert into v2aA values ((select max(col1) from v2Aa)); -ERROR HY000: Table 'v2aA' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into v3Aa (col1) values ((select max(col1) from v1Aa)); -ERROR HY000: The definition of table 'v1Aa' prevents operation INSERT on table 'v3Aa' insert into v3aA (col1) values ((select max(col1) from t1aA)); -ERROR HY000: The definition of table 'v3aA' prevents operation INSERT on table 'v3aA' insert into v3Aa (col1) values ((select max(col1) from v2aA)); -ERROR HY000: The definition of table 'v2aA' prevents operation INSERT on table 'v3Aa' drop view v3aA,v2Aa,v1aA; drop table t1Aa,t2Aa; create table t1Aa (col1 int); diff --git a/mysql-test/main/lowercase_view.test b/mysql-test/main/lowercase_view.test index cdd0256d639..52aae7b2b3c 100644 --- a/mysql-test/main/lowercase_view.test +++ b/mysql-test/main/lowercase_view.test @@ -23,29 +23,17 @@ create table t2aA (col1 int); create view v1Aa as select * from t1aA; create view v2aA as select * from v1aA; create view v3Aa as select v2Aa.col1 from v2aA,t2Aa where v2Aa.col1 = t2aA.col1; --- error 1443 insert into v2Aa values ((select max(col1) from v1aA)); --- error 1443 insert into t1aA values ((select max(col1) from v1Aa)); --- error 1443 insert into v2aA values ((select max(col1) from v1aA)); --- error 1443 insert into v2Aa values ((select max(col1) from t1Aa)); --- error 1093 insert into t1aA values ((select max(col1) from t1Aa)); --- error 1443 insert into v2aA values ((select max(col1) from t1aA)); --- error 1093 insert into v2Aa values ((select max(col1) from v2aA)); --- error 1443 insert into t1Aa values ((select max(col1) from v2Aa)); --- error 1093 insert into v2aA values ((select max(col1) from v2Aa)); --- error 1443 insert into v3Aa (col1) values ((select max(col1) from v1Aa)); --- error 1443 insert into v3aA (col1) values ((select max(col1) from t1aA)); --- error 1443 insert into v3Aa (col1) values ((select max(col1) from v2aA)); drop view v3aA,v2Aa,v1aA; drop table t1Aa,t2Aa; diff --git a/mysql-test/main/mdev-35721-ubsan.result b/mysql-test/main/mdev-35721-ubsan.result new file mode 100644 index 00000000000..8a3e61ad6ac --- /dev/null +++ b/mysql-test/main/mdev-35721-ubsan.result @@ -0,0 +1,21 @@ +CREATE TABLE t (c1 VARCHAR(10),c2 VARCHAR(10),PRIMARY KEY(c1,c2),FULLTEXT KEY k (c2)) ENGINE=InnoDB; +INSERT INTO t VALUES ('a','b'); +DROP TABLE t; +CREATE TABLE t (c1 VARCHAR(10),c2 VARCHAR(10),PRIMARY KEY(c1,c2),FULLTEXT KEY k (c2)) ENGINE=InnoDB; +DELETE FROM t; +DROP TABLE t; +CREATE TABLE t (a INT(1),d INT(1),b VARCHAR(1),c CHAR(1),c3 INT(1) GENERATED ALWAYS AS ((a + LENGTH (d))) STORED,c2 CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,k1 CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b (1),a,d),KEY d (d),KEY a (a),KEY c_renamed (c (1),b (1)),KEY b (b (1),c (1),a),KEY k1 (k1),KEY a_2 (a,k1),KEY k1_2 (k1,d)) DEFAULT CHARSET=latin1 ENGINE=InnoDB; +DELETE FROM t; +DROP TABLE t; +CREATE TABLE t (a INT,ROW_START TIMESTAMP(6) AS ROW START,ROW_END TIMESTAMP(6) AS ROW END,PERIOD FOR SYSTEM_TIME(ROW_START,ROW_END),INDEX (ROW_START),INDEX (ROW_END),PRIMARY KEY(ROW_END,a,ROW_START),INDEX (ROW_END,ROW_START,a)) WITH SYSTEM VERSIONING ENGINE=InnoDB; +SHOW INDEX FROM t; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored +t 0 PRIMARY 1 ROW_END A 0 NULL NULL BTREE NO +t 0 PRIMARY 2 a A 0 NULL NULL BTREE NO +t 0 PRIMARY 3 ROW_START A 0 NULL NULL BTREE NO +t 1 ROW_START 1 ROW_START A 0 NULL NULL BTREE NO +t 1 ROW_END 1 ROW_END A 0 NULL NULL BTREE NO +t 1 ROW_END_2 1 ROW_END A 0 NULL NULL BTREE NO +t 1 ROW_END_2 2 ROW_START A 0 NULL NULL BTREE NO +t 1 ROW_END_2 3 a A 0 NULL NULL BTREE NO +DROP TABLE t; diff --git a/mysql-test/main/mdev-35721-ubsan.test b/mysql-test/main/mdev-35721-ubsan.test new file mode 100644 index 00000000000..24f580f82b4 --- /dev/null +++ b/mysql-test/main/mdev-35721-ubsan.test @@ -0,0 +1,22 @@ + +--source include/have_innodb.inc + +CREATE TABLE t (c1 VARCHAR(10),c2 VARCHAR(10),PRIMARY KEY(c1,c2),FULLTEXT KEY k (c2)) ENGINE=InnoDB; +INSERT INTO t VALUES ('a','b'); + +DROP TABLE t; + +CREATE TABLE t (c1 VARCHAR(10),c2 VARCHAR(10),PRIMARY KEY(c1,c2),FULLTEXT KEY k (c2)) ENGINE=InnoDB; +DELETE FROM t; + +DROP TABLE t; + +CREATE TABLE t (a INT(1),d INT(1),b VARCHAR(1),c CHAR(1),c3 INT(1) GENERATED ALWAYS AS ((a + LENGTH (d))) STORED,c2 CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,k1 CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,PRIMARY KEY(b (1),a,d),KEY d (d),KEY a (a),KEY c_renamed (c (1),b (1)),KEY b (b (1),c (1),a),KEY k1 (k1),KEY a_2 (a,k1),KEY k1_2 (k1,d)) DEFAULT CHARSET=latin1 ENGINE=InnoDB; +DELETE FROM t; + +DROP TABLE t; + +CREATE TABLE t (a INT,ROW_START TIMESTAMP(6) AS ROW START,ROW_END TIMESTAMP(6) AS ROW END,PERIOD FOR SYSTEM_TIME(ROW_START,ROW_END),INDEX (ROW_START),INDEX (ROW_END),PRIMARY KEY(ROW_END,a,ROW_START),INDEX (ROW_END,ROW_START,a)) WITH SYSTEM VERSIONING ENGINE=InnoDB; +SHOW INDEX FROM t; + +DROP TABLE t; diff --git a/mysql-test/main/mdl_sync.result b/mysql-test/main/mdl_sync.result index bece98a675e..a5b6d339564 100644 --- a/mysql-test/main/mdl_sync.result +++ b/mysql-test/main/mdl_sync.result @@ -2431,9 +2431,6 @@ create table t1 (a int) engine=myisam; create table t2 (a int) stats_persistent=0, engine=innodb; insert into t1 values (1); insert into t2 values (1); -connect con1, localhost, root; -start transaction with consistent snapshot; -connection default; SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait execute 2'; update t1,t2 set t1.a=2,t2.a=3; connection con2; @@ -2456,6 +2453,7 @@ SET DEBUG_SYNC= 'now SIGNAL grlwait'; SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait'; FLUSH TABLES WITH READ LOCK; +InnoDB 0 transactions not purged SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME MDL_BACKUP_FTWRL2 Backup lock @@ -2465,7 +2463,6 @@ connection default; SET DEBUG_SYNC= 'RESET'; drop table t1,t2; disconnect con2; -disconnect con1; # # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null' # failed in open_ltable() diff --git a/mysql-test/main/mdl_sync.test b/mysql-test/main/mdl_sync.test index aa3bd60e64e..b0fcf911e06 100644 --- a/mysql-test/main/mdl_sync.test +++ b/mysql-test/main/mdl_sync.test @@ -3115,12 +3115,6 @@ create table t2 (a int) stats_persistent=0, engine=innodb; insert into t1 values (1); insert into t2 values (1); -connect (con1, localhost, root); -# disable innodb purge thread, otherwise it might start purging t2, -# and will take an mdl, affecting metadata_lock_info output. -start transaction with consistent snapshot; -connection default; - SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait execute 2'; --send update t1,t2 set t1.a=2,t2.a=3 @@ -3156,6 +3150,7 @@ FLUSH TABLES WITH READ LOCK; let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.metadata_lock_info; --source include/wait_condition.inc +--source ../suite/innodb/include/wait_all_purged.inc SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; unlock tables; @@ -3166,7 +3161,6 @@ connection default; SET DEBUG_SYNC= 'RESET'; drop table t1,t2; disconnect con2; -disconnect con1; --echo # --echo # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null' diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result index cebb5381645..4ca76a8cbca 100644 --- a/mysql-test/main/multi_update.result +++ b/mysql-test/main/multi_update.result @@ -1385,6 +1385,26 @@ c1 c2 c3 drop table t1,t2,t3,t; # End of 10.4 tests # +# MDEV-31647 Stack looping and SIGSEGV in Item_args::walk_args on UPDATE +# +create table t1 (c int, c2 int) engine=innodb; +update t1 set c=0 where c=( +select 1 from (select 1 as v1) as v2 +natural join t1) order by last_value (c2) over (order by c2); +ERROR HY000: Invalid use of group function +update t1 set c=0 where c=( +select 1 from (select 1 as v1) as v2 +natural join t1) order by last_value (c2) over (); +ERROR HY000: Invalid use of group function +update t1 set c=0 where c=( +select 1 from (select 1 as v1) as v2 +natural join t1) order by c2; +select 1 from (select 1 as v1) as v2 +natural join t1 order by last_value (c2) over (order by c2); +1 +drop table t1; +# End of 10.5 tests +# # MDEV-31150: 2nd execution of multi-update with # mergeable derived table in WHERE # diff --git a/mysql-test/main/multi_update.test b/mysql-test/main/multi_update.test index c6247a21b21..3561ff43375 100644 --- a/mysql-test/main/multi_update.test +++ b/mysql-test/main/multi_update.test @@ -1202,6 +1202,34 @@ drop table t1,t2,t3,t; --echo # End of 10.4 tests +--echo # +--echo # MDEV-31647 Stack looping and SIGSEGV in Item_args::walk_args on UPDATE +--echo # +--source include/have_innodb.inc +create table t1 (c int, c2 int) engine=innodb; + +--error ER_INVALID_GROUP_FUNC_USE +update t1 set c=0 where c=( + select 1 from (select 1 as v1) as v2 + natural join t1) order by last_value (c2) over (order by c2); + +--error ER_INVALID_GROUP_FUNC_USE +update t1 set c=0 where c=( + select 1 from (select 1 as v1) as v2 + natural join t1) order by last_value (c2) over (); + +update t1 set c=0 where c=( + select 1 from (select 1 as v1) as v2 + natural join t1) order by c2; + +select 1 from (select 1 as v1) as v2 + natural join t1 order by last_value (c2) over (order by c2); + + +drop table t1; + +--echo # End of 10.5 tests + --echo # --echo # MDEV-31150: 2nd execution of multi-update with --echo # mergeable derived table in WHERE diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result index 1532890cbd1..2f105809dc6 100644 --- a/mysql-test/main/query_cache.result +++ b/mysql-test/main/query_cache.result @@ -2235,6 +2235,29 @@ SET @qc= @@query_cache_size; set global Query_cache_size=18446744073709547520; SET GLOBAL query_cache_size= @qc; # +# MDEV-34075 corruption when query cache cannot allocate block +# +set global query_cache_type=1; +create table t1 (c1 smallint null, c2 binary (25) not null, c3 tinyint(4) null, c4 binary (15) not null primary key, c5 smallint not null unique key,c6 decimal(10,8) not null default 3.141592) engine=innodb; +set global query_cache_size=81920; +select * from t1 where b=1 and c=1; +ERROR 42S22: Unknown column 'b' in 'WHERE' +set session query_cache_type=1; +drop table t1; +create table t1 (c1 int not null, c2 char(5)) engine=innodb partition by linear key(c1) partitions 99; +select * from t1 where c1 <='1998-12-29 00:00:00' order by c1,c2; +c1 c2 +select group_concat(a separator '###') as names from t1 having left(names, 1)='j'; +ERROR 42S22: Unknown column 'a' in 'SELECT' +select * from t1; +c1 c2 +select count(*) from t1; +count(*) +0 +select G.a, c.a from t1 c, t1 G; +ERROR 42S22: Unknown column 'G.a' in 'SELECT' +drop table t1; +# # End of 10.5 tests # # diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index 8c6af0a65c4..7a51fb9f0a6 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -2,6 +2,8 @@ -- source include/long_test.inc -- source include/no_valgrind_without_big.inc -- source include/no_view_protocol.inc +-- source include/have_partition.inc +-- source include/have_innodb.inc --disable_ps2_protocol set @save_query_cache_size=@@query_cache_size; @@ -1852,6 +1854,26 @@ set global Query_cache_size=18446744073709547520; SET GLOBAL query_cache_size= @qc; --enable_warnings +--echo # +--echo # MDEV-34075 corruption when query cache cannot allocate block +--echo # +set global query_cache_type=1; +create table t1 (c1 smallint null, c2 binary (25) not null, c3 tinyint(4) null, c4 binary (15) not null primary key, c5 smallint not null unique key,c6 decimal(10,8) not null default 3.141592) engine=innodb; +set global query_cache_size=81920; +--error ER_BAD_FIELD_ERROR +select * from t1 where b=1 and c=1; +set session query_cache_type=1; +drop table t1; +create table t1 (c1 int not null, c2 char(5)) engine=innodb partition by linear key(c1) partitions 99; +select * from t1 where c1 <='1998-12-29 00:00:00' order by c1,c2; +--error ER_BAD_FIELD_ERROR +select group_concat(a separator '###') as names from t1 having left(names, 1)='j'; +select * from t1; +select count(*) from t1; +--error ER_BAD_FIELD_ERROR +select G.a, c.a from t1 c, t1 G; +drop table t1; + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index 503b56c4842..54e544c4fc5 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -690,22 +690,24 @@ create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); ERROR 21000: Subquery returns more than 1 row INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; x +NULL 1 insert into t2 values (1); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; select * from t1; x +NULL 1 2 3 @@ -713,6 +715,7 @@ x INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; select * from t1; x +NULL 1 2 3 @@ -722,6 +725,7 @@ x INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 3 @@ -738,7 +742,7 @@ insert into t3 values (1),(2); select * from t1; x y replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 23000: Column 'x' cannot be null replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); ERROR 21000: Subquery returns more than 1 row replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); @@ -806,13 +810,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); id 2 INSERT INTO t2 VALUES ((SELECT * FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row INSERT INTO t2 VALUES ((SELECT id FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row +select * from t2; +id +1 +2 +INSERT INTO t2 VALUES ((SELECT count(*) FROM t2)); +INSERT INTO t2 VALUES ((SELECT max(id) FROM t2)); SELECT * FROM t2; id 1 2 +2 +2 CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); UPDATE t2 SET id=(SELECT * FROM t1); diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index f02238fecde..206c856b8f6 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -425,7 +425,6 @@ create table t2 (a int) ENGINE=MyISAM; create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); --- error ER_UPDATE_TABLE_USED INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); -- error ER_SUBQUERY_NO_1_ROW INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); @@ -460,7 +459,7 @@ create table t3 (a int); insert into t2 values (1); insert into t3 values (1),(2); select * from t1; --- error ER_UPDATE_TABLE_USED +-- error ER_BAD_NULL_ERROR replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); -- error ER_SUBQUERY_NO_1_ROW replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); @@ -500,10 +499,13 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); --disable_prepare_warnings SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); --- error ER_UPDATE_TABLE_USED +-- error ER_SUBQUERY_NO_1_ROW INSERT INTO t2 VALUES ((SELECT * FROM t2)); --- error ER_UPDATE_TABLE_USED +-- error ER_SUBQUERY_NO_1_ROW INSERT INTO t2 VALUES ((SELECT id FROM t2)); +select * from t2; +INSERT INTO t2 VALUES ((SELECT count(*) FROM t2)); +INSERT INTO t2 VALUES ((SELECT max(id) FROM t2)); SELECT * FROM t2; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); diff --git a/mysql-test/main/subselect_elimination.result b/mysql-test/main/subselect_elimination.result index 17400e490bc..e2bbbe1b6f2 100644 --- a/mysql-test/main/subselect_elimination.result +++ b/mysql-test/main/subselect_elimination.result @@ -136,12 +136,22 @@ DROP TABLE t1; # access within null pointer CREATE TABLE x (x INT) ENGINE=InnoDB; INSERT INTO x (x) VALUES (0); +select NULL IN (SELECT (SELECT x FROM (SELECT x FROM +(SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT +(SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN +(SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x) +AS x) IN (SELECT 0 AS x) AS x FROM x) as exp; +exp +NULL INSERT INTO x (x) VALUES (x IN (SELECT (SELECT x FROM (SELECT x FROM (SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT (SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN (SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x) AS x) IN (SELECT 0 AS x) AS x FROM x)); -ERROR HY000: Table 'x' is specified twice, both as a target for 'INSERT' and as a separate source for data +select * from x; +x +0 +NULL DROP TABLE x; # MDEV-28622: Item_subselect eliminated flag set but Item still # evaluated/used. diff --git a/mysql-test/main/subselect_elimination.test b/mysql-test/main/subselect_elimination.test index 9d973477b28..e2b5b50f36d 100644 --- a/mysql-test/main/subselect_elimination.test +++ b/mysql-test/main/subselect_elimination.test @@ -133,12 +133,17 @@ DROP TABLE t1; CREATE TABLE x (x INT) ENGINE=InnoDB; INSERT INTO x (x) VALUES (0); ---error ER_UPDATE_TABLE_USED +select NULL IN (SELECT (SELECT x FROM (SELECT x FROM +(SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT +(SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN +(SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x) +AS x) IN (SELECT 0 AS x) AS x FROM x) as exp; INSERT INTO x (x) VALUES (x IN (SELECT (SELECT x FROM (SELECT x FROM (SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT (SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN (SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x) AS x) IN (SELECT 0 AS x) AS x FROM x)); +select * from x; DROP TABLE x; --echo # MDEV-28622: Item_subselect eliminated flag set but Item still diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index 4d8abb85ad2..ed076f087b9 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -694,22 +694,24 @@ create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); ERROR 21000: Subquery returns more than 1 row INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; x +NULL 1 insert into t2 values (1); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; select * from t1; x +NULL 1 2 3 @@ -717,6 +719,7 @@ x INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; select * from t1; x +NULL 1 2 3 @@ -726,6 +729,7 @@ x INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 3 @@ -742,7 +746,7 @@ insert into t3 values (1),(2); select * from t1; x y replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 23000: Column 'x' cannot be null replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); ERROR 21000: Subquery returns more than 1 row replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); @@ -810,13 +814,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); id 2 INSERT INTO t2 VALUES ((SELECT * FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row INSERT INTO t2 VALUES ((SELECT id FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row +select * from t2; +id +1 +2 +INSERT INTO t2 VALUES ((SELECT count(*) FROM t2)); +INSERT INTO t2 VALUES ((SELECT max(id) FROM t2)); SELECT * FROM t2; id 1 2 +2 +2 CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); UPDATE t2 SET id=(SELECT * FROM t1); diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index 5f2d1b86bdc..94df89312d1 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -697,22 +697,24 @@ create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); ERROR 21000: Subquery returns more than 1 row INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; x +NULL 1 insert into t2 values (1); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; select * from t1; x +NULL 1 2 3 @@ -720,6 +722,7 @@ x INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; select * from t1; x +NULL 1 2 3 @@ -729,6 +732,7 @@ x INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 3 @@ -745,7 +749,7 @@ insert into t3 values (1),(2); select * from t1; x y replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 23000: Column 'x' cannot be null replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); ERROR 21000: Subquery returns more than 1 row replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); @@ -813,13 +817,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); id 2 INSERT INTO t2 VALUES ((SELECT * FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row INSERT INTO t2 VALUES ((SELECT id FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row +select * from t2; +id +1 +2 +INSERT INTO t2 VALUES ((SELECT count(*) FROM t2)); +INSERT INTO t2 VALUES ((SELECT max(id) FROM t2)); SELECT * FROM t2; id 1 2 +2 +2 CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); UPDATE t2 SET id=(SELECT * FROM t1); diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index f2f3d299980..14113d0e13a 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -693,22 +693,24 @@ create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); ERROR 21000: Subquery returns more than 1 row INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; x +NULL 1 insert into t2 values (1); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; select * from t1; x +NULL 1 2 3 @@ -716,6 +718,7 @@ x INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; select * from t1; x +NULL 1 2 3 @@ -725,6 +728,7 @@ x INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 3 @@ -741,7 +745,7 @@ insert into t3 values (1),(2); select * from t1; x y replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 23000: Column 'x' cannot be null replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); ERROR 21000: Subquery returns more than 1 row replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); @@ -809,13 +813,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); id 2 INSERT INTO t2 VALUES ((SELECT * FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row INSERT INTO t2 VALUES ((SELECT id FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row +select * from t2; +id +1 +2 +INSERT INTO t2 VALUES ((SELECT count(*) FROM t2)); +INSERT INTO t2 VALUES ((SELECT max(id) FROM t2)); SELECT * FROM t2; id 1 2 +2 +2 CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); UPDATE t2 SET id=(SELECT * FROM t1); diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 1d540628eff..30b46153ae9 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -696,22 +696,24 @@ create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); ERROR 21000: Subquery returns more than 1 row INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; x +NULL 1 insert into t2 values (1); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; select * from t1; x +NULL 1 2 3 @@ -719,6 +721,7 @@ x INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; select * from t1; x +NULL 1 2 3 @@ -728,6 +731,7 @@ x INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 3 @@ -744,7 +748,7 @@ insert into t3 values (1),(2); select * from t1; x y replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 23000: Column 'x' cannot be null replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); ERROR 21000: Subquery returns more than 1 row replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); @@ -812,13 +816,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); id 2 INSERT INTO t2 VALUES ((SELECT * FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row INSERT INTO t2 VALUES ((SELECT id FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row +select * from t2; +id +1 +2 +INSERT INTO t2 VALUES ((SELECT count(*) FROM t2)); +INSERT INTO t2 VALUES ((SELECT max(id) FROM t2)); SELECT * FROM t2; id 1 2 +2 +2 CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); UPDATE t2 SET id=(SELECT * FROM t1); diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index 9736f0df864..9147cb55504 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -693,22 +693,24 @@ create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); ERROR 21000: Subquery returns more than 1 row INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; x +NULL 1 insert into t2 values (1); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; select * from t1; x +NULL 1 2 3 @@ -716,6 +718,7 @@ x INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; select * from t1; x +NULL 1 2 3 @@ -725,6 +728,7 @@ x INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); select * from t1; x +NULL 1 2 3 @@ -741,7 +745,7 @@ insert into t3 values (1),(2); select * from t1; x y replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 23000: Column 'x' cannot be null replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); ERROR 21000: Subquery returns more than 1 row replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); @@ -809,13 +813,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); id 2 INSERT INTO t2 VALUES ((SELECT * FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row INSERT INTO t2 VALUES ((SELECT id FROM t2)); -ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data +ERROR 21000: Subquery returns more than 1 row +select * from t2; +id +1 +2 +INSERT INTO t2 VALUES ((SELECT count(*) FROM t2)); +INSERT INTO t2 VALUES ((SELECT max(id) FROM t2)); SELECT * FROM t2; id 1 2 +2 +2 CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); UPDATE t2 SET id=(SELECT * FROM t1); diff --git a/mysql-test/main/type_binary.result b/mysql-test/main/type_binary.result index d1aa4ada5af..32593cb728b 100644 --- a/mysql-test/main/type_binary.result +++ b/mysql-test/main/type_binary.result @@ -397,3 +397,61 @@ indexed_col not_indexed_col DROP TABLE t2; DROP TABLE t1; SET note_verbosity=DEFAULT; +# +# MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +# +CREATE TABLE t1 (c1 BINARY(16), UNIQUE (c1)); +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2); +SELECT HEX(c1) FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +HEX(c1) +31000000000000000000000000000000 +32000000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '-2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +SELECT HEX(c1) FROM t1 IGNORE KEY(c1) WHERE 'a' BETWEEN 0 AND (c1); +HEX(c1) +31000000000000000000000000000000 +32000000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '-2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: '2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +SELECT HEX(c1) FROM t1 WHERE '#' BETWEEN c1 AND 0; +HEX(c1) +2D310000000000000000000000000000 +2D320000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '-2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +SELECT HEX(c1) FROM t1 IGNORE KEY(c1) WHERE '#' BETWEEN c1 AND 0; +HEX(c1) +2D320000000000000000000000000000 +2D310000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '-2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +DROP TABLE t1; diff --git a/mysql-test/main/type_binary.test b/mysql-test/main/type_binary.test index 495c776cc75..916d6402b63 100644 --- a/mysql-test/main/type_binary.test +++ b/mysql-test/main/type_binary.test @@ -178,3 +178,14 @@ DELIMITER ;$$ --source unusable_keys_joins.inc DROP TABLE t1; SET note_verbosity=DEFAULT; + +--echo # +--echo # MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +--echo # +CREATE TABLE t1 (c1 BINARY(16), UNIQUE (c1)); +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2); +SELECT HEX(c1) FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT HEX(c1) FROM t1 IGNORE KEY(c1) WHERE 'a' BETWEEN 0 AND (c1); +SELECT HEX(c1) FROM t1 WHERE '#' BETWEEN c1 AND 0; +SELECT HEX(c1) FROM t1 IGNORE KEY(c1) WHERE '#' BETWEEN c1 AND 0; +DROP TABLE t1; diff --git a/mysql-test/main/type_blob.result b/mysql-test/main/type_blob.result index bc25af5af90..6ff275d945d 100644 --- a/mysql-test/main/type_blob.result +++ b/mysql-test/main/type_blob.result @@ -1419,3 +1419,193 @@ Note 1105 Cannot use key parts with `test`.`t1`.`indexed_col` in the rewritten c DROP TABLE t2; DROP TABLE t1; SET note_verbosity=DEFAULT; +# +# MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +# +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))) engine=myisam; +INSERT INTO t1 (c1) VALUES (1); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +DROP TABLE t1; +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))); +INSERT INTO t1 (c1) VALUES (1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +3 +4 +5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 WHERE 3 BETWEEN 10*POW(-1,c1) AND (c1); +c1 +3 +5 +SELECT c1 FROM t1 WHERE 'a' BETWEEN 10*POW(-1,c1) AND (c1); +c1 +1 +3 +5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +DROP TABLE t1; +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))) engine=myisam; +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +3 +4 +5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +c1 +-2 +-1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +DROP TABLE t1; +CREATE TABLE t1 (c1 TINYBLOB NOT NULL); +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +3 +4 +5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +c1 +-2 +-1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +DROP TABLE t1; +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))) engine=innodb; +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +3 +4 +5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +c1 +-2 +-1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +ALTER TABLE t1 engine=myisam; +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +3 +4 +5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +c1 +-2 +-1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +DROP TABLE t1; +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1)) engine=innodb; +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +3 +4 +5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +c1 +-2 +-1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +DROP TABLE t1; diff --git a/mysql-test/main/type_blob.test b/mysql-test/main/type_blob.test index ad58946afea..bb90e7434d6 100644 --- a/mysql-test/main/type_blob.test +++ b/mysql-test/main/type_blob.test @@ -808,3 +808,48 @@ DELIMITER ;$$ --source unusable_keys_joins.inc DROP TABLE t1; SET note_verbosity=DEFAULT; + +--echo # +--echo # MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +--echo # +# myisam has a special optimization for tables with one row +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))) engine=myisam; +INSERT INTO t1 (c1) VALUES (1); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +DROP TABLE t1; + +# This case shows that we don't transform the entire WHERE clause +# into a range condition. +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))); +INSERT INTO t1 (c1) VALUES (1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 WHERE 3 BETWEEN 10*POW(-1,c1) AND (c1); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 10*POW(-1,c1) AND (c1); +DROP TABLE t1; + +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))) engine=myisam; +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +DROP TABLE t1; + +CREATE TABLE t1 (c1 TINYBLOB NOT NULL); +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +DROP TABLE t1; + +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1(2))) engine=innodb; +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +ALTER TABLE t1 engine=myisam; +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +DROP TABLE t1; + +CREATE TABLE t1 (c1 TINYBLOB, UNIQUE (c1)) engine=innodb; +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2),(3),(4),(5); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +DROP TABLE t1; diff --git a/mysql-test/main/type_varbinary.result b/mysql-test/main/type_varbinary.result new file mode 100644 index 00000000000..41f7403a24f --- /dev/null +++ b/mysql-test/main/type_varbinary.result @@ -0,0 +1,42 @@ +# +# MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +# +CREATE TABLE t1 (c1 VARBINARY(10), UNIQUE (c1)); +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 IGNORE KEY(c1) WHERE 'a' BETWEEN 0 AND (c1); +c1 +1 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +c1 +-1 +-2 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +SELECT c1 FROM t1 IGNORE KEY(c1) WHERE '#' BETWEEN c1 AND 0; +c1 +-2 +-1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +Warning 1292 Truncated incorrect DECIMAL value: '#' +DROP TABLE t1; diff --git a/mysql-test/main/type_varbinary.test b/mysql-test/main/type_varbinary.test new file mode 100644 index 00000000000..2bb35dfd195 --- /dev/null +++ b/mysql-test/main/type_varbinary.test @@ -0,0 +1,10 @@ +--echo # +--echo # MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +--echo # +CREATE TABLE t1 (c1 VARBINARY(10), UNIQUE (c1)); +INSERT INTO t1 (c1) VALUES (-2),(-1),(1),(2); +SELECT c1 FROM t1 WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 IGNORE KEY(c1) WHERE 'a' BETWEEN 0 AND (c1); +SELECT c1 FROM t1 WHERE '#' BETWEEN c1 AND 0; +SELECT c1 FROM t1 IGNORE KEY(c1) WHERE '#' BETWEEN c1 AND 0; +DROP TABLE t1; diff --git a/mysql-test/main/userstat.result b/mysql-test/main/userstat.result index eec7910aae8..046375732a7 100644 --- a/mysql-test/main/userstat.result +++ b/mysql-test/main/userstat.result @@ -245,6 +245,11 @@ select f() from information_schema.index_statistics; ERROR 21000: Subquery returns more than 1 row set global userstat= 0; drop function f; -# # End of 10.2 tests # +# MDEV-36586 USER_STATISTICS.BUSY_TIME is in microseconds +# +select distinct busy_time>1e5, cpu_time>1e5 from information_schema.user_statistics; +busy_time>1e5 cpu_time>1e5 +0 0 +# End of 10.11 tests diff --git a/mysql-test/main/userstat.test b/mysql-test/main/userstat.test index 0c49acaa19e..d14228ed1b9 100644 --- a/mysql-test/main/userstat.test +++ b/mysql-test/main/userstat.test @@ -135,6 +135,11 @@ set global userstat= 0; drop function f; --enable_ps2_protocol ---echo # --echo # End of 10.2 tests + --echo # +--echo # MDEV-36586 USER_STATISTICS.BUSY_TIME is in microseconds +--echo # +select distinct busy_time>1e5, cpu_time>1e5 from information_schema.user_statistics; + +--echo # End of 10.11 tests diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index 6306b568023..6ec76740552 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -944,31 +944,19 @@ create view v1 as select * from t1; create view v2 as select * from v1; create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; insert into v2 values ((select max(col1) from v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2' insert into t1 values ((select max(col1) from v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 't1' insert into v2 values ((select max(col1) from v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2' insert into v2 values ((select max(col1) from t1)); -ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2' insert into t1 values ((select max(col1) from t1)); -ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into v2 values ((select max(col1) from t1)); -ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2' insert into v2 values ((select max(col1) from v2)); -ERROR HY000: Table 'v2' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into t1 values ((select max(col1) from v2)); -ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 't1' insert into v2 values ((select max(col1) from v2)); -ERROR HY000: Table 'v2' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into v3 (col1) values ((select max(col1) from v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v3' insert into v3 (col1) values ((select max(col1) from t1)); -ERROR HY000: The definition of table 'v3' prevents operation INSERT on table 'v3' insert into v3 (col1) values ((select max(col1) from v2)); -ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3' -insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); -ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3' +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2 LIMIT 1)); +ERROR 22003: Out of range value for column 'col1' at row 3 insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); ERROR 23000: Column 'col1' cannot be null @@ -978,6 +966,18 @@ insert into t1 (col1) values ((select max(col1) from v4)); select * from t1; col1 NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL 1 2 3 @@ -1339,9 +1339,26 @@ create view v3 as select * from t1 where 20 < (select (s1) from v2); insert into v3 values (30); ERROR HY000: The target table v3 of the INSERT is not insertable-into create view v4 as select * from v2 where 20 < (select (s1) from t1); +select * from t1; +s1 insert into v4 values (30); -ERROR HY000: The target table v4 of the INSERT is not insertable-into -drop view v4, v3, v2, v1; +select * from t1; +s1 +30 +create view v5 as select * from v2 where s1 < (select min(s1) from t1) WITH CHECK OPTION; +# can't insert only less then minimum +insert into v5 values (40); +ERROR 44000: CHECK OPTION failed `test`.`v5` +# allow insert the new minimum +insert into v5 values (10); +# always emply view (can't be something less than minimum) +select * from v5; +s1 +select * from t1; +s1 +30 +10 +drop view v5, v4, v3, v2, v1; drop table t1; create table t1 (a int); create view v1 as select * from t1; diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 875f808f040..d9a76abfee8 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -866,33 +866,21 @@ create table t3 (col1 datetime not null); create view v1 as select * from t1; create view v2 as select * from v1; create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; --- error ER_VIEW_PREVENT_UPDATE insert into v2 values ((select max(col1) from v1)); --- error ER_VIEW_PREVENT_UPDATE insert into t1 values ((select max(col1) from v1)); --- error ER_VIEW_PREVENT_UPDATE insert into v2 values ((select max(col1) from v1)); --- error ER_VIEW_PREVENT_UPDATE insert into v2 values ((select max(col1) from t1)); --- error ER_UPDATE_TABLE_USED insert into t1 values ((select max(col1) from t1)); --- error ER_VIEW_PREVENT_UPDATE insert into v2 values ((select max(col1) from t1)); --- error ER_UPDATE_TABLE_USED insert into v2 values ((select max(col1) from v2)); --- error ER_VIEW_PREVENT_UPDATE insert into t1 values ((select max(col1) from v2)); --- error ER_UPDATE_TABLE_USED insert into v2 values ((select max(col1) from v2)); --- error ER_VIEW_PREVENT_UPDATE insert into v3 (col1) values ((select max(col1) from v1)); --- error ER_VIEW_PREVENT_UPDATE insert into v3 (col1) values ((select max(col1) from t1)); --- error ER_VIEW_PREVENT_UPDATE insert into v3 (col1) values ((select max(col1) from v2)); # check with TZ tables in list --- error ER_VIEW_PREVENT_UPDATE -insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); +--error ER_WARN_DATA_OUT_OF_RANGE +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2 LIMIT 1)); insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); -- error ER_BAD_NULL_ERROR insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); @@ -1212,9 +1200,19 @@ create view v3 as select * from t1 where 20 < (select (s1) from v2); -- error ER_NON_INSERTABLE_TABLE insert into v3 values (30); create view v4 as select * from v2 where 20 < (select (s1) from t1); --- error ER_NON_INSERTABLE_TABLE +select * from t1; insert into v4 values (30); -drop view v4, v3, v2, v1; +select * from t1; +create view v5 as select * from v2 where s1 < (select min(s1) from t1) WITH CHECK OPTION; +--echo # can't insert only less then minimum +--error ER_VIEW_CHECK_FAILED +insert into v5 values (40); +--echo # allow insert the new minimum +insert into v5 values (10); +--echo # always emply view (can't be something less than minimum) +select * from v5; +select * from t1; +drop view v5, v4, v3, v2, v1; drop table t1; # diff --git a/mysql-test/main/view_grant.result b/mysql-test/main/view_grant.result index 18290b6bafe..926fa7a90a4 100644 --- a/mysql-test/main/view_grant.result +++ b/mysql-test/main/view_grant.result @@ -1979,6 +1979,52 @@ connection default; DROP VIEW v1; DROP USER foo; DROP USER FOO; +# +# MDEV-36380: User has unauthorized access to a sequence through +# a view with security invoker +# +create database db; +use db; +create sequence s; +create sql security invoker view vin as select nextval(s); +create sql security definer view vdn as select nextval(s); +create sql security invoker view vil as select lastval(s); +create sql security definer view vdl as select lastval(s); +create sql security invoker view vis as select setval(s,20); +create sql security definer view vds as select setval(s,30); +create user u@localhost; +grant select on db.vin to u@localhost; +grant select on db.vdn to u@localhost; +grant select on db.vil to u@localhost; +grant select on db.vdl to u@localhost; +grant select on db.vis to u@localhost; +grant select on db.vds to u@localhost; +connect con1,localhost,u,,db; +select nextval(s); +ERROR 42000: SELECT, INSERT command denied to user 'u'@'localhost' for table `db`.`s` +select * from vin; +ERROR HY000: View 'db.vin' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from vdn; +nextval(s) +1 +select lastval(s); +ERROR 42000: SELECT command denied to user 'u'@'localhost' for table `db`.`s` +select * from vil; +ERROR HY000: View 'db.vil' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from vdl; +lastval(s) +1 +select setval(s,10); +ERROR 42000: INSERT command denied to user 'u'@'localhost' for table `db`.`s` +select * from vis; +ERROR HY000: View 'db.vis' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from vds; +setval(s,30) +30 +disconnect con1; +connection default; +drop database db; +drop user u@localhost; # End of 10.5 tests # Check that a user without access to the schema 'foo' cannot query # a JSON_TABLE view in that schema. diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test index 765bc3ea7a4..ee9e0b66ab7 100644 --- a/mysql-test/main/view_grant.test +++ b/mysql-test/main/view_grant.test @@ -2238,6 +2238,53 @@ DROP VIEW v1; DROP USER foo; DROP USER FOO; +--echo # +--echo # MDEV-36380: User has unauthorized access to a sequence through +--echo # a view with security invoker +--echo # +create database db; +use db; +create sequence s; +create sql security invoker view vin as select nextval(s); +create sql security definer view vdn as select nextval(s); +create sql security invoker view vil as select lastval(s); +create sql security definer view vdl as select lastval(s); +create sql security invoker view vis as select setval(s,20); +create sql security definer view vds as select setval(s,30); +create user u@localhost; +grant select on db.vin to u@localhost; +grant select on db.vdn to u@localhost; +grant select on db.vil to u@localhost; +grant select on db.vdl to u@localhost; +grant select on db.vis to u@localhost; +grant select on db.vds to u@localhost; + +--connect (con1,localhost,u,,db) +--error ER_TABLEACCESS_DENIED_ERROR +select nextval(s); +--error ER_VIEW_INVALID +select * from vin; +--disable_ps2_protocol +select * from vdn; +--enable_ps2_protocol + +--error ER_TABLEACCESS_DENIED_ERROR +select lastval(s); +--error ER_VIEW_INVALID +select * from vil; +select * from vdl; + +--error ER_TABLEACCESS_DENIED_ERROR +select setval(s,10); +--error ER_VIEW_INVALID +select * from vis; +select * from vds; + +--disconnect con1 +--connection default +drop database db; +drop user u@localhost; + --echo # End of 10.5 tests --echo # Check that a user without access to the schema 'foo' cannot query diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index d7f4b517ca3..05c1427008b 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -130,6 +130,8 @@ our $path_language; our $path_current_testlog; our $path_testlog; +our $opt_open_files_limit; + our $default_vardir; our $opt_vardir; # Path to use for var/ dir our $plugindir; @@ -1279,6 +1281,7 @@ sub command_line_setup { 'list-options' => \$opt_list_options, 'skip-test-list=s' => \@opt_skip_test_list, 'xml-report=s' => \$opt_xml_report, + 'open-files-limit=i', => \$opt_open_files_limit, My::Debugger::options(), My::CoreDump::options(), @@ -5779,6 +5782,7 @@ sub start_mysqltest ($) { append => 1, error => $path_current_testlog, verbose => $opt_verbose, + open_files_limit => $opt_open_files_limit, ); mtr_verbose("Started $proc"); return $proc; @@ -6077,6 +6081,8 @@ Misc options timediff With --timestamp, also print time passed since *previous* test started max-connections=N Max number of open connection to server in mysqltest + open-files-limit=N Max number of open files allowed for any of the children + of my_safe_process. Default is 1024. report-times Report how much time has been spent on different phases of test execution. stress=ARGS Run stress test, providing options to diff --git a/mysql-test/suite/archive/archive-big.test b/mysql-test/suite/archive/archive-big.test index fd59df66b43..8cd19b1d809 100644 --- a/mysql-test/suite/archive/archive-big.test +++ b/mysql-test/suite/archive/archive-big.test @@ -1,6 +1,7 @@ --source include/big_test.inc -# Valgrind is to slow for this test +# Valgrind and msan is to slow for this test --source include/not_valgrind.inc +--source include/not_msan.inc --source include/have_archive.inc CREATE TABLE t1(a BLOB) ENGINE=ARCHIVE; --disable_query_log diff --git a/mysql-test/suite/atomic/README.txt b/mysql-test/suite/atomic/README.txt index b1453d8a4f8..160bd1decd6 100644 --- a/mysql-test/suite/atomic/README.txt +++ b/mysql-test/suite/atomic/README.txt @@ -3,7 +3,7 @@ the following: - Add # before --exec echo "restart" ... - Force $e (engine), $c (crash point) and $r (crash position) to the values - where things goes wrong. See comments in alter_table.test for how to do this. + where things goes wrong. See comments in alter_table.inc for how to do this. - start mariadbd in a debugger run the following in the debugger diff --git a/mysql-test/suite/atomic/alter_table.test b/mysql-test/suite/atomic/alter_table.inc similarity index 99% rename from mysql-test/suite/atomic/alter_table.test rename to mysql-test/suite/atomic/alter_table.inc index c621547cee4..6ec5b93f37f 100644 --- a/mysql-test/suite/atomic/alter_table.test +++ b/mysql-test/suite/atomic/alter_table.inc @@ -1,6 +1,5 @@ --source include/long_test.inc --source include/have_debug.inc ---source include/have_innodb.inc --source include/have_log_bin.inc if (!$BIG_TEST) diff --git a/mysql-test/suite/atomic/alter_table_aria.test b/mysql-test/suite/atomic/alter_table_aria.test index 6bf44b0463d..a83137956b1 100644 --- a/mysql-test/suite/atomic/alter_table_aria.test +++ b/mysql-test/suite/atomic/alter_table_aria.test @@ -4,4 +4,4 @@ let $engine_count=1; let $engines='aria'; let $extra_engine=myisam; ---source alter_table.test +--source alter_table.inc diff --git a/mysql-test/suite/atomic/alter_table.opt b/mysql-test/suite/atomic/alter_table_innodb.opt similarity index 100% rename from mysql-test/suite/atomic/alter_table.opt rename to mysql-test/suite/atomic/alter_table_innodb.opt diff --git a/mysql-test/suite/atomic/alter_table_innodb.result b/mysql-test/suite/atomic/alter_table_innodb.result new file mode 100644 index 00000000000..258895a0cd6 --- /dev/null +++ b/mysql-test/suite/atomic/alter_table_innodb.result @@ -0,0 +1,1396 @@ +create database test2; +RESET MASTER; + +engine: innodb + + +query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new" + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 COMMENT "new" + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 change column a c int COMMENT "new" + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 +crash point: ddl_log_alter_after_rename_triggers +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 disable keys + +crash point: ddl_log_alter_after_create_frm +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_create_table +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_copy +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_log +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_rename_frm +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_delete_backup +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +"No crash!" + +query: ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_prepare_inplace +"No crash!" +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" +crash point: ddl_log_alter_after_drop_original_table +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" + +query: ALTER TABLE t1 rename t2 + +crash point: ddl_log_alter_after_create_frm +"No crash!" +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +"No crash!" +crash point: ddl_log_alter_after_copy +"No crash!" +crash point: ddl_log_alter_after_log +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_rename_triggers +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 COMMENT "new", rename t2 + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename t2 +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename t2 +crash point: ddl_log_alter_after_rename_triggers +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename t2 +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 change column a c int COMMENT "new", rename t2 + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", rename t2 +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", rename t2 +crash point: ddl_log_alter_after_rename_triggers +t2.frm +t2.ibd +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", rename t2 +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 ENGINE=aria, COMMENT "new" + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_prepare_inplace +"No crash!" +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup_log +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" +crash point: ddl_log_alter_after_drop_original_table +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" + +query: ALTER TABLE t1 change column a c int COMMENT "new", engine=aria + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_prepare_inplace +"No crash!" +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria +crash point: ddl_log_alter_after_rename_to_backup +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria +crash point: ddl_log_alter_after_rename_to_backup_log +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria +crash point: ddl_log_alter_after_drop_original_table +t1.MAD +t1.MAI +t1.frm +Table Create Table +t1 CREATE TABLE `t1` ( + `c` int(11) DEFAULT NULL COMMENT 'new', + `b` int(11) DEFAULT NULL, + KEY `a` (`c`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria + +query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_prepare_inplace +"No crash!" +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria +crash point: ddl_log_alter_after_rename_to_backup +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria +crash point: ddl_log_alter_after_rename_to_backup_log +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria +crash point: ddl_log_alter_before_rename_triggers +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria +crash point: ddl_log_alter_after_rename_triggers +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria +crash point: ddl_log_alter_after_delete_backup +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria +crash point: ddl_log_alter_after_drop_original_table +t2.MAD +t2.MAI +t2.frm +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria + +query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +t2.frm +t2.ibd +"Table is in test2" +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 +crash point: ddl_log_alter_after_rename_triggers +t2.frm +t2.ibd +"Table is in test2" +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 COMMENT "new", rename test2.t2 + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename test2.t2 +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +t2.frm +t2.ibd +"Table is in test2" +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename test2.t2 +crash point: ddl_log_alter_after_rename_triggers +t2.frm +t2.ibd +"Table is in test2" +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename test2.t2 +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 ADD key(b), COMMENT "new" + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD key(b), COMMENT "new" +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" + +query: ALTER TABLE t1 DROP INDEX a + +crash point: ddl_log_alter_after_create_frm +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_create_table +"No crash!" +crash point: ddl_log_alter_after_prepare_inplace +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_copy +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +crash point: ddl_log_alter_after_log +t1.frm +t1.ibd +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +count(*) +2 +master-bin.000002 # Query # # use `test`; ALTER TABLE t1 DROP INDEX a +crash point: ddl_log_alter_after_rename_to_backup +"No crash!" +crash point: ddl_log_alter_after_rename_to_backup_log +"No crash!" +crash point: ddl_log_alter_rename_frm +"No crash!" +crash point: ddl_log_alter_after_rename_to_original +"No crash!" +crash point: ddl_log_alter_before_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_rename_triggers +"No crash!" +crash point: ddl_log_alter_after_delete_backup +"No crash!" +crash point: ddl_log_alter_after_drop_original_table +"No crash!" diff --git a/mysql-test/suite/atomic/alter_table_innodb.test b/mysql-test/suite/atomic/alter_table_innodb.test new file mode 100644 index 00000000000..a70d05eba20 --- /dev/null +++ b/mysql-test/suite/atomic/alter_table_innodb.test @@ -0,0 +1,7 @@ +# +# Test atomic alter table with InnoDB + +--source include/have_innodb.inc +let $engine_count=1; +let $engines='innodb'; +--source alter_table.inc diff --git a/mysql-test/suite/atomic/alter_table.result b/mysql-test/suite/atomic/alter_table_myisam.result similarity index 54% rename from mysql-test/suite/atomic/alter_table.result rename to mysql-test/suite/atomic/alter_table_myisam.result index 8475f3c8c76..c072401359c 100644 --- a/mysql-test/suite/atomic/alter_table.result +++ b/mysql-test/suite/atomic/alter_table_myisam.result @@ -1739,1397 +1739,3 @@ t1 CREATE TABLE `t1` ( count(*) 2 master-bin.000002 # Query # # use `test`; ALTER TABLE t1 DROP INDEX a - -engine: innodb - - -query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new" - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 COMMENT "new" - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 change column a c int COMMENT "new" - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 -crash point: ddl_log_alter_after_rename_triggers -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2 -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 disable keys - -crash point: ddl_log_alter_after_create_frm -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_create_table -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_copy -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_log -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_rename_frm -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_delete_backup -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -Warnings: -Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option -"No crash!" - -query: ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_prepare_inplace -"No crash!" -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" -crash point: ddl_log_alter_after_drop_original_table -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" - -query: ALTER TABLE t1 rename t2 - -crash point: ddl_log_alter_after_create_frm -"No crash!" -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -"No crash!" -crash point: ddl_log_alter_after_copy -"No crash!" -crash point: ddl_log_alter_after_log -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_rename_triggers -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 COMMENT "new", rename t2 - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename t2 -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename t2 -crash point: ddl_log_alter_after_rename_triggers -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename t2 -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 change column a c int COMMENT "new", rename t2 - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", rename t2 -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", rename t2 -crash point: ddl_log_alter_after_rename_triggers -t2.frm -t2.ibd -Table Create Table -t2 CREATE TABLE `t2` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", rename t2 -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 ENGINE=aria, COMMENT "new" - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_prepare_inplace -"No crash!" -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup_log -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" -crash point: ddl_log_alter_after_drop_original_table -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ENGINE=aria, COMMENT "new" - -query: ALTER TABLE t1 change column a c int COMMENT "new", engine=aria - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_prepare_inplace -"No crash!" -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria -crash point: ddl_log_alter_after_rename_to_backup -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria -crash point: ddl_log_alter_after_rename_to_backup_log -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria -crash point: ddl_log_alter_after_drop_original_table -t1.MAD -t1.MAI -t1.frm -Table Create Table -t1 CREATE TABLE `t1` ( - `c` int(11) DEFAULT NULL COMMENT 'new', - `b` int(11) DEFAULT NULL, - KEY `a` (`c`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 change column a c int COMMENT "new", engine=aria - -query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_prepare_inplace -"No crash!" -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria -crash point: ddl_log_alter_after_rename_to_backup -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria -crash point: ddl_log_alter_after_rename_to_backup_log -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria -crash point: ddl_log_alter_before_rename_triggers -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria -crash point: ddl_log_alter_after_rename_triggers -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria -crash point: ddl_log_alter_after_delete_backup -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria -crash point: ddl_log_alter_after_drop_original_table -t2.MAD -t2.MAI -t2.frm -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename t2, engine=aria - -query: ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -t2.frm -t2.ibd -"Table is in test2" -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 -crash point: ddl_log_alter_after_rename_triggers -t2.frm -t2.ibd -"Table is in test2" -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, COMMENT "new", rename test2.t2 -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 COMMENT "new", rename test2.t2 - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename test2.t2 -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -t2.frm -t2.ibd -"Table is in test2" -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename test2.t2 -crash point: ddl_log_alter_after_rename_triggers -t2.frm -t2.ibd -"Table is in test2" -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 COMMENT "new", rename test2.t2 -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 ADD key(b), COMMENT "new" - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`), - KEY `b` (`b`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='new' -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD key(b), COMMENT "new" -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" - -query: ALTER TABLE t1 DROP INDEX a - -crash point: ddl_log_alter_after_create_frm -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_create_table -"No crash!" -crash point: ddl_log_alter_after_prepare_inplace -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_copy -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -crash point: ddl_log_alter_after_log -t1.frm -t1.ibd -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -count(*) -2 -master-bin.000002 # Query # # use `test`; ALTER TABLE t1 DROP INDEX a -crash point: ddl_log_alter_after_rename_to_backup -"No crash!" -crash point: ddl_log_alter_after_rename_to_backup_log -"No crash!" -crash point: ddl_log_alter_rename_frm -"No crash!" -crash point: ddl_log_alter_after_rename_to_original -"No crash!" -crash point: ddl_log_alter_before_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_rename_triggers -"No crash!" -crash point: ddl_log_alter_after_delete_backup -"No crash!" -crash point: ddl_log_alter_after_drop_original_table -"No crash!" diff --git a/mysql-test/suite/atomic/alter_table_myisam.test b/mysql-test/suite/atomic/alter_table_myisam.test new file mode 100644 index 00000000000..917438f464c --- /dev/null +++ b/mysql-test/suite/atomic/alter_table_myisam.test @@ -0,0 +1,6 @@ +# +# Test atomic alter table with MyISAM + +let $engine_count=1; +let $engines='myisam'; +--source alter_table.inc diff --git a/mysql-test/suite/atomic/alter_table_rocksdb.test b/mysql-test/suite/atomic/alter_table_rocksdb.test index fa34008dd58..3e51fc87f1c 100644 --- a/mysql-test/suite/atomic/alter_table_rocksdb.test +++ b/mysql-test/suite/atomic/alter_table_rocksdb.test @@ -3,4 +3,4 @@ let $engine_count=1; let $engines='rocksdb'; set global rocksdb_flush_log_at_trx_commit=1; ---source alter_table.test +--source alter_table.inc diff --git a/mysql-test/suite/atomic/alter_table_trigger.test b/mysql-test/suite/atomic/alter_table_trigger.test index 1d6d5c224c7..1c06fc49483 100644 --- a/mysql-test/suite/atomic/alter_table_trigger.test +++ b/mysql-test/suite/atomic/alter_table_trigger.test @@ -7,7 +7,7 @@ # # Testing of atomic create table with crashes in a lot of different places # -# This is very similar to the alter_table.test, but includes testing of +# This is very similar to the alter_table.inc, but includes testing of # triggers in with ALTER TABLE .. RENAME. # diff --git a/mysql-test/suite/binlog/r/binlog_commit_fail.result b/mysql-test/suite/binlog/r/binlog_commit_fail.result new file mode 100644 index 00000000000..dd9e62be638 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_commit_fail.result @@ -0,0 +1,116 @@ +set @@session.gtid_domain_id=1; +set @save_gtid_stric_mode=@@global.gtid_strict_mode; +create table ta (a int) engine=aria; +create table ti (a int) engine=innodb; +create table ti_pk (a int primary key) engine=innodb; +create table t (a int) engine=innodb; +create function f_i() +returns integer +begin +insert into ti set a=1; +return 1; +end | +create function f_ia(arg int) +returns integer +begin +insert into ti_pk set a=1; +insert into ta set a=1; +insert into ti_pk set a=arg; +return 1; +end | +call mtr.add_suppression("Error writing file"); +select count(*) as zero from t; +zero +0 +select count(*) as zero from ta; +zero +0 +select count(*) as zero from ti; +zero +0 +# 1. simple Innodb test +set @@global.gtid_strict_mode=0; +set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +insert into t set a=1; +ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled +# observe effective rollback +select count(*) as zero from t; +zero +0 +# 2. simple Aira test +set @@global.gtid_strict_mode=0; +set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +insert into ta values (1),(2); +ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled +# note no rollback +select count(*) as '*NON-zero*' from ta; +*NON-zero* +2 +delete from ta; +# 3. multi-engine test +set @@global.gtid_strict_mode=0; +set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +insert into ta set a=f_i(); +ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled +# note no rollback.. +select count(*) as one from ta; +one +1 +# ..except transactional engine +select count(*) as zero from ti; +zero +0 +delete from ta; +set @@global.gtid_strict_mode=0; +set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +insert into t set a=f_ia(0); +ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled +# note no rollback.. +select count(*) as one from ta; +one +1 +# ..except transactional engine +select count(*) as zero from t; +zero +0 +select count(*) as zero from ti_pk; +zero +0 +delete from ta; +# 4. create-table-select-f() +set @@global.gtid_strict_mode=0; +set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +create table f_x (a int) select f_i() as a; +ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled +# rollback indeed takes place in the pure transactional case +select count(*) as zero from ti; +zero +0 +set @@global.gtid_strict_mode=0; +set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +create table t_x (a int) engine=aria select f_ia(0) as a; +ERROR HY000: An attempt was made to binlog GTID VALUE which would create an out-of-order sequence number with existing GTID VALUE, and gtid strict mode is enabled +select * from t_x; +ERROR 42S02: Table 'test.t_x' doesn't exist +# **TODO**: fix MDEV-36027 +# **TODO**: the empty binlog is buggy .. +include/show_binlog_events.inc +# .. as non-transactional `ta` (and `t_x` sic!) are modified +select count(*) as one from ta; +one +1 +select count(*) as zero from ti; +zero +0 +delete from ta; +#. +set @@global.gtid_strict_mode=@save_gtid_stric_mode; +drop function f_i; +drop function f_ia; +drop table t, ta, ti, ti_pk; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_warn_stop_position.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_warn_stop_position.result index 1517fd765ac..40fb791cf02 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_warn_stop_position.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_warn_stop_position.result @@ -18,6 +18,51 @@ drop table t1; # Ensuring file offset of binlog_f2_mid < binlog_f1_end # # +# Test using --read-from-remote-server +# +connection default; +# +# --stop-position tests +# +# Case 1.a) With one binlog file, a --stop-position before the end of +# the file should not result in a warning +# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f1_pre_rotate binlog_f1_full --result-file=tmp/warn_position_test_file.out 2>&1 +# +# Case 1.b) With one binlog file, a --stop-position at the exact end of +# the file should not result in a warning +# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f1_end binlog_f1_full --result-file=tmp/warn_position_test_file.out 2>&1 +# +# Case 1.c) With one binlog file, a --stop-position past the end of the +# file should(!) result in a warning +# MYSQL_BINLOG --read-from-remote-server --short-form --stop-position=binlog_f1_over_eof binlog_f1_full --result-file=tmp/warn_position_test_file.out 2>&1 +WARNING: Did not reach stop position before end of input +# +# Case 2.a) With two binlog files, a --stop-position targeting b2 which +# exists in the size of b1 should: +# 1) not provide any warnings +# 2) not prevent b2 from outputting its desired events before the +# stop position +# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f2_mid binlog_f1_full binlog_f2_full --result-file=tmp/warn_position_test_file.out 2>&1 +include/assert_grep.inc [Ensure all intended GTIDs are present] +include/assert_grep.inc [Ensure the next GTID binlogged is _not_ present] +# +# Case 2.b) With two binlog files, a --stop-position targeting the end +# of binlog 2 should: +# 1) not provide any warnings +# 2) not prevent b2 from outputting its entire binary log +# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f2_end binlog_f1_full binlog_f2_full --result-file=tmp/warn_position_test_file.out 2>&1 +include/assert_grep.inc [Ensure a GTID exists for each transaction] +include/assert_grep.inc [Ensure the last GTID binlogged is present] +# +# Case 2.c) With two binlog files, a --stop-position targeting beyond +# the eof of binlog 2 should: +# 1) provide a warning that the stop position was not reached +# 2) not prevent b2 from outputting its entire binary log +# MYSQL_BINLOG --read-from-remote-server --stop-position=binlog_f2_over_eof binlog_f1_full binlog_f2_full --result-file=tmp/warn_position_test_file.out 2>&1 +WARNING: Did not reach stop position before end of input +include/assert_grep.inc [Ensure a GTID exists for each transaction] +# +# # Test using local binlog files # connection default; diff --git a/mysql-test/suite/binlog/t/binlog_commit_fail.test b/mysql-test/suite/binlog/t/binlog_commit_fail.test new file mode 100644 index 00000000000..d88ad552b07 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_commit_fail.test @@ -0,0 +1,135 @@ +# Tests of commit time failures. +# At committing of an auto-commit statement a failure to commit in its +# binlog branch should rollback at least the transactional part of the statement. +# +# References: +# MDEV-35506 commit policy of one-phase-commit even at errored-out binlogging leads to assert +# MDEV-36027 Errored-out CREATE-SELECT does not binlog results of non-transactional table modification + +source include/have_innodb.inc; +source include/have_binlog_format_row.inc; + +set @@session.gtid_domain_id=1; +set @save_gtid_stric_mode=@@global.gtid_strict_mode; + +create table ta (a int) engine=aria; +create table ti (a int) engine=innodb; +create table ti_pk (a int primary key) engine=innodb; +create table t (a int) engine=innodb; +delimiter |; +create function f_i() +returns integer +begin + insert into ti set a=1; +return 1; +end | +create function f_ia(arg int) +returns integer +begin + insert into ti_pk set a=1; + insert into ta set a=1; + insert into ti_pk set a=arg; + return 1; +end | +delimiter ;| + +call mtr.add_suppression("Error writing file"); + +# Naturally all empty now +select count(*) as zero from t; +select count(*) as zero from ta; +select count(*) as zero from ti; + +# Force manual value assignement to gtid::seq_no while in the strict mode +# so that the value is rejected. Despite the errorred out statement +# being at its commit phase it will eventually be rolled back. +# Side effects of non-transactional engines, like Aria, are displayed. +--echo # 1. simple Innodb test +set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +# mask possible allowed seq_no shift +--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/ +--error ER_GTID_STRICT_OUT_OF_ORDER +insert into t set a=1; + +--echo # observe effective rollback +select count(*) as zero from t; + +--echo # 2. simple Aira test +set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/ +--error ER_GTID_STRICT_OUT_OF_ORDER +insert into ta values (1),(2); + +--echo # note no rollback +select count(*) as '*NON-zero*' from ta; +# local cleanup +delete from ta; + +--echo # 3. multi-engine test +# A. non-transactional top-level +set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/ +--error ER_GTID_STRICT_OUT_OF_ORDER +insert into ta set a=f_i(); +--echo # note no rollback.. +select count(*) as one from ta; +--echo # ..except transactional engine +select count(*) as zero from ti; +delete from ta; + +# B. non-transactional in the leaf +set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/ +--error ER_GTID_STRICT_OUT_OF_ORDER +insert into t set a=f_ia(0); + +--echo # note no rollback.. +select count(*) as one from ta; +--echo # ..except transactional engine +select count(*) as zero from t; +select count(*) as zero from ti_pk; +delete from ta; + +--echo # 4. create-table-select-f() +--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) +--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) +# A. two phase commit branch +set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/ +--error ER_GTID_STRICT_OUT_OF_ORDER +create table f_x (a int) select f_i() as a; +--echo # rollback indeed takes place in the pure transactional case +select count(*) as zero from ti; + +# B. one phase commit branch +--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) +--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) +set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1; +set @@global.gtid_strict_mode=1; +--replace_regex /GTID 1-1-[0-9]+/GTID VALUE/ +--error ER_GTID_STRICT_OUT_OF_ORDER +create table t_x (a int) engine=aria select f_ia(0) as a; +--error ER_NO_SUCH_TABLE +select * from t_x; + +--echo # **TODO**: fix MDEV-36027 +--echo # **TODO**: the empty binlog is buggy .. +--source include/show_binlog_events.inc +--echo # .. as non-transactional `ta` (and `t_x` sic!) are modified +select count(*) as one from ta; +select count(*) as zero from ti; + +delete from ta; +--echo #. + +# cleanup + +set @@global.gtid_strict_mode=@save_gtid_stric_mode; +drop function f_i; +drop function f_ia; +drop table t, ta, ti, ti_pk; diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_warn_stop_position.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_warn_stop_position.test index a9179297220..472e208229c 100644 --- a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_warn_stop_position.test +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_warn_stop_position.test @@ -64,13 +64,12 @@ if ($binlog_f2_mid > $binlog_f1_end) --die Mid point chosen to end in binlog 2 does not exist in earlier binlog } -#--echo # -#--echo # -#--echo # Test using --read-from-remote-server -#--echo # -#--let $read_from_remote_server= 1 -#--emit warning is not supported by --read-from-remote-server now -#--source binlog_mysqlbinlog_warn_stop_position.inc +--echo # +--echo # +--echo # Test using --read-from-remote-server +--echo # +--let $read_from_remote_server= 1 +--source binlog_mysqlbinlog_warn_stop_position.inc --echo # --echo # diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index a090c640425..64d67ae646b 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -7,9 +7,6 @@ connection default; set global federated_pushdown=1; -#Enable after fix MDEV-31846 or in v. 10.5 and later ---disable_cursor_protocol - connection slave; DROP TABLE IF EXISTS federated.t1; @@ -170,11 +167,13 @@ insert into federated.t4 select * from federated.t1; --sorted_result select * from federated.t4; +--disable_cursor_protocol select name into @var from federated.t1 where id=3 limit 1 ; select @var; --disable_ps2_protocol select name into outfile 'tmp.txt' from federated.t1; --enable_ps2_protocol +--enable_cursor_protocol let $path=`select concat(@@datadir, 'test/tmp.txt')`; remove_file $path; @@ -860,7 +859,5 @@ connection default; set global federated_pushdown=0; ---enable_cursor_protocol - source include/federated_cleanup.inc; diff --git a/mysql-test/suite/galera/r/galera_as_slave_nonprim.result b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result index 969e844577e..3f625989fa1 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_nonprim.result +++ b/mysql-test/suite/galera/r/galera_as_slave_nonprim.result @@ -12,7 +12,6 @@ connection node_1; connection node_4; INSERT INTO t1 VALUES (1),(2),(3),(4),(5); connection node_2; -connection node_1; expected_error 1 connection node_2; diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result b/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result index 5412cd3faee..abdf46f84ba 100644 --- a/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result +++ b/mysql-test/suite/galera/r/galera_toi_ddl_nonconflicting.result @@ -1,29 +1,69 @@ connection node_2; connection node_1; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +INSERT INTO t1(f2) SELECT seq FROM seq_1_to_1000; +connection node_2a; +SET SESSION wsrep_sync_wait=0; +connection node_1a; +# Block the applier on node_1 and issue a ddl from node_2 +SET SESSION wsrep_sync_wait=0; +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; connection node_2; -ALTER TABLE t1 ADD COLUMN f3 INTEGER; INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 123);; +# DDL 1 +ALTER TABLE t1 ADD COLUMN f3 INTEGER; INSERT INTO t1 VALUES (NULL, 10000, 10000);; +connection node_1a; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +# This will block on acquiring total order isolation connection node_1; +# DDL 2 CREATE UNIQUE INDEX i1 ON t1(f2);; +connection node_1a; +# Signal DDL 1 +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; connection node_2; -INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 234); -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 3 -1 -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 2 FROM t1; -COUNT(*) = 2 -1 connection node_1; -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -COUNT(*) = 3 -1 -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; -COUNT(*) = 2 -1 -SELECT COUNT(*) = 2 FROM t1; -COUNT(*) = 2 -1 +connection node_2; +SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +EXPECT_3 +3 +SELECT COUNT(*) AS EXPECT_2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +EXPECT_2 +2 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL AUTO_INCREMENT, + `f2` int(11) DEFAULT NULL, + `f3` int(11) DEFAULT NULL, + PRIMARY KEY (`f1`), + UNIQUE KEY `i1` (`f2`) +) ENGINE=InnoDB AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT COUNT(*) AS EXPECT_1001 FROM t1; +EXPECT_1001 +1001 +connection node_1; +SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +EXPECT_3 +3 +SELECT COUNT(*) AS EXPECT_2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +EXPECT_2 +2 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL AUTO_INCREMENT, + `f2` int(11) DEFAULT NULL, + `f3` int(11) DEFAULT NULL, + PRIMARY KEY (`f1`), + UNIQUE KEY `i1` (`f2`) +) ENGINE=InnoDB AUTO_INCREMENT=2047 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT COUNT(*) AS EXPECT_1001 FROM t1; +EXPECT_1001 +1001 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result b/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result index 20701aa1108..5679265743c 100644 --- a/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result +++ b/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result @@ -203,6 +203,9 @@ id b 3 200 4 5 connection node_2; +SELECT COUNT(*) FROM t1; +COUNT(*) +10 SELECT * FROM t1 ORDER BY id; id b 1 1 @@ -228,6 +231,9 @@ DROP TABLE t1, t2; CREATE TABLE t1 (a INT, b INT, UNIQUE(a)) ENGINE=MyISAM; CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a=1; INSERT INTO t1 (a,b) VALUES (10,20); +SELECT * from t1; +a b +1 20 connection node_2; SELECT * from t1; a b diff --git a/mysql-test/suite/galera/r/galera_vote_during_ist.result b/mysql-test/suite/galera/r/galera_vote_during_ist.result new file mode 100644 index 00000000000..adbe0e2fe7d --- /dev/null +++ b/mysql-test/suite/galera/r/galera_vote_during_ist.result @@ -0,0 +1,112 @@ +connection node_4; +connection node_3; +connection node_2; +connection node_1; +# Correct Galera library found +connection node_1; +connection node_2; +connection node_3; +connection node_4; +connection node_1; +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); +CREATE PROCEDURE p1(IN max INT) +BEGIN +DECLARE i INT; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET i = 0; +WHILE i < max DO +INSERT IGNORE INTO t1 VALUES (DEFAULT); +SET i = i + 1; +END WHILE; +END| +CALL p1(130); +connection node_4; +Shutting down server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +Server 4 left the cluster +connection node_1; +CALL p1(130); +connection node_1; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_2; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_3; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +INSERT INTO t2 VALUES (DEFAULT); +CALL p1(130); +connection node_1; +SET GLOBAL debug = "+d,sync.wsrep_sst_donor_after_donation"; +Restarting server 4 +Wait for server 1 to become a donor +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_sst_donor_after_donation_reached"; +Server 1 got SST request from server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_sst_donor_after_donation_continue"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; +Waiting for server 4 to leave the cluster +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_4; +Server 4 left the cluster, killing it... +Killed server 4... +Restarting server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SELECT count(*) AS expect1_390 FROM t1; +expect1_390 +390 +SELECT count(*) AS expect1_1 FROM t2; +expect1_1 +1 +connection node_2; +SELECT count(*) AS expect2_390 FROM t1; +expect2_390 +390 +SELECT count(*) AS expect2_1 FROM t2; +expect2_1 +1 +connection node_3; +SELECT count(*) AS expect3_390 FROM t1; +expect3_390 +390 +SELECT count(*) AS expect3_1 FROM t2; +expect3_1 +1 +connection node_4; +SELECT count(*) AS expect4_390 FROM t1; +expect4_390 +390 +SELECT count(*) AS expect4_1 FROM t2; +expect4_1 +1 +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); +CALL mtr.add_suppression("Failed to apply write set"); +CALL mtr.add_suppression("Sending JOIN failed: -103"); +CALL mtr.add_suppression("Failed to JOIN the cluster after SST"); diff --git a/mysql-test/suite/galera/r/galera_vote_joined_apply.result b/mysql-test/suite/galera/r/galera_vote_joined_apply.result new file mode 100644 index 00000000000..4458dd32fb8 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_vote_joined_apply.result @@ -0,0 +1,94 @@ +connection node_4; +connection node_3; +connection node_2; +connection node_1; +# Correct Galera library found +connection node_1; +connection node_2; +connection node_3; +connection node_4; +connection node_1; +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); +CREATE PROCEDURE p1(IN max INT) +BEGIN +DECLARE i INT; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET i = 0; +WHILE i < max DO +INSERT IGNORE INTO t1 VALUES (DEFAULT); +SET i = i + 1; +END WHILE; +END| +CALL p1(130); +connection node_4; +Shutting down server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +SET GLOBAL debug = "+d,sync.wsrep_donor_state"; +connection node_4; +Restarting server 4... +connection node_1; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_donor_state_reached"; +Tables on server 1 flushed and locked for SST to server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_donor_state"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; +Wait for the state snapshot to be copied to server 4 +SST script unlocked server 1 +connection node_1; +CALL p1(130); +connection node_1; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_2; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_3; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +INSERT INTO t2 VALUES (DEFAULT); +CALL p1(130); +Waiting for server 4 to leave the cluster +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_4; +Server 4 left the cluster, killing it... +Killed server 4... +Restarting server 4... +DROP TABLE t2; +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SELECT count(*) AS expect1_390 FROM t1; +expect1_390 +390 +connection node_2; +SELECT count(*) AS expect2_390 FROM t1; +expect2_390 +390 +connection node_3; +SELECT count(*) AS expect3_390 FROM t1; +expect3_390 +390 +connection node_4; +SELECT count(*) AS expect4_390 FROM t1; +expect4_390 +390 +DROP TABLE t1; +DROP PROCEDURE p1; +connection node_4; +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus"); +CALL mtr.add_suppression("Failed to apply write set: gtid:"); diff --git a/mysql-test/suite/galera/r/galera_vote_joined_skip.result b/mysql-test/suite/galera/r/galera_vote_joined_skip.result new file mode 100644 index 00000000000..187028fd55c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_vote_joined_skip.result @@ -0,0 +1,102 @@ +connection node_4; +connection node_3; +connection node_2; +connection node_1; +# Correct Galera library found +connection node_1; +connection node_2; +connection node_3; +connection node_4; +connection node_1; +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); +CREATE PROCEDURE p1(IN max INT) +BEGIN +DECLARE i INT; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET i = 0; +WHILE i < max DO +INSERT IGNORE INTO t1 VALUES (DEFAULT); +SET i = i + 1; +END WHILE; +END| +CALL p1(130); +connection node_4; +Shutting down server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +SET GLOBAL debug = "+d,sync.wsrep_donor_state"; +connection node_4; +Restarting server 4... +connection node_1; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_donor_state_reached"; +Tables on server 1 flushed and locked for SST to server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_donor_state"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; +Wait for the state snapshot to be copied to server 4 +SST script unlocked server 1 +connection node_1; +CALL p1(130); +connection node_3; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +INSERT INTO t2 VALUES (DEFAULT); +SET SESSION wsrep_on = OFF; +connection node_1; +CALL p1(130); +Waiting for server 3 to leave the cluster +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_4; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +Server 3 left the cluster, killing it... +Killed server 3. +Restarting server 3... +Waiting for server 3 to rejoin the cluster +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +sleeping for 20 +Waiting ready +Server 3 restarted. +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SELECT count(*) AS expect1_390 FROM t1; +expect1_390 +390 +connection node_2; +SELECT count(*) AS expect2_390 FROM t1; +expect2_390 +390 +connection node_3; +SELECT count(*) AS expect3_390 FROM t1; +expect3_390 +390 +connection node_4; +SELECT count(*) AS expect4_390 FROM t1; +expect4_390 +390 +DROP TABLE t1; +DROP PROCEDURE p1; +connection node_1; +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +connection node_2; +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +connection node_3; +CALL mtr.add_suppression("Vote 0 \\(success\\) on .+ is inconsistent with group"); +connection node_4; +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); diff --git a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test index 2769357c05e..b0bbf5e0030 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_nonprim.test +++ b/mysql-test/suite/galera/t/galera_as_slave_nonprim.test @@ -2,7 +2,7 @@ # Test the behavior of a Galera async slave if it goes non-prim. Async replication # should abort with an error but it should be possible to restart it. # -# The galera/galera_2node_slave.cnf describes the setup of the nodes +# The galera_3nodes_as_slave.cnf describes the setup of the nodes # --source include/have_innodb.inc @@ -45,9 +45,8 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; INSERT INTO t1 VALUES (1),(2),(3),(4),(5); --connection node_2 ---sleep 5 +wait_for_slave_to_stop; --let $value = query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1) ---connection node_1 --disable_query_log --eval SELECT "$value" IN ("Error 'Unknown command' on query. Default database: 'test'. Query: 'BEGIN'", "Node has dropped from cluster") AS expected_error --enable_query_log @@ -75,7 +74,6 @@ START SLAVE; --connection node_4 DROP TABLE t1; ---sleep 2 --connection node_2 --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test b/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test index d431fc0b9ed..9836aaa57ef 100644 --- a/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test +++ b/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test @@ -1,43 +1,81 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_sequence.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/galera_have_debug_sync.inc # # In this test, we simultaneously send two non-conflicting ALTER TABLE statements # +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); +INSERT INTO t1(f2) SELECT seq FROM seq_1_to_1000; ---connection node_2 +--connection node_2a +SET SESSION wsrep_sync_wait=0; --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; --source include/wait_condition.inc ---send ALTER TABLE t1 ADD COLUMN f3 INTEGER; INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 123); +--let $wait_condition = SELECT COUNT(*) = 1000 FROM t1; +--source include/wait_condition.inc +--connection node_1a +--echo # Block the applier on node_1 and issue a ddl from node_2 +SET SESSION wsrep_sync_wait=0; +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_set_sync_point.inc + +--connection node_2 +--echo # DDL 1 +--send ALTER TABLE t1 ADD COLUMN f3 INTEGER; INSERT INTO t1 VALUES (NULL, 10000, 10000); + +--connection node_1a +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + +--echo # This will block on acquiring total order isolation --connection node_1 +--echo # DDL 2 --send CREATE UNIQUE INDEX i1 ON t1(f2); +--connection node_1a +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'acquiring total order%' or STATE LIKE 'Waiting for table metadata%' +--source include/wait_condition.inc + +--echo # Signal DDL 1 +--source include/galera_clear_sync_point.inc +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_signal_sync_point.inc + --connection node_2 --reap -INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 234); - ---let $wait_condition = SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc ---let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; -SELECT COUNT(*) = 2 FROM t1; --connection node_1 --reap +--connection node_2 --let $wait_condition = SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc -SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; -SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; -SELECT COUNT(*) = 2 FROM t1; +SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) AS EXPECT_2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +SHOW CREATE TABLE t1; +SELECT COUNT(*) AS EXPECT_1001 FROM t1; + +--connection node_1 +--let $wait_condition = SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) AS EXPECT_2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +SHOW CREATE TABLE t1; +SELECT COUNT(*) AS EXPECT_1001 FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test index feec79196c3..9364b9b52d6 100644 --- a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test +++ b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test @@ -22,6 +22,8 @@ SET GLOBAL wsrep_on = ON; DROP TABLE t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc SHOW TABLES; # Drop schema that does not exist @@ -33,6 +35,8 @@ SET GLOBAL wsrep_on = ON; DROP SCHEMA s1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 's1'; +--source include/wait_condition.inc SHOW SCHEMAS; # Drop index that does not exist using DROP INDEX @@ -45,6 +49,10 @@ SET GLOBAL wsrep_on = ON; DROP INDEX idx1 ON t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE NAME LIKE 'idx1'; +--source include/wait_condition.inc SHOW CREATE TABLE t1; DROP TABLE t1; @@ -58,6 +66,10 @@ SET GLOBAL wsrep_on = ON; ALTER TABLE t1 DROP INDEX idx1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE NAME LIKE 'idx1'; +--source include/wait_condition.inc SHOW CREATE TABLE t1; DROP TABLE t1; @@ -71,6 +83,11 @@ SET GLOBAL wsrep_on = ON; ALTER TABLE t1 DROP COLUMN f2; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE NAME LIKE 'f2'; +--source include/wait_condition.inc + SHOW CREATE TABLE t1; DROP TABLE t1; @@ -93,6 +110,10 @@ DELETE FROM t1 WHERE f1 = 1; SELECT COUNT(*) AS expect_0 FROM t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 0 FROM t1; +--source include/wait_condition.inc SELECT COUNT(*) AS expect_0 FROM t1; DROP TABLE t1; @@ -112,6 +133,10 @@ COMMIT; SELECT COUNT(*) AS expect_1 FROM t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc SELECT COUNT(*) AS expect_1 FROM t1; DROP TABLE t1; @@ -136,6 +161,8 @@ DELETE FROM t1; SELECT COUNT(*) AS expect_0 FROM t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 0 FROM t1; --source include/wait_condition.inc SELECT VARIABLE_VALUE expect_Primary FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; @@ -171,6 +198,8 @@ SET AUTOCOMMIT=ON; SELECT COUNT(*) AS expect_0 FROM t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 0 FROM t1; --source include/wait_condition.inc SELECT VARIABLE_VALUE expect_Primary FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; @@ -202,6 +231,8 @@ DELETE t1, t2 FROM t1 JOIN t2 WHERE t1.f1 = t2.f1; SELECT COUNT(*) expect_0 FROM t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 0 FROM t1; --source include/wait_condition.inc SELECT VARIABLE_VALUE = 'Primary' FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; @@ -219,6 +250,10 @@ CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KE INSERT INTO child VALUES (1,1),(2,2),(3,3); --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/parent'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/child'; +--source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 3 FROM child; --source include/wait_condition.inc @@ -233,6 +268,10 @@ SELECT COUNT(*) AS expect_0 FROM parent; SELECT COUNT(*) AS expect_0 FROM child; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/parent'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/child'; +--source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 0 FROM child; --source include/wait_condition.inc SELECT VARIABLE_VALUE = 'Primary' FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; diff --git a/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test b/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test index 8cfe82fd457..45936676d4f 100644 --- a/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test +++ b/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test @@ -21,6 +21,11 @@ INSERT INTO t1 VALUES (2), (3); INSERT INTO t1 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 5 FROM t1; +--source include/wait_condition.inc + SELECT COUNT(*) AS EXPECT_5 FROM t1; DROP TABLE t1; @@ -36,6 +41,13 @@ REPLACE INTO t1 VALUES (1, 'klm'), (2,'xyz'); REPLACE INTO t1 SELECT 3, 'yyy' FROM DUAL; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 3 FROM t1; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 3 AND f2 = 'yyy'; +--source include/wait_condition.inc + SELECT COUNT(*) AS EXPECT_3 FROM t1; SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f1 = 1 AND f2 = 'klm'; SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f1 = 2 AND f2 = 'xyz'; @@ -49,6 +61,9 @@ SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f1 = 3 AND f2 = 'yyy'; UPDATE t1 SET f2 = 'zzz' WHERE f2 = 'yyy'; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'zzz'; +--source include/wait_condition.inc + SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'zzz'; # @@ -59,6 +74,9 @@ SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'zzz'; DELETE FROM t1 WHERE f2 = 'zzz'; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM t1 WHERE f2 = 'zzz'; +--source include/wait_condition.inc + SELECT COUNT(*) AS EXPECT_0 FROM t1 WHERE f2 = 'zzz'; # @@ -69,6 +87,9 @@ SELECT COUNT(*) AS EXPECT_0 FROM t1 WHERE f2 = 'zzz'; TRUNCATE TABLE t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM t1; +--source include/wait_condition.inc + SELECT COUNT(*) AS EXPECT_0 FROM t1; DROP TABLE t1; @@ -86,6 +107,15 @@ INSERT INTO t2 VALUES (1); COMMIT; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t2; +--source include/wait_condition.inc + SELECT COUNT(*) AS EXPECT_1 FROM t1; SELECT COUNT(*) AS EXPECT_1 FROM t2; @@ -100,6 +130,11 @@ INSERT INTO t2 VALUES (2); ROLLBACK; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 2 FROM t1; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t2; +--source include/wait_condition.inc + SELECT COUNT(*) AS EXPECT_2 FROM t1; SELECT COUNT(*) AS EXPECT_1 FROM t2; @@ -119,7 +154,13 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); --connection node_2 -# The MyISAM update is replicated immediately, so a duplicate key error happens even before the COMMIT +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc +# The MyISAM update is replicated when executed, so a duplicate key error happens even before the COMMIT --error ER_DUP_ENTRY INSERT INTO t1 VALUES (1); @@ -147,6 +188,10 @@ EXECUTE rep; SELECT * FROM t1 ORDER BY id; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 11 FROM t1; +--source include/wait_condition.inc SELECT * FROM t1 ORDER BY id; DROP TABLE t1; @@ -173,6 +218,10 @@ CALL proc(); SELECT * FROM t1 ORDER BY id; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 11 FROM t1; +--source include/wait_condition.inc SELECT * FROM t1 ORDER BY id; DROP PROCEDURE proc; @@ -196,6 +245,13 @@ SELECT * FROM t1 ORDER BY id; SELECT * FROM t2 ORDER BY id; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'; +--source include/wait_condition.inc +SELECT COUNT(*) FROM t1; +--let $wait_condition = SELECT COUNT(*) = 10 FROM t1; +--source include/wait_condition.inc SELECT * FROM t1 ORDER BY id; SELECT * FROM t2 ORDER BY id; DROP TRIGGER tr1; @@ -206,8 +262,14 @@ DROP TABLE t1, t2; CREATE TABLE t1 (a INT, b INT, UNIQUE(a)) ENGINE=MyISAM; CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a=1; INSERT INTO t1 (a,b) VALUES (10,20); +SELECT * from t1; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc + SELECT * from t1; --connection node_1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_vote_during_ist.cnf b/mysql-test/suite/galera/t/galera_vote_during_ist.cnf new file mode 100644 index 00000000000..d6c7d771d5d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_during_ist.cnf @@ -0,0 +1,20 @@ +!include ../galera_4nodes.cnf + +[mysqld] +wsrep-ignore-apply-errors=0 + +[mysqld.1] +wsrep_node_name='node_1' + +[mysqld.2] +wsrep_node_name='node_2' + +[mysqld.3] +wsrep_node_name='node_3' + +[mysqld.4] +wsrep_node_name='node_4' +wsrep_sst_donor='node_1' + +[ENV] +galera_cluster_size=4 diff --git a/mysql-test/suite/galera/t/galera_vote_during_ist.test b/mysql-test/suite/galera/t/galera_vote_during_ist.test new file mode 100644 index 00000000000..eff7f527300 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_during_ist.test @@ -0,0 +1,165 @@ +# +# Test a case where a joiner encounters an error during IST +# Instead of voting it should assume error and bail out. +# + +--source include/galera_cluster.inc +--source include/big_test.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# Make sure that the test is operating on the right version of galera library. +--let $galera_version=26.4.19 +source ../wsrep/include/check_galera_version.inc; + +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--let $node_4=node_4 +--source ../include/auto_increment_offset_save.inc + +# create table t1 and procedure p1 to generate wirtesets +--connection node_1 +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); + +DELIMITER |; +CREATE PROCEDURE p1(IN max INT) +BEGIN + DECLARE i INT; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + + SET i = 0; + WHILE i < max DO + INSERT IGNORE INTO t1 VALUES (DEFAULT); + SET i = i + 1; + END WHILE; +END| +DELIMITER ;| + +CALL p1(130); + +--connection node_4 +--echo Shutting down server 4... +--let $node_4_server_id= `SELECT @@server_id` +--let $node_4_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$node_4_server_id.expect +--let $node_4_pid_file= `SELECT @@pid_file` +--source include/shutdown_mysqld.inc + +# Wait for node #4 to leave cluster +--let $members = 3 +--connection node_1 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_3 +--source include/wsrep_wait_membership.inc +--echo Server 4 left the cluster + +# Create some writesets for IST +--connection node_1 +CALL p1(130); + +# Create a writeset that node 4 won't be able to apply by creating a table +# that won't be present in the replication stream +--connection node_1 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_2 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_3 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +# This should cause error during IST +INSERT INTO t2 VALUES (DEFAULT); + +# make sure nodes 1,2,3 progress far enough for commit cut update +CALL p1(130); + +--connection node_1 +# prepare to stop SST donor thread when it receives a request from starting node #4 +SET GLOBAL debug = "+d,sync.wsrep_sst_donor_after_donation"; + +--echo Restarting server 4 +# Need to use this form instead of start_mysqld.inc because the latter is blocking +--exec echo "restart:$start_mysqld_params" > $node_4_expect_file_name + +--echo Wait for server 1 to become a donor +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_sst_donor_after_donation_reached"; +--echo Server 1 got SST request from server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_sst_donor_after_donation_continue"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; + +# +# After this point node #4 shall proceed to IST and bail out +# + +--echo Waiting for server 4 to leave the cluster +--let $members = 3 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_3 +--source include/wsrep_wait_membership.inc + +--connection node_4 +--echo Server 4 left the cluster, killing it... + +# Kill the connected server +--exec echo "wait" > $node_4_expect_file_name +--let KILL_NODE_PIDFILE = $node_4_pid_file +--perl + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -9 $mysqld_pid"); + exit(0); +EOF +--echo Killed server 4... +--source include/wait_until_disconnected.inc +--echo Restarting server 4... +--source include/start_mysqld.inc +--source include/galera_wait_ready.inc + +# Confirm node #4 has rejoined +--connection node_1 +--let $members = 4 +--source include/wsrep_wait_membership.inc + +# Confirm that all is good and all nodes have identical data + +--connection node_1 +SELECT count(*) AS expect1_390 FROM t1; +SELECT count(*) AS expect1_1 FROM t2; + +--connection node_2 +SELECT count(*) AS expect2_390 FROM t1; +SELECT count(*) AS expect2_1 FROM t2; + +--connection node_3 +SELECT count(*) AS expect3_390 FROM t1; +SELECT count(*) AS expect3_1 FROM t2; + +--connection node_4 +SELECT count(*) AS expect4_390 FROM t1; +SELECT count(*) AS expect4_1 FROM t2; + +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; + +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); +CALL mtr.add_suppression("Failed to apply write set"); +CALL mtr.add_suppression("Sending JOIN failed: -103"); +CALL mtr.add_suppression("Failed to JOIN the cluster after SST"); + +--source ../include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_vote_joined_apply.cnf b/mysql-test/suite/galera/t/galera_vote_joined_apply.cnf new file mode 100644 index 00000000000..88a1982bf66 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_apply.cnf @@ -0,0 +1,21 @@ +!include ../galera_4nodes.cnf + +[mysqld] +wsrep-ignore-apply-errors=0 + +[mysqld.1] +wsrep_node_name='node_1' + +[mysqld.2] +wsrep_node_name='node_2' + +[mysqld.3] +wsrep_node_name='node_3' + +[mysqld.4] +wsrep_node_name='node_4' +wsrep_sst_donor='node_1' + +[ENV] +galera_cluster_size=4 +MTR_SST_JOINER_DELAY=20 diff --git a/mysql-test/suite/galera/t/galera_vote_joined_apply.test b/mysql-test/suite/galera/t/galera_vote_joined_apply.test new file mode 100644 index 00000000000..bbd40323f87 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_apply.test @@ -0,0 +1,73 @@ +# +# Test a case where a vote happens in JOINED state after SST on a writeset +# that should be applied. +# + +--source galera_vote_joined_begin.inc +# +# At this point state snapshot has been copied, node 1 is operational and +# we have about 10 seconds while everything we do will go into the replication +# queue on node 4 which it will have to apply on top of the snapshot. +# + +# Increase replication queue on node_4 +--connection node_1 +CALL p1(130); + +# Create a writeset that node 4 won't be able to apply by creating a table +# that won't be present in the replication stream +--connection node_1 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_2 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_3 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +# This should cause node #4 to initiate a vote and leave the cluster +INSERT INTO t2 VALUES (DEFAULT); + +# make sure nodes 1,2,3 progress far enough for commit cut update +CALL p1(130); + +--echo Waiting for server 4 to leave the cluster +--let $members = 3 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_1 +--source include/wsrep_wait_membership.inc + +--connection node_4 +--echo Server 4 left the cluster, killing it... +# Kill the connected server +--exec echo "wait" > $node_4_expect_file_name +--let KILL_NODE_PIDFILE = $node_4_pid_file +--perl + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -9 $mysqld_pid"); + exit(0); +EOF +--echo Killed server 4... +--source include/wait_until_disconnected.inc +--echo Restarting server 4... +--source include/start_mysqld.inc +--source include/galera_wait_ready.inc +DROP TABLE t2; + +--source galera_vote_joined_end.inc + +--connection node_4 +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus"); +CALL mtr.add_suppression("Failed to apply write set: gtid:"); diff --git a/mysql-test/suite/galera/t/galera_vote_joined_begin.inc b/mysql-test/suite/galera/t/galera_vote_joined_begin.inc new file mode 100644 index 00000000000..3e8befc3ece --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_begin.inc @@ -0,0 +1,79 @@ +# This file purpose is to set up node 4 to require SST which is artificaially +# prolonged and as a result accumulate sufficient relication queue. +# The contents of the qeuee are controlled in the sourcing test files. + +--source include/galera_cluster.inc +--source include/big_test.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# Make sure that the test is operating on the right version of galera library. +--let $galera_version=26.4.19 +source ../wsrep/include/check_galera_version.inc; + +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--let $node_4=node_4 +--source ../include/auto_increment_offset_save.inc + +# create table t1 and procedure p1 to generate wirtesets +--connection node_1 +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); + +DELIMITER |; +CREATE PROCEDURE p1(IN max INT) +BEGIN + DECLARE i INT; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + + SET i = 0; + WHILE i < max DO + INSERT IGNORE INTO t1 VALUES (DEFAULT); + SET i = i + 1; + END WHILE; +END| +DELIMITER ;| + +# 130 events move the commit cut, it is essential in voting +CALL p1(130); + +--connection node_4 +--echo Shutting down server 4... +--let $node_4_server_id= `SELECT @@server_id` +--let $node_4_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$node_4_server_id.expect +--let $node_4_pid_file= `SELECT @@pid_file` +--source include/shutdown_mysqld.inc +# enforce SST +--exec rm -rf $MYSQLTEST_VARDIR/mysqld.4/data/grastate.dat + +# Wait for node #4 to leave cluster +--connection node_1 +--let $members = 3 +--source include/wsrep_wait_membership.inc + +# prepare to stop SST donor thread when node is in donor state +SET GLOBAL debug = "+d,sync.wsrep_donor_state"; + +--connection node_4 +--echo Restarting server 4... +# Need to use this form instead of start_mysqld.inc because the latter is blocking +--exec echo "restart:$start_mysqld_params" > $node_4_expect_file_name + +# Wait for node #1 to become a donor +--connection node_1 +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_donor_state_reached"; +--echo Tables on server 1 flushed and locked for SST to server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_donor_state"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; + +--echo Wait for the state snapshot to be copied to server 4 +--source include/galera_wait_ready.inc +--echo SST script unlocked server 1 + +# +# At this point state snapshot has been copied, node 1 is operational and +# we have about 20 seconds while everything we do will go into the replication +# queue on node 4 which it will have to apply on top of the snapshot. +# diff --git a/mysql-test/suite/galera/t/galera_vote_joined_end.inc b/mysql-test/suite/galera/t/galera_vote_joined_end.inc new file mode 100644 index 00000000000..3ba138bbbf9 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_end.inc @@ -0,0 +1,33 @@ +# Confirm node #4 has rejoined +--connection node_1 +--let $members = 4 +--source include/wsrep_wait_membership.inc +#DROP TABLE IF EXISTS t2; + +# Confirm that all is good and all nodes have identical data + +--connection node_1 +SELECT count(*) AS expect1_390 FROM t1; + +#CALL mtr.add_suppression("Replica SQL: Could not execute Delete_rows"); +#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno [0-9]+"); + +--connection node_2 +SELECT count(*) AS expect2_390 FROM t1; + +#CALL mtr.add_suppression("mysqld: Can't find record in 't1'"); +#CALL mtr.add_suppression("Replica SQL: Could not execute Delete_rows"); +#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno seqno [0-9]+"); + +--connection node_3 +SELECT count(*) AS expect3_390 FROM t1; + +--connection node_4 +SELECT count(*) AS expect4_390 FROM t1; + +DROP TABLE t1; +DROP PROCEDURE p1; + +#CALL mtr.add_suppression("inconsistent with group"); + +--source ../include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_vote_joined_skip.cnf b/mysql-test/suite/galera/t/galera_vote_joined_skip.cnf new file mode 100644 index 00000000000..88a1982bf66 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_skip.cnf @@ -0,0 +1,21 @@ +!include ../galera_4nodes.cnf + +[mysqld] +wsrep-ignore-apply-errors=0 + +[mysqld.1] +wsrep_node_name='node_1' + +[mysqld.2] +wsrep_node_name='node_2' + +[mysqld.3] +wsrep_node_name='node_3' + +[mysqld.4] +wsrep_node_name='node_4' +wsrep_sst_donor='node_1' + +[ENV] +galera_cluster_size=4 +MTR_SST_JOINER_DELAY=20 diff --git a/mysql-test/suite/galera/t/galera_vote_joined_skip.test b/mysql-test/suite/galera/t/galera_vote_joined_skip.test new file mode 100644 index 00000000000..2019b639be1 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_skip.test @@ -0,0 +1,100 @@ +# +# Test a case where a vote happens in JOINED state after SST on a writeset +# that should be skipped. I.e. JOINED node should continue operation. +# + +--source galera_vote_joined_begin.inc +# +# At this point state snapshot has been copied, node 1 is operational and +# we have about 10 seconds while everything we do will go into the replication +# queue on node 4 which it will have to apply on top of the snapshot. +# + +# Increase replication queue on node_4 +--connection node_1 +CALL p1(130); + +# +# Create a writeset that node 4 won't be able to apply by making node 3 +# inconsisitent +# +--connection node_3 +--let $node_3_server_id= `SELECT @@server_id` +--let $node_3_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$node_3_server_id.expect +--let $node_3_pid_file= `SELECT @@pid_file` +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +# This should cause nodes #1 and #2 to initiate a vote and kick node #3 +# out of the cluster, node #4 should recover the vote when fails to apply +# the event and continue +INSERT INTO t2 VALUES (DEFAULT); +SET SESSION wsrep_on = OFF; + +# make sure nodes 1,2 progress far enough for commit cut update +--connection node_1 +CALL p1(130); + +--let $members = 3 +--echo Waiting for server 3 to leave the cluster +--connection node_1 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_4 +# need to wait for extra SST delay on joiner +--sleep $MTR_SST_JOINER_DELAY +--sleep $MTR_SST_JOINER_DELAY +--enable_reconnect +--let $wait_timeout = 60 +--source include/wsrep_wait_membership.inc + +--connection node_3 +--echo Server 3 left the cluster, killing it... +# Kill the connected server +--exec echo "wait" > $node_3_expect_file_name +--let KILL_NODE_PIDFILE = $node_3_pid_file +--perl + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -9 $mysqld_pid"); + exit(0); +EOF +--echo Killed server 3. +--source include/wait_until_disconnected.inc +--echo Restarting server 3... +--exec echo "restart:$start_mysqld_params" > $node_3_expect_file_name + +--echo Waiting for server 3 to rejoin the cluster +--connection node_1 +--let $members = 3 +--source include/wsrep_wait_membership.inc + +--connection node_3 +--echo sleeping for $MTR_SST_JOINER_DELAY +# need to wait for extra SST delay on joiner +--sleep $MTR_SST_JOINER_DELAY +--sleep $MTR_SST_JOINER_DELAY +--echo Waiting ready +--enable_reconnect +--source include/galera_wait_ready.inc +--echo Server 3 restarted. + +--source galera_vote_joined_end.inc + +--connection node_1 +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); + +--connection node_2 +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); + +--connection node_3 +CALL mtr.add_suppression("Vote 0 \\(success\\) on .+ is inconsistent with group"); + +--connection node_4 +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); diff --git a/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test index c0dbc7d493d..659b293582b 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test +++ b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test @@ -77,6 +77,8 @@ select @@gtid_binlog_state; --echo cluster 2 node 1 --connection node_4 +--let $wait_condition = SELECT COUNT(*) = 1 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 21, 1); select @@gtid_binlog_state; @@ -85,11 +87,16 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 1 node 2 --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc + select @@gtid_binlog_state; insert into t1 values (1, 12, 3); select @@gtid_binlog_state; @@ -99,10 +106,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 1 node 3 --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (1, 13, 4); select @@gtid_binlog_state; @@ -112,10 +123,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 2 --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 22, 2); select @@gtid_binlog_state; @@ -125,37 +140,55 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 3 --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 23, 3); select @@gtid_binlog_state; --echo #wait for sync cluster 2 and 1 --connection node_4 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo # check other nodes are consistent --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --echo cluster 1 node 1 --connection node_1 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; drop table t1; stop slave; @@ -250,6 +283,8 @@ select @@gtid_binlog_state; --sleep 2 --echo cluster 2 node 1 --connection node_4 +--let $wait_condition = SELECT COUNT(*) = 1 FROM test.t1; +--source include/wait_condition.inc insert into t1 values (2, 21, 1); select @@gtid_binlog_state; @@ -258,11 +293,16 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc + select * from t1 order by 1, 2, 3; --echo cluster 1 node 2 --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (1, 12, 3); select @@gtid_binlog_state; @@ -272,10 +312,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 1 node 3 --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (1, 13, 4); select @@gtid_binlog_state; @@ -285,10 +329,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 2 --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 22, 2); select @@gtid_binlog_state; @@ -298,10 +346,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 3 --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 23, 3); select @@gtid_binlog_state; @@ -311,24 +363,36 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo # check other nodes are consistent --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --echo cluster 1 node 1 --connection node_1 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; drop table t1; stop slave; diff --git a/mysql-test/suite/gcol/r/innodb_virtual_basic.result b/mysql-test/suite/gcol/r/innodb_virtual_basic.result index db8e39d8e51..843592511e0 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_basic.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_basic.result @@ -86,6 +86,8 @@ delete from t where a =13; DROP INDEX idx1 ON t; DROP INDEX idx2 ON t; DROP TABLE t; +# restart +set default_storage_engine=innodb; /* Test large BLOB data */ CREATE TABLE `t` ( `a` BLOB, diff --git a/mysql-test/suite/gcol/t/innodb_virtual_basic.test b/mysql-test/suite/gcol/t/innodb_virtual_basic.test index cb4f2295353..611d659ca85 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_basic.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_basic.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc --source include/have_partition.inc ---source include/big_test.inc +--source include/not_embedded.inc call mtr.add_suppression("\\[Warning\\] InnoDB: Compute virtual"); @@ -66,6 +66,41 @@ DROP INDEX idx1 ON t; DROP INDEX idx2 ON t; DROP TABLE t; +let MYSQLD_DATADIR=`select @@datadir`; +let PAGE_SIZE=`select @@innodb_page_size`; +--source include/shutdown_mysqld.inc +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; +my $file = "$ENV{MYSQLD_DATADIR}/ibdata1"; +open(FILE, "+<$file") || die "Unable to open $file"; +binmode FILE; +my $ps= $ENV{PAGE_SIZE}; +my $page; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS +sysseek(FILE, 7*$ps, 0) || die "Unable to seek $file\n"; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +substr($page,54,4)=pack("N",0xc001cafe); # 32 MSB of 64-bit DICT_HDR_INDEX_ID +my $polynomial = 0x82f63b78; # CRC-32C +if ($full_crc32) +{ + my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial); + substr($page, $ps-4, 4) = pack("N", $ck); +} +else +{ + my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^ + mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); + substr($page,0,4)=$ck; + substr($page,$ps-8,4)=$ck; +} +sysseek(FILE, 7*$ps, 0) || die "Unable to rewind $file\n"; +syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; +close(FILE) || die "Unable to close $file"; +EOF +--source include/start_mysqld.inc +set default_storage_engine=innodb; + /* Test large BLOB data */ CREATE TABLE `t` ( `a` BLOB, diff --git a/mysql-test/suite/innodb/r/alter_copy_bulk.result b/mysql-test/suite/innodb/r/alter_copy_bulk.result index cd57d95af96..ea9d8e2787c 100644 --- a/mysql-test/suite/innodb/r/alter_copy_bulk.result +++ b/mysql-test/suite/innodb/r/alter_copy_bulk.result @@ -91,3 +91,24 @@ INSERT INTO t1 VALUES ALTER TABLE t1 FORCE, ALGORITHM=COPY; DROP TABLE t1; SET GLOBAL innodb_stats_persistent=@default_stats_persistent; +# +# MDEV-36504 Memory leak after insert into empty table +# +CREATE TABLE t1 (k INT PRIMARY KEY)ENGINE=InnoDB; +INSERT INTO t1 SET k= 1; +START TRANSACTION; +INSERT INTO t1 SET k= 2; +SELECT COUNT(*) > 0 FROM mysql.innodb_index_stats LOCK IN SHARE MODE; +COUNT(*) > 0 +1 +connect con1,localhost,root,,,; +SET innodb_lock_wait_timeout=0; +CREATE TABLE t2(f1 INT DEFAULT 1 PRIMARY KEY) +STATS_PERSISTENT= 1 ENGINE=InnoDB as SELECT k FROM t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +disconnect con1; +connection default; +SET innodb_lock_wait_timeout=default; +DROP TABLE t1; +DROP TABLE IF EXISTS t2; +# restart diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result index 1a43b91468d..1127d8691d8 100644 --- a/mysql-test/suite/innodb/r/foreign_key.result +++ b/mysql-test/suite/innodb/r/foreign_key.result @@ -155,7 +155,6 @@ INSERT INTO parent SET a=0; FLUSH TABLES; # restart disconnect incomplete; -SET @save_stats_persistent = @@GLOBAL.innodb_stats_persistent; SET GLOBAL innodb_stats_persistent = 0; INSERT INTO child SET a=0; INSERT INTO child SET a=1; @@ -1182,6 +1181,25 @@ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fail ALTER TABLE t2 ADD KEY(b), ALGORITHM=NOCOPY; DELETE FROM t1; DROP TABLE t2, t1; +# +# MDEV-33167 ASAN errors after failing to load foreign key +# relation for the table +# +call mtr.add_suppression("InnoDB: Load table `test`.`t3` failed, the table has missing foreign key indexes. Turn off 'foreign_key_checks' and try again."); +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t1(f1 VARCHAR(8), +FOREIGN KEY(f1) REFERENCES test.t3(f1))ENGINE=InnoDB; +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t2(f1 VARCHAR(8), +FOREIGN KEY(f1) REFERENCES test.t3(f1)) +ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t3(f1 VARCHAR(8) PRIMARY KEY) +ENGINE=InnoDB DEFAULT CHARSET=latin1; +set GLOBAL innodb_fast_shutdown=0; +# restart +ALTER TABLE t2 FORCE; +DROP TABLE t2, t1, t3; # End of 10.6 tests CREATE TABLE t1 ( @@ -1204,5 +1222,4 @@ ALTER TABLE t2 ADD FOREIGN KEY (f2) REFERENCES t2 (f2), ADD UNIQUE INDEX(f3); ERROR HY000: Cannot delete rows from table which is parent in a foreign key constraint 't1_ibfk_1' of table 't1' drop table t1, t2; -SET GLOBAL innodb_stats_persistent = @save_stats_persistent; # End of 10.11 tests diff --git a/mysql-test/suite/innodb/r/innodb_bug52663.result b/mysql-test/suite/innodb/r/innodb_bug52663.result index 348a7b21022..a87638d6555 100644 --- a/mysql-test/suite/innodb/r/innodb_bug52663.result +++ b/mysql-test/suite/innodb/r/innodb_bug52663.result @@ -1,10 +1,11 @@ +SET @save_innodb_timeout=@@innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout=1; set session transaction isolation level read committed; create table innodb_bug52663 (what varchar(5), id integer, count integer, primary key (what, id)) engine=innodb; insert into innodb_bug52663 values ('total', 0, 0); begin; connect addconroot, localhost, root,,; -connection addconroot; set session transaction isolation level read committed; begin; connection default; @@ -31,3 +32,4 @@ select * from innodb_bug52663; what id count total 0 2 drop table innodb_bug52663; +SET GLOBAL innodb_lock_wait_timeout=@save_innodb_timeout; diff --git a/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff b/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff index cf72c37bde8..ba4aeadaa50 100644 --- a/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff +++ b/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff @@ -1,8 +1,9 @@ -@@ -527,6 +527,6 @@ +@@ -576,7 +576,7 @@ FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; instants -37 +38 - SET GLOBAL innodb_stats_persistent = @save_stats_persistent; - # End of 10.6 tests + CREATE TABLE t1(f1 INT, f2 TEXT)ENGINE=InnoDB; + INSERT INTO t1 VALUES(1, 'a'); + ALTER TABLE t1 ADD COLUMN f3 TEXT FIRST; diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result index dd032e1d1f6..c7e749c0837 100644 --- a/mysql-test/suite/innodb/r/instant_alter_debug.result +++ b/mysql-test/suite/innodb/r/instant_alter_debug.result @@ -569,5 +569,16 @@ FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; instants 37 +CREATE TABLE t1(f1 INT, f2 TEXT)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 'a'); +ALTER TABLE t1 ADD COLUMN f3 TEXT FIRST; +SET STATEMENT DEBUG_DBUG="+d,instant_insert_fail" FOR +ALTER TABLE t1 DROP COLUMN f1; +ERROR HY000: Internal error: InnoDB: Insert into SYS_COLUMNS failed +ALTER TABLE t1 DROP COLUMN f1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; SET GLOBAL innodb_stats_persistent = @save_stats_persistent; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/r/lock_isolation.result b/mysql-test/suite/innodb/r/lock_isolation.result index 5975b531451..1e1625ae458 100644 --- a/mysql-test/suite/innodb/r/lock_isolation.result +++ b/mysql-test/suite/innodb/r/lock_isolation.result @@ -1,3 +1,6 @@ +connect disable_purging,localhost,root; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; # # MDEV-26642 Weird SELECT view when a record is # modified to the same value by two transactions @@ -52,15 +55,17 @@ DROP TABLE t; # MDEV-26643 Inconsistent behaviors of UPDATE under # READ UNCOMMITTED and READ COMMITTED isolation level # -CREATE TABLE t(a INT, b INT) ENGINE=InnoDB; +CREATE TABLE t(a INT, b INT) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t VALUES(NULL, 1), (2, 2); SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; BEGIN; UPDATE t SET a = 10; connection consistent; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; UPDATE t SET b = 20 WHERE a; connection default; +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; COMMIT; connection consistent; SELECT * FROM t; @@ -74,8 +79,10 @@ BEGIN; UPDATE t SET a = 10; connection consistent; SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; UPDATE t SET b = 20 WHERE a; connection default; +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; COMMIT; connection consistent; SELECT * FROM t; @@ -89,8 +96,10 @@ BEGIN; UPDATE t SET a = 10; connection con_weird; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; UPDATE t SET b = 20 WHERE a; connection default; +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; SELECT * FROM t; a b 10 1 @@ -113,8 +122,10 @@ UPDATE t SET b = 3; connection consistent; SET TRANSACTION ISOLATION LEVEL READ COMMITTED; BEGIN; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; UPDATE t SET b = 2 WHERE a; connection default; +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; UPDATE t SET a = 1; COMMIT; connection consistent; @@ -128,20 +139,25 @@ DROP TABLE t; # # MDEV-33802 Weird read view after ROLLBACK of other transactions # -CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; -INSERT INTO t SET a=1; -BEGIN; -INSERT INTO t SET a=2; +CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB STATS_PERSISTENT=0; connection consistent; START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; +INSERT INTO t SET a=1; +connection consistent; SAVEPOINT sp1; SELECT * FROM t FORCE INDEX (b) FOR UPDATE; ERROR HY000: Record has changed since last read in table 't' SAVEPOINT sp1; +connection default; +BEGIN; +INSERT INTO t SET a=2; connection con_weird; START TRANSACTION WITH CONSISTENT SNAPSHOT; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; SELECT * FROM t FORCE INDEX (b) FOR UPDATE; connection default; +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; ROLLBACK; connection con_weird; a b @@ -149,12 +165,74 @@ a b SELECT * FROM t FORCE INDEX (b) FOR UPDATE; a b 1 NULL +COMMIT; disconnect con_weird; connection consistent; SELECT * FROM t FORCE INDEX (b) FOR UPDATE; a b 1 NULL -disconnect consistent; +COMMIT; connection default; +TRUNCATE TABLE t; +# +# MDEV-36639 innodb_snapshot_isolation=1 gives error for not comitted row changes +# +INSERT INTO t VALUES (1,1),(2,2); +connection default; +# Case 1: Transaction A modifies a record, transaction B with snapshot +# isolation level is blocked by A, then A is committed. +# Expected behaviour: B gets ER_CHECKREAD. +BEGIN; +UPDATE t SET b=3 WHERE a = 1; +connection consistent; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t; +a b +1 1 +2 2 +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; +SELECT * FROM t WHERE a=1 FOR UPDATE; +connection default; +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; +COMMIT; +connection consistent; +ERROR HY000: Record has changed since last read in table 't' +# Case 2: Transaction A modifies a record, transaction B with snapshot +# isolation level is blocked by A, then A is rolled back. +# Expected behaviour: B continues execution. +connection default; +BEGIN; +UPDATE t SET b=4 WHERE a=1; +connection consistent; +BEGIN; +SELECT * FROM t; +a b +2 2 +1 3 +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; +SELECT * FROM t WHERE a=1 FOR UPDATE; +connection default; +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; +ROLLBACK; +connection consistent; +a b +1 3 +ROLLBACK; +# Case 3: Transaction B with snapshot isolation level started with +# consistent snapshot. Transaction A modifies a record and is committed. +# Both B tries to read modified by A record. +# Expected behavior: B gets ER_CHECKREAD. +connection consistent; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; +UPDATE t SET b=4 WHERE a=1; +connection consistent; +SELECT * FROM t WHERE a=1 FOR UPDATE; +ERROR HY000: Record has changed since last read in table 't' +disconnect consistent; +disconnect disable_purging; +connection default; +SET DEBUG_SYNC="RESET"; DROP TABLE t; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/alter_copy_bulk.test b/mysql-test/suite/innodb/t/alter_copy_bulk.test index bc19aca00da..acca4c2d9f0 100644 --- a/mysql-test/suite/innodb/t/alter_copy_bulk.test +++ b/mysql-test/suite/innodb/t/alter_copy_bulk.test @@ -109,3 +109,24 @@ INSERT INTO t1 VALUES ALTER TABLE t1 FORCE, ALGORITHM=COPY; DROP TABLE t1; SET GLOBAL innodb_stats_persistent=@default_stats_persistent; + +--echo # +--echo # MDEV-36504 Memory leak after insert into empty table +--echo # +CREATE TABLE t1 (k INT PRIMARY KEY)ENGINE=InnoDB; +INSERT INTO t1 SET k= 1; +START TRANSACTION; +INSERT INTO t1 SET k= 2; +SELECT COUNT(*) > 0 FROM mysql.innodb_index_stats LOCK IN SHARE MODE; + +connect(con1,localhost,root,,,); +SET innodb_lock_wait_timeout=0; +--error ER_LOCK_WAIT_TIMEOUT +CREATE TABLE t2(f1 INT DEFAULT 1 PRIMARY KEY) + STATS_PERSISTENT= 1 ENGINE=InnoDB as SELECT k FROM t1; +disconnect con1; +connection default; +SET innodb_lock_wait_timeout=default; +DROP TABLE t1; +DROP TABLE IF EXISTS t2; +--source include/restart_mysqld.inc diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test index 22fe7562558..d09d48e3fdb 100644 --- a/mysql-test/suite/innodb/t/foreign_key.test +++ b/mysql-test/suite/innodb/t/foreign_key.test @@ -133,7 +133,6 @@ FLUSH TABLES; --let $shutdown_timeout= disconnect incomplete; -SET @save_stats_persistent = @@GLOBAL.innodb_stats_persistent; SET GLOBAL innodb_stats_persistent = 0; INSERT INTO child SET a=0; @@ -1245,6 +1244,33 @@ ALTER TABLE t2 ADD KEY(b), ALGORITHM=NOCOPY; DELETE FROM t1; DROP TABLE t2, t1; +--echo # +--echo # MDEV-33167 ASAN errors after failing to load foreign key +--echo # relation for the table +--echo # +call mtr.add_suppression("InnoDB: Load table `test`.`t3` failed, the table has missing foreign key indexes. Turn off 'foreign_key_checks' and try again."); +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t1(f1 VARCHAR(8), + FOREIGN KEY(f1) REFERENCES test.t3(f1))ENGINE=InnoDB; + +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t2(f1 VARCHAR(8), + FOREIGN KEY(f1) REFERENCES test.t3(f1)) + ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t3(f1 VARCHAR(8) PRIMARY KEY) + ENGINE=InnoDB DEFAULT CHARSET=latin1; + +set GLOBAL innodb_fast_shutdown=0; +--let $shutdown_timeout= +--source include/restart_mysqld.inc +# Error encountered while loading the foreign key +# constraint for t3. t1 wasn't loaded into memory yet +# t2 failed to find index for foreign key relation +ALTER TABLE t2 FORCE; +DROP TABLE t2, t1, t3; + --echo # End of 10.6 tests CREATE TABLE t1 @@ -1270,7 +1296,5 @@ ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES t2 (f2); ALTER TABLE t2 ADD FOREIGN KEY (f2) REFERENCES t2 (f2), ADD UNIQUE INDEX(f3); drop table t1, t2; -SET GLOBAL innodb_stats_persistent = @save_stats_persistent; --echo # End of 10.11 tests ---source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test index 59afed24521..d997c722edd 100644 --- a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test @@ -25,8 +25,8 @@ SET DEBUG_SYNC='buf_pool_shrink_before_wakeup SIGNAL blocked WAIT_FOR go'; send SET GLOBAL innodb_buffer_pool_size=8388608; connection default; SET DEBUG_SYNC='now WAIT_FOR blocked'; -# adjust for 32-bit ---replace_result 504/504 505/505 +# adjust for 32-bit and SUX_LOCK_GENERIC +--replace_regex /(5..)\/\1/505\/505/ SHOW STATUS LIKE 'innodb_buffer_pool_resize_status'; SET DEBUG_SYNC='now SIGNAL go'; connection con1; diff --git a/mysql-test/suite/innodb/t/innodb_bug52663.test b/mysql-test/suite/innodb/t/innodb_bug52663.test index dd246297d94..1d12fb63ef8 100644 --- a/mysql-test/suite/innodb/t/innodb_bug52663.test +++ b/mysql-test/suite/innodb/t/innodb_bug52663.test @@ -1,6 +1,7 @@ ---source include/long_test.inc --source include/have_innodb.inc +SET @save_innodb_timeout=@@innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout=1; set session transaction isolation level read committed; create table innodb_bug52663 (what varchar(5), id integer, count integer, primary key @@ -9,7 +10,6 @@ insert into innodb_bug52663 values ('total', 0, 0); begin; connect (addconroot, localhost, root,,); -connection addconroot; set session transaction isolation level read committed; begin; @@ -33,3 +33,4 @@ select * from innodb_bug52663; connection default; select * from innodb_bug52663; drop table innodb_bug52663; +SET GLOBAL innodb_lock_wait_timeout=@save_innodb_timeout; diff --git a/mysql-test/suite/innodb/t/instant_alter_debug.test b/mysql-test/suite/innodb/t/instant_alter_debug.test index a20f21020cc..9a9918baaf0 100644 --- a/mysql-test/suite/innodb/t/instant_alter_debug.test +++ b/mysql-test/suite/innodb/t/instant_alter_debug.test @@ -652,11 +652,19 @@ DROP TABLE t1; SET DEBUG_SYNC=RESET; --echo # End of 10.5 tests - SELECT variable_value-@old_instant instants FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; -SET GLOBAL innodb_stats_persistent = @save_stats_persistent; +CREATE TABLE t1(f1 INT, f2 TEXT)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 'a'); +ALTER TABLE t1 ADD COLUMN f3 TEXT FIRST; +--error ER_INTERNAL_ERROR +SET STATEMENT DEBUG_DBUG="+d,instant_insert_fail" FOR +ALTER TABLE t1 DROP COLUMN f1; +ALTER TABLE t1 DROP COLUMN f1; +CHECK TABLE t1; +DROP TABLE t1; +SET GLOBAL innodb_stats_persistent = @save_stats_persistent; --echo # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/lock_isolation.test b/mysql-test/suite/innodb/t/lock_isolation.test index bac034a50e4..b332f2e867a 100644 --- a/mysql-test/suite/innodb/t/lock_isolation.test +++ b/mysql-test/suite/innodb/t/lock_isolation.test @@ -1,9 +1,16 @@ --source include/have_innodb.inc +--source include/count_sessions.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc --disable_query_log call mtr.add_suppression("InnoDB: Transaction was aborted due to "); --enable_query_log +--connect disable_purging,localhost,root +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +--connection default --echo # --echo # MDEV-26642 Weird SELECT view when a record is --echo # modified to the same value by two transactions @@ -41,22 +48,18 @@ DROP TABLE t; --echo # READ UNCOMMITTED and READ COMMITTED isolation level --echo # -CREATE TABLE t(a INT, b INT) ENGINE=InnoDB; +CREATE TABLE t(a INT, b INT) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t VALUES(NULL, 1), (2, 2); SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; BEGIN; UPDATE t SET a = 10; --connection consistent SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; --send UPDATE t SET b = 20 WHERE a --connection default -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = 'Updating' - and info = 'UPDATE t SET b = 20 WHERE a'; ---source include/wait_condition.inc - +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; COMMIT; --connection consistent @@ -70,14 +73,11 @@ BEGIN; UPDATE t SET a = 10; --connection consistent SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; --send UPDATE t SET b = 20 WHERE a --connection default -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where info = 'UPDATE t SET b = 20 WHERE a'; ---source include/wait_condition.inc - +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; COMMIT; --connection consistent @@ -91,15 +91,11 @@ BEGIN; UPDATE t SET a = 10; --connection con_weird SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; send UPDATE t SET b = 20 WHERE a; --connection default -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = 'Updating' - and info = 'UPDATE t SET b = 20 WHERE a'; ---source include/wait_condition.inc - +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; SELECT * FROM t; COMMIT; @@ -123,14 +119,11 @@ SET TRANSACTION ISOLATION LEVEL READ COMMITTED; BEGIN; # As semi-consistent read is disabled for innodb_snapshot_isolation=ON, the # following UPDATE must be blocked on the first record. +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; --send UPDATE t SET b = 2 WHERE a --connection default -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = 'Updating' and info = 'UPDATE t SET b = 2 WHERE a'; ---source include/wait_condition.inc - +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; UPDATE t SET a = 1; COMMIT; --connection consistent @@ -149,13 +142,15 @@ DROP TABLE t; --echo # MDEV-33802 Weird read view after ROLLBACK of other transactions --echo # -CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; -INSERT INTO t SET a=1; - -BEGIN; INSERT INTO t SET a=2; +CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB STATS_PERSISTENT=0; --connection consistent START TRANSACTION WITH CONSISTENT SNAPSHOT; + +--connection default +INSERT INTO t SET a=1; + +--connection consistent SAVEPOINT sp1; --disable_ps2_protocol --error ER_CHECKREAD @@ -163,29 +158,100 @@ SELECT * FROM t FORCE INDEX (b) FOR UPDATE; --enable_ps2_protocol SAVEPOINT sp1; +--connection default +BEGIN; INSERT INTO t SET a=2; + --connection con_weird START TRANSACTION WITH CONSISTENT SNAPSHOT; -send -SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; +--send SELECT * FROM t FORCE INDEX (b) FOR UPDATE --connection default -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = 'Sending data' - and info LIKE 'SELECT * FROM t %'; ---source include/wait_condition.inc +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; ROLLBACK; --connection con_weird --reap SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +COMMIT; --disconnect con_weird --connection consistent SELECT * FROM t FORCE INDEX (b) FOR UPDATE; ---disconnect consistent +COMMIT; --connection default +TRUNCATE TABLE t; + +--echo # +--echo # MDEV-36639 innodb_snapshot_isolation=1 gives error for not comitted row changes +--echo # +INSERT INTO t VALUES (1,1),(2,2); + +--connection default +--echo # Case 1: Transaction A modifies a record, transaction B with snapshot +--echo # isolation level is blocked by A, then A is committed. +--echo # Expected behaviour: B gets ER_CHECKREAD. +BEGIN; +UPDATE t SET b=3 WHERE a = 1; + +--connection consistent +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; +--send SELECT * FROM t WHERE a=1 FOR UPDATE + +--connection default +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; +COMMIT; + +--connection consistent +--error ER_CHECKREAD +--reap + +--echo # Case 2: Transaction A modifies a record, transaction B with snapshot +--echo # isolation level is blocked by A, then A is rolled back. +--echo # Expected behaviour: B continues execution. + +--connection default +BEGIN; +UPDATE t SET b=4 WHERE a=1; + +--connection consistent +BEGIN; +SELECT * FROM t; +SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL select_blocked"; +--send SELECT * FROM t WHERE a=1 FOR UPDATE + +--connection default +SET DEBUG_SYNC="now WAIT_FOR select_blocked"; +ROLLBACK; + +--connection consistent +--reap +ROLLBACK; + +--echo # Case 3: Transaction B with snapshot isolation level started with +--echo # consistent snapshot. Transaction A modifies a record and is committed. +--echo # Both B tries to read modified by A record. +--echo # Expected behavior: B gets ER_CHECKREAD. + +--connection consistent +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +--connection default +UPDATE t SET b=4 WHERE a=1; + +--connection consistent +--error ER_CHECKREAD +SELECT * FROM t WHERE a=1 FOR UPDATE; +--disconnect consistent +--disconnect disable_purging + +--connection default +SET DEBUG_SYNC="RESET"; DROP TABLE t; +--source include/wait_until_count_sessions.inc --echo # End of 10.6 tests diff --git a/mysql-test/suite/json/r/json_no_table.result b/mysql-test/suite/json/r/json_no_table.result index 5819a10ebfa..ab32364b163 100644 --- a/mysql-test/suite/json/r/json_no_table.result +++ b/mysql-test/suite/json/r/json_no_table.result @@ -2886,7 +2886,7 @@ json_unquote(json_compact('["a", "b", "c"]')) ["a", "b", "c"] select charset(json_unquote('"abc"')); charset(json_unquote('"abc"')) -utf8mb3 +utf8mb4 select json_quote(convert(X'e68891' using utf8)); json_quote(convert(X'e68891' using utf8)) "我" diff --git a/mysql-test/suite/merge/merge.result b/mysql-test/suite/merge/merge.result index b33031b8f0e..27f18b06a41 100644 --- a/mysql-test/suite/merge/merge.result +++ b/mysql-test/suite/merge/merge.result @@ -3674,33 +3674,22 @@ insert into tmp (b) values (1); insert into t1 (a) values (1); insert into t3 (b) values (1); insert into m1 (a) values ((select max(a) from m1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from m2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from t1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from t2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from t3, m1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from t3, m2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from t3, t1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from t3, t2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from tmp, m1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from tmp, m2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from tmp, t1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from tmp, t2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into m1 (a) values ((select max(a) from v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1' insert into m1 (a) values ((select max(a) from tmp, v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1' +select count(*) from m1; +count(*) +15 drop view v1; drop temporary table tmp; drop table t1, t2, t3, m1, m2; diff --git a/mysql-test/suite/merge/merge.test b/mysql-test/suite/merge/merge.test index 5d38023aef3..33e2279411c 100644 --- a/mysql-test/suite/merge/merge.test +++ b/mysql-test/suite/merge/merge.test @@ -2670,37 +2670,24 @@ insert into tmp (b) values (1); insert into t1 (a) values (1); insert into t3 (b) values (1); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from m1)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from m2)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from t1)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from t2)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from t3, m1)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from t3, m2)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from t3, t1)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from t3, t2)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from tmp, m1)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from tmp, m2)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from tmp, t1)); ---error ER_UPDATE_TABLE_USED insert into m1 (a) values ((select max(a) from tmp, t2)); - ---error ER_VIEW_PREVENT_UPDATE + insert into m1 (a) values ((select max(a) from v1)); ---error ER_VIEW_PREVENT_UPDATE insert into m1 (a) values ((select max(a) from tmp, v1)); +select count(*) from m1; drop view v1; diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index 75cefc34074..e78b3cc0629 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -20,6 +20,9 @@ set global server_audit_file_path=null; set global server_audit_incl_users=null; set global server_audit_file_path='server_audit.log'; set global server_audit_output_type=file; +set global server_audit_file_path=REPEAT(REPEAT('new_file_name', 50), 50); +Warnings: +Warning 1 server_audit_file_path can't exceed FN_LEN characters. set global server_audit_logging=on; set global server_audit_incl_users= repeat("'root',", 10000); ERROR 42000: Variable 'server_audit_incl_users' can't be set to the value of ''root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','root','...' diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test index ce4d96d70e3..b39677c5610 100644 --- a/mysql-test/suite/plugins/t/server_audit.test +++ b/mysql-test/suite/plugins/t/server_audit.test @@ -20,6 +20,10 @@ set global server_audit_file_path=null; set global server_audit_incl_users=null; set global server_audit_file_path='server_audit.log'; set global server_audit_output_type=file; + +--replace_regex /[1-9][0-9][0-9]+/FN_LEN/ +set global server_audit_file_path=REPEAT(REPEAT('new_file_name', 50), 50); + set global server_audit_logging=on; --error ER_WRONG_VALUE_FOR_VAR diff --git a/mysql-test/suite/rpl/r/rpl_create_select_row.result b/mysql-test/suite/rpl/r/rpl_create_select_row.result new file mode 100644 index 00000000000..3176415fc5b --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_create_select_row.result @@ -0,0 +1,158 @@ +include/master-slave.inc +[connection master] +connection master; +set @max_binlog_cache_size = @@global.max_binlog_cache_size; +set @binlog_cache_size = @@global.binlog_cache_size; +set @@global.max_binlog_cache_size = 4096; +set @@global. binlog_cache_size = 4096; +# +# MDEV-35207 ignored error at binlogging by CREATE-TABLE-SELECT leads to assert +# +connect conn_err,localhost,root,,; +call mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage"); +create table t engine=myisam select repeat ('a',4096*3) AS a; +ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +create table t engine=innodb select repeat ('a',4096*3) AS a; +ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +create table t (a int unique, b char) select 1 AS a, 'b' as b union select 1 as a, 'c' as b; +ERROR 23000: Duplicate entry '1' for key 'a' +select * from t; +ERROR 42S02: Table 'test.t' doesn't exist +disconnect conn_err; +connection master; + +# +# MDEV-35499 errored CREATE-OR-REPLACE-SELECT does not DROP table in binlog +# +# +# Engine = innodb +# +set statement binlog_format=statement for create table t (a int) select 1 as a; +set statement binlog_format=row for create or replace table t (a int primary key, b char) engine=innodb select 1 AS a, 'b' as b union select 1 as a, 'c' as b; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t; +ERROR 42S02: Table 'test.t' doesn't exist +# +# Prove an expected lonely `DROP table t' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK +set statement binlog_format=statement for create table t (a int) select 1 as a; +set statement binlog_format=row for create or replace table t (a text) engine=innodb select repeat ('a',1024) AS a union select repeat ('a',3*4096) AS a union select repeat ('a',3*4096) AS a; +ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +select * from t; +ERROR 42S02: Table 'test.t' doesn't exist +# +# Prove an expected lonely `DROP table t' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK +set statement binlog_format=statement for create table t (a int) select 1 as a; +set statement binlog_format=row for create or replace table t (a text) engine=innodb select repeat ('a',4096*3) AS a;; +ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +select * from t; +ERROR 42S02: Table 'test.t' doesn't exist +# +# Prove an expected lonely `DROP table t' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK +# +# Engine = myisam +# +set statement binlog_format=statement for create table t (a int) select 1 as a; +set statement binlog_format=row for create or replace table t (a int primary key, b char) engine=myisam select 1 AS a, 'b' as b union select 1 as a, 'c' as b; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t; +ERROR 42S02: Table 'test.t' doesn't exist +# +# Prove an expected lonely `DROP table t' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK +set statement binlog_format=statement for create table t (a int) select 1 as a; +set statement binlog_format=row for create or replace table t (a text) engine=myisam select repeat ('a',1024) AS a union select repeat ('a',3*4096) AS a union select repeat ('a',3*4096) AS a; +ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +select * from t; +ERROR 42S02: Table 'test.t' doesn't exist +# +# Prove an expected lonely `DROP table t' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK +set statement binlog_format=statement for create table t (a int) select 1 as a; +set statement binlog_format=row for create or replace table t (a text) engine=myisam select repeat ('a',4096*3) AS a;; +ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mariadbd variable and try again +select * from t; +ERROR 42S02: Table 'test.t' doesn't exist +# +# Prove an expected lonely `DROP table t' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */ +master-bin.000001 # Query # # ROLLBACK +create table ti_pk (a int primary key) engine=innodb; +create table ta (a int) engine=aria; +create function f_ia(arg int) +returns integer +begin +insert into ti_pk set a=1; +insert into ta set a=1; +insert into ti_pk set a=arg; +return 1; +end | +set statement binlog_format = ROW for create table t_y (a int) engine=aria select f_ia(1 /* err */) as a; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t_y; +ERROR 42S02: Table 'test.t_y' doesn't exist +# correct execution: `ta` is modified and its new record is binlogged +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Table_map # # table_id: # (test.ta) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +select * from ta; +a +1 +select * from ti_pk; +a +connection slave; +include/diff_tables.inc [master:ta,slave:ta] +connection master; +delete from ta; +connection slave; +connection master; +set statement binlog_format = STATEMENT for create table t_y (a int) engine=aria select f_ia(1 /* err */) as a; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t_y; +ERROR 42S02: Table 'test.t_y' doesn't exist +# ***TODO: fix MDEV-36027***. As of now `ta` is modified but that's not binlogged +include/show_binlog_events.inc +select *,'on_master' from ta; +a on_master +1 on_master +select * from ti_pk; +a +connection slave; +select *,'on_slave' from ta; +a on_slave +connection master; +drop function f_ia; +drop table ti_pk, ta; +SET @@global.max_binlog_cache_size = @max_binlog_cache_size; +SET @@global. binlog_cache_size = @binlog_cache_size; +connection slave; +End of the tests +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_master_pos_wait.result b/mysql-test/suite/rpl/r/rpl_master_pos_wait.result index 4d19d81d407..089193db509 100644 --- a/mysql-test/suite/rpl/r/rpl_master_pos_wait.result +++ b/mysql-test/suite/rpl/r/rpl_master_pos_wait.result @@ -43,6 +43,9 @@ NULL select master_pos_wait('master-bin.000001',1000000,1,"my_slave"); master_pos_wait('master-bin.000001',1000000,1,"my_slave") -1 +select master_pos_wait('master-bin.000001',1000000,1,"MY_SLAVE"); +master_pos_wait('master-bin.000001',1000000,1,"MY_SLAVE") +-1 STOP SLAVE 'my_slave'; RESET SLAVE 'my_slave' ALL; change master to master_port=MASTER_MYPORT, master_host='127.0.0.1', master_user='root'; diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_master_disable_with_slave.result b/mysql-test/suite/rpl/r/rpl_semi_sync_master_disable_with_slave.result new file mode 100644 index 00000000000..3b0686c351e --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_master_disable_with_slave.result @@ -0,0 +1,41 @@ +# Set up Semi-Sync with rpl_semi_sync_master_wait_no_slave=0 +include/master-slave.inc +[connection master] +SET @@GLOBAL.rpl_semi_sync_master_enabled= 1; +SET @@GLOBAL.rpl_semi_sync_master_wait_no_slave= 0; +connection slave; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1; +include/start_slave.inc +connection master; +connection slave; +connection master; +SELECT ID INTO @binlog_dump_tid +FROM information_schema.PROCESSLIST WHERE COMMAND = 'Binlog Dump'; +# Control State +SELECT STATE FROM information_schema.PROCESSLIST WHERE ID = @binlog_dump_tid; +STATE +Master has sent all binlog to slave; waiting for more updates +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 1 +# Disable Semi-Sync while the dump thread is still connected to its slave +SET @@GLOBAL.rpl_semi_sync_master_enabled = 0; +SELECT STATE FROM information_schema.PROCESSLIST WHERE ID = @binlog_dump_tid; +STATE +Master has sent all binlog to slave; waiting for more updates +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 1 +# Disconnect the slave and wait until the master's dump thread is gone +connection slave; +STOP SLAVE; +connection master; +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 0 +# Cleanup +SET @@GLOBAL.rpl_semi_sync_master_enabled= 0; +SET @@GLOBAL.rpl_semi_sync_master_wait_no_slave= 1; +connection slave; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_ssl_stop.result b/mysql-test/suite/rpl/r/rpl_semi_sync_ssl_stop.result new file mode 100644 index 00000000000..bcd8878056e --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_ssl_stop.result @@ -0,0 +1,53 @@ +# Skip starting the slave because we manually start with SSL later +include/master-slave.inc +[connection master] +# +# Setup +connection master; +CREATE USER replssl@localhost; +GRANT REPLICATION SLAVE on *.* to replssl@localhost REQUIRE SSL; +set @orig_master_enabled= @@GLOBAL.rpl_semi_sync_master_enabled; +SET @@GLOBAL.rpl_semi_sync_master_enabled= 1; +connection slave; +CHANGE MASTER TO +master_user='replssl', +master_password='', +master_ssl=1, +master_ssl_ca='MYSQL_TEST_DIR/std_data/cacert.pem', +master_ssl_cert='MYSQL_TEST_DIR/std_data/client-cert.pem', +master_ssl_key='MYSQL_TEST_DIR/std_data/client-key.pem'; +set @orig_slave_enabled= @@GLOBAL.rpl_semi_sync_slave_enabled; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1; +include/start_slave.inc +connection master; +# Verify Semi-Sync is active +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 1 +# Create some table so slave can be seen as up-to-date and working +connection master; +CREATE TABLE t1 (a INT); +connection slave; +# Disconnect the slave and wait until the master's dump thread is gone +connection slave; +STOP SLAVE; +connection master; +# MDEV-36663: Verifying dump thread connection is killed.. +# ..done +# Cleanup +connection master; +SET @@GLOBAL.rpl_semi_sync_master_enabled= @orig_master_enabled; +DROP USER replssl@localhost; +DROP TABLE t1; +connection slave; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= @orig_slave_enabled; +CHANGE MASTER TO +master_user='root', +master_ssl=1, +master_ssl_ca='', +master_ssl_cert='', +master_ssl_key=''; +connection slave; +include/start_slave.inc +include/rpl_end.inc +# End of rpl_semi_sync_ssl_stop.inc diff --git a/mysql-test/suite/rpl/t/rpl_create_select_row.test b/mysql-test/suite/rpl/t/rpl_create_select_row.test new file mode 100644 index 00000000000..90d2b85d4e8 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_create_select_row.test @@ -0,0 +1,161 @@ +--source include/have_binlog_format_row.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--connection master +set @max_binlog_cache_size = @@global.max_binlog_cache_size; +set @binlog_cache_size = @@global.binlog_cache_size; +set @@global.max_binlog_cache_size = 4096; +set @@global. binlog_cache_size = 4096; + +--echo # +--echo # MDEV-35207 ignored error at binlogging by CREATE-TABLE-SELECT leads to assert +--echo # +# fix the current (write) binlog position +--let $binlog_file_0= query_get_value(SHOW MASTER STATUS, File, 1) +--let $binlog_start_0 = query_get_value(SHOW MASTER STATUS, Position, 1) + +# use a separate connection also to validate its close will be clean +connect (conn_err,localhost,root,,); + +call mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage"); +--error ER_TRANS_CACHE_FULL +create table t engine=myisam select repeat ('a',4096*3) AS a; + +--error ER_TRANS_CACHE_FULL +create table t engine=innodb select repeat ('a',4096*3) AS a; + +--error ER_DUP_ENTRY +create table t (a int unique, b char) select 1 AS a, 'b' as b union select 1 as a, 'c' as b; +--error ER_NO_SUCH_TABLE +select * from t; + +--disconnect conn_err + +--connection master +--let $binlog_file_1= query_get_value(SHOW MASTER STATUS, File, 1) +--let $binlog_start_1= query_get_value(SHOW MASTER STATUS, Position, 1) + +--let $cmp = `select strcmp('$binlog_file_1', '$binlog_file_0') <> 0 OR $binlog_start_1 <> $binlog_start_0` +if (!$cmp) +{ + --echo *** Error: unexpected advance of binlog position + --die +} + +--echo +--echo # +--echo # MDEV-35499 errored CREATE-OR-REPLACE-SELECT does not DROP table in binlog +--echo # +--let $i = 2 +while ($i) +{ + --let $engine=`select if($i % 2, "myisam", "innodb")` + --echo # + --echo # Engine = $engine + --echo # + set statement binlog_format=statement for create table t (a int) select 1 as a; + --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) + --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) + --error ER_DUP_ENTRY + --eval set statement binlog_format=row for create or replace table t (a int primary key, b char) engine=$engine select 1 AS a, 'b' as b union select 1 as a, 'c' as b + --error ER_NO_SUCH_TABLE + select * from t; + --echo # + --echo # Prove an expected lonely `DROP table t' + --source include/show_binlog_events.inc + + # error before stmt commit + set statement binlog_format=statement for create table t (a int) select 1 as a; + --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) + --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) + --error ER_TRANS_CACHE_FULL + --eval set statement binlog_format=row for create or replace table t (a text) engine=$engine select repeat ('a',1024) AS a union select repeat ('a',3*4096) AS a union select repeat ('a',3*4096) AS a + --error ER_NO_SUCH_TABLE + select * from t; + --echo # + --echo # Prove an expected lonely `DROP table t' + --source include/show_binlog_events.inc + + # error at stmt commit + set statement binlog_format=statement for create table t (a int) select 1 as a; + --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) + --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) + --error ER_TRANS_CACHE_FULL + --eval set statement binlog_format=row for create or replace table t (a text) engine=$engine select repeat ('a',4096*3) AS a; + --error ER_NO_SUCH_TABLE + select * from t; + --echo # + --echo # Prove an expected lonely `DROP table t' + --source include/show_binlog_events.inc + +--dec $i +} + +# Tests of mixed engines to demonstrate non-transaction table updates +# are binlogged or otherwise MDEV-36027. +create table ti_pk (a int primary key) engine=innodb; +create table ta (a int) engine=aria; +delimiter |; +create function f_ia(arg int) +returns integer +begin + insert into ti_pk set a=1; + insert into ta set a=1; + insert into ti_pk set a=arg; + return 1; +end | +delimiter ;| + +--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) +--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) + +--error ER_DUP_ENTRY +set statement binlog_format = ROW for create table t_y (a int) engine=aria select f_ia(1 /* err */) as a; +--error ER_NO_SUCH_TABLE +select * from t_y; + +--echo # correct execution: `ta` is modified and its new record is binlogged +--source include/show_binlog_events.inc +select * from ta; +select * from ti_pk; + +--sync_slave_with_master +--let $diff_tables=master:ta,slave:ta +--source include/diff_tables.inc + +--connection master +delete from ta; +--sync_slave_with_master + +--connection master +# MDEV-36027 Errored-out CREATE-SELECT does not binlog results of any function modifying non-transactional table +--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) +--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) +--error ER_DUP_ENTRY +set statement binlog_format = STATEMENT for create table t_y (a int) engine=aria select f_ia(1 /* err */) as a; +--error ER_NO_SUCH_TABLE +select * from t_y; + +--echo # ***TODO: fix MDEV-36027***. As of now `ta` is modified but that's not binlogged +--source include/show_binlog_events.inc +select *,'on_master' from ta; +select * from ti_pk; + +--sync_slave_with_master +select *,'on_slave' from ta; + +# Cleanup +--connection master +drop function f_ia; +drop table ti_pk, ta; + +SET @@global.max_binlog_cache_size = @max_binlog_cache_size; +SET @@global. binlog_cache_size = @binlog_cache_size; + +# test that binlog replicates correctly to slave +# --connection slave +--sync_slave_with_master + +--echo End of the tests +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_master_pos_wait.test b/mysql-test/suite/rpl/t/rpl_master_pos_wait.test index e815502d22f..a69a432db5f 100644 --- a/mysql-test/suite/rpl/t/rpl_master_pos_wait.test +++ b/mysql-test/suite/rpl/t/rpl_master_pos_wait.test @@ -48,6 +48,7 @@ select master_pos_wait('master-bin.000001',1000000,1); --echo # Call with a valid connection name -- hangs before MDEV-7130 fix (expected -1) select master_pos_wait('master-bin.000001',1000000,1,"my_slave"); +select master_pos_wait('master-bin.000001',1000000,1,"MY_SLAVE"); STOP SLAVE 'my_slave'; RESET SLAVE 'my_slave' ALL; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_master_disable_with_slave.test b/mysql-test/suite/rpl/t/rpl_semi_sync_master_disable_with_slave.test new file mode 100644 index 00000000000..28d8e7fcf7b --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_master_disable_with_slave.test @@ -0,0 +1,68 @@ +# MDEV-36359: Master crashes when reverting to async after Semi-Sync disabled. +# +# Assert behavior of turning Semi-Sync off on +# the master when still connected to a slave + +--source include/have_binlog_format_mixed.inc # format-agnostic + +--echo # Set up Semi-Sync with rpl_semi_sync_master_wait_no_slave=0 +--let $rpl_skip_start_slave= 1 +--source include/master-slave.inc + +--let $orig_master_enabled=`SELECT @@GLOBAL.rpl_semi_sync_master_enabled` +SET @@GLOBAL.rpl_semi_sync_master_enabled= 1; +--let $orig_wait_no_slave=`SELECT @@GLOBAL.rpl_semi_sync_master_wait_no_slave` +SET @@GLOBAL.rpl_semi_sync_master_wait_no_slave= 0; + +--connection slave +--let $orig_slave_enabled=`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled` +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1; +--source include/start_slave.inc + +--connection master +# Make sure Semi-Sync is active +--let $status_var= Rpl_semi_sync_master_status +--let $status_var_value= ON +--source include/wait_for_status_var.inc + +--sync_slave_with_master +--connection master + +--disable_cursor_protocol +SELECT ID INTO @binlog_dump_tid + FROM information_schema.PROCESSLIST WHERE COMMAND = 'Binlog Dump'; +--enable_cursor_protocol + +--echo # Control State +SELECT STATE FROM information_schema.PROCESSLIST WHERE ID = @binlog_dump_tid; +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; + +--echo # Disable Semi-Sync while the dump thread is still connected to its slave +SET @@GLOBAL.rpl_semi_sync_master_enabled = 0; +--let $status_var_value= OFF +--source include/wait_for_status_var.inc + +SELECT STATE FROM information_schema.PROCESSLIST WHERE ID = @binlog_dump_tid; +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; + +--echo # Disconnect the slave and wait until the master's dump thread is gone +--connection slave +STOP SLAVE; +# Starting with MDEV-13073, +# Semi-Sync STOP SLAVE also terminates its dump thread on the master. +--connection master + +# MDEV-36359: The disconnection would crash the master and leave the wait with +# error 2013 'Lost connection to server during query' +--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.PROCESSLIST WHERE ID = @binlog_dump_tid +--source include/wait_condition.inc +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; + +--echo # Cleanup +--eval SET @@GLOBAL.rpl_semi_sync_master_enabled= $orig_master_enabled +--eval SET @@GLOBAL.rpl_semi_sync_master_wait_no_slave= $orig_wait_no_slave +--connection slave +--eval SET @@GLOBAL.rpl_semi_sync_slave_enabled= $orig_slave_enabled + +--let $rpl_only_running_threads= 1 +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_ssl_stop.test b/mysql-test/suite/rpl/t/rpl_semi_sync_ssl_stop.test new file mode 100644 index 00000000000..3c788b7908a --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_ssl_stop.test @@ -0,0 +1,100 @@ +# +# This test verifies that semi-sync setups configured to use SSL can kill +# the replication connection when the IO thread is stopped (e.g. from +# STOP SLAVE). The way it should happen, is that the IO thread creates a new +# connection to the primary which issues KILL on the connection id of the +# replication connection. MDEV-36663 reported an issue where this new +# kill-oriented connection could not connect to a primary when it requires +# connections to use SSL. +# +# This test sets up a semi-sync SSL master-slave topology, and stops the +# slave IO thread. It then validates that the connection was killed by using +# the wait_condition.inc utility to wait for the binlog dump thread to die, +# and also validates that the status variable Rpl_semi_sync_master_clients +# reports as 0. +# +# References: +# MDEV-36663: Semi-sync Replica Can't Kill Dump Thread When Using SSL +# +--source include/have_binlog_format_mixed.inc # format-agnostic +--source include/have_ssl_communication.inc + +--echo # Skip starting the slave because we manually start with SSL later +--let $rpl_skip_start_slave= 1 +--source include/master-slave.inc + +--echo # +--echo # Setup +--connection master +CREATE USER replssl@localhost; +GRANT REPLICATION SLAVE on *.* to replssl@localhost REQUIRE SSL; + +set @orig_master_enabled= @@GLOBAL.rpl_semi_sync_master_enabled; +SET @@GLOBAL.rpl_semi_sync_master_enabled= 1; + +--connection slave +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +eval CHANGE MASTER TO + master_user='replssl', + master_password='', + master_ssl=1, + master_ssl_ca='$MYSQL_TEST_DIR/std_data/cacert.pem', + master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', + master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem'; + +set @orig_slave_enabled= @@GLOBAL.rpl_semi_sync_slave_enabled; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1; + +--source include/start_slave.inc + +--connection master +--echo # Verify Semi-Sync is active +--let $status_var= Rpl_semi_sync_master_status +--let $status_var_value= ON +--source include/wait_for_status_var.inc +SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; + +--echo # Create some table so slave can be seen as up-to-date and working +--connection master +CREATE TABLE t1 (a INT); +--sync_slave_with_master + +--echo # Disconnect the slave and wait until the master's dump thread is gone +--connection slave +STOP SLAVE; +--connection master + +--echo # MDEV-36663: Verifying dump thread connection is killed.. +# Prior to MDEV-36663 fixes, this would time out and +# Rpl_semi_sync_master_clients would remain 1. +--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.PROCESSLIST WHERE COMMAND = 'Binlog Dump' +--source include/wait_condition.inc + +--let $n_master_clients= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_master_clients', Value, 1) +if ($n_master_clients) +{ + --echo # Rpl_semi_sync_master_clients: $n_master_clients + --die Semi-sync dump thread connection not killed +} +--echo # ..done + +--echo # Cleanup +--connection master +SET @@GLOBAL.rpl_semi_sync_master_enabled= @orig_master_enabled; +DROP USER replssl@localhost; +DROP TABLE t1; + +--connection slave +SET @@GLOBAL.rpl_semi_sync_slave_enabled= @orig_slave_enabled; +CHANGE MASTER TO + master_user='root', + master_ssl=1, + master_ssl_ca='', + master_ssl_cert='', + master_ssl_key=''; + +--connection slave +--source include/start_slave.inc + +--source include/rpl_end.inc +--echo # End of rpl_semi_sync_ssl_stop.inc diff --git a/mysql-test/suite/sql_sequence/grant.result b/mysql-test/suite/sql_sequence/grant.result index 0a69d69fc74..fc3421efcb6 100644 --- a/mysql-test/suite/sql_sequence/grant.result +++ b/mysql-test/suite/sql_sequence/grant.result @@ -47,14 +47,57 @@ next_not_cached_value minimum_value maximum_value start_value increment cache_si 11 1 9223372036854775806 1 1 1000 0 0 connection only_alter; select next value for s1; -ERROR 42000: INSERT command denied to user 'only_alter'@'localhost' for table `mysqltest_1`.`s1` +ERROR 42000: SELECT, INSERT command denied to user 'only_alter'@'localhost' for table `mysqltest_1`.`s1` alter sequence s1 restart= 11; select * from s1; ERROR 42000: SELECT command denied to user 'only_alter'@'localhost' for table `mysqltest_1`.`s1` connection default; -drop database mysqltest_1; drop user 'normal'@'%'; drop user 'read_only'@'%'; drop user 'read_write'@'%'; drop user 'alter'@'%'; drop user 'only_alter'@'%'; +drop sequence s1; +# +# MDEV-36413 User without any privileges to a sequence can read from +# it and modify it via column default +# +create sequence s1; +create sequence s2; +select * from s2; +next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count +1 1 9223372036854775806 1 1 1000 0 0 +create table t2 (a int not null default(nextval(s1))); +insert into t2 values(); +create user u; +grant create, insert, select, drop on mysqltest_1.t1 to u; +grant insert, select on mysqltest_1.s1 to u; +grant select on mysqltest_1.t2 to u; +connect con1,localhost,u,,mysqltest_1; +select nextval(s2); +ERROR 42000: SELECT, INSERT command denied to user 'u'@'localhost' for table `mysqltest_1`.`s2` +show create sequence s2; +ERROR 42000: SHOW command denied to user 'u'@'localhost' for table `mysqltest_1`.`s2` +create table t1 (a int not null default(nextval(s1))); +drop table t1; +create table t1 (a int not null default(nextval(s1))) select a from t2; +insert into t1 values(); +select * from t1; +a +1 +2 +drop table t1; +create table t1 (a int not null default(nextval(s1))) select a from (select t2.a from t2,t2 as t3 where t2.a=t3.a) as t4; +drop table t1; +create table t1 (a int not null default(nextval(s2))); +ERROR 42000: SELECT, INSERT command denied to user 'u'@'localhost' for table `mysqltest_1`.`s2` +create table t1 (a int not null default(nextval(s1)), +b int not null default(nextval(s2))); +ERROR 42000: SELECT, INSERT command denied to user 'u'@'localhost' for table `mysqltest_1`.`s2` +disconnect con1; +connection default; +drop user u; +drop database mysqltest_1; +# +# End of 10.11 tests +# diff --git a/mysql-test/suite/sql_sequence/grant.test b/mysql-test/suite/sql_sequence/grant.test index fb8a9f813a6..c205bd34223 100644 --- a/mysql-test/suite/sql_sequence/grant.test +++ b/mysql-test/suite/sql_sequence/grant.test @@ -60,10 +60,58 @@ select * from s1; # connection default; -drop database mysqltest_1; drop user 'normal'@'%'; drop user 'read_only'@'%'; drop user 'read_write'@'%'; drop user 'alter'@'%'; drop user 'only_alter'@'%'; +drop sequence s1; +--echo # +--echo # MDEV-36413 User without any privileges to a sequence can read from +--echo # it and modify it via column default +--echo # + +create sequence s1; +create sequence s2; +select * from s2; +create table t2 (a int not null default(nextval(s1))); +insert into t2 values(); + +create user u; +grant create, insert, select, drop on mysqltest_1.t1 to u; +grant insert, select on mysqltest_1.s1 to u; +grant select on mysqltest_1.t2 to u; + +--connect(con1,localhost,u,,mysqltest_1) +--error ER_TABLEACCESS_DENIED_ERROR +select nextval(s2); +--error ER_TABLEACCESS_DENIED_ERROR +show create sequence s2; + +create table t1 (a int not null default(nextval(s1))); +drop table t1; +create table t1 (a int not null default(nextval(s1))) select a from t2; +insert into t1 values(); +select * from t1; +drop table t1; +create table t1 (a int not null default(nextval(s1))) select a from (select t2.a from t2,t2 as t3 where t2.a=t3.a) as t4; +drop table t1; +--error ER_TABLEACCESS_DENIED_ERROR +create table t1 (a int not null default(nextval(s2))); +--error ER_TABLEACCESS_DENIED_ERROR +create table t1 (a int not null default(nextval(s1)), + b int not null default(nextval(s2))); +--disconnect con1 +--connection default +drop user u; + +# +# Cleanup +# + +drop database mysqltest_1; + +--echo # +--echo # End of 10.11 tests +--echo # diff --git a/mysql-test/suite/sql_sequence/gtid.result b/mysql-test/suite/sql_sequence/gtid.result index f23ebc56688..018bd0dc2ff 100644 --- a/mysql-test/suite/sql_sequence/gtid.result +++ b/mysql-test/suite/sql_sequence/gtid.result @@ -174,7 +174,7 @@ create sequence s_db.s2; drop sequence s_db.s2; connection m_normal_2; select next value for s_db.s1; -ERROR 42000: INSERT command denied to user 'normal_2'@'localhost' for table `s_db`.`s1` +ERROR 42000: SELECT, INSERT command denied to user 'normal_2'@'localhost' for table `s_db`.`s1` create sequence s_db.s2; ERROR 42000: CREATE command denied to user 'normal_2'@'localhost' for table `s_db`.`s2` connection m_normal_1; diff --git a/mysql-test/suite/sql_sequence/other.result b/mysql-test/suite/sql_sequence/other.result index b950a7d8b13..247eb5b30a8 100644 --- a/mysql-test/suite/sql_sequence/other.result +++ b/mysql-test/suite/sql_sequence/other.result @@ -48,7 +48,6 @@ create sequence s2; insert into s1 (next_not_cached_value, minimum_value) values (100,1000); ERROR HY000: Field 'maximum_value' doesn't have a default value insert into s1 values (next value for s1, 1,9223372036854775806,1,1,1000,0,0); -ERROR HY000: Table 's1' is specified twice, both as a target for 'INSERT' and as a separate source for data insert into s1 values(1000,9223372036854775806,1,1,1,1000,0,0); ERROR HY000: Sequence 'test.s1' has out of range value for options insert into s1 values(0,9223372036854775806,1,1,1,1000,0,0); diff --git a/mysql-test/suite/sql_sequence/other.test b/mysql-test/suite/sql_sequence/other.test index 9761e4268a8..f727f4856fb 100644 --- a/mysql-test/suite/sql_sequence/other.test +++ b/mysql-test/suite/sql_sequence/other.test @@ -38,7 +38,6 @@ create sequence s1; create sequence s2; --error ER_NO_DEFAULT_FOR_FIELD insert into s1 (next_not_cached_value, minimum_value) values (100,1000); ---error ER_UPDATE_TABLE_USED insert into s1 values (next value for s1, 1,9223372036854775806,1,1,1000,0,0); --error ER_SEQUENCE_INVALID_DATA insert into s1 values(1000,9223372036854775806,1,1,1,1000,0,0); diff --git a/mysql-test/suite/sql_sequence/replication.result b/mysql-test/suite/sql_sequence/replication.result index 94b1c72b9e0..ee6f8b2ae68 100644 --- a/mysql-test/suite/sql_sequence/replication.result +++ b/mysql-test/suite/sql_sequence/replication.result @@ -285,7 +285,7 @@ create sequence s_db.s2; drop sequence s_db.s2; connection m_normal_2; select NEXT VALUE for s_db.s1; -ERROR 42000: INSERT command denied to user 'normal_2'@'localhost' for table `s_db`.`s1` +ERROR 42000: SELECT, INSERT command denied to user 'normal_2'@'localhost' for table `s_db`.`s1` create sequence s_db.s2; ERROR 42000: CREATE command denied to user 'normal_2'@'localhost' for table `s_db`.`s2` connection m_normal_1; diff --git a/mysql-test/suite/sql_sequence/view.test b/mysql-test/suite/sql_sequence/view.test index affac002878..7e2cd712325 100644 --- a/mysql-test/suite/sql_sequence/view.test +++ b/mysql-test/suite/sql_sequence/view.test @@ -1,5 +1,4 @@ --source include/have_sequence.inc ---source include/have_innodb.inc # # Test sequences with views diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 35bc5cba9e1..10a4d0d4307 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1008,7 +1008,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE INT UNSIGNED -VARIABLE_COMMENT Delay between log buffer spin lock polls (0 to use a blocking latch) +VARIABLE_COMMENT Deprecated parameter with no effect NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 6000 NUMERIC_BLOCK_SIZE 0 diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 44df58886a1..7e662e1046a 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -173,7 +173,7 @@ IF(HAVE_BFD_H) ENDIF(HAVE_BFD_H) IF (WIN32) - TARGET_LINK_LIBRARIES(mysys iphlpapi dbghelp) + TARGET_LINK_LIBRARIES(mysys iphlpapi dbghelp ws2_32 synchronization) ENDIF(WIN32) # Need explicit pthread for gcc -fsanitize=address diff --git a/plugin/auth_examples/auth_0x0100.c b/plugin/auth_examples/auth_0x0100.c index e23f495f43b..e0639dddf90 100644 --- a/plugin/auth_examples/auth_0x0100.c +++ b/plugin/auth_examples/auth_0x0100.c @@ -56,6 +56,10 @@ struct st_mysql_auth }; #endif +/* function-type-mismatch ignore */ +#if defined(__clang__) +__attribute__((no_sanitize("undefined"))) +#endif static int do_auth_0x0100(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) { info->password_used= 1; diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 43249df744d..fee20a1a543 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -2855,6 +2855,18 @@ static void update_file_path(MYSQL_THD thd, { char *new_name= (*(char **) save) ? *(char **) save : empty_str; + if (strlen(new_name) + 4 > FN_REFLEN) + { + error_header(); + fprintf(stderr, + "server_audit_file_path can't exceed %d characters.\n", + FN_REFLEN - 4); + fprintf(stderr, "Log filename remains unchanged '%s'.\n", file_path); + CLIENT_ERROR(1, "server_audit_file_path can't exceed %d characters.", + MYF(ME_WARNING), FN_REFLEN - 4); + return; + } + ADD_ATOMIC(internal_stop_logging, 1); error_header(); fprintf(stderr, "Log file name was changed to '%s'.\n", new_name); diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.result b/plugin/type_inet/mysql-test/type_inet/type_inet6.result index 4620f405327..5b32002efa8 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result @@ -2419,3 +2419,26 @@ f::f DROP TABLE t1; SET max_sort_length=DEFAULT; # End of 10.8 tests +# +# MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +# +CREATE OR REPLACE TABLE t1 (c1 BINARY(16), UNIQUE (c1)); +INSERT INTO t1 (c1) VALUES (0x00000000000000000000000000000001); +INSERT INTO t1 (c1) VALUES (0x00000000000000000000000000000002); +SELECT CAST(c1 AS INET6) FROM t1 WHERE '::1' BETWEEN CAST('::1' AS INET6) AND c1; +CAST(c1 AS INET6) +::1 +::2 +SELECT CAST(c1 AS INET6) FROM t1 IGNORE KEY(c1) WHERE '::1' BETWEEN CAST('::1' AS INET6) AND c1; +CAST(c1 AS INET6) +::1 +::2 +SELECT CAST(c1 AS INET6) FROM t1 WHERE '::2' BETWEEN c1 AND CAST('::2' AS INET6); +CAST(c1 AS INET6) +::1 +::2 +SELECT CAST(c1 AS INET6) FROM t1 IGNORE KEY(c1) WHERE '::2' BETWEEN c1 AND CAST('::2' AS INET6); +CAST(c1 AS INET6) +::1 +::2 +DROP TABLE t1; diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.test b/plugin/type_inet/mysql-test/type_inet/type_inet6.test index c3128140b71..1fd5feea004 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test @@ -1741,3 +1741,15 @@ DROP TABLE t1; SET max_sort_length=DEFAULT; --echo # End of 10.8 tests + +--echo # +--echo # MDEV-36235 Incorrect result for BETWEEN over unique blob prefix +--echo # +CREATE OR REPLACE TABLE t1 (c1 BINARY(16), UNIQUE (c1)); +INSERT INTO t1 (c1) VALUES (0x00000000000000000000000000000001); +INSERT INTO t1 (c1) VALUES (0x00000000000000000000000000000002); +SELECT CAST(c1 AS INET6) FROM t1 WHERE '::1' BETWEEN CAST('::1' AS INET6) AND c1; +SELECT CAST(c1 AS INET6) FROM t1 IGNORE KEY(c1) WHERE '::1' BETWEEN CAST('::1' AS INET6) AND c1; +SELECT CAST(c1 AS INET6) FROM t1 WHERE '::2' BETWEEN c1 AND CAST('::2' AS INET6); +SELECT CAST(c1 AS INET6) FROM t1 IGNORE KEY(c1) WHERE '::2' BETWEEN c1 AND CAST('::2' AS INET6); +DROP TABLE t1; diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc b/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc index 596036fc0ee..9cf91169528 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc @@ -36,3 +36,16 @@ SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); DROP TABLE t1; + +--echo # +--echo # MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +--echo # Type_handler_fbt::Field_fbt::store_native, +--echo # Assertion `item->null_value' failed in Type_handler::Item_send_str +--echo # + +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +DROP TABLE t1; + +--echo # End of 10.5 tests diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result index deb1c718b49..dd5e3ba9f7f 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result @@ -88,6 +88,18 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = INET6'::ff' DROP TABLE t1; # +# MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +# Type_handler_fbt::Field_fbt::store_native, +# Assertion `item->null_value' failed in Type_handler::Item_send_str +# +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +cast('::' AS INET6) min(1) +:: NULL +DROP TABLE t1; +# End of 10.5 tests +# # MDEV-26742 Assertion `field->type_handler() == this' failed in FixedBinTypeBundle::Type_handler_fbt::stored_field_cmp_to_item # CREATE TABLE t1 (pk inet6, c text) engine=myisam; diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result index e805b167136..9bf8e58fb0b 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result @@ -155,5 +155,17 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = INET6'::ff' DROP TABLE t1; # +# MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +# Type_handler_fbt::Field_fbt::store_native, +# Assertion `item->null_value' failed in Type_handler::Item_send_str +# +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +cast('::' AS INET6) min(1) +:: NULL +DROP TABLE t1; +# End of 10.5 tests +# # End of 10.5 tests # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result index 0f20e16db9c..7bbc09c86f8 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result @@ -88,6 +88,18 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = INET6'::ff' DROP TABLE t1; # +# MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +# Type_handler_fbt::Field_fbt::store_native, +# Assertion `item->null_value' failed in Type_handler::Item_send_str +# +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +cast('::' AS INET6) min(1) +:: NULL +DROP TABLE t1; +# End of 10.5 tests +# # MDEV-26742 Assertion `field->type_handler() == this' failed in FixedBinTypeBundle::Type_handler_fbt::stored_field_cmp_to_item # CREATE TABLE t1 (c varchar(64), key(c)) engine=myisam; diff --git a/plugin/userstat/client_stats.cc b/plugin/userstat/client_stats.cc index 72c71785606..42d510b4a9b 100644 --- a/plugin/userstat/client_stats.cc +++ b/plugin/userstat/client_stats.cc @@ -45,8 +45,8 @@ static int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table) table->field[j++]->store((longlong)user_stats->total_connections,TRUE); table->field[j++]->store((longlong)user_stats->concurrent_connections, TRUE); table->field[j++]->store((longlong)user_stats->connected_time, TRUE); - table->field[j++]->store((double)user_stats->busy_time); - table->field[j++]->store((double)user_stats->cpu_time); + table->field[j++]->store((double)user_stats->busy_time/1e6); + table->field[j++]->store((double)user_stats->cpu_time/1e6); table->field[j++]->store((longlong)user_stats->bytes_received, TRUE); table->field[j++]->store((longlong)user_stats->bytes_sent, TRUE); table->field[j++]->store((longlong)user_stats->binlog_bytes_written, TRUE); diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index efda991bdec..8e00a972f11 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -1910,4 +1910,17 @@ create_data SST_PID="$DATA/wsrep_sst.pid" +if [ -n "${MTR_SST_JOINER_DELAY:-}" ]; then + MTR_SST_JOINER_DELAY=$(trim_string "$MTR_SST_JOINER_DELAY") +fi + +simulate_long_sst() +{ + # Delay for MTR tests if needed to simulate long SST/IST: + if [ ${MTR_SST_JOINER_DELAY:-0} -gt 0 ]; then + wsrep_log_info "Sleeping $MTR_SST_JOINER_DELAY seconds for MTR test" + sleep $MTR_SST_JOINER_DELAY + fi +} + wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE started on $WSREP_SST_OPT_ROLE" diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index ac42c7ffae5..2db1895e7e8 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -1574,6 +1574,8 @@ else # joiner exit 2 fi + simulate_long_sst + # use donor magic file, if present # if IST was used, donor magic file was not created # Remove special tags from the magic file, and from the output: diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index b889b298970..8270dc509ce 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -184,5 +184,9 @@ else echo "$SET_START_POSITION" | $MYSQL || exit $? fi +if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then + simulate_long_sst +fi + wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE completed on $WSREP_SST_OPT_ROLE" exit 0 diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 25057c498fd..361cef4a9fc 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -915,6 +915,8 @@ EOF fi fi + simulate_long_sst + # Remove special tags from the magic file, and from the output: coords=$(head -n1 "$MAGIC_FILE") wsrep_log_info "Galera co-ords from recovery: $coords" diff --git a/sql/filesort.cc b/sql/filesort.cc index 69fee121138..277a0037127 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -694,19 +694,8 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, static char dbug_row_print_buf[4096]; -/* - Print table's current row into a buffer and return a pointer to it. - This is intended to be used from gdb: - - (gdb) p dbug_print_table_row(table) - $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" - (gdb) - - Only columns in table->read_set are printed -*/ - -const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names) +String dbug_format_row(TABLE *table, const uchar *rec, bool print_names) { Field **pfield; char row_buff_tmp[512]; @@ -775,13 +764,36 @@ const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names) } } output.append(')'); - if (output.c_ptr() == dbug_row_print_buf) - return dbug_row_print_buf; - else - return "Couldn't fit into buffer"; + + return output; } +/** + A function to display a row in debugger. + Example usage: + (gdb) p dbug_print_row(table, table->record[1]) +*/ +const char *dbug_print_row(TABLE *table, const uchar *rec) +{ + String row= dbug_format_row(table, table->record[0]); + if (row.length() > sizeof dbug_row_print_buf - 1) + return "Couldn't fit into buffer"; + memcpy(dbug_row_print_buf, row.c_ptr(), row.length()); + return dbug_row_print_buf; +} + +/** + Print table's current row into a buffer and return a pointer to it. + + This is intended to be used from gdb: + + (gdb) p dbug_print_table_row(table) + $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" + (gdb) + + Only columns in table->read_set are printed +*/ const char* dbug_print_table_row(TABLE *table) { return dbug_print_row(table, table->record[0]); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 433accf1426..94250796d4f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2141,7 +2141,9 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, m_added_file[i]->extra(HA_EXTRA_BEGIN_ALTER_COPY); error= copy_partitions(copied, deleted); for (i= 0; i < part_count; i++) - m_added_file[i]->extra(HA_EXTRA_END_ALTER_COPY); + m_added_file[i]->extra(error + ? HA_EXTRA_ABORT_ALTER_COPY + : HA_EXTRA_END_ALTER_COPY); if (unlikely(error)) { /* @@ -9469,6 +9471,7 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN: case HA_EXTRA_BEGIN_ALTER_COPY: case HA_EXTRA_END_ALTER_COPY: + case HA_EXTRA_ABORT_ALTER_COPY: DBUG_RETURN(loop_partitions(extra_cb, &operation)); default: { diff --git a/sql/handle_connections_win.cc b/sql/handle_connections_win.cc index ffacfcab88f..9c98620e6d2 100644 --- a/sql/handle_connections_win.cc +++ b/sql/handle_connections_win.cc @@ -595,11 +595,8 @@ void network_init_win() void handle_connections_win() { - int n_waits; - create_shutdown_event(); wait_events.push_back(hEventShutdown); - n_waits= 1; for (size_t i= 0; i < all_listeners.size(); i++) { diff --git a/sql/handler.cc b/sql/handler.cc index d4f15a7c4a9..984eb8d0948 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1945,6 +1945,8 @@ int ha_commit_trans(THD *thd, bool all) } #endif /* WITH_WSREP */ error= ha_commit_one_phase(thd, all); + if (error) + goto err; #ifdef WITH_WSREP // Here in case of error we must return 2 for inconsistency if (run_wsrep_hooks && !error) @@ -2185,7 +2187,7 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) if (ha_info) { - int err; + int err= 0; if (has_binlog_hton(ha_info) && (err= binlog_commit(thd, all, @@ -2193,6 +2195,8 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) { my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); error= 1; + + goto err; } for (; ha_info; ha_info= ha_info_next) { @@ -2228,7 +2232,7 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) if (count >= 2) statistic_increment(transactions_multi_engine, LOCK_status); } - + err: DBUG_RETURN(error); } @@ -7996,7 +8000,8 @@ int handler::ha_write_row(const uchar *buf) TABLE_IO_WAIT(tracker, PSI_TABLE_WRITE_ROW, MAX_KEY, error, { error= write_row(buf); }) - DBUG_PRINT("dml", ("INSERT: %s = %d", dbug_print_row(table, buf, false), error)); + DBUG_PRINT("dml", ("INSERT: %s = %d", + dbug_format_row(table, buf, false).c_ptr_safe(), error)); MYSQL_INSERT_ROW_DONE(error); if (likely(!error)) @@ -8046,8 +8051,10 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) TABLE_IO_WAIT(tracker, PSI_TABLE_UPDATE_ROW, active_index, 0, { error= update_row(old_data, new_data);}) - DBUG_PRINT("dml", ("UPDATE: %s => %s = %d", dbug_print_row(table, old_data, false), - dbug_print_row(table, new_data, false), error)); + DBUG_PRINT("dml", ("UPDATE: %s => %s = %d", + dbug_format_row(table, old_data, false).c_ptr_safe(), + dbug_format_row(table, new_data, false).c_ptr_safe(), + error)); MYSQL_UPDATE_ROW_DONE(error); if (likely(!error)) @@ -8125,7 +8132,8 @@ int handler::ha_delete_row(const uchar *buf) TABLE_IO_WAIT(tracker, PSI_TABLE_DELETE_ROW, active_index, error, { error= delete_row(buf);}) - DBUG_PRINT("dml", ("DELETE: %s = %d", dbug_print_row(table, buf, false), error)); + DBUG_PRINT("dml", ("DELETE: %s = %d", + dbug_format_row(table, buf, false).c_ptr_safe(), error)); MYSQL_DELETE_ROW_DONE(error); if (likely(!error)) { @@ -8467,16 +8475,6 @@ int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info) VERSIONING functions ******************************************************************************/ -bool Vers_parse_info::is_start(const char *name) const -{ - DBUG_ASSERT(name); - return as_row.start && as_row.start.streq(name); -} -bool Vers_parse_info::is_end(const char *name) const -{ - DBUG_ASSERT(name); - return as_row.end && as_row.end.streq(name); -} bool Vers_parse_info::is_start(const Create_field &f) const { return f.flags & VERS_ROW_START; @@ -8531,8 +8529,8 @@ bool Vers_parse_info::create_sys_field(THD *thd, const char *field_name, return false; } -const Lex_ident Vers_parse_info::default_start= "row_start"; -const Lex_ident Vers_parse_info::default_end= "row_end"; +const Lex_ident Vers_parse_info::default_start= { STRING_WITH_LEN("row_start")}; +const Lex_ident Vers_parse_info::default_end= { STRING_WITH_LEN("row_end")}; bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info) { @@ -8791,7 +8789,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, if (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING) { - if (check_sys_fields(table_name, share->db, alter_info)) + if (check_sys_fields(share->table_name, share->db, alter_info)) return true; } @@ -9097,8 +9095,8 @@ bool Table_scope_and_contents_source_st::check_period_fields( } } - bool res= period_info.check_field(row_start, period.start.str) - || period_info.check_field(row_end, period.end.str); + bool res= period_info.check_field(row_start, period.start) + || period_info.check_field(row_end, period.end); if (res) return true; diff --git a/sql/handler.h b/sql/handler.h index 40b99325a67..9c22c8b826c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2157,8 +2157,6 @@ struct Vers_parse_info: public Table_period_info } protected: - bool is_start(const char *name) const; - bool is_end(const char *name) const; bool is_start(const Create_field &f) const; bool is_end(const Create_field &f) const; bool fix_implicit(THD *thd, Alter_info *alter_info); @@ -5799,6 +5797,6 @@ int get_select_field_pos(Alter_info *alter_info, int select_field_count, bool versioned); #ifndef DBUG_OFF -const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names= true); +String dbug_format_row(TABLE *table, const uchar *rec, bool print_names= true); #endif /* DBUG_OFF */ #endif /* HANDLER_INCLUDED */ diff --git a/sql/item.cc b/sql/item.cc index 5f6bc3a8d57..1ae61be5ab5 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5302,6 +5302,7 @@ bool Item_param::assign_default(Field *field) double Item_copy_string::val_real() { + DBUG_ASSERT(copied_in); int err_not_used; char *end_not_used; return (null_value ? 0.0 : @@ -5312,6 +5313,7 @@ double Item_copy_string::val_real() longlong Item_copy_string::val_int() { + DBUG_ASSERT(copied_in); int err; return null_value ? 0 : str_value.charset()->strntoll(str_value.ptr(), str_value.length(), 10, @@ -5321,6 +5323,7 @@ longlong Item_copy_string::val_int() int Item_copy_string::save_in_field(Field *field, bool no_conversions) { + DBUG_ASSERT(copied_in); return save_str_value_in_field(field, &str_value); } @@ -5331,11 +5334,15 @@ void Item_copy_string::copy() if (res && res != &str_value) str_value.copy(*res); null_value=item->null_value; +#ifndef DBUG_OFF + copied_in= 1; +#endif } /* ARGSUSED */ String *Item_copy_string::val_str(String *str) { + DBUG_ASSERT(copied_in); // Item_copy_string is used without fix_fields call if (null_value) return (String*) 0; @@ -5345,6 +5352,7 @@ String *Item_copy_string::val_str(String *str) my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value) { + DBUG_ASSERT(copied_in); // Item_copy_string is used without fix_fields call if (null_value) return (my_decimal *) 0; @@ -11086,8 +11094,8 @@ void dummy_error_processor(THD *thd, void *data) {} /** - Wrapper of hide_view_error call for Name_resolution_context error - processor. + Wrapper of replace_view_error_with_generic call for Name_resolution_context + error processor. @note hide view underlying tables details in error messages @@ -11095,7 +11103,7 @@ void dummy_error_processor(THD *thd, void *data) void view_error_processor(THD *thd, void *data) { - ((TABLE_LIST *)data)->hide_view_error(thd); + ((TABLE_LIST *)data)->replace_view_error_with_generic(thd); } diff --git a/sql/item.h b/sql/item.h index 58d446b9089..dae9d3feb2a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -757,6 +757,17 @@ public: virtual const String *const_ptr_string() const { return NULL; } }; +struct subselect_table_finder_param +{ + THD *thd; + /* + We're searching for different TABLE_LIST objects referring to the same + table as this one + */ + const TABLE_LIST *find; + /* NUL - not found, ERROR_TABLE - search error, or the found table reference */ + TABLE_LIST *dup; +}; /****************************************************************************/ @@ -1954,6 +1965,19 @@ public: */ virtual Item *clone_item(THD *thd) const { return nullptr; } + /* + @detail + The meaning of this function seems to be: + Check what the item would return if it was provided with two identical + non-NULL arguments. + It is not clear why it is defined for generic class Item or what its other + uses are. + + @return + COND_TRUE Would return true + COND_FALSE Would return false + COND_OK May return either, depending on the argument type. + */ virtual cond_result eq_cmp_result() const { return COND_OK; } inline uint float_length(uint decimals_par) const { return decimals < FLOATING_POINT_DECIMALS ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;} @@ -2292,6 +2316,7 @@ public: set_extraction_flag(*(int16*)arg); return 0; } + virtual bool subselect_table_finder_processor(void *arg) { return 0; }; /* TRUE if the expression depends only on the table indicated by tab_map @@ -6707,8 +6732,15 @@ protected: Type_std_attributes::set(item); name= item->name; set_handler(item->type_handler()); +#ifndef DBUG_OFF + copied_in= 0; +#endif } +#ifndef DBUG_OFF + bool copied_in; +#endif + public: /** @@ -6774,7 +6806,10 @@ public: double val_real() override; longlong val_int() override; bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override - { return get_date_from_string(thd, ltime, fuzzydate); } + { + DBUG_ASSERT(copied_in); + return get_date_from_string(thd, ltime, fuzzydate); + } void copy() override; int save_in_field(Field *field, bool no_conversions) override; Item *do_get_copy(THD *thd) const override @@ -6804,9 +6839,13 @@ public: null_value= tmp.is_null(); m_value= tmp.is_null() ? Timestamp_or_zero_datetime() : Timestamp_or_zero_datetime(tmp); +#ifndef DBUG_OFF + copied_in=1; +#endif } int save_in_field(Field *field, bool) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); if (null_value) return set_field_to_null(field); @@ -6815,30 +6854,35 @@ public: } longlong val_int() override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? 0 : m_value.to_datetime(current_thd).to_longlong(); } double val_real() override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? 0e0 : m_value.to_datetime(current_thd).to_double(); } String *val_str(String *to) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? NULL : m_value.to_datetime(current_thd).to_string(to, decimals); } my_decimal *val_decimal(my_decimal *to) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? NULL : m_value.to_datetime(current_thd).to_decimal(to); } bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); bool res= m_value.to_TIME(thd, ltime, fuzzydate); DBUG_ASSERT(!res); @@ -6846,6 +6890,7 @@ public: } bool val_native(THD *thd, Native *to) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value || m_value.to_native(to, decimals); } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 29588730d4c..364dc947187 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1015,6 +1015,23 @@ public: class Item_func_between :public Item_func_opt_neg { + /* + If the types of the arguments to BETWEEN permit, then: + + WHERE const1 BETWEEN expr2 AND field1 + can be optimized as if it was just: + WHERE const1 <= field1 + + as expr2 could be an arbitrary expression. More generally, + this optimization is permitted if aggregation for comparison + for three expressions (const1,const2,field1) and for two + expressions (const1,field1) return the same type handler. + + @param [IN] field_item - This is a field from the right side + of the BETWEEN operator. + */ + bool can_optimize_range_const(Item_field *field_item) const; + protected: SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Field *field, Item *value) override; @@ -2958,9 +2975,18 @@ public: TODO: We could still replace "expr1" to "const" in "expr1 LIKE expr2" in case of a "PAD SPACE" collation, but only if "expr2" has '%' - at the end. + at the end. */ - return compare_collation() == &my_charset_bin ? COND_TRUE : COND_OK; + if (compare_collation() == &my_charset_bin) + { + /* + 'foo' NOT LIKE 'foo' is false, + 'foo' LIKE 'foo' is true. + */ + return negated? COND_FALSE : COND_TRUE; + } + + return COND_OK; } void add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, table_map usable_tables, SARGABLE_PARAM **sargables) diff --git a/sql/item_func.cc b/sql/item_func.cc index cbf70379850..01d46fa2a44 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -7068,6 +7068,16 @@ longlong Item_func_cursor_rowcount::val_int() /***************************************************************************** SEQUENCE functions *****************************************************************************/ +bool Item_func_nextval::check_access_and_fix_fields(THD *thd, Item **ref, + privilege_t want_access) +{ + table_list->sequence= false; + bool error= check_single_table_access(thd, want_access, table_list, false); + table_list->sequence= true; + if (error && table_list->belong_to_view) + table_list->replace_view_error_with_generic(thd); + return error || Item_longlong_func::fix_fields(thd, ref); +} longlong Item_func_nextval::val_int() { diff --git a/sql/item_func.h b/sql/item_func.h index 098ac4a461d..bb67ce75941 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -4240,6 +4240,7 @@ protected: TABLE_LIST *table_list; TABLE *table; bool print_table_list_identifier(THD *thd, String *to) const; + bool check_access_and_fix_fields(THD *, Item **ref, privilege_t); public: Item_func_nextval(THD *thd, TABLE_LIST *table_list_arg): Item_longlong_func(thd), table_list(table_list_arg) {} @@ -4249,6 +4250,8 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("nextval") }; return name; } + bool fix_fields(THD *thd, Item **ref) override + { return check_access_and_fix_fields(thd, ref, INSERT_ACL | SELECT_ACL); } bool fix_length_and_dec(THD *thd) override { unsigned_flag= 0; @@ -4290,6 +4293,8 @@ class Item_func_lastval :public Item_func_nextval public: Item_func_lastval(THD *thd, TABLE_LIST *table_list_arg): Item_func_nextval(thd, table_list_arg) {} + bool fix_fields(THD *thd, Item **ref) override + { return check_access_and_fix_fields(thd, ref, SELECT_ACL); } longlong val_int() override; LEX_CSTRING func_name_cstring() const override { @@ -4314,6 +4319,8 @@ public: : Item_func_nextval(thd, table_list_arg), nextval(nextval_arg), round(round_arg), is_used(is_used_arg) {} + bool fix_fields(THD *thd, Item **ref) override + { return check_access_and_fix_fields(thd, ref, INSERT_ACL); } longlong val_int() override; LEX_CSTRING func_name_cstring() const override { diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 02f7ed6fb56..f14bb4b20cf 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -79,7 +79,8 @@ static bool eq_ascii_string(const CHARSET_INFO *cs, } -static bool append_simple(String *s, const char *a, size_t a_len) +static bool __attribute__((warn_unused_result)) +append_simple(String *s, const char *a, size_t a_len) { if (!s->realloc_with_extra_if_needed(s->length() + a_len)) { @@ -91,7 +92,8 @@ static bool append_simple(String *s, const char *a, size_t a_len) } -static inline bool append_simple(String *s, const uchar *a, size_t a_len) +static inline bool __attribute__((warn_unused_result)) +append_simple(String *s, const uchar *a, size_t a_len) { return append_simple(s, (const char *) a, a_len); } @@ -305,8 +307,10 @@ static int json_nice(json_engine_t *je, String *nice_js, nice_js->length(0); nice_js->set_charset(je->s.cs); - nice_js->alloc(je->s.str_end - je->s.c_str + 32); + if (nice_js->alloc(je->s.str_end - je->s.c_str + 32)) + goto error; + DBUG_ASSERT(mode != Item_func_json_format::DETAILED || (tab_size >= 0 && tab_size <= TAB_SIZE_LIMIT)); @@ -352,7 +356,8 @@ static int json_nice(json_engine_t *je, String *nice_js, goto error; nice_js->append('"'); - append_simple(nice_js, key_start, key_end - key_start); + if (append_simple(nice_js, key_start, key_end - key_start)) + goto error; nice_js->append(colon, colon_len); } /* now we have key value to handle, so no 'break'. */ @@ -864,7 +869,7 @@ String *Item_func_json_quote::val_str(String *str) bool Item_func_json_unquote::fix_length_and_dec(THD *thd) { - collation.set(&my_charset_utf8mb3_general_ci, + collation.set(&my_charset_utf8mb4_bin, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); max_length= args[0]->max_char_length() * collation.collation->mbmaxlen; set_maybe_null(); @@ -907,12 +912,12 @@ String *Item_func_json_unquote::val_str(String *str) return js; str->length(0); - str->set_charset(&my_charset_utf8mb3_general_ci); + str->set_charset(&my_charset_utf8mb4_bin); if (str->realloc_with_extra_if_needed(je.value_len) || (c_len= json_unescape(js->charset(), je.value, je.value + je.value_len, - &my_charset_utf8mb3_general_ci, + &my_charset_utf8mb4_bin, (uchar *) str->ptr(), (uchar *) (str->ptr() + je.value_len))) < 0) goto error; @@ -2261,24 +2266,67 @@ String *Item_func_json_array_insert::val_str(String *str) str->set_charset(js->charset()); if (item_pos) { - if (append_simple(str, js->ptr(), item_pos - js->ptr()) || - (n_item > 0 && str->append(" ", 1)) || - append_json_value(str, args[n_arg+1], &tmp_val) || - str->append(",", 1) || - (n_item == 0 && str->append(" ", 1)) || - append_simple(str, item_pos, js->end() - item_pos)) + my_ptrdiff_t size= item_pos - js->ptr(); + if (append_simple(str, js->ptr(), size)) + { + my_error(ER_OUTOFMEMORY, MYF(0), (int) size); goto return_null; /* Out of memory. */ + } + if (n_item > 0 && str->append(" ", 1)) + { + my_error(ER_OUTOFMEMORY, MYF(0), 1); + goto return_null; /* Out of memory. */ + } + if (append_json_value(str, args[n_arg+1], &tmp_val)) + { + my_error(ER_OUTOFMEMORY, MYF(0), tmp_val.length()); + goto return_null; /* Out of memory. */ + } + if (str->append(",", 1)) + { + my_error(ER_OUTOFMEMORY, MYF(0), 1); + goto return_null; /* Out of memory. */ + } + if (n_item == 0 && str->append(" ", 1)) + { + my_error(ER_OUTOFMEMORY, MYF(0), 1); + goto return_null; /* Out of memory. */ + } + size= js->end() - item_pos; + if (append_simple(str, item_pos, size)) + { + my_error(ER_OUTOFMEMORY, MYF(0), (int) size); + goto return_null; /* Out of memory. */ + } } else { + my_ptrdiff_t size; /* Insert position wasn't found - append to the array. */ DBUG_ASSERT(je.state == JST_ARRAY_END); item_pos= (const char *) (je.s.c_str - je.sav_c_len); - if (append_simple(str, js->ptr(), item_pos - js->ptr()) || - (n_item > 0 && str->append(", ", 2)) || - append_json_value(str, args[n_arg+1], &tmp_val) || - append_simple(str, item_pos, js->end() - item_pos)) + size= item_pos - js->ptr(); + if (append_simple(str, js->ptr(), size)) + { + my_error(ER_OUTOFMEMORY, MYF(0), (int) size); goto return_null; /* Out of memory. */ + } + if (n_item > 0 && str->append(", ", 2)) + { + my_error(ER_OUTOFMEMORY, MYF(0), 2); + goto return_null; /* Out of memory. */ + } + if (append_json_value(str, args[n_arg+1], &tmp_val)) + { + my_error(ER_OUTOFMEMORY, MYF(0), tmp_val.length()); + goto return_null; /* Out of memory. */ + } + size= js->end() - item_pos; + if (append_simple(str, item_pos, size)) + { + my_error(ER_OUTOFMEMORY, MYF(0), (int) size); + goto return_null; /* Out of memory. */ + } } { @@ -4130,13 +4178,23 @@ int Arg_comparator::compare_json_str_basic(Item *j, Item *s) goto error; if (je.value_type == JSON_VALUE_STRING) { - if (value2.realloc_with_extra_if_needed(je.value_len) || - (c_len= json_unescape(js->charset(), je.value, + if (value2.realloc_with_extra_if_needed(je.value_len)) + { + my_error(ER_OUTOFMEMORY, MYF(0), je.value_len); + goto error; + } + if ((c_len= json_unescape(js->charset(), je.value, je.value + je.value_len, - &my_charset_utf8mb3_general_ci, + &my_charset_utf8mb4_bin, (uchar *) value2.ptr(), (uchar *) (value2.ptr() + je.value_len))) < 0) + { + if (current_thd) + push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, + ER_JSON_BAD_CHR, ER_THD(current_thd, ER_JSON_BAD_CHR), + 0, "comparison", (int)((const char *) je.s.c_str - js->ptr())); goto error; + } value2.length(c_len); js= &value2; @@ -4179,13 +4237,23 @@ int Arg_comparator::compare_e_json_str_basic(Item *j, Item *s) if (type == JSON_VALUE_STRING) { - if (value1.realloc_with_extra_if_needed(value_len) || - (c_len= json_unescape(value1.charset(), (uchar *) value, + if (value1.realloc_with_extra_if_needed(value_len)) + { + my_error(ER_OUTOFMEMORY, MYF(0), value_len); + return 1; + } + if ((c_len= json_unescape(value1.charset(), (uchar *) value, (uchar *) value+value_len, - &my_charset_utf8mb3_general_ci, + &my_charset_utf8mb4_bin, (uchar *) value1.ptr(), (uchar *) (value1.ptr() + value_len))) < 0) + { + if (current_thd) + push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, + ER_JSON_BAD_CHR, ER_THD(current_thd, ER_JSON_BAD_CHR), + 0, "equality comparison", 0); return 1; + } value1.length(c_len); res1= &value1; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 92a2eec6557..246ef5673dc 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -7202,3 +7202,27 @@ void Subq_materialization_tracker::report_partial_merge_keys( for (uint i= 0; i < merge_keys_count; i++) partial_match_array_sizes[i]= merge_keys[i]->get_key_buff_elements(); } + + +/* + Check if somewhere inside this subselect we read the table. This means a + full read "(SELECT ... FROM tbl)", outside reference to tbl.column does not + count +*/ + +bool +Item_subselect::subselect_table_finder_processor(void *arg) +{ + subselect_table_finder_param *param= (subselect_table_finder_param *)arg; + for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) + { + TABLE_LIST *dup; + if ((dup= sl->find_table(param->thd, ¶m->find->db, + ¶m->find->table_name))) + { + param->dup= dup; + return TRUE; + } + } + return FALSE; +}; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index bf7e484303b..e6e8d4b6271 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -273,6 +273,7 @@ public: { return TRUE; } + bool subselect_table_finder_processor(void *arg) override; void register_as_with_rec_ref(With_element *with_elem); void init_expr_cache_tracker(THD *thd); diff --git a/sql/lex_string.h b/sql/lex_string.h index c296d50eb32..192eb950ea5 100644 --- a/sql/lex_string.h +++ b/sql/lex_string.h @@ -135,7 +135,7 @@ class Lex_cstring : public LEX_CSTRING class Lex_cstring_strlen: public Lex_cstring { public: - Lex_cstring_strlen(const char *from) + explicit Lex_cstring_strlen(const char *from) :Lex_cstring(from, from ? strlen(from) : 0) { } }; diff --git a/sql/log.cc b/sql/log.cc index e8f802dbc09..79341487194 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2398,6 +2398,18 @@ void binlog_reset_cache(THD *thd) } +void binlog_clear_incident(THD *thd) +{ + binlog_cache_mngr *const cache_mngr= opt_bin_log ? + (binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton) : 0; + if (cache_mngr) + { + cache_mngr->stmt_cache.clear_incident(); + cache_mngr->trx_cache.clear_incident(); + } +} + + void Event_log::set_write_error(THD *thd, bool is_transactional) { DBUG_ENTER("MYSQL_BIN_LOG::set_write_error"); diff --git a/sql/log.h b/sql/log.h index 3ee06e17264..b2699373f74 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1384,6 +1384,7 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, void make_default_log_name(char **out, const char* log_ext, bool once); void binlog_reset_cache(THD *thd); +void binlog_clear_incident(THD *thd); bool write_annotated_row(THD *thd); int binlog_flush_pending_rows_event(THD *thd, bool stmt_end, bool is_transactional, diff --git a/sql/log_cache.h b/sql/log_cache.h index cdff752b806..1cde55bc94c 100644 --- a/sql/log_cache.h +++ b/sql/log_cache.h @@ -81,6 +81,11 @@ public: incident= TRUE; } + void clear_incident(void) + { + incident= FALSE; + } + bool has_incident(void) const { return(incident); diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 61fa17596aa..776762a52ad 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -344,10 +344,29 @@ static char *init_bootstrap_command_line(char *cmdline, size_t size) static char my_ini_path[MAX_PATH]; +/** + Wrapper for WritePrivateProfileStringA, with retries and sleeps + if file is locked by another process. +*/ +static BOOL write_private_profile_string_with_retries(const char *appname, + const char *key, const char *val, const char *filename) +{ + static constexpr int RETRIES=50; + static constexpr int SLEEP_MS=10; + for (int n= RETRIES;; n--) + { + if (WritePrivateProfileStringA(appname, key, val, filename)) + return TRUE; + if (GetLastError() != ERROR_ACCESS_DENIED || !n) + return FALSE; + Sleep(SLEEP_MS); + } +} + static void write_myini_str(const char *key, const char* val, const char *section="mysqld") { DBUG_ASSERT(my_ini_path[0]); - if (!WritePrivateProfileString(section, key, val, my_ini_path)) + if (!write_private_profile_string_with_retries(section, key, val, my_ini_path)) { die("Can't write to ini file key=%s, val=%s, section=%s, Windows error %u",key,val,section, GetLastError()); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 38394d33675..47050d9f31e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1417,10 +1417,6 @@ Dynamic_array listen_sockets(PSI_INSTRUMENT_MEM, 0); bool unix_sock_is_online= false; static int systemd_sock_activation; /* systemd socket activation */ -/** wakeup listening(main) thread by writing to this descriptor */ -static int termination_event_fd= -1; - - C_MODE_START #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE @@ -1474,9 +1470,14 @@ static pthread_t select_thread; #endif /* OS specific variables */ - +#ifndef EMBEDDED_LIBRARY #ifdef _WIN32 +/** wakeup main thread by signaling this event */ HANDLE hEventShutdown; +#else +/** wakeup listening(main) thread by writing to this descriptor */ +static int termination_event_fd= -1; +#endif #endif @@ -8947,15 +8948,22 @@ char *set_server_version(char *buf, size_t size) bool is_log= opt_log || global_system_variables.sql_log_slow || opt_bin_log; bool is_debug= IF_DBUG(!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"), 0); const char *is_valgrind= -#ifdef HAVE_VALGRIND +#ifdef HAVE_valgrind !strstr(MYSQL_SERVER_SUFFIX_STR, "-valgrind") ? "-valgrind" : #endif ""; + const char *is_asan= +#ifdef __SANITIZE_ADDRESS__ + !strstr(MYSQL_SERVER_SUFFIX_STR, "-asan") ? "-asan" : +#endif + ""; + return strxnmov(buf, size - 1, MYSQL_SERVER_VERSION, MYSQL_SERVER_SUFFIX_STR, IF_EMBEDDED("-embedded", ""), is_valgrind, + is_asan, is_debug ? "-debug" : "", is_log ? "-log" : "", NullS); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 567d3d0467f..3f7fac54e0d 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8598,56 +8598,58 @@ SEL_TREE *Item_func_in::get_func_row_mm_tree(RANGE_OPT_PARAM *param, /* Build conjunction of all SEL_TREEs for a simple predicate applying equalities - + SYNOPSIS get_full_func_mm_tree() param PARAM from SQL_SELECT::test_quick_select field_item field in the predicate - value constant in the predicate (or a field already read from + value constant in the predicate (or a field already read from a table in the case of dynamic range access) (for BETWEEN it contains the number of the field argument, - for IN it's always 0) + for IN it's always 0) inv TRUE <> NOT cond_func is considered (makes sense only when cond_func is BETWEEN or IN) DESCRIPTION - For a simple SARGable predicate of the form (f op c), where f is a field and - c is a constant, the function builds a conjunction of all SEL_TREES that can - be obtained by the substitution of f for all different fields equal to f. + For a simple SARGable predicate of the form (f op c), where f is a field + and c is a constant, the function builds a conjunction of all SEL_TREES that + can be obtained by the substitution of f for all different fields equal to f. - NOTES + NOTES If the WHERE condition contains a predicate (fi op c), then not only SELL_TREE for this predicate is built, but the trees for the results of substitution of fi for each fj belonging to the same multiple equality as fi are built as well. - E.g. for WHERE t1.a=t2.a AND t2.a > 10 + E.g. for WHERE t1.a=t2.a AND t2.a > 10 a SEL_TREE for t2.a > 10 will be built for quick select from t2 - and + and a SEL_TREE for t1.a > 10 will be built for quick select from t1. - A BETWEEN predicate of the form (fi [NOT] BETWEEN c1 AND c2) is treated - in a similar way: we build a conjuction of trees for the results - of all substitutions of fi for equal fj. + A BETWEEN predicate of the form (fi [NOT] BETWEEN c1 AND c2), where fi + is some field, is treated in a similar way: we build a conjuction of + trees for the results of all substitutions of fi equal fj. + Yet a predicate of the form (c BETWEEN f1i AND f2i) is processed differently. It is considered as a conjuction of two SARGable - predicates (f1i <= c) and (f2i <=c) and the function get_full_func_mm_tree - is called for each of them separately producing trees for - AND j (f1j <=c ) and AND j (f2j <= c) + predicates (f1i <= c) and (c <= f2i) and the function get_full_func_mm_tree + is called for each of them separately producing trees for + AND j (f1j <= c) and AND j (c <= f2j) After this these two trees are united in one conjunctive tree. It's easy to see that the same tree is obtained for - AND j,k (f1j <=c AND f2k<=c) - which is equivalent to + AND j,k (f1j <= c AND c <= f2k) + which is equivalent to AND j,k (c BETWEEN f1j AND f2k). + The validity of the processing of the predicate (c NOT BETWEEN f1i AND f2i) which equivalent to (f1i > c OR f2i < c) is not so obvious. Here the - function get_full_func_mm_tree is called for (f1i > c) and (f2i < c) - producing trees for AND j (f1j > c) and AND j (f2j < c). Then this two - trees are united in one OR-tree. The expression + function get_full_func_mm_tree is called for (f1i > c) and called for + (f2i < c) producing trees for AND j (f1j > c) and AND j (f2j < c). Then + this two trees are united in one OR-tree. The expression (AND j (f1j > c) OR AND j (f2j < c) is equivalent to the expression - AND j,k (f1j > c OR f2k < c) - which is just a translation of + AND j,k (f1j > c OR f2k < c) + which is just a translation of AND j,k (c NOT BETWEEN f1j AND f2k) In the cases when one of the items f1, f2 is a constant c1 we do not create @@ -8660,9 +8662,9 @@ SEL_TREE *Item_func_in::get_func_row_mm_tree(RANGE_OPT_PARAM *param, As to IN predicates only ones of the form (f IN (c1,...,cn)), where f1 is a field and c1,...,cn are constant, are considered as SARGable. We never try to narrow the index scan using predicates of - the form (c IN (c1,...,f,...,cn)). - - RETURN + the form (c IN (c1,...,f,...,cn)). + + RETURN Pointer to the tree representing the built conjunction of SEL_TREEs */ @@ -8870,6 +8872,19 @@ SEL_TREE *Item::get_mm_tree(RANGE_OPT_PARAM *param, Item **cond_ptr) } +bool +Item_func_between::can_optimize_range_const(Item_field *field_item) const +{ + const Type_handler *fi_handler= field_item->type_handler_for_comparison(); + Type_handler_hybrid_field_type cmp(fi_handler); + if (cmp.aggregate_for_comparison(args[0]->type_handler_for_comparison()) || + cmp.type_handler() != m_comparator.type_handler()) + return false; // Cannot optimize range because of type mismatch. + + return true; +} + + SEL_TREE * Item_func_between::get_mm_tree(RANGE_OPT_PARAM *param, Item **cond_ptr) { @@ -8895,6 +8910,8 @@ Item_func_between::get_mm_tree(RANGE_OPT_PARAM *param, Item **cond_ptr) if (arguments()[i]->real_item()->type() == Item::FIELD_ITEM) { Item_field *field_item= (Item_field*) (arguments()[i]->real_item()); + if (!can_optimize_range_const(field_item)) + continue; SEL_TREE *tmp= get_full_func_mm_tree(param, field_item, (Item*)(intptr) i); if (negated) diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index 6a1c724809a..446b319535c 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -146,7 +146,6 @@ public: }; transaction() : m_thd(NULL) { } - transaction(transaction const&); ~transaction(); /* Clear transaction, i.e., make calls to 'good()' return false. */ diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 7d8b70d5f8e..e0819a07f31 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -22,6 +22,7 @@ #include "strfunc.h" #include "sql_repl.h" #include "sql_acl.h" +#include #ifdef HAVE_REPLICATION @@ -1373,19 +1374,16 @@ Master_info_index::get_master_info(const LEX_CSTRING *connection_name, ("connection_name: '%.*s'", (int) connection_name->length, connection_name->str)); - /* Make name lower case for comparison */ - IdentBufferCasedn buff(connection_name->str ? - *connection_name : - empty_clex_str); + if (!connection_name->str) + connection_name= &empty_clex_str; mi= (Master_info*) my_hash_search(&master_info_hash, - (const uchar*) buff.ptr(), buff.length()); + (uchar*) connection_name->str, + connection_name->length); if (!mi && warning != Sql_condition::WARN_LEVEL_NOTE) { my_error(WARN_NO_MASTER_INFO, - MYF(warning == Sql_condition::WARN_LEVEL_WARN ? ME_WARNING : - 0), - (int) connection_name->length, - connection_name->str); + MYF(warning == Sql_condition::WARN_LEVEL_WARN ? ME_WARNING : 0), + (int) connection_name->length, connection_name->str); } DBUG_RETURN(mi); } @@ -2076,4 +2074,48 @@ bool Master_info_index::flush_all_relay_logs() DBUG_RETURN(result); } +void setup_mysql_connection_for_master(MYSQL *mysql, Master_info *mi, + uint timeout) +{ + DBUG_ASSERT(mi); + DBUG_ASSERT(mi->mysql); + mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &timeout); + mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &timeout); + +#ifdef HAVE_OPENSSL + if (mi->ssl) + { + mysql_ssl_set(mysql, mi->ssl_key, mi->ssl_cert, mi->ssl_ca, mi->ssl_capath, + mi->ssl_cipher); + mysql_options(mysql, MYSQL_OPT_SSL_CRL, mi->ssl_crl); + mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, mi->ssl_crlpath); + mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + &mi->ssl_verify_server_cert); + } + else +#endif + mysql->options.use_ssl= 0; + + /* + If server's default charset is not supported (like utf16, utf32) as client + charset, then set client charset to 'latin1' (default client charset). + */ + if (is_supported_parser_charset(default_charset_info)) + mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->cs_name.str); + else + { + sql_print_information("'%s' can not be used as client character set. " + "'%s' will be used as default client character set " + "while connecting to master.", + default_charset_info->cs_name.str, + default_client_charset_info->cs_name.str); + mysql_options(mysql, MYSQL_SET_CHARSET_NAME, + default_client_charset_info->cs_name.str); + } + + /* Set MYSQL_PLUGIN_DIR in case master asks for an external authentication plugin */ + if (opt_plugin_dir_ptr && *opt_plugin_dir_ptr) + mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr); +} + #endif /* HAVE_REPLICATION */ diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 7f2e4c50a1b..0b659d81f11 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -487,5 +487,16 @@ void free_key_master_info(Master_info *mi); uint any_slave_sql_running(bool already_locked); bool give_error_if_slave_running(bool already_lock); +/* + Sets up the basic options for a MYSQL connection, mysql, to connect to the + primary server described by the Master_info parameter, mi. The timeout must + be passed explicitly, as different types of connections created by the slave + will use different values. + + Assumes mysql_init() has already been called on the mysql connection object. +*/ +void setup_mysql_connection_for_master(MYSQL *mysql, Master_info *mi, + uint timeout); + #endif /* HAVE_REPLICATION */ #endif /* RPL_MI_H */ diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 0b78897481d..d1bbd0c0145 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -124,8 +124,8 @@ handle_queued_pos_update(THD *thd, rpl_parallel_thread::queued_event *qev) else if (cmp == 0 && rli->group_master_log_pos < qev->future_event_master_log_pos) rli->group_master_log_pos= qev->future_event_master_log_pos; - mysql_mutex_unlock(&rli->data_lock); mysql_cond_broadcast(&rli->data_cond); + mysql_mutex_unlock(&rli->data_lock); } diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc index 91a4cb1f4fd..a239497c2c2 100644 --- a/sql/semisync_master.cc +++ b/sql/semisync_master.cc @@ -565,12 +565,14 @@ void Repl_semi_sync_master::remove_slave() { lock(); DBUG_ASSERT(rpl_semi_sync_master_clients > 0); - if (!(--rpl_semi_sync_master_clients) && !rpl_semi_sync_master_wait_no_slave) + if (!(--rpl_semi_sync_master_clients) && !rpl_semi_sync_master_wait_no_slave + && get_master_enabled()) { /* Signal transactions waiting in commit_trx() that they do not have to wait anymore. */ + DBUG_ASSERT(m_active_tranxs); m_active_tranxs->clear_active_tranx_nodes(NULL, 0, signal_waiting_transaction); } diff --git a/sql/semisync_slave.cc b/sql/semisync_slave.cc index d10754ad374..32e53dab758 100644 --- a/sql/semisync_slave.cc +++ b/sql/semisync_slave.cc @@ -141,7 +141,7 @@ void Repl_semi_sync_slave::slave_stop(Master_info *mi) DBUG_ASSERT(!debug_sync_set_action(mi->io_thd, STRING_WITH_LEN(act))); };); #endif - kill_connection(mi->mysql); + kill_connection(mi); } set_slave_enabled(0); @@ -158,8 +158,9 @@ void Repl_semi_sync_slave::slave_reconnect(Master_info *mi) } -void Repl_semi_sync_slave::kill_connection(MYSQL *mysql) +void Repl_semi_sync_slave::kill_connection(Master_info *mi) { + MYSQL *mysql= mi->mysql; if (!mysql) return; @@ -168,8 +169,8 @@ void Repl_semi_sync_slave::kill_connection(MYSQL *mysql) size_t kill_buffer_length; kill_mysql = mysql_init(kill_mysql); - mysql_options(kill_mysql, MYSQL_OPT_CONNECT_TIMEOUT, &m_kill_conn_timeout); - mysql_options(kill_mysql, MYSQL_OPT_READ_TIMEOUT, &m_kill_conn_timeout); + + setup_mysql_connection_for_master(kill_mysql, mi, m_kill_conn_timeout); mysql_options(kill_mysql, MYSQL_OPT_WRITE_TIMEOUT, &m_kill_conn_timeout); bool ret= (!mysql_real_connect(kill_mysql, mysql->host, diff --git a/sql/semisync_slave.h b/sql/semisync_slave.h index 6811584c9c8..79949067de8 100644 --- a/sql/semisync_slave.h +++ b/sql/semisync_slave.h @@ -92,7 +92,7 @@ public: void slave_stop(Master_info *mi); void slave_reconnect(Master_info *mi); int request_transmit(Master_info *mi); - void kill_connection(MYSQL *mysql); + void kill_connection(Master_info *mi); private: /* True when init_object has been called */ diff --git a/sql/slave.cc b/sql/slave.cc index 8b5797de935..25195f80862 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5978,9 +5978,9 @@ err_during_init: rli->relay_log.description_event_for_exec= 0; rli->reset_inuse_relaylog(); /* Wake up master_pos_wait() */ - mysql_mutex_unlock(&rli->data_lock); DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions")); mysql_cond_broadcast(&rli->data_cond); + mysql_mutex_unlock(&rli->data_lock); rli->ignore_log_space_limit= 0; /* don't need any lock */ /* we die so won't remember charset - re-update them on next thread start */ thd->system_thread_info.rpl_sql_info->cached_charset_invalidate(); @@ -7282,45 +7282,9 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, if (opt_slave_compressed_protocol) client_flag|= CLIENT_COMPRESS; /* We will use compression */ - mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &slave_net_timeout); - mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, &slave_net_timeout); + setup_mysql_connection_for_master(mi->mysql, mi, slave_net_timeout); mysql_options(mysql, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, &my_true); -#ifdef HAVE_OPENSSL - if (mi->ssl) - { - mysql_ssl_set(mysql, mi->ssl_key, mi->ssl_cert, mi->ssl_ca, mi->ssl_capath, - mi->ssl_cipher); - mysql_options(mysql, MYSQL_OPT_SSL_CRL, mi->ssl_crl); - mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, mi->ssl_crlpath); - mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, - &mi->ssl_verify_server_cert); - } - else -#endif - mysql->options.use_ssl= 0; - - /* - If server's default charset is not supported (like utf16, utf32) as client - charset, then set client charset to 'latin1' (default client charset). - */ - if (is_supported_parser_charset(default_charset_info)) - mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->cs_name.str); - else - { - sql_print_information("'%s' can not be used as client character set. " - "'%s' will be used as default client character set " - "while connecting to master.", - default_charset_info->cs_name.str, - default_client_charset_info->cs_name.str); - mysql_options(mysql, MYSQL_SET_CHARSET_NAME, - default_client_charset_info->cs_name.str); - } - - /* Set MYSQL_PLUGIN_DIR in case master asks for an external authentication plugin */ - if (opt_plugin_dir_ptr && *opt_plugin_dir_ptr) - mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr); - /* we disallow empty users */ if (mi->user[0] == 0) { diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0e41dea1324..9cef0b2478b 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -8437,19 +8437,13 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables, /* If sequence is used as part of NEXT VALUE, PREVIOUS VALUE or SELECT, - we need to modify the requested access rights depending on how the - sequence is used. + the privilege will be checked in ::fix_fields(). + Direct SELECT of a sequence table doesn't set t_ref->sequence, so + privileges will be checked normally, as for any table. */ if (t_ref->sequence && !(want_access & ~(SELECT_ACL | INSERT_ACL | UPDATE_ACL | DELETE_ACL))) - { - /* - We want to have either SELECT or INSERT rights to sequences depending - on how they are accessed - */ - orig_want_access= ((t_ref->lock_type >= TL_FIRST_WRITE) ? - INSERT_ACL : SELECT_ACL); - } + continue; const ACL_internal_table_access *access= get_cached_table_access(&t_ref->grant.m_internal, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3e5afe5ea89..ac064d66bfc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -19,6 +19,7 @@ #include "mariadb.h" #include "sql_base.h" // setup_table_map +#include "sql_list.h" #include "sql_priv.h" #include "unireg.h" #include "debug_sync.h" @@ -1181,7 +1182,6 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, t_name= &table->table_name; t_alias= &table->alias; -retry: DBUG_PRINT("info", ("real table: %s.%s", d_name->str, t_name->str)); for (TABLE_LIST *tl= table_list; tl ; tl= tl->next_global, res= 0) { @@ -1254,43 +1254,73 @@ retry: TABLE_LIST *derived= res->belong_to_derived; if (derived->is_merged_derived() && !derived->derived->is_excluded()) { - bool materialize= true; if (thd->lex->sql_command == SQLCOM_UPDATE) { Sql_cmd_update *cmd= (Sql_cmd_update *) (thd->lex->m_sql_cmd); - if (cmd->is_multitable() || derived->derived->outer_select()) - materialize= false; - else if (!cmd->processing_as_multitable_update_prohibited(thd)) + if (!(cmd->is_multitable() || derived->derived->outer_select()) && + (!cmd->processing_as_multitable_update_prohibited(thd))) { cmd->set_as_multitable(); - materialize= false; } } else if (thd->lex->sql_command == SQLCOM_DELETE) - { + { Sql_cmd_delete *cmd= (Sql_cmd_delete *) (thd->lex->m_sql_cmd); - if (cmd->is_multitable() || derived->derived->outer_select()) - materialize= false; - else if (!cmd->processing_as_multitable_delete_prohibited(thd)) + if (!(cmd->is_multitable() || derived->derived->outer_select()) && + (!cmd->processing_as_multitable_delete_prohibited(thd))) { cmd->set_as_multitable(); - materialize= false; } } - if (materialize) - { - DBUG_PRINT("info", - ("convert merged to materialization to resolve the conflict")); - derived->change_refs_to_fields(); - derived->set_materialized_derived(); - goto retry; - } } } DBUG_RETURN(res); } +TABLE_LIST* unique_table_in_select_list(THD *thd, TABLE_LIST *table, SELECT_LEX *sel) +{ + subselect_table_finder_param param= {thd, table, NULL}; + List_iterator_fast it(sel->item_list); + Item *item; + while ((item= it++)) + { + if (item->walk(&Item::subselect_table_finder_processor, FALSE, ¶m)) + { + if (param.dup == NULL) + return ERROR_TABLE; + return param.dup; + } + DBUG_ASSERT(param.dup == NULL); + } + return NULL; +} + + +typedef TABLE_LIST* (*find_table_callback)(THD *thd, TABLE_LIST *table, + TABLE_LIST *table_list, + uint check_flag, SELECT_LEX *sel); + +static +TABLE_LIST* +find_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, + uint check_flag, SELECT_LEX *sel, find_table_callback callback ); + +TABLE_LIST* unique_table_callback(THD *thd, TABLE_LIST *table, + TABLE_LIST *table_list, + uint check_flag, SELECT_LEX *sel) +{ + return find_dup_table(thd, table, table_list, check_flag); +} + + +TABLE_LIST* unique_in_sel_table_callback(THD *thd, TABLE_LIST *table, + TABLE_LIST *table_list, + uint check_flag, SELECT_LEX *sel) +{ + return unique_table_in_select_list(thd, table, sel); +} + /** Test that the subject table of INSERT/UPDATE/DELETE/CREATE or (in case of MyISAMMRG) one of its children are not used later @@ -1309,6 +1339,25 @@ retry: TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, uint check_flag) +{ + return find_table(thd, table, table_list, check_flag, NULL, + &unique_table_callback); +} + + +TABLE_LIST* +unique_table_in_insert_returning_subselect(THD *thd, TABLE_LIST *table, SELECT_LEX *sel) +{ + return find_table(thd, table, NULL, 0, sel, + &unique_in_sel_table_callback); + +} + + +static +TABLE_LIST* +find_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, + uint check_flag, SELECT_LEX *sel, find_table_callback callback ) { TABLE_LIST *dup; @@ -1340,12 +1389,12 @@ unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, if (!tmp_parent) break; - if ((dup= find_dup_table(thd, child, child->next_global, check_flag))) + if ((dup= (*callback)(thd, child, child->next_global, check_flag, sel))) break; } } else - dup= find_dup_table(thd, table, table_list, check_flag); + dup= (*callback)(thd, table, table_list, check_flag, sel); return dup; } @@ -7465,6 +7514,9 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2, if (!found) continue; // No matching field + /* Restore field_2 to point to the field which was a match for field_1. */ + field_2= nj_col_2->field(); + /* field_1 and field_2 have the same names. Check if they are in the USING clause (if present), mark them as common fields, and add a new @@ -8447,7 +8499,7 @@ bool setup_tables_and_check_access(THD *thd, Name_resolution_context *context, if (table_list->belong_to_view && !table_list->view && check_single_table_access(thd, access, table_list, FALSE)) { - tables->hide_view_error(thd); + tables->replace_view_error_with_generic(thd); DBUG_RETURN(TRUE); } access= want_access; @@ -8953,14 +9005,15 @@ static bool vers_update_or_validate_fields(TABLE *table) } -static void unwind_stored_field_offsets(const List &fields, Field *end) +static void unwind_stored_field_offsets(const List &fields, Item_field *end) { - for (Item &item_field: fields) + for (Item &item: fields) { - Field *f= item_field.field_for_view_update()->field; - if (f == end) + Item_field *item_field= item.field_for_view_update(); + if (item_field == end) break; + Field *f= item_field->field; if (f->stored_in_db()) { TABLE *table= f->table; @@ -9004,7 +9057,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, { List_iterator_fast f(fields),v(values); Item *value, *fld; - Item_field *field; + Item_field *field= NULL; Field *rfield; TABLE *table; bool only_unvers_fields= update && table_arg->versioned(); @@ -9022,11 +9075,8 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, while ((fld= f++)) { - if (!(field= fld->field_for_view_update())) - { - my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name.str); - goto err_unwind_fields; - } + field= fld->field_for_view_update(); + DBUG_ASSERT(field); // ensured by check_fields or check_view_insertability. value=v++; DBUG_ASSERT(value); rfield= field->field; @@ -9094,7 +9144,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, DBUG_RETURN(thd->is_error()); err_unwind_fields: if (update && thd->variables.sql_mode & MODE_SIMULTANEOUS_ASSIGNMENT) - unwind_stored_field_offsets(fields, rfield); + unwind_stored_field_offsets(fields, field); err: DBUG_PRINT("error",("got error")); thd->abort_on_warning= save_abort_on_warning; diff --git a/sql/sql_base.h b/sql/sql_base.h index 60a7238234f..ba2abdd33bc 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -300,6 +300,8 @@ bool open_tables_for_query(THD *thd, TABLE_LIST *tables, bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags); int decide_logging_format(THD *thd, TABLE_LIST *tables); void close_thread_table(THD *thd, TABLE **table_ptr); +TABLE_LIST* +unique_table_in_insert_returning_subselect(THD *thd, TABLE_LIST *table, SELECT_LEX *sel); TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, uint check_flag); bool is_equal(const LEX_CSTRING *a, const LEX_CSTRING *b); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index d19e7933beb..097170c17ac 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -3553,6 +3553,7 @@ Query_cache::insert_table(THD *thd, size_t key_len, const char *key, if (table_block == 0) { DBUG_PRINT("qcache", ("Can't write table name to cache")); + node->parent= NULL; DBUG_RETURN(0); } Query_cache_table *header= table_block->table(); @@ -3576,6 +3577,7 @@ Query_cache::insert_table(THD *thd, size_t key_len, const char *key, DBUG_PRINT("qcache", ("Can't insert table to hash")); // write_block_data return locked block free_memory_block(table_block); + node->parent= NULL; DBUG_RETURN(0); } char *db= header->db(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index fe3e19ddcd8..2e2f5ee13b8 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -57,6 +57,7 @@ */ #include "mariadb.h" /* NO_EMBEDDED_ACCESS_CHECKS */ +#include "sql_list.h" #include "sql_priv.h" #include "sql_insert.h" #include "sql_update.h" // compare_record @@ -728,6 +729,8 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, Name_resolution_context_state ctx_state; SELECT_LEX *returning= thd->lex->has_returning() ? thd->lex->returning() : 0; unsigned char *readbuff= NULL; + List insert_values_cache; + bool cache_insert_values= FALSE; #ifndef EMBEDDED_LIBRARY char *query= thd->query(); @@ -785,7 +788,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, if ((res= mysql_prepare_insert(thd, table_list, fields, values, update_fields, update_values, duplic, ignore, - &unused_conds, FALSE))) + &unused_conds, FALSE, &cache_insert_values))) { retval= thd->is_error(); if (res < 0) @@ -1033,8 +1036,41 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, if (returning) fix_rownum_pointers(thd, thd->lex->returning(), &info.accepted_rows); + if (cache_insert_values) + { + insert_values_cache.empty(); + while ((values= its++)) + { + List *caches= new (thd->mem_root) List_item; + List_iterator_fast iv(*values); + Item *item; + if (caches == 0) + { + error= 1; + goto values_loop_end; + } + caches->empty(); + while((item= iv++)) + { + Item_cache *cache= item->get_cache(thd); + if (!cache) + { + error= 1; + goto values_loop_end; + } + cache->setup(thd, item); + caches->push_back(cache); + } + insert_values_cache.push_back(caches); + } + its.rewind(); + } + do { + List_iterator_fast itc(insert_values_cache); + List_iterator_fast *itr; + DBUG_PRINT("info", ("iteration %llu", iteration)); if (iteration && bulk_parameters_set(thd)) { @@ -1042,7 +1078,24 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, goto values_loop_end; } - while ((values= its++)) + if (cache_insert_values) + { + List_item *caches; + while ((caches= itc++)) + { + List_iterator_fast ic(*caches); + Item_cache *cache; + while((cache= (Item_cache*) ic++)) + { + cache->cache_value(); + } + } + itc.rewind(); + itr= &itc; + } + else + itr= &its; + while ((values= (*itr)++)) { thd->get_stmt_da()->inc_current_row_for_warning(); if (fields.elements || !value_count) @@ -1142,7 +1195,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, break; info.accepted_rows++; } - its.rewind(); + itr->rewind(); iteration++; } while (bulk_parameters_iterations(thd)); @@ -1654,6 +1707,7 @@ static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables) table_list Global/local table list where Where clause (for insert ... select) select_insert TRUE if INSERT ... SELECT statement + cache_insert_values insert's VALUES(...) has to be pre-computed TODO (in far future) In cases of: @@ -1676,7 +1730,7 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, List &update_fields, List &update_values, enum_duplicates duplic, bool ignore, COND **where, - bool select_insert) + bool select_insert, bool * const cache_insert_values) { SELECT_LEX *select_lex= thd->lex->first_select_lex(); Name_resolution_context *context= &select_lex->context; @@ -1780,6 +1834,15 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, thd->vers_insert_history(row_start); // check privileges } + /* + Check if we read from the same table we're inserting into. + Queries like INSERT INTO t1 VALUES ((SELECT ... FROM t1...)) have + to pre-compute the VALUES part. + Reading from the same table in the RETURNING clause is not allowed. + + INSERT...SELECT detects this case in select_insert::prepare and also + uses buffering to handle it correcly. + */ if (!select_insert) { Item *fake_conds= 0; @@ -1787,10 +1850,30 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, if ((duplicate= unique_table(thd, table_list, table_list->next_global, CHECK_DUP_ALLOW_DIFFERENT_ALIAS))) { - update_non_unique_table_error(table_list, "INSERT", duplicate); - DBUG_RETURN(1); + /* + This is INSERT INTO ... VALUES (...) and it must pre-compute the + values to be inserted. + */ + (*cache_insert_values)= true; } + else + (*cache_insert_values)= false; + select_lex->fix_prepare_information(thd, &fake_conds, &fake_conds); + + if ((*cache_insert_values) && thd->lex->has_returning()) + { + // Check if the table we're inserting into is also in RETURNING clause + TABLE_LIST *dup= + unique_table_in_insert_returning_subselect(thd, table_list, + thd->lex->returning()); + if (dup) + { + if (dup != ERROR_TABLE) + update_non_unique_table_error(table_list, "INSERT", duplicate); + DBUG_RETURN(1); + } + } } /* Only call prepare_for_posistion() if we are not performing a DELAYED @@ -3927,6 +4010,7 @@ int mysql_insert_select_prepare(THD *thd, select_result *sel_res) int res; LEX *lex= thd->lex; SELECT_LEX *select_lex= lex->first_select_lex(); + bool cache_insert_values= false; DBUG_ENTER("mysql_insert_select_prepare"); /* @@ -3937,7 +4021,7 @@ int mysql_insert_select_prepare(THD *thd, select_result *sel_res) if ((res= mysql_prepare_insert(thd, lex->query_tables, lex->field_list, 0, lex->update_list, lex->value_list, lex->duplicates, lex->ignore, - &select_lex->where, TRUE))) + &select_lex->where, TRUE, &cache_insert_values))) DBUG_RETURN(res); /* @@ -4346,7 +4430,11 @@ bool select_insert::store_values(List &values) bool select_insert::prepare_eof() { int error; - bool const trans_table= table->file->has_transactions_and_rollback(); + // make sure any ROW format pending event is logged in the same binlog cache + bool const trans_table= (thd->is_current_stmt_binlog_format_row() && + table->file->row_logging) ? + table->file->row_logging_has_trans : + table->file->has_transactions_and_rollback(); bool changed; bool binary_logged= 0; killed_state killed_status= thd->killed; @@ -4525,7 +4613,7 @@ void select_insert::abort_result_set() table->file->ha_rnd_end(); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); - + table->file->extra(HA_EXTRA_ABORT_ALTER_COPY); /* If at least one row has been inserted/modified and will stay in the table (the table doesn't have transactions) we must write to @@ -4571,7 +4659,8 @@ void select_insert::abort_result_set() query_cache_invalidate3(thd, table, 1); } DBUG_ASSERT(transactional_table || !changed || - thd->transaction->stmt.modified_non_trans_table); + (thd->transaction->stmt.modified_non_trans_table || + thd->transaction->all.modified_non_trans_table)); table->s->table_creation_was_logged|= binary_logged; table->file->ha_release_auto_increment(); @@ -5264,9 +5353,14 @@ bool select_create::send_eof() /* Remember xid's for the case of row based logging */ ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid); ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid); - trans_commit_stmt(thd); - if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) - trans_commit_implicit(thd); + if (trans_commit_stmt(thd) || + (!(thd->variables.option_bits & OPTION_GTID_BEGIN) && + trans_commit_implicit(thd))) + { + abort_result_set(); + DBUG_RETURN(true); + } + thd->binlog_xid= 0; #ifdef WITH_WSREP @@ -5386,7 +5480,13 @@ void select_create::abort_result_set() /* possible error of writing binary log is ignored deliberately */ (void) thd->binlog_flush_pending_rows_event(TRUE, TRUE); + /* + In the error case, we remove any partially created table. So clear any + incident event generates due to cache error, as it no longer relevant. + */ + binlog_clear_incident(thd); + bool drop_table_was_logged= false; if (table) { bool tmp_table= table->s->tmp_table; @@ -5433,6 +5533,7 @@ void select_create::abort_result_set() create_info->db_type == partition_hton, &create_info->tabledef_version, tmp_table); + drop_table_was_logged= true; debug_crash_here("ddl_log_create_after_binlog"); thd->binlog_xid= 0; } @@ -5457,8 +5558,21 @@ void select_create::abort_result_set() if (create_info->table_was_deleted) { - /* Unlock locked table that was dropped by CREATE. */ - (void) trans_rollback_stmt(thd); + if (drop_table_was_logged) + { + /* for DROP binlogging the error status has to be canceled first */ + Diagnostics_area new_stmt_da(thd->query_id, false, true); + Diagnostics_area *old_stmt_da= thd->get_stmt_da(); + + thd->set_stmt_da(&new_stmt_da); + (void) trans_rollback_stmt(thd); + thd->set_stmt_da(old_stmt_da); + } + else + { + /* Unlock locked table that was dropped by CREATE. */ + (void) trans_rollback_stmt(thd); + } thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket); } diff --git a/sql/sql_insert.h b/sql/sql_insert.h index 2080761a0dc..176c861cfad 100644 --- a/sql/sql_insert.h +++ b/sql/sql_insert.h @@ -28,7 +28,7 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, List &update_fields, List &update_values, enum_duplicates duplic, bool ignore, - COND **where, bool select_insert); + COND **where, bool select_insert, bool * const cache_results); bool mysql_insert(THD *thd,TABLE_LIST *table,List &fields, List &values, List &update_fields, List &update_values, enum_duplicates flag, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 935fbdd2c4c..a0a66f01032 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -11293,7 +11293,8 @@ st_select_lex::build_pushable_cond_for_having_pushdown(THD *thd, Item *cond) Field_pair *get_corresponding_field_pair(Item *item, List pair_list) { - DBUG_ASSERT(item->type() == Item::FIELD_ITEM || + DBUG_ASSERT(item->type() == Item::DEFAULT_VALUE_ITEM || + item->type() == Item::FIELD_ITEM || (item->type() == Item::REF_ITEM && ((((Item_ref *) item)->ref_type() == Item_ref::VIEW_REF) || (((Item_ref *) item)->ref_type() == Item_ref::REF)))); @@ -12381,6 +12382,48 @@ bool SELECT_LEX_UNIT::explainable() const false; } +/** + Find the real table in prepared SELECT tree + + NOTE: all SELECT must be prepared (to have leaf table list). + + NOTE: it looks only for real tables (not view or derived) + + @param thd the current thread handle + @param db_name name of db of the table to look for + @param db_name name of db of the table to look for + + @return first found table, NULL or ERROR_TABLE +*/ + +TABLE_LIST *SELECT_LEX::find_table(THD *thd, + const LEX_CSTRING *db_name, + const LEX_CSTRING *table_name) +{ + uchar buff[STACK_BUFF_ALLOC]; // Max argument in function + if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) + return NULL; + + List_iterator_fast ti(leaf_tables); + TABLE_LIST *table; + while ((table= ti++)) + { + if (cmp(&table->db, db_name) == 0 && + cmp(&table->table_name, table_name) == 0) + return table; + } + + for (SELECT_LEX_UNIT *u= first_inner_unit(); u; u= u->next_unit()) + { + for (st_select_lex *sl= u->first_select(); sl; sl=sl->next_select()) + { + if ((table= sl->find_table(thd, db_name, table_name))) + return table; + } + } + return NULL; +} + bool st_select_lex::is_query_topmost(THD *thd) { diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 2979d976d8e..9e8b56ed243 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1693,6 +1693,10 @@ public: bool is_unit_nest() { return (nest_flags & UNIT_NEST_FL); } void mark_as_unit_nest() { nest_flags= UNIT_NEST_FL; } bool is_sj_conversion_prohibited(THD *thd); + + TABLE_LIST *find_table(THD *thd, + const LEX_CSTRING *db_name, + const LEX_CSTRING *table_name); }; typedef class st_select_lex SELECT_LEX; @@ -4750,7 +4754,7 @@ public: int add_period(Lex_ident name, Lex_ident_sys_st start, Lex_ident_sys_st end) { - if (check_period_name(name.str)) { + if (check_column_name(name)) { my_error(ER_WRONG_COLUMN_NAME, MYF(0), name.str); return 1; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 40980341c7c..175b1f4f027 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7029,18 +7029,9 @@ check_table_access(THD *thd, privilege_t requirements, TABLE_LIST *tables, DBUG_PRINT("info", ("derived: %d view: %d", table_ref->derived != 0, table_ref->view != 0)); - if (table_ref->is_anonymous_derived_table()) + if (table_ref->is_anonymous_derived_table() || table_ref->sequence) continue; - if (table_ref->sequence) - { - /* We want to have either SELECT or INSERT rights to sequences depending - on how they are accessed - */ - want_access= ((table_ref->lock_type >= TL_FIRST_WRITE) ? - INSERT_ACL : SELECT_ACL); - } - if (check_access(thd, want_access, table_ref->get_db_name().str, &table_ref->grant.privilege, &table_ref->grant.m_internal, @@ -10124,7 +10115,13 @@ bool check_string_char_length(const LEX_CSTRING *str, uint err_msg, bool check_ident_length(const LEX_CSTRING *ident) { - if (check_string_char_length(ident, 0, NAME_CHAR_LEN, system_charset_info, 1)) + /* + string_char_length desite the names, goes into Well_formed_prefix_status + so this is more than just a length comparison. Things like a primary key + doesn't have a name, therefore no length. Also the ident grammar allows + empty backtick. Check quickly the length, and if 0, accept that. + */ + if (ident->length && check_string_char_length(ident, 0, NAME_CHAR_LEN, system_charset_info, 1)) { my_error(ER_TOO_LONG_IDENT, MYF(0), ident->str); return 1; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 35f67b43a3d..40cce7e6b37 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1316,6 +1316,7 @@ static bool mysql_test_insert_common(Prepared_statement *stmt, THD *thd= stmt->thd; List_iterator_fast its(values_list); List_item *values; + bool cache_results= FALSE; DBUG_ENTER("mysql_test_insert_common"); if (insert_precheck(thd, table_list)) @@ -1348,7 +1349,8 @@ static bool mysql_test_insert_common(Prepared_statement *stmt, if (mysql_prepare_insert(thd, table_list, fields, values, update_fields, update_values, duplic, ignore, - &unused_conds, FALSE)) + &unused_conds, FALSE, + &cache_results)) goto error; value_count= values->elements; diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 8f602273fe7..cd6259b1936 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -622,7 +622,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) if (table_list->belong_to_view && check_single_table_access(thd, PRIV_LOCK_TABLES, table_list, FALSE)) { - table_list->hide_view_error(thd); + table_list->replace_view_error_with_generic(thd); goto error_reset_bits; } if (table_list->is_view_or_derived()) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c16f37eb93f..6f45048a27b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -23697,6 +23697,8 @@ do_select(JOIN *join, Procedure *procedure) */ clear_tables(join, &cleared_tables); } + if (join->tmp_table_param.copy_funcs.elements) + copy_fields(&join->tmp_table_param); if (!join->having || join->having->val_bool()) { List *columns_list= (procedure ? &join->procedure_fields_list : @@ -28415,9 +28417,13 @@ find_order_in_list(THD *thd, Ref_ptr_array ref_pointer_array, original field name, we should additionally check if we have conflict for this name (in case if we would perform lookup in all tables). */ - if (resolution == RESOLVED_BEHIND_ALIAS && - order_item->fix_fields_if_needed_for_order_by(thd, order->item)) - return TRUE; + if (resolution == RESOLVED_BEHIND_ALIAS) + { + if (order_item->fix_fields_if_needed_for_order_by(thd, order->item)) + return TRUE; + // fix_fields may have replaced order->item, reset local variable. + order_item= *order->item; + } /* Lookup the current GROUP field in the FROM clause. */ order_item_type= order_item->type(); @@ -31901,7 +31907,7 @@ void st_select_lex::print_item_list(THD *thd, String *str, */ if (top_level || item->is_explicit_name() || - !check_column_name(item->name.str)) + !check_column_name(item->name)) item->print_item_w_name(str, query_type); else item->print(str, query_type); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4c5e9de96da..0901421fdac 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4375,7 +4375,7 @@ bool get_lookup_field_values(THD *thd, COND *cond, bool fix_table_name_case, break; } - if (lower_case_table_names && !rc) + if (lower_case_table_names == 1 && !rc) { /* We can safely do in-place upgrades here since all of the above cases diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 49b541ec04f..1ef6e9fade4 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -3139,7 +3139,7 @@ read_statistics_for_table(THD *thd, TABLE *table, double avg_frequency= pk_read_stats->get_avg_frequency(j-1); set_if_smaller(avg_frequency, 1); double val= (pk_read_stats->get_avg_frequency(j) / - avg_frequency); + avg_frequency > 0 ? avg_frequency : 1); index_statistics->set_avg_frequency (l, val); } } diff --git a/sql/sql_string.h b/sql/sql_string.h index fadbbd37042..27e3bf8b8b3 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -909,6 +909,8 @@ public: :Charset(cs), Binary_string(str, len) { } String(const String &str) = default; + String(String &&str) noexcept + :Charset(std::move(str)), Binary_string(std::move(str)){} void set(String &str,size_t offset,size_t arg_length) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 632171ebea8..2bd9be12fb9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3106,7 +3106,7 @@ static bool mysql_prepare_create_table_stage1(THD *thd, DBUG_ASSERT(sql_field->charset); - if (check_column_name(sql_field->field_name.str)) + if (check_column_name(sql_field->field_name)) { my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name.str); DBUG_RETURN(TRUE); @@ -3744,7 +3744,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info, key_part_info++; } - if (!key_info->name.str || check_column_name(key_info->name.str)) + if (!key_info->name.str || check_column_name(key_info->name)) { my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name.str); DBUG_RETURN(TRUE); @@ -6234,7 +6234,7 @@ drop_create_field: } else if (drop->type == Alter_drop::PERIOD) { - if (table->s->period.name.streq(drop->name)) + if (table->s->period.name.streq(Lex_ident(drop->name))) remove_drop= FALSE; } else /* Alter_drop::KEY and Alter_drop::FOREIGN_KEY */ @@ -9226,7 +9226,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, for (bool found= false; !found && (drop= drop_it++); ) { found= drop->type == Alter_drop::PERIOD && - table->s->period.name.streq(drop->name); + table->s->period.name.streq(Lex_ident(drop->name)); } if (drop) @@ -9269,7 +9269,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } } - if (share->period.constr_name.streq(check->name.str)) + if (share->period.constr_name.streq(check->name)) { if (!drop_period && !keep) { @@ -12687,6 +12687,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, if (alt_error > 0) { error= alt_error; + to->file->extra(HA_EXTRA_ABORT_ALTER_COPY); copy_data_error_ignore(error, false, to, thd, alter_ctx); } } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 8e3b4a80e7a..35bdaaeba08 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1522,7 +1522,7 @@ static bool multi_update_check_table_access(THD *thd, TABLE_LIST *table, if (multi_update_check_table_access(thd, tbl, tables_for_update, &updated)) { - tbl->hide_view_error(thd); + tbl->replace_view_error_with_generic(thd); return true; } } @@ -2048,7 +2048,8 @@ multi_update::initialize_tables(JOIN *join) if (unlikely((thd->variables.option_bits & OPTION_SAFE_UPDATES) && error_if_full_join(join))) DBUG_RETURN(1); - if (join->implicit_grouping) + if (join->implicit_grouping || + join->select_lex->have_window_funcs()) { my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0)); DBUG_RETURN(1); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 58a6dbb42d7..40694b80da6 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -183,7 +183,7 @@ void make_valid_column_names(THD *thd, List &item_list) for (uint column_no= 1; (item= it++); column_no++) { - if (item->is_explicit_name() || !check_column_name(item->name.str)) + if (item->is_explicit_name() || !check_column_name(item->name)) continue; name_len= my_snprintf(buff, NAME_LEN, "Name_exp_%u", column_no); item->orig_name= item->name; @@ -341,7 +341,7 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view, { if (check_single_table_access(thd, SELECT_ACL, tbl, FALSE)) { - tbl->hide_view_error(thd); + tbl->replace_view_error_with_generic(thd); goto err; } } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d83cd8d2a41..ce47f6759a8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9254,7 +9254,7 @@ select_item: if ($4.str) { if (unlikely(Lex->sql_command == SQLCOM_CREATE_VIEW && - check_column_name($4.str))) + check_column_name($4))) my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), $4.str)); $2->base_flags|= item_base_t::IS_EXPLICIT_NAME; $2->set_name(thd, $4); diff --git a/sql/table.cc b/sql/table.cc index 6a60beea3da..513ac114e2e 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5388,9 +5388,10 @@ bool Lex_ident_fs::check_db_name_with_error() const } -bool check_column_name(const char *name) +bool check_column_name(const Lex_ident &ident) { // name length in symbols + const char *name= ident.str, *end= ident.str + ident.length; size_t name_length= 0; bool last_char_is_space= TRUE; @@ -5400,9 +5401,7 @@ bool check_column_name(const char *name) last_char_is_space= my_isspace(system_charset_info, *name); if (system_charset_info->use_mb()) { - int len=my_ismbchar(system_charset_info, name, - name+system_charset_info->mbmaxlen); - if (len) + if (int len= my_ismbchar(system_charset_info, name, end)) { name += len; name_length++; @@ -5422,12 +5421,6 @@ bool check_column_name(const char *name) } -bool check_period_name(const char *name) -{ - return check_column_name(name); -} - - /** Checks whether a table is intact. Should be done *just* after the table has been opened. @@ -6433,9 +6426,9 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type) @pre This method can be called only if there is an error. */ -void TABLE_LIST::hide_view_error(THD *thd) +void TABLE_LIST::replace_view_error_with_generic(THD *thd) { - if ((thd->killed && !thd->is_error())|| thd->get_internal_handler()) + if ((thd->killed && !thd->is_error()) || thd->get_internal_handler()) return; /* Hide "Unknown column" or "Unknown function" error */ DBUG_ASSERT(thd->is_error()); diff --git a/sql/table.h b/sql/table.h index efc0d37e3d3..f4a72b62247 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2269,7 +2269,7 @@ struct vers_select_conds_t void init(vers_system_time_t _type, Vers_history_point _start= Vers_history_point(), Vers_history_point _end= Vers_history_point(), - Lex_ident _name= "SYSTEM_TIME") + Lex_ident _name= { STRING_WITH_LEN("SYSTEM_TIME") }) { type= _type; orig_type= _type; @@ -2284,7 +2284,7 @@ struct vers_select_conds_t void set_all() { type= SYSTEM_TIME_ALL; - name= "SYSTEM_TIME"; + name= { STRING_WITH_LEN("SYSTEM_TIME") }; } void print(String *str, enum_query_type query_type) const; @@ -2655,7 +2655,7 @@ struct TABLE_LIST List *view_tables; /* most upper view this table belongs to */ TABLE_LIST *belong_to_view; - /* A derived table this table belongs to */ + /* A merged derived table this table belongs to */ TABLE_LIST *belong_to_derived; /* The view directly referencing this table @@ -2912,7 +2912,7 @@ struct TABLE_LIST bool check_single_table(TABLE_LIST **table, table_map map, TABLE_LIST *view); bool set_insert_values(MEM_ROOT *mem_root); - void hide_view_error(THD *thd); + void replace_view_error_with_generic(THD *thd); TABLE_LIST *find_underlying_table(TABLE *table); TABLE_LIST *first_leaf_for_name_resolution(); TABLE_LIST *last_leaf_for_name_resolution(); @@ -3160,6 +3160,8 @@ private: ulonglong m_table_ref_version; }; +#define ERROR_TABLE ((TABLE_LIST*) 0x1) + class Item; /* @@ -3468,9 +3470,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, void open_table_error(TABLE_SHARE *share, enum open_frm_error error, int db_errno); void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form); - -bool check_column_name(const char *name); -bool check_period_name(const char *name); +bool check_column_name(const Lex_ident &name); bool check_table_name(const char *name, size_t length, bool check_for_path_chars); int rename_file_ext(const char * from,const char * to,const char * ext); char *get_field(MEM_ROOT *mem, Field *field); diff --git a/sql/vers_string.h b/sql/vers_string.h index 93740ea8523..30e3c434e1a 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -59,7 +59,7 @@ public: { } Lex_cstring_with_compare(const LEX_CSTRING src) : Lex_cstring(src.str, src.length) { } - Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str)) + explicit Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str)) { } bool streq(const Lex_cstring_with_compare& b) const { diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index f64c500a011..f45a1aed14e 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -412,14 +412,16 @@ IF(NOT TARGET connect) RETURN() ENDIF() -IF(MSVC AND (CMAKE_CXX_FLAGS MATCHES "/MP")) +IF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # domdoc.cpp uses compiler directive #import which is not compatible # with the /MP option, resulting in compiler error C2813. # Remove /MP for this file. + GET_TARGET_PROPERTY(CURRENT_COMPILE_OPTIONS connect COMPILE_OPTIONS) + LIST(REMOVE_ITEM CURRENT_COMPILE_OPTIONS "$<$:/MP>") + SET_TARGET_PROPERTIES(connect PROPERTIES COMPILE_OPTIONS "${CURRENT_COMPILE_OPTIONS}") SET(src_list ${CONNECT_SOURCES}) LIST(FIND src_list domdoc.cpp idx) IF(idx GREATER -1) - STRING(REPLACE "/MP" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") LIST(REMOVE_AT src_list ${idx}) SET_SOURCE_FILES_PROPERTIES(${src_list} PROPERTIES COMPILE_FLAGS "/MP") ENDIF() diff --git a/storage/connect/plgxml.h b/storage/connect/plgxml.h index 82629e4c7db..6b49e6ac527 100644 --- a/storage/connect/plgxml.h +++ b/storage/connect/plgxml.h @@ -5,7 +5,7 @@ /******************************************************************/ /* Dual XML implementation base classes defines. */ /******************************************************************/ -#if !defined(BASE_BUFFER_SIZE) +#ifndef LIBXML2_SUPPORT enum ElementType { // libxml2 XML_ELEMENT_NODE = 1, XML_ATTRIBUTE_NODE = 2, @@ -28,7 +28,7 @@ enum ElementType { // libxml2 XML_XINCLUDE_START = 19, XML_XINCLUDE_END = 20, XML_DOCB_DOCUMENT_NODE = 21}; -#endif // !BASE_BUFFER_SIZE +#endif //#if !defined(NODE_TYPE_LIST) #ifdef NOT_USED diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index d5302759bc4..bc2ebb6e581 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -25,6 +25,9 @@ #include #include //#include +#ifdef LIBXML2_SUPPORT +#include +#endif #include "osutil.h" #define _O_RDONLY O_RDONLY #endif // !_WIN32 diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index b2b9faf0aca..51667bc6d24 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -1504,20 +1504,20 @@ static void fill_server(MEM_ROOT *mem_root, FEDERATEDX_SERVER *server, sizeof(int) + 8); key.append(scheme); key.q_append('\0'); - server->hostname= (const char *) (intptr) key.length(); + size_t hostname_pos= key.length(); key.append(hostname); key.q_append('\0'); - server->database= (const char *) (intptr) key.length(); + size_t database_pos= key.length(); key.append(database); key.q_append('\0'); key.q_append((uint32) share->port); - server->socket= (const char *) (intptr) key.length(); + size_t socket_pos= key.length(); key.append(socket); key.q_append('\0'); - server->username= (const char *) (intptr) key.length(); + size_t username_pos= key.length(); key.append(username); key.q_append('\0'); - server->password= (const char *) (intptr) key.length(); + size_t password_pos= key.length(); key.append(password); key.c_ptr_safe(); // Ensure we have end \0 @@ -1525,13 +1525,12 @@ static void fill_server(MEM_ROOT *mem_root, FEDERATEDX_SERVER *server, /* Copy and add end \0 */ server->key= (uchar *) strmake_root(mem_root, key.ptr(), key.length()); - /* pointer magic */ - server->scheme+= (intptr) server->key; - server->hostname+= (intptr) server->key; - server->database+= (intptr) server->key; - server->username+= (intptr) server->key; - server->password+= (intptr) server->key; - server->socket+= (intptr) server->key; + server->scheme= (const char *)server->key; + server->hostname= (const char *)server->key + hostname_pos; + server->database= (const char *)server->key + database_pos; + server->username= (const char *)server->key + username_pos; + server->password= (const char *)server->key + password_pos; + server->socket= (const char*)server->key + socket_pos; server->port= share->port; if (!share->socket) diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc index 9a7fbafa3e1..c97bba1c5c1 100644 --- a/storage/innobase/buf/buf0buddy.cc +++ b/storage/innobase/buf/buf0buddy.cc @@ -385,7 +385,7 @@ static void *buf_buddy_alloc_from(void *buf, ulint i) ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN)); ut_ad(i <= BUF_BUDDY_SIZES); ut_ad(!ut_align_offset(buf, srv_page_size)); - ut_ad(!buf_pool.contains_zip(buf, srv_page_size)); + ut_ad(!buf_pool.contains_zip(buf, srv_page_size_shift)); /* Add the unused parts of the block to the free lists. */ for (ulint j = BUF_BUDDY_SIZES, offs = srv_page_size; j-- > i; ) { diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 7d957758329..75afcc5a16c 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -557,16 +557,18 @@ buf_page_is_checksum_valid_crc32( } #ifndef UNIV_INNOCHECKSUM -/** Checks whether the lsn present in the page is lesser than the -peek current lsn. -@param check_lsn lsn to check +/** Check whether a page is newer than the durable LSN. +@param check_lsn whether to check the LSN @param read_buf page frame -@return whether the FIL_PAGE_LSN is invalid */ -static bool buf_page_check_lsn(bool check_lsn, const byte *read_buf) +@return whether the FIL_PAGE_LSN is invalid (ahead of the durable LSN) */ +static bool buf_page_check_lsn(bool check_lsn, const byte *read_buf) noexcept { if (!check_lsn) return false; - lsn_t current_lsn= log_sys.get_lsn(); + /* A page may not be read before it is written, and it may not be + written before the corresponding log has been durably written. + Hence, we refer to the current durable LSN here */ + lsn_t current_lsn= log_sys.get_flushed_lsn(std::memory_order_relaxed); if (UNIV_UNLIKELY(current_lsn == log_sys.FIRST_LSN) && srv_force_recovery == SRV_FORCE_NO_LOG_REDO) return false; @@ -1692,8 +1694,7 @@ ATTRIBUTE_COLD buf_pool_t::shrink_status buf_pool_t::shrink(size_t size) continue; } - if (UNIV_LIKELY_NULL(b->zip.data) && - will_be_withdrawn(b->zip.data, size)) + if (UNIV_UNLIKELY(will_be_withdrawn(b->zip.data, size))) { block= buf_buddy_shrink(b, block); ut_ad(mach_read_from_4(b->zip.data + FIL_PAGE_OFFSET) == id.page_no()); @@ -2654,8 +2655,8 @@ buf_page_get_gen( innodb_undo_tablespaces=127. */ ut_d(extern bool ibuf_upgrade_was_needed;) ut_ad(mode == BUF_GET_RECOVER - ? recv_recovery_is_on() || log_sys.get_lsn() < 120000 - || log_sys.get_lsn() == recv_sys.lsn + SIZE_OF_FILE_CHECKPOINT + ? recv_recovery_is_on() || log_get_lsn() < 120000 + || log_get_lsn() == recv_sys.lsn + SIZE_OF_FILE_CHECKPOINT || ibuf_upgrade_was_needed : !recv_recovery_is_on() || recv_sys.after_apply); ut_ad(mtr->is_active()); @@ -3017,7 +3018,6 @@ void buf_block_t::initialise(const page_id_t page_id, ulint zip_size, { ut_ad(!page.in_file()); buf_block_init_low(this); - page.lock.init(); page.init(fix, page_id); page.set_os_used(); page_zip_set_size(&page.zip, zip_size); diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 361b6732a23..310547cf518 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -366,7 +366,7 @@ void buf_dblwr_t::recover() noexcept ut_ad(log_sys.last_checkpoint_lsn); if (!is_created()) return; - const lsn_t max_lsn{log_sys.get_lsn()}; + const lsn_t max_lsn{log_sys.get_flushed_lsn(std::memory_order_relaxed)}; ut_ad(recv_sys.scanned_lsn == max_lsn); ut_ad(recv_sys.scanned_lsn >= recv_sys.lsn); @@ -627,7 +627,7 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) noexcept static_cast(srv_fatal_semaphore_wait_threshold); size_t log_count= first_log_count; - for (ulong count= 0;;) + for (size_t count= 0;;) { if (!active_slot->first_free) return false; @@ -785,6 +785,9 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request) ut_ad(lsn); ut_ad(lsn >= bpage->oldest_modification()); log_write_up_to(lsn, true); + ut_ad(!e.request.node->space->full_crc32() || + !buf_page_is_corrupted(true, static_cast(frame), + e.request.node->space->flags)); e.request.node->space->io(e.request, bpage->physical_offset(), e_size, frame, bpage); } diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 78591744fc2..78cb4aec0a1 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -694,7 +694,6 @@ not_compressed: { static_assert(FIL_PAGE_FCRC32_CHECKSUM == 4, "alignment"); mach_write_to_4(tmp + len - 4, my_crc32c(0, tmp, len - 4)); - ut_ad(!buf_page_is_corrupted(true, tmp, space->flags)); } d= tmp; @@ -854,6 +853,8 @@ bool buf_page_t::flush(fil_space_t *space) noexcept if (!space->is_temporary() && !space->is_being_imported() && lsn > log_sys.get_flushed_lsn()) log_write_up_to(lsn, true); + ut_ad(space->is_temporary() || !space->full_crc32() || + !buf_page_is_corrupted(true, write_frame, space->flags)); space->io(IORequest{type, this, slot}, physical_offset(), size, write_frame, this); } @@ -1209,6 +1210,21 @@ static void buf_flush_discard_page(buf_page_t *bpage) noexcept buf_LRU_free_page(bpage, true); } +/** Adjust to_withdraw during buf_pool_t::shrink() */ +ATTRIBUTE_COLD static size_t buf_flush_LRU_to_withdraw(size_t to_withdraw, + const buf_page_t &bpage) + noexcept +{ + mysql_mutex_assert_owner(&buf_pool.mutex); + if (!buf_pool.is_shrinking()) + return 0; + const size_t size{buf_pool.size_in_bytes_requested}; + if (buf_pool.will_be_withdrawn(bpage.frame, size) || + buf_pool.will_be_withdrawn(bpage.zip.data, size)) + to_withdraw--; + return to_withdraw; +} + /** Flush dirty blocks from the end buf_pool.LRU, and move clean blocks to buf_pool.free. @param max maximum number of blocks to flush @@ -1219,7 +1235,9 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n, { size_t scanned= 0; mysql_mutex_assert_owner(&buf_pool.mutex); - size_t free_limit{buf_pool.LRU_scan_depth + to_withdraw}; + size_t free_limit{buf_pool.LRU_scan_depth}; + if (UNIV_UNLIKELY(to_withdraw > free_limit)) + to_withdraw= free_limit; const auto neighbors= UT_LIST_GET_LEN(buf_pool.LRU) < BUF_LRU_OLD_MIN_LEN ? 0 : buf_pool.flush_neighbors; fil_space_t *space= nullptr; @@ -1229,7 +1247,7 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n, /* BUF_LRU_MIN_LEN (256) is too high value for low buffer pool(BP) size. For example, for BP size lower than 80M and 16 K page size, the limit is more than - 5% of total BP and for lowest BP 5M, it is 80% of the BP. Non-data objects + 5% of total BP and for lowest BP 6M, it is 80% of the BP. Non-data objects like explicit locks could occupy part of the BP pool reducing the pages available for LRU. If LRU reaches minimum limit and if no free pages are available, server would hang with page cleaner not able to free any more @@ -1243,6 +1261,7 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n, bpage && ((UT_LIST_GET_LEN(buf_pool.LRU) > buf_lru_min_len && UT_LIST_GET_LEN(buf_pool.free) < free_limit) || + to_withdraw || recv_recovery_is_on()); ++scanned, bpage= buf_pool.lru_hp.get()) { @@ -1258,6 +1277,8 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n, if (state != buf_page_t::FREED && (state >= buf_page_t::READ_FIX || (~buf_page_t::LRU_MASK & state))) continue; + if (UNIV_UNLIKELY(to_withdraw != 0)) + to_withdraw= buf_flush_LRU_to_withdraw(to_withdraw, *bpage); buf_LRU_free_page(bpage, true); ++n->evicted; if (UNIV_LIKELY(scanned & 31)) @@ -1329,23 +1350,32 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n, continue; } + if (state < buf_page_t::UNFIXED) + goto flush; + if (n->flushed >= max && !recv_recovery_is_on()) { bpage->lock.u_unlock(true); break; } - if (neighbors && space->is_rotational() && + if (neighbors && space->is_rotational() && UNIV_LIKELY(!to_withdraw) && /* Skip neighbourhood flush from LRU list if we haven't yet reached half of the free page target. */ UT_LIST_GET_LEN(buf_pool.free) * 2 >= free_limit) n->flushed+= buf_flush_try_neighbors(space, page_id, bpage, neighbors == 1, n->flushed, max); - else if (bpage->flush(space)) - ++n->flushed; else - continue; + { + flush: + if (UNIV_UNLIKELY(to_withdraw != 0)) + to_withdraw= buf_flush_LRU_to_withdraw(to_withdraw, *bpage); + if (bpage->flush(space)) + ++n->flushed; + else + continue; + } goto reacquire_mutex; } @@ -1743,7 +1773,7 @@ static ulint buf_flush_LRU(ulint max_n) noexcept pthread_cond_broadcast(&buf_pool.done_free); } else if (!pages && !buf_pool.try_LRU_scan) - /* For example, with the minimum innodb_buffer_pool_size=5M and + /* For example, with the minimum innodb_buffer_pool_size=6M 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 @@ -1771,8 +1801,9 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept { ut_ad(!srv_read_only_mode); ut_ad(end_lsn >= next_checkpoint_lsn); - ut_ad(end_lsn <= get_lsn()); - ut_ad(end_lsn + SIZE_OF_FILE_CHECKPOINT <= get_lsn() || + ut_d(const lsn_t current_lsn{get_lsn()}); + ut_ad(end_lsn <= current_lsn); + ut_ad(end_lsn + SIZE_OF_FILE_CHECKPOINT <= current_lsn || srv_shutdown_state > SRV_SHUTDOWN_INITIATED); DBUG_PRINT("ib_log", @@ -1901,7 +1932,8 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept ut_ad(!is_opened()); my_munmap(buf, file_size); buf= resize_buf; - set_buf_free(START_OFFSET + (get_lsn() - resizing)); + buf_size= unsigned(std::min(resize_target - START_OFFSET, + buf_size_max)); } else #endif @@ -2030,9 +2062,9 @@ static bool log_checkpoint() noexcept } /** Make a checkpoint. */ -ATTRIBUTE_COLD void log_make_checkpoint() +ATTRIBUTE_COLD void log_make_checkpoint() noexcept { - buf_flush_wait_flushed(log_sys.get_lsn(std::memory_order_acquire)); + buf_flush_wait_flushed(log_get_lsn()); while (!log_checkpoint()); } @@ -2040,8 +2072,6 @@ ATTRIBUTE_COLD void log_make_checkpoint() NOTE: The calling thread is not allowed to hold any buffer page latches! */ static void buf_flush_wait(lsn_t lsn) noexcept { - ut_ad(lsn <= log_sys.get_lsn()); - lsn_t oldest_lsn; while ((oldest_lsn= buf_pool.get_oldest_modification(lsn)) < lsn) @@ -2243,13 +2273,13 @@ static void buf_flush_sync_for_checkpoint(lsn_t lsn) noexcept mysql_mutex_unlock(&buf_pool.flush_list_mutex); } -/** Check if the adpative flushing threshold is recommended based on +/** Check if the adaptive flushing threshold is recommended based on redo log capacity filled threshold. @param oldest_lsn buf_pool.get_oldest_modification() @return true if adaptive flushing is recommended. */ static bool af_needed_for_redo(lsn_t oldest_lsn) noexcept { - lsn_t age= (log_sys.get_lsn() - oldest_lsn); + lsn_t age= log_sys.get_lsn_approx() - oldest_lsn; lsn_t af_lwm= static_cast(srv_adaptive_flushing_lwm * static_cast(log_sys.log_capacity) / 100); @@ -2309,7 +2339,7 @@ static ulint page_cleaner_flush_pages_recommendation(ulint last_pages_in, lsn_t lsn_rate; ulint n_pages = 0; - const lsn_t cur_lsn = log_sys.get_lsn(); + const lsn_t cur_lsn = log_sys.get_lsn_approx(); ut_ad(oldest_lsn <= cur_lsn); ulint pct_for_lsn = af_get_pct_for_lsn(cur_lsn - oldest_lsn); time_t curr_time = time(nullptr); @@ -2781,7 +2811,7 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool() noexcept NOTE: The calling thread is not allowed to hold any buffer page latches! */ void buf_flush_sync_batch(lsn_t lsn) noexcept { - lsn= std::max(lsn, log_sys.get_lsn()); + lsn= std::max(lsn, log_get_lsn()); mysql_mutex_lock(&buf_pool.flush_list_mutex); buf_flush_wait(lsn); mysql_mutex_unlock(&buf_pool.flush_list_mutex); @@ -2800,20 +2830,26 @@ void buf_flush_sync() noexcept thd_wait_begin(nullptr, THD_WAIT_DISKIO); tpool::tpool_wait_begin(); - mysql_mutex_lock(&buf_pool.flush_list_mutex); - for (;;) + log_sys.latch.wr_lock(SRW_LOCK_CALL); + + for (lsn_t lsn= log_sys.get_lsn();;) { - const lsn_t lsn= log_sys.get_lsn(); + log_sys.latch.wr_unlock(); + mysql_mutex_lock(&buf_pool.flush_list_mutex); buf_flush_wait(lsn); /* Wait for the page cleaner to be idle (for log resizing at startup) */ while (buf_flush_sync_lsn) my_cond_wait(&buf_pool.done_flush_list, &buf_pool.flush_list_mutex.m_mutex); - if (lsn == log_sys.get_lsn()) + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + log_sys.latch.wr_lock(SRW_LOCK_CALL); + lsn_t new_lsn= log_sys.get_lsn(); + if (lsn == new_lsn) break; + lsn= new_lsn; } - mysql_mutex_unlock(&buf_pool.flush_list_mutex); + log_sys.latch.wr_unlock(); tpool::tpool_wait_end(); thd_wait_end(nullptr); } @@ -2833,7 +2869,7 @@ ATTRIBUTE_COLD void buf_pool_t::print_flush_info() const noexcept "-------------------", lru_size, free_size, dirty_size, dirty_pct); - lsn_t lsn= log_sys.get_lsn(); + lsn_t lsn= log_get_lsn(); lsn_t clsn= log_sys.last_checkpoint_lsn; sql_print_information("InnoDB: LSN flush parameters\n" "-------------------\n" diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 22121ea27dc..e1f379e5abf 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -738,6 +738,8 @@ lookup: dict_sys.freeze(SRW_LOCK_CALL); goto return_without_mdl; } + else + goto return_without_mdl; if (*mdl) { diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 070a07f128f..a9fe4a657c6 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -2496,10 +2496,12 @@ corrupted: if (!table->is_readable()) { /* Don't attempt to load the indexes from disk. */ } else if (err == DB_SUCCESS) { + auto i = fk_tables.size(); err = dict_load_foreigns(table->name.m_name, nullptr, 0, true, ignore_err, fk_tables); if (err != DB_SUCCESS) { + fk_tables.erase(fk_tables.begin() + i, fk_tables.end()); ib::warn() << "Load table " << table->name << " failed, the table has missing" " foreign key indexes. Turn off" diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index cb08721a86e..fa132e27cca 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -153,11 +153,6 @@ void close_thread_tables(THD* thd); #include "wsrep_sst.h" #endif /* WITH_WSREP */ -#ifdef HAVE_URING -/** The Linux kernel version if io_uring() is considered unsafe */ -const char *io_uring_may_be_unsafe; -#endif - #define INSIDE_HA_INNOBASE_CC #define EQ_CURRENT_THD(thd) ((thd) == current_thd) @@ -243,11 +238,11 @@ static void innodb_max_purge_lag_wait_update(THD *thd, st_mysql_sys_var *, if (thd_kill_level(thd)) break; /* Adjust for purge_coordinator_state::refresh() */ - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); const lsn_t last= log_sys.last_checkpoint_lsn, max_age= log_sys.max_checkpoint_age; - log_sys.latch.rd_unlock(); const lsn_t lsn= log_sys.get_lsn(); + log_sys.latch.wr_unlock(); if ((lsn - last) / 4 >= max_age / 5) buf_flush_ahead(last + max_age / 5, false); purge_sys.wake_if_not_active(); @@ -1128,7 +1123,7 @@ innobase_rollback_to_savepoint_can_release_mdl( be rolled back to savepoint */ /** Request notification of log writes */ -static void innodb_log_flush_request(void *cookie); +static void innodb_log_flush_request(void *cookie) noexcept; /** Requests for log flushes */ struct log_flush_request @@ -3620,7 +3615,7 @@ ha_innobase::init_table_handle_for_HANDLER(void) m_prebuilt->used_in_HANDLER = TRUE; reset_template(); - m_prebuilt->trx->bulk_insert = false; + m_prebuilt->trx->bulk_insert &= TRX_DDL_BULK; } /*********************************************************************//** @@ -4044,13 +4039,6 @@ skip_buffering_tweak: cases, we ignore the setting of innodb_use_native_aio. */ srv_use_native_aio= FALSE; #endif -#ifdef HAVE_URING - if (srv_use_native_aio && io_uring_may_be_unsafe) - sql_print_warning("innodb_use_native_aio may cause " - "hangs with this kernel %s; see " - "https://jira.mariadb.org/browse/MDEV-26674", - io_uring_may_be_unsafe); -#endif srv_lock_table_size= 5 * buf_pool.curr_size(); DBUG_RETURN(0); @@ -4485,7 +4473,7 @@ static bool end_of_statement(trx_t *trx) noexcept undo_no_t savept= 0; trx->rollback(&savept); /* MariaDB will roll back the entire transaction. */ - trx->bulk_insert= false; + trx->bulk_insert&= TRX_DDL_BULK; trx->last_stmt_start= 0; return true; } @@ -4733,11 +4721,13 @@ void log_flush_notify(lsn_t flush_lsn) We put the request in a queue, so that we can notify upper layer about checkpoint complete when we have flushed the redo log. If we have already flushed all relevant redo log, we notify immediately.*/ -static void innodb_log_flush_request(void *cookie) +static void innodb_log_flush_request(void *cookie) noexcept { + log_sys.latch.wr_lock(SRW_LOCK_CALL); lsn_t flush_lsn= log_sys.get_flushed_lsn(); /* Load lsn relaxed after flush_lsn was loaded from the same cache line */ const lsn_t lsn= log_sys.get_lsn(); + log_sys.latch.wr_unlock(); if (flush_lsn >= lsn) /* All log is already persistent. */; @@ -14937,13 +14927,13 @@ stats_fetch: ulint stat_clustered_index_size; ulint stat_sum_of_other_index_sizes; - ut_ad(ib_table->stat_initialized()); - #if !defined NO_ELISION && !defined SUX_LOCK_GENERIC if (xbegin()) { if (ib_table->stats_mutex_is_locked()) xabort(); + ut_ad(ib_table->stat_initialized()); + n_rows = ib_table->stat_n_rows; stat_clustered_index_size @@ -14958,6 +14948,8 @@ stats_fetch: { ib_table->stats_shared_lock(); + ut_ad(ib_table->stat_initialized()); + n_rows = ib_table->stat_n_rows; stat_clustered_index_size @@ -15866,7 +15858,7 @@ ha_innobase::extra( stmt_boundary: trx->bulk_insert_apply(); trx->end_bulk_insert(*m_prebuilt->table); - trx->bulk_insert = false; + trx->bulk_insert &= TRX_DDL_BULK; break; case HA_EXTRA_NO_KEYREAD: (void)check_trx_exists(ha_thd()); @@ -15932,7 +15924,7 @@ ha_innobase::extra( break; } m_prebuilt->table->skip_alter_undo = 0; - if (dberr_t err= trx->bulk_insert_apply()) { + if (dberr_t err= trx->bulk_insert_apply()) { m_prebuilt->table->skip_alter_undo = 0; return convert_error_code_to_mysql( err, m_prebuilt->table->flags, @@ -15940,7 +15932,7 @@ ha_innobase::extra( } trx->end_bulk_insert(*m_prebuilt->table); - trx->bulk_insert = false; + trx->bulk_insert &= TRX_DML_BULK; if (!m_prebuilt->table->is_temporary() && !high_level_read_only) { /* During copy_data_between_tables(), InnoDB only @@ -15959,6 +15951,13 @@ ha_innobase::extra( log_buffer_flush_to_disk(); } break; + case HA_EXTRA_ABORT_ALTER_COPY: + if (m_prebuilt->table->skip_alter_undo) { + trx = check_trx_exists(ha_thd()); + m_prebuilt->table->skip_alter_undo = 0; + trx->rollback(); + } + break; default:/* Do nothing */ ; } @@ -16053,7 +16052,8 @@ ha_innobase::start_stmt( break; } - trx->bulk_insert = false; + ut_ad(trx->bulk_insert != TRX_DDL_BULK); + trx->bulk_insert = TRX_NO_BULK; trx->last_stmt_start = trx->undo_no; } @@ -16261,7 +16261,7 @@ ha_innobase::external_lock( if (!trx->bulk_insert) { break; } - trx->bulk_insert = false; + trx->bulk_insert &= TRX_DDL_BULK; trx->last_stmt_start = trx->undo_no; } @@ -18413,11 +18413,16 @@ checkpoint_now_set(THD* thd, st_mysql_sys_var*, void*, const void *save) const auto size= log_sys.is_encrypted() ? SIZE_OF_FILE_CHECKPOINT + 8 : SIZE_OF_FILE_CHECKPOINT; mysql_mutex_unlock(&LOCK_global_system_variables); - lsn_t lsn; - while (!thd_kill_level(thd) && - log_sys.last_checkpoint_lsn.load(std::memory_order_acquire) + size < - (lsn= log_sys.get_lsn(std::memory_order_acquire))) + while (!thd_kill_level(thd)) + { + log_sys.latch.wr_lock(SRW_LOCK_CALL); + lsn_t cp= log_sys.last_checkpoint_lsn.load(std::memory_order_relaxed), + lsn= log_sys.get_lsn(); + log_sys.latch.wr_unlock(); + if (cp + size >= lsn) + break; log_make_checkpoint(); + } mysql_mutex_lock(&LOCK_global_system_variables); } @@ -18668,35 +18673,23 @@ static void innodb_log_file_size_update(THD *thd, st_mysql_sys_var*, mysql_mutex_unlock(&buf_pool.flush_list_mutex); if (!resizing || !log_sys.resize_running(thd)) break; - if (resizing > log_sys.get_lsn()) + log_sys.latch.wr_lock(SRW_LOCK_CALL); + while (resizing > log_sys.get_lsn()) { ut_ad(!log_sys.is_mmap()); /* The server is almost idle. Write dummy FILE_CHECKPOINT records to ensure that the log resizing will complete. */ - log_sys.latch.wr_lock(SRW_LOCK_CALL); - while (resizing > log_sys.get_lsn()) - { - mtr_t mtr; - mtr.start(); - mtr.commit_files(log_sys.last_checkpoint_lsn); - } - log_sys.latch.wr_unlock(); + mtr_t mtr; + mtr.start(); + mtr.commit_files(log_sys.last_checkpoint_lsn); } + log_sys.latch.wr_unlock(); } } } mysql_mutex_lock(&LOCK_global_system_variables); } -static void innodb_log_spin_wait_delay_update(THD *, st_mysql_sys_var*, - void *, const void *save) -{ - log_sys.latch.wr_lock(SRW_LOCK_CALL); - mtr_t::spin_wait_delay= *static_cast(save); - mtr_t::finisher_update(); - log_sys.latch.wr_unlock(); -} - /** Update innodb_status_output or innodb_status_output_locks, which control InnoDB "status monitor" output to the error log. @param[out] var current value @@ -19533,11 +19526,12 @@ static MYSQL_SYSVAR_ULONGLONG(log_file_size, srv_log_file_size, nullptr, innodb_log_file_size_update, 96 << 20, 4 << 20, std::numeric_limits::max(), 4096); -static MYSQL_SYSVAR_UINT(log_spin_wait_delay, mtr_t::spin_wait_delay, - PLUGIN_VAR_OPCMDARG, - "Delay between log buffer spin lock polls (0 to use a blocking latch)", - nullptr, innodb_log_spin_wait_delay_update, - 0, 0, 6000, 0); +static uint innodb_log_spin_wait_delay; + +static MYSQL_SYSVAR_UINT(log_spin_wait_delay, innodb_log_spin_wait_delay, + PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_DEPRECATED, + "Deprecated parameter with no effect", + nullptr, nullptr, 0, 0, 6000, 0); static MYSQL_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct, PLUGIN_VAR_RQCMDARG, @@ -19642,37 +19636,10 @@ static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode, AUTOINC_OLD_STYLE_LOCKING, /* Minimum value */ AUTOINC_NO_LOCKING, 0); /* Maximum value */ -#ifdef HAVE_URING -# include -static utsname uname_for_io_uring; -#else -static -#endif -bool innodb_use_native_aio_default() -{ -#ifdef HAVE_URING - utsname &u= uname_for_io_uring; - if (!uname(&u) && u.release[0] == '5' && u.release[1] == '.' && - u.release[2] == '1' && u.release[3] >= '1' && u.release[3] <= '5' && - u.release[4] == '.') - { - if (u.release[3] == '5') { - const char *s= strstr(u.version, "5.15."); - if (s || (s= strstr(u.release, "5.15."))) - if ((s[5] >= '3' || s[6] >= '0')) - return true; /* 5.15.3 and later should be fine */ - } - io_uring_may_be_unsafe= u.release; - return false; /* working around io_uring hangs (MDEV-26674) */ - } -#endif - return true; -} - static MYSQL_SYSVAR_BOOL(use_native_aio, srv_use_native_aio, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Use native AIO if supported on this platform.", - NULL, NULL, innodb_use_native_aio_default()); + NULL, NULL, TRUE); #ifdef HAVE_LIBNUMA static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave, diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 479c3647214..c8bcf1d9652 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -621,6 +621,16 @@ inline bool dict_table_t::instant_column(const dict_table_t& table, } dict_index_t* index = dict_table_get_first_index(this); + if (instant) { + instant->field_map= static_cast( + mem_heap_dup(heap, instant->field_map, + (index->n_fields - + index->first_user_field()) * + sizeof *instant->field_map)); + instant= static_cast( + mem_heap_dup(heap, instant, sizeof *instant)); + } + bool metadata_changed; { const dict_index_t& i = *dict_table_get_first_index(&table); @@ -5531,6 +5541,12 @@ static bool innodb_insert_sys_columns( return false; } + DBUG_EXECUTE_IF("instant_insert_fail", + my_error(ER_INTERNAL_ERROR, MYF(0), + "InnoDB: Insert into SYS_COLUMNS failed"); + mem_heap_free(info->heap); + return true;); + if (DB_SUCCESS != que_eval_sql( info, "PROCEDURE ADD_COL () IS\n" diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index f8b7056e7d2..3e9230da79b 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1228,7 +1228,7 @@ public: bool will_be_withdrawn(const byte *ptr, size_t size) const noexcept { const char *p= reinterpret_cast(ptr); - ut_ad(p >= memory); + ut_ad(!p || p >= memory); ut_ad(p < memory + size_in_bytes_max); return p >= memory + size; } diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 4e0744b2207..d05b89329ab 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -319,7 +319,7 @@ struct fil_space_t final /** fil_system.spaces chain node */ fil_space_t *hash= nullptr; /** log_sys.get_lsn() of the most recent fil_names_write_if_was_clean(). - Reset to 0 by fil_names_clear(). Protected by log_sys.mutex. + Reset to 0 by fil_names_clear(). Protected by log_sys.latch_have_wr(). If and only if this is nonzero, the tablespace will be in named_spaces. */ lsn_t max_lsn= 0; /** base node for the chain of data files; multiple entries are @@ -390,7 +390,7 @@ private: bool being_imported= false; /** Whether any corrupton of this tablespace has been reported */ - mutable std::atomic_flag is_corrupted{false}; + mutable std::atomic_flag is_corrupted= ATOMIC_FLAG_INIT; public: /** mutex to protect freed_ranges and last_freed_lsn */ @@ -1536,7 +1536,10 @@ extern fil_system_t fil_system; inline void fil_space_t::reacquire() noexcept { - ut_d(uint32_t n=) n_pending.fetch_add(1, std::memory_order_relaxed); +#ifdef SAFE_MUTEX + uint32_t n= +#endif + n_pending.fetch_add(1, std::memory_order_relaxed); #ifdef SAFE_MUTEX if (mysql_mutex_is_owner(&fil_system.mutex)) return; ut_ad(n & PENDING); diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 6a6d722f135..ce6a4f27794 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -64,20 +64,19 @@ void log_write_up_to(lsn_t lsn, bool durable, /** Write to the log file up to the last log entry. @param durable whether to wait for a durable write to complete */ -void log_buffer_flush_to_disk(bool durable= true); - +void log_buffer_flush_to_disk(bool durable= true) noexcept; /** Prepare to invoke log_write_and_flush(), before acquiring log_sys.latch. */ -ATTRIBUTE_COLD void log_write_and_flush_prepare(); +ATTRIBUTE_COLD void log_write_and_flush_prepare() noexcept; /** Durably write the log up to log_sys.get_lsn(). */ -ATTRIBUTE_COLD void log_write_and_flush(); +ATTRIBUTE_COLD void log_write_and_flush() noexcept; /** Make a checkpoint */ -ATTRIBUTE_COLD void log_make_checkpoint(); +ATTRIBUTE_COLD void log_make_checkpoint() noexcept; /** Make a checkpoint at the latest lsn on shutdown. */ -ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown(); +ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown() noexcept; /******************************************************//** Prints info of the log. */ @@ -167,40 +166,35 @@ struct log_t static constexpr lsn_t FIRST_LSN= START_OFFSET; private: - /** the lock bit in buf_free */ - static constexpr size_t buf_free_LOCK= ~(~size_t{0} >> 1); + /** the least significant bit of the write_to_buf buffer */ + static constexpr size_t WRITE_TO_BUF_SHIFT{34}; + /** write_lsn_offset component for incrementing write_to_buf */ + static constexpr uint64_t WRITE_TO_BUF{1ULL << WRITE_TO_BUF_SHIFT}; + /** write_lsn_offset flag to indicate that append_prepare_wait() is active */ + static constexpr uint64_t WRITE_BACKOFF{1ULL << 33}; + + /** The current log sequence number, relative to base_lsn, and flags; + may be modified while latch_have_any() */ alignas(CPU_LEVEL1_DCACHE_LINESIZE) - /** first free offset within buf used; - the most significant bit is set by lock_lsn() to protect this field - as well as write_to_buf, waits */ - std::atomic buf_free; -public: - /** number of write requests (to buf); protected by lock_lsn() or lsn_lock */ - size_t write_to_buf; - /** log record buffer, written to by mtr_t::commit() */ - byte *buf; -private: - /** The log sequence number of the last change of durable InnoDB files; - protected by lock_lsn() or lsn_lock or latch.wr_lock() */ - std::atomic lsn; + Atomic_relaxed write_lsn_offset; + /** the LSN of the last write_buf() or persist(); protected by latch */ + std::atomic base_lsn; /** the first guaranteed-durable log sequence number */ std::atomic flushed_to_disk_lsn; public: - /** number of append_prepare_wait(); protected by lock_lsn() or lsn_lock */ - size_t waits; - /** innodb_log_buffer_size (size of buf,flush_buf if !is_mmap(), in bytes) */ + /** innodb_log_buffer_size (usable append_prepare() size in bytes) */ unsigned buf_size; /** log file size in bytes, including the header */ lsn_t file_size; #ifdef LOG_LATCH_DEBUG typedef srw_lock_debug log_rwlock; - typedef srw_mutex log_lsn_lock; bool latch_have_wr() const { return latch.have_wr(); } bool latch_have_rd() const { return latch.have_rd(); } bool latch_have_any() const { return latch.have_any(); } #else + typedef srw_lock log_rwlock; # ifndef UNIV_DEBUG # elif defined SUX_LOCK_GENERIC bool latch_have_wr() const { return true; } @@ -211,23 +205,23 @@ public: bool latch_have_rd() const { return latch.is_locked(); } bool latch_have_any() const { return latch.is_locked(); } # endif -# ifdef __aarch64__ - /* On ARM, we spin more */ - typedef srw_spin_lock log_rwlock; - typedef pthread_mutex_wrapper log_lsn_lock; -# else - typedef srw_lock log_rwlock; - typedef srw_mutex log_lsn_lock; -# endif #endif - /** exclusive latch for checkpoint, shared for mtr_t::commit() to buf */ - alignas(CPU_LEVEL1_DCACHE_LINESIZE) log_rwlock latch; + /** latch_have_wr() for checkpoint, latch_have_any() for append_prepare() */ + log_rwlock latch; + + /** log record buffer, written to by mtr_t::commit() */ + alignas(CPU_LEVEL1_DCACHE_LINESIZE) byte *buf; + + /** number of write requests to buf, + excluding (write_lsn_offset & WRITE_TO_BUF); + protected by latch.wr_lock() */ + size_t write_to_buf; /** number of writes from buf or flush_buf to log; protected by latch.wr_lock() */ - ulint write_to_log; + size_t write_to_log; - /** Last written LSN */ + /** Last written LSN; protected by latch */ lsn_t write_lsn; /** Buffer for writing data to ib_logfile0, or nullptr if is_mmap(). @@ -241,8 +235,6 @@ public: Atomic_relaxed checkpoint_pending; /** next checkpoint number (protected by latch.wr_lock()) */ byte next_checkpoint_no; - /** recommended maximum buf_free size, after which the buffer is flushed */ - unsigned max_buf_free; /** Log sequence number when a log file overwrite (broken crash recovery) was noticed. Protected by latch.wr_lock(). */ lsn_t overwrite_warned; @@ -266,12 +258,6 @@ private: /** Buffer for writing to resize_log; @see flush_buf */ byte *resize_flush_buf; - /** Special implementation of lock_lsn() for IA-32 and AMD64 */ - void lsn_lock_bts() noexcept; - /** Acquire a lock for updating buf_free and related fields. - @return the value of buf_free */ - size_t lock_lsn() noexcept; - /** log sequence number when log resizing was initiated; 0 if the log is not being resized, 1 if resize_start() is in progress */ std::atomic resize_lsn; @@ -330,34 +316,24 @@ public: private: /** the thread that initiated resize_lsn() */ Atomic_relaxed resize_initiator; - /** A lock when the spin-only lock_lsn() is not being used */ - log_lsn_lock lsn_lock; +#ifdef HAVE_PMEM + /** mutex protecting wrap-around in resize_write() */ + srw_mutex resize_wrap_mutex; +#endif public: + /** number of long append_prepare_wait(); protected by latch_have_wr() */ + size_t waits; - bool is_initialised() const noexcept { return max_buf_free != 0; } - - /** whether there is capacity in the log buffer */ - bool buf_free_ok() const noexcept - { - ut_ad(!is_mmap()); - return (buf_free.load(std::memory_order_relaxed) & ~buf_free_LOCK) < - max_buf_free; - } - + bool is_initialised() const noexcept + { return base_lsn.load(std::memory_order_relaxed) != 0; } inline void set_recovered() noexcept; - void set_buf_free(size_t f) noexcept - { ut_ad(f < buf_free_LOCK); buf_free.store(f, std::memory_order_relaxed); } - bool is_mmap() const noexcept { return !flush_buf; } /** @return whether a handle to the log is open; is_mmap() && !is_opened() holds for PMEM */ bool is_opened() const noexcept { return log.is_opened(); } - /** @return target write LSN to react on !buf_free_ok() */ - inline lsn_t get_write_target() const; - /** @return LSN at which log resizing was started and is still in progress @retval 0 if no log resizing is in progress @retval 1 if resize_start() is in progress */ @@ -410,55 +386,66 @@ public: { return resize_buf + resize_target; } /** Initialise the redo log subsystem. */ - void create(); + void create() noexcept; /** Attach a log file. @return whether the memory allocation succeeded */ - bool attach(log_file_t file, os_offset_t size); + bool attach(log_file_t file, os_offset_t size) noexcept; /** Disable memory-mapped access (update log_mmap) */ - void clear_mmap(); - void close_file(bool really_close= true); + void clear_mmap() noexcept; + void close_file(bool really_close= true) noexcept; #if defined __linux__ || defined _WIN32 /** Try to enable or disable file system caching (update log_buffered) */ - void set_buffered(bool buffered); + void set_buffered(bool buffered) noexcept; #endif /** Try to enable or disable durable writes (update log_write_through) */ void set_write_through(bool write_through); /** Calculate the checkpoint safety margins. */ - static void set_capacity(); + static void set_capacity() noexcept; /** Write a log file header. @param buf log header buffer @param lsn log sequence number corresponding to log_sys.START_OFFSET @param encrypted whether the log is encrypted */ - static void header_write(byte *buf, lsn_t lsn, bool encrypted); + static void header_write(byte *buf, lsn_t lsn, bool encrypted) noexcept; - lsn_t get_lsn(std::memory_order order= std::memory_order_relaxed) const - { return lsn.load(order); } + /** @return a lower bound estimate of get_lsn(), + using acquire-release ordering with write_buf() or persist(); + this is exact unless append_prepare_wait() is pending */ + lsn_t get_lsn_approx() const noexcept + { + /* acquire-release ordering with write_buf() and persist() */ + lsn_t lsn= base_lsn.load(std::memory_order_acquire); + lsn += write_lsn_offset.load(std::memory_order_relaxed) & + (WRITE_BACKOFF - 1); + return lsn; + } + + /** @return the current log sequence number (logical time stamp) */ + lsn_t get_lsn() const noexcept + { + ut_ad(latch_have_wr()); + return base_lsn.load(std::memory_order_relaxed) + + (write_lsn_offset & (WRITE_BACKOFF - 1)); + } lsn_t get_flushed_lsn(std::memory_order order= std::memory_order_acquire) const noexcept { return flushed_to_disk_lsn.load(order); } /** Initialize the LSN on initial log file creation. */ - lsn_t init_lsn() noexcept - { - latch.wr_lock(SRW_LOCK_CALL); - const lsn_t lsn{get_lsn()}; - flushed_to_disk_lsn.store(lsn, std::memory_order_relaxed); - write_lsn= lsn; - latch.wr_unlock(); - return lsn; - } + inline lsn_t init_lsn() noexcept; void set_recovered_lsn(lsn_t lsn) noexcept { ut_ad(latch_have_wr()); - write_lsn= lsn; - this->lsn.store(lsn, std::memory_order_relaxed); + uint64_t lsn_offset= ((write_size - 1) & (lsn - first_lsn)); + write_lsn_offset= lsn_offset; + base_lsn.store(lsn - lsn_offset, std::memory_order_relaxed); flushed_to_disk_lsn.store(lsn, std::memory_order_relaxed); + write_lsn= lsn; } #ifdef HAVE_PMEM @@ -496,22 +483,16 @@ private: void writer_update(bool resizing) noexcept; /** Wait in append_prepare() for buffer to become available - @tparam spin whether to use the spin-only lock_lsn() - @param b the value of buf_free - @param ex whether log_sys.latch is exclusively locked - @param lsn log sequence number to write up to - @return the new value of buf_free */ - template - ATTRIBUTE_COLD size_t append_prepare_wait(size_t b, bool ex, lsn_t lsn) - noexcept; + @param late whether the WRITE_BACKOFF flag had already been set + @param ex whether log_sys.latch is exclusively locked */ + ATTRIBUTE_COLD void append_prepare_wait(bool late, bool ex) noexcept; public: /** Reserve space in the log buffer for appending data. - @tparam spin whether to use the spin-only lock_lsn() @tparam mmap log_sys.is_mmap() @param size total length of the data to append(), in bytes @param ex whether log_sys.latch is exclusively locked @return the start LSN and the buffer position for append() */ - template + template std::pair append_prepare(size_t size, bool ex) noexcept; /** Append a string of bytes to the redo log. @@ -582,7 +563,10 @@ extern log_t log_sys; /** Wait for a log checkpoint if needed. NOTE that this function may only be called while not holding any synchronization objects except dict_sys.latch. */ -void log_free_check(); +void log_free_check() noexcept; + +/** @return the current log sequence number (may be stale) */ +lsn_t log_get_lsn() noexcept; /** Release the latches that protect log resizing. */ -void log_resize_release(); +void log_resize_release() noexcept; diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 4ca431711e8..ad0410093a8 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -691,19 +691,19 @@ private: @param mtr mini-transaction @param lsns {start_lsn,flush_ahead} */ template - static void commit_log(mtr_t *mtr, std::pair lsns); + static void commit_log(mtr_t *mtr, std::pair lsns) + noexcept; /** Append the redo log records to the redo log buffer. @return {start_lsn,flush_ahead} */ std::pair do_write(); /** Append the redo log records to the redo log buffer. - @tparam spin whether to use the spin-only log_sys.lock_lsn() @tparam mmap log_sys.is_mmap() @param mtr mini-transaction @param len number of bytes to write @return {start_lsn,flush_ahead} */ - template static + template static std::pair finish_writer(mtr_t *mtr, size_t len); /** The applicable variant of commit_log() */ @@ -714,9 +714,6 @@ private: std::pair finish_write(size_t len) { return finisher(this, len); } public: - /** Poll interval in log_sys.lock_lsn(); 0 to use log_sys.lsn_lock. - Protected by LOCK_global_system_variables and log_sys.latch. */ - static unsigned spin_wait_delay; /** Update finisher when spin_wait_delay is changing to or from 0. */ static void finisher_update(); private: diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 889437aa1d2..8f1a6388daa 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -809,9 +809,13 @@ public: /** normally set; "SET unique_checks=0, foreign_key_checks=0" enables bulk insert into an empty table */ unsigned check_unique_secondary:1; - - /** whether an insert into an empty table is active */ - unsigned bulk_insert:1; + /** whether an insert into an empty table is active + Possible states are + TRX_NO_BULK + TRX_DML_BULK + TRX_DDL_BULK + @see trx_bulk_insert in trx0types.h */ + unsigned bulk_insert:2; /*------------------------------*/ /* MySQL has a transaction coordinator to coordinate two phase commit between multiple storage engines and the binary log. When @@ -1118,6 +1122,7 @@ public: ut_ad(!is_not_inheriting_locks()); ut_ad(check_foreigns); ut_ad(check_unique_secondary); + ut_ad(bulk_insert == TRX_NO_BULK); } /** This has to be invoked on SAVEPOINT or at the end of a statement. @@ -1143,6 +1148,8 @@ public: rollback to the start of a statement will work. */ void end_bulk_insert() { + if (bulk_insert == TRX_DDL_BULK) + return; for (auto& t : mod_tables) t.second.end_bulk_insert(); } @@ -1150,7 +1157,15 @@ public: /** @return whether a bulk insert into empty table is in progress */ bool is_bulk_insert() const { - if (!bulk_insert || check_unique_secondary || check_foreigns) + switch (bulk_insert) { + case TRX_NO_BULK: + return false; + case TRX_DDL_BULK: + return true; + default: + ut_ad(bulk_insert == TRX_DML_BULK); + } + if (check_unique_secondary || check_foreigns) return false; for (const auto& t : mod_tables) if (t.second.is_bulk_insert()) @@ -1180,9 +1195,11 @@ public: /** Do the bulk insert for the buffered insert operation for the transaction. @return DB_SUCCESS or error code */ + template dberr_t bulk_insert_apply() { - return UNIV_UNLIKELY(bulk_insert) ? bulk_insert_apply_low(): DB_SUCCESS; + static_assert(type != TRX_NO_BULK, ""); + return bulk_insert == type ? bulk_insert_apply_low(): DB_SUCCESS; } private: diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h index ecb8ecc023b..2da83a226d0 100644 --- a/storage/innobase/include/trx0types.h +++ b/storage/innobase/include/trx0types.h @@ -65,6 +65,15 @@ enum trx_state_t { TRX_STATE_COMMITTED_IN_MEMORY }; +/** Transaction bulk insert operation @see trx_t::bulk_insert */ +enum trx_bulk_insert { + TRX_NO_BULK, + /** bulk insert is being executed during DML */ + TRX_DML_BULK, + /** bulk insert is being executed in copy_data_between_tables() */ + TRX_DDL_BULK +}; + /** Memory objects */ /* @{ */ /** Transaction */ diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index 3ff5f8853e0..398dd0dcc9e 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -277,7 +277,6 @@ public: #ifdef UNIV_PFS_MEMORY /** Default constructor. */ - explicit ut_allocator(PSI_memory_key key = PSI_NOT_INSTRUMENTED) : m_key(key) { diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index ea6c9a909db..33c8bf3bb16 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -6277,17 +6277,10 @@ lock_clust_rec_modify_check_and_lock( for it */ trx_t *trx = thr_get_trx(thr); - if (const trx_t *owner = - lock_rec_convert_impl_to_expl(trx, *block, - rec, index, offsets)) { - if (owner == trx) { - /* We already hold an exclusive lock. */ - return DB_SUCCESS; - } - - if (trx->snapshot_isolation && trx->read_view.is_open()) { - return DB_RECORD_CHANGED; - } + if (lock_rec_convert_impl_to_expl(trx, *block, + rec, index, offsets) == trx) { + /* We already hold an exclusive lock. */ + return DB_SUCCESS; } err = lock_rec_lock(true, LOCK_X | LOCK_REC_NOT_GAP, @@ -6449,19 +6442,11 @@ lock_sec_rec_read_check_and_lock( return DB_SUCCESS; } - if (page_rec_is_supremum(rec)) { - } else if (const trx_t *owner = - lock_rec_convert_impl_to_expl(trx, *block, - rec, index, offsets)) { - if (owner == trx) { - if (gap_mode == LOCK_REC_NOT_GAP) { - /* We already hold an exclusive lock. */ - return DB_SUCCESS; - } - } else if (trx->snapshot_isolation - && trx->read_view.is_open()) { - return DB_RECORD_CHANGED; - } + if (!page_rec_is_supremum(rec) + && lock_rec_convert_impl_to_expl(trx, *block, rec, index, + offsets) == trx + && gap_mode == LOCK_REC_NOT_GAP) { + return DB_SUCCESS; } #ifdef WITH_WSREP @@ -6541,28 +6526,24 @@ lock_clust_rec_read_check_and_lock( trx_t *trx = thr_get_trx(thr); if (lock_table_has(trx, index->table, LOCK_X) || heap_no == PAGE_HEAP_NO_SUPREMUM) { - } else if (const trx_t *owner = - lock_rec_convert_impl_to_expl(trx, *block, - rec, index, offsets)) { - if (owner == trx) { - if (gap_mode == LOCK_REC_NOT_GAP) { - /* We already hold an exclusive lock. */ - return DB_SUCCESS; - } - } else if (trx->snapshot_isolation - && trx->read_view.is_open()) { - return DB_RECORD_CHANGED; - } + } else if (lock_rec_convert_impl_to_expl(trx, *block, rec, index, + offsets) == trx + && gap_mode == LOCK_REC_NOT_GAP) { + /* We already hold an exclusive lock. */ + return DB_SUCCESS; } if (heap_no > PAGE_HEAP_NO_SUPREMUM && gap_mode != LOCK_GAP && trx->snapshot_isolation - && trx->read_view.is_open() - && !trx->read_view.changes_visible( - trx_read_trx_id(rec + row_trx_id_offset(rec, index))) - && IF_WSREP(!(trx->is_wsrep() + && trx->read_view.is_open()) { + trx_id_t trx_id= trx_read_trx_id(rec + + row_trx_id_offset(rec, index)); + if (!trx_sys.is_registered(trx, trx_id) + && !trx->read_view.changes_visible(trx_id) + && IF_WSREP(!(trx->is_wsrep() && wsrep_thd_skip_locking(trx->mysql_thd)), true)) { - return DB_RECORD_CHANGED; + return DB_RECORD_CHANGED; + } } dberr_t err = lock_rec_lock(false, gap_mode | mode, @@ -7333,10 +7314,6 @@ and less modified rows. Bit 0 is used to prefer orig_trx in case of a tie. victim->lock.was_chosen_as_deadlock_victim= true; DEBUG_SYNC_C("deadlock_report_before_lock_releasing"); lock_cancel_waiting_and_release(victim->lock.wait_lock); -#ifdef WITH_WSREP - if (victim->is_wsrep() && wsrep_thd_is_SR(victim->mysql_thd)) - wsrep_handle_SR_rollback(trx->mysql_thd, victim->mysql_thd); -#endif } func_exit: diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc index fc7a5180797..42591e39baa 100644 --- a/storage/innobase/log/log0crypt.cc +++ b/storage/innobase/log/log0crypt.cc @@ -566,7 +566,7 @@ ATTRIBUTE_NOINLINE void mtr_t::encrypt() alignas(8) byte iv[MY_AES_BLOCK_SIZE]; - m_commit_lsn= log_sys.get_lsn(); + m_commit_lsn= log_sys.get_flushed_lsn(); ut_ad(m_commit_lsn); byte *tmp= static_cast(alloca(srv_page_size)), *t= tmp; byte *dst= static_cast(alloca(srv_page_size)); diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 6ff2da60916..0d13ef035f6 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -67,7 +67,7 @@ log_t log_sys; #define LOG_BUF_FLUSH_MARGIN ((4 * 4096) /* cf. log_t::append_prepare() */ \ + (4U << srv_page_size_shift)) -void log_t::set_capacity() +void log_t::set_capacity() noexcept { ut_ad(log_sys.latch_have_wr()); /* Margin for the free space in the smallest log, before a new query @@ -86,13 +86,15 @@ void log_t::set_capacity() log_sys.max_checkpoint_age = margin; } -void log_t::create() +void log_t::create() noexcept { ut_ad(this == &log_sys); ut_ad(!is_initialised()); + latch.SRW_LOCK_INIT(log_latch_key); + write_lsn_offset= 0; /* LSN 0 and 1 are reserved; @see buf_page_t::oldest_modification_ */ - lsn.store(FIRST_LSN, std::memory_order_relaxed); + base_lsn.store(FIRST_LSN, std::memory_order_relaxed); flushed_to_disk_lsn.store(FIRST_LSN, std::memory_order_relaxed); need_checkpoint.store(true, std::memory_order_relaxed); write_lsn= FIRST_LSN; @@ -101,10 +103,10 @@ void log_t::create() ut_ad(!buf); ut_ad(!flush_buf); ut_ad(!writer); - max_buf_free= 1; - latch.SRW_LOCK_INIT(log_latch_key); - lsn_lock.init(); +#ifdef HAVE_PMEM + resize_wrap_mutex.init(); +#endif last_checkpoint_lsn= FIRST_LSN; log_capacity= 0; @@ -113,8 +115,6 @@ void log_t::create() next_checkpoint_lsn= 0; checkpoint_pending= false; - set_buf_free(0); - ut_ad(is_initialised()); } @@ -305,7 +305,7 @@ remap: #if defined __linux__ || defined _WIN32 /** Display a message about opening the log */ -ATTRIBUTE_COLD static void log_file_message() +ATTRIBUTE_COLD static void log_file_message() noexcept { sql_print_information("InnoDB: %s (block size=%u bytes)", log_sys.log_mmap @@ -319,10 +319,10 @@ ATTRIBUTE_COLD static void log_file_message() log_sys.write_size); } #else -static inline void log_file_message() {} +static inline void log_file_message() noexcept {} #endif -bool log_t::attach(log_file_t file, os_offset_t size) +bool log_t::attach(log_file_t file, os_offset_t size) noexcept { log= file; ut_ad(!size || size >= START_OFFSET + SIZE_OF_FILE_CHECKPOINT); @@ -351,7 +351,6 @@ bool log_t::attach(log_file_t file, os_offset_t size) } # endif buf= static_cast(ptr); - max_buf_free= 1; writer_update(false); # ifdef HAVE_PMEM if (is_pmem) @@ -365,7 +364,7 @@ bool log_t::attach(log_file_t file, os_offset_t size) if (!buf) { alloc_fail: - max_buf_free= 0; + base_lsn.store(0, std::memory_order_relaxed); sql_print_error("InnoDB: Cannot allocate memory;" " too large innodb_log_buffer_size?"); return false; @@ -393,7 +392,6 @@ bool log_t::attach(log_file_t file, os_offset_t size) TRASH_ALLOC(buf, buf_size); TRASH_ALLOC(flush_buf, buf_size); - max_buf_free= buf_size / LOG_BUF_FLUSH_RATIO - LOG_BUF_FLUSH_MARGIN; writer_update(false); memset_aligned<512>(checkpoint_buf, 0, write_size); @@ -406,7 +404,7 @@ bool log_t::attach(log_file_t file, os_offset_t size) @param buf log header buffer @param lsn log sequence number corresponding to log_sys.START_OFFSET @param encrypted whether the log is encrypted */ -void log_t::header_write(byte *buf, lsn_t lsn, bool encrypted) +void log_t::header_write(byte *buf, lsn_t lsn, bool encrypted) noexcept { mach_write_to_4(my_assume_aligned<4>(buf) + LOG_HEADER_FORMAT, log_sys.FORMAT_10_8); @@ -435,8 +433,9 @@ void log_t::create(lsn_t lsn) noexcept ut_ad(is_latest()); ut_ad(this == &log_sys); - this->lsn.store(lsn, std::memory_order_relaxed); - this->flushed_to_disk_lsn.store(lsn, std::memory_order_relaxed); + write_lsn_offset= 0; + base_lsn.store(lsn, std::memory_order_relaxed); + flushed_to_disk_lsn.store(lsn, std::memory_order_relaxed); first_lsn= lsn; write_lsn= lsn; @@ -451,14 +450,13 @@ void log_t::create(lsn_t lsn) noexcept mprotect(buf, size_t(file_size), PROT_READ | PROT_WRITE); memset_aligned<4096>(buf, 0, 4096); log_sys.header_write(buf, lsn, is_encrypted()); - set_buf_free(START_OFFSET); pmem_persist(buf, 512); + buf_size= unsigned(std::min(capacity(), buf_size_max)); } else #endif { ut_ad(!is_mmap()); - set_buf_free(0); memset_aligned<4096>(flush_buf, 0, buf_size); memset_aligned<4096>(buf, 0, buf_size); log_sys.header_write(buf, lsn, is_encrypted()); @@ -467,12 +465,12 @@ void log_t::create(lsn_t lsn) noexcept } } -ATTRIBUTE_COLD static void log_close_failed(dberr_t err) +ATTRIBUTE_COLD static void log_close_failed(dberr_t err) noexcept { ib::fatal() << "closing ib_logfile0 failed: " << err; } -void log_t::close_file(bool really_close) +void log_t::close_file(bool really_close) noexcept { if (is_mmap()) { @@ -507,16 +505,25 @@ void log_t::close_file(bool really_close) log_close_failed(err); } +/** @return the current log sequence number (may be stale) */ +lsn_t log_get_lsn() noexcept +{ + log_sys.latch.wr_lock(SRW_LOCK_CALL); + lsn_t lsn= log_sys.get_lsn(); + log_sys.latch.wr_unlock(); + return lsn; +} + /** Acquire all latches that protect the log. */ -static void log_resize_acquire() +static void log_resize_acquire() noexcept { #ifdef HAVE_PMEM if (!log_sys.is_mmap()) #endif { - while (flush_lock.acquire(log_sys.get_lsn() + 1, nullptr) != + while (flush_lock.acquire(log_get_lsn() + 1, nullptr) != group_commit_lock::ACQUIRED); - while (write_lock.acquire(log_sys.get_lsn() + 1, nullptr) != + while (write_lock.acquire(log_get_lsn() + 1, nullptr) != group_commit_lock::ACQUIRED); } @@ -524,7 +531,7 @@ static void log_resize_acquire() } /** Release the latches that protect the log. */ -void log_resize_release() +void log_resize_release() noexcept { log_sys.latch.wr_unlock(); @@ -541,7 +548,7 @@ void log_resize_release() #if defined __linux__ || defined _WIN32 /** Try to enable or disable file system caching (update log_buffered) */ -void log_t::set_buffered(bool buffered) +void log_t::set_buffered(bool buffered) noexcept { if (!log_maybe_unbuffered || #ifdef HAVE_PMEM @@ -911,9 +918,7 @@ void log_t::persist(lsn_t lsn) noexcept ut_ad(!is_opened()); ut_ad(!write_lock.is_owner()); ut_ad(!flush_lock.is_owner()); -#ifdef LOG_LATCH_DEBUG - ut_ad(latch_have_any()); -#endif + ut_ad(latch_have_wr()); lsn_t old= flushed_to_disk_lsn.load(std::memory_order_relaxed); @@ -931,26 +936,26 @@ void log_t::persist(lsn_t lsn) noexcept else pmem_persist(buf + start, end - start); - old= flushed_to_disk_lsn.load(std::memory_order_relaxed); - - if (old < lsn) - { - while (!flushed_to_disk_lsn.compare_exchange_weak - (old, lsn, std::memory_order_release, std::memory_order_relaxed)) - if (old >= lsn) - break; - - log_flush_notify(lsn); - DBUG_EXECUTE_IF("crash_after_log_write_upto", DBUG_SUICIDE();); - } + uint64_t offset{write_lsn_offset}; + const lsn_t new_base_lsn= base_lsn.load(std::memory_order_relaxed) + + (offset & (WRITE_BACKOFF - 1)); + ut_ad(new_base_lsn >= lsn); + write_to_buf+= size_t(offset >> WRITE_TO_BUF_SHIFT); + /* This synchronizes with get_lsn_approx(); + we must store write_lsn_offset before base_lsn. */ + write_lsn_offset.store(0, std::memory_order_relaxed); + base_lsn.store(new_base_lsn, std::memory_order_release); + flushed_to_disk_lsn.store(lsn, std::memory_order_relaxed); + log_flush_notify(lsn); + DBUG_EXECUTE_IF("crash_after_log_write_upto", DBUG_SUICIDE();); } ATTRIBUTE_NOINLINE static void log_write_persist(lsn_t lsn) noexcept { - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); log_sys.persist(lsn); - log_sys.latch.rd_unlock(); + log_sys.latch.wr_unlock(); } #endif @@ -1001,7 +1006,7 @@ lsn_t log_t::write_buf() noexcept ut_ad(resizing == RETAIN_LATCH || (resizing == RESIZING) == (resize_in_progress() > 1)); - const lsn_t lsn{get_lsn(std::memory_order_relaxed)}; + const lsn_t lsn{get_lsn()}; if (write_lsn >= lsn) { @@ -1017,7 +1022,8 @@ lsn_t log_t::write_buf() noexcept ut_ad(write_lsn >= get_flushed_lsn()); const size_t write_size_1{write_size - 1}; ut_ad(ut_is_2pow(write_size)); - size_t length{buf_free.load(std::memory_order_relaxed)}; + lsn_t base= base_lsn.load(std::memory_order_relaxed); + size_t length{size_t(lsn - base)}; lsn_t offset{calc_lsn_offset(write_lsn)}; ut_ad(length >= (offset & write_size_1)); ut_ad(write_size_1 >= 511); @@ -1039,14 +1045,8 @@ lsn_t log_t::write_buf() noexcept { ut_ad(!((length ^ (size_t(lsn) - size_t(first_lsn))) & write_size_1)); /* Keep filling the same buffer until we have more than one block. */ -#if 0 /* TODO: Pad the last log block with dummy records. */ - buf_free= log_pad(lsn, (write_size_1 + 1) - length, - buf + length, flush_buf); - ... /* TODO: Update the LSN and adjust other code. */ -#else MEM_MAKE_DEFINED(buf + length, (write_size_1 + 1) - length); buf[length]= 0; /* ensure that recovery catches EOF */ -#endif if (UNIV_LIKELY_NULL(re_write_buf)) { MEM_MAKE_DEFINED(re_write_buf + length, (write_size_1 + 1) - length); @@ -1057,8 +1057,13 @@ lsn_t log_t::write_buf() noexcept else { const size_t new_buf_free{length & write_size_1}; + base+= length & ~write_size_1; ut_ad(new_buf_free == ((lsn - first_lsn) & write_size_1)); - buf_free.store(new_buf_free, std::memory_order_relaxed); + write_to_buf+= size_t(write_lsn_offset >> WRITE_TO_BUF_SHIFT); + /* This synchronizes with get_lsn_approx(); + we must store write_lsn_offset before base_lsn. */ + write_lsn_offset.store(new_buf_free, std::memory_order_relaxed); + base_lsn.store(base, std::memory_order_release); if (new_buf_free) { @@ -1087,7 +1092,9 @@ lsn_t log_t::write_buf() noexcept std::swap(resize_buf, resize_flush_buf); } + ut_ad(base + (write_lsn_offset & (WRITE_TO_BUF - 1)) == lsn); write_to_log++; + if (resizing != RETAIN_LATCH) latch.wr_unlock(); @@ -1131,7 +1138,7 @@ bool log_t::flush(lsn_t lsn) noexcept @retval 0 if there are no pending callbacks on flush_lock or there is another group commit lead. */ -static lsn_t log_flush(lsn_t lsn) +static lsn_t log_flush(lsn_t lsn) noexcept { ut_ad(!log_sys.is_mmap()); ut_a(log_sys.flush(lsn)); @@ -1150,11 +1157,9 @@ wait and check if an already running write is covering the request. void log_write_up_to(lsn_t lsn, bool durable, const completion_callback *callback) noexcept { - ut_ad(!srv_read_only_mode || log_sys.buf_free_ok()); + ut_ad(!srv_read_only_mode); ut_ad(lsn != LSN_MAX); ut_ad(lsn != 0); - ut_ad(lsn <= log_sys.get_lsn()); - #ifdef HAVE_PMEM if (log_sys.is_mmap()) { @@ -1173,10 +1178,10 @@ repeat: if (flush_lock.acquire(lsn, callback) != group_commit_lock::ACQUIRED) return; /* Promise to other concurrent flush_lock.acquire() that we - will durable at least up to the current LSN. The LSN may still - advance until we acquire log_sys.latch below. */ - lsn= log_sys.get_lsn(); - flush_lock.set_pending(lsn); + will be durable at least up to the current LSN. The LSN may still + advance when we acquire log_sys.latch below. */ + if (lsn > log_sys.get_flushed_lsn()) + flush_lock.set_pending(lsn); } lsn_t pending_write_lsn= 0, pending_flush_lsn= 0; @@ -1223,33 +1228,40 @@ void log_t::writer_update(bool resizing) noexcept /** Write to the log file up to the last log entry. @param durable whether to wait for a durable write to complete */ -void log_buffer_flush_to_disk(bool durable) +void log_buffer_flush_to_disk(bool durable) noexcept { - log_write_up_to(log_sys.get_lsn(std::memory_order_acquire), durable); + log_write_up_to(log_get_lsn(), durable); } /** Prepare to invoke log_write_and_flush(), before acquiring log_sys.latch. */ -ATTRIBUTE_COLD void log_write_and_flush_prepare() +ATTRIBUTE_COLD void log_write_and_flush_prepare() noexcept { #ifdef HAVE_PMEM if (log_sys.is_mmap()) return; #endif - while (flush_lock.acquire(log_sys.get_lsn() + 1, nullptr) != + while (flush_lock.acquire(log_get_lsn() + 1, nullptr) != group_commit_lock::ACQUIRED); - while (write_lock.acquire(log_sys.get_lsn() + 1, nullptr) != + while (write_lock.acquire(log_get_lsn() + 1, nullptr) != group_commit_lock::ACQUIRED); } -void log_t::clear_mmap() +void log_t::clear_mmap() noexcept { - if (!is_mmap() || -#ifdef HAVE_PMEM - !is_opened() || -#endif - high_level_read_only) + if (!is_mmap() || high_level_read_only) return; +#ifdef HAVE_PMEM + if (!is_opened()) + { + ut_d(latch.wr_lock(SRW_LOCK_CALL)); + ut_ad(!resize_in_progress()); + ut_ad(get_lsn() == get_flushed_lsn(std::memory_order_relaxed)); + ut_d(latch.wr_unlock()); + return; + } +#endif + log_resize_acquire(); ut_ad(!resize_in_progress()); ut_ad(write_lsn == get_lsn()); @@ -1259,10 +1271,10 @@ void log_t::clear_mmap() { alignas(16) byte log_block[4096]; const size_t bs{write_size}; - const size_t bf{buf_free.load(std::memory_order_relaxed)}; { - byte *const b= buf; - memcpy_aligned<16>(log_block, b + (bf & ~(bs - 1)), bs); + const size_t bf= + size_t(write_lsn - base_lsn.load(std::memory_order_relaxed)); + memcpy_aligned<16>(log_block, buf + (bf & ~(bs - 1)), bs); } close_file(false); @@ -1270,14 +1282,13 @@ void log_t::clear_mmap() ut_a(attach(log, file_size)); ut_ad(!is_mmap()); - set_buf_free(bf & (bs - 1)); - memcpy_aligned<16>(log_sys.buf, log_block, bs); + memcpy_aligned<16>(buf, log_block, bs); } log_resize_release(); } /** Durably write the log up to log_sys.get_lsn(). */ -ATTRIBUTE_COLD void log_write_and_flush() +ATTRIBUTE_COLD void log_write_and_flush() noexcept { ut_ad(!srv_read_only_mode); #ifdef HAVE_PMEM @@ -1297,17 +1308,17 @@ Tries to establish a big enough margin of free space in the log, such that a new log entry can be catenated without an immediate need for a checkpoint. NOTE: this function may only be called if the calling thread owns no synchronization objects! */ -ATTRIBUTE_COLD static void log_checkpoint_margin() +ATTRIBUTE_COLD static void log_checkpoint_margin() noexcept { while (log_sys.check_for_checkpoint()) { - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); ut_ad(!recv_no_log_write); if (!log_sys.check_for_checkpoint()) { func_exit: - log_sys.latch.rd_unlock(); + log_sys.latch.wr_unlock(); return; } @@ -1325,7 +1336,7 @@ func_exit: } DBUG_EXECUTE_IF("ib_log_checkpoint_avoid_hard", goto skip_checkpoint;); - log_sys.latch.rd_unlock(); + log_sys.latch.wr_unlock(); /* We must wait to prevent the tail of the log overwriting the head. */ buf_flush_wait_flushed(std::min(sync_lsn, checkpoint + (1U << 20))); @@ -1337,7 +1348,7 @@ func_exit: /** Wait for a log checkpoint if needed. NOTE that this function may only be called while not holding any synchronization objects except dict_sys.latch. */ -void log_free_check() +void log_free_check() noexcept { ut_ad(!lock_sys.is_holder()); if (log_sys.check_for_checkpoint()) @@ -1354,7 +1365,7 @@ inline void buf_mem_pressure_shutdown() noexcept {} #endif /** Make a checkpoint at the latest lsn on shutdown. */ -ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown() +ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown() noexcept { lsn_t lsn; ulint count = 0; @@ -1483,7 +1494,7 @@ wait_suspend_loop: ? SIZE_OF_FILE_CHECKPOINT + 8 : SIZE_OF_FILE_CHECKPOINT; - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); lsn = log_sys.get_lsn(); @@ -1491,7 +1502,7 @@ wait_suspend_loop: && lsn != log_sys.last_checkpoint_lsn + sizeof_cp; ut_ad(lsn >= log_sys.last_checkpoint_lsn); - log_sys.latch.rd_unlock(); + log_sys.latch.wr_unlock(); if (lsn_changed) { goto loop; @@ -1509,7 +1520,7 @@ wait_suspend_loop: "Free innodb buffer pool"); ut_d(buf_pool.assert_all_freed()); - ut_a(lsn == log_sys.get_lsn() + ut_a(lsn == log_get_lsn() || srv_force_recovery == SRV_FORCE_NO_LOG_REDO); if (UNIV_UNLIKELY(lsn < recv_sys.lsn)) { @@ -1523,7 +1534,7 @@ wait_suspend_loop: /* Make some checks that the server really is quiet */ ut_ad(!srv_any_background_activity()); - ut_a(lsn == log_sys.get_lsn() + ut_a(lsn == log_get_lsn() || srv_force_recovery == SRV_FORCE_NO_LOG_REDO); } @@ -1534,44 +1545,42 @@ log_print( /*======*/ FILE* file) /*!< in: file where to print */ { - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); const lsn_t lsn= log_sys.get_lsn(); mysql_mutex_lock(&buf_pool.flush_list_mutex); const lsn_t pages_flushed = buf_pool.get_oldest_modification(lsn); mysql_mutex_unlock(&buf_pool.flush_list_mutex); + const lsn_t flushed_lsn{log_sys.get_flushed_lsn()}; + const lsn_t checkpoint_lsn{log_sys.last_checkpoint_lsn}; + log_sys.latch.wr_unlock(); fprintf(file, "Log sequence number " LSN_PF "\n" "Log flushed up to " LSN_PF "\n" "Pages flushed up to " LSN_PF "\n" "Last checkpoint at " LSN_PF "\n", - lsn, - log_sys.get_flushed_lsn(), - pages_flushed, - lsn_t{log_sys.last_checkpoint_lsn}); - - log_sys.latch.rd_unlock(); + lsn, flushed_lsn, pages_flushed, checkpoint_lsn); } /** Shut down the redo log subsystem. */ void log_t::close() { ut_ad(this == &log_sys); - ut_ad(!(buf_free & buf_free_LOCK)); if (!is_initialised()) return; close_file(); ut_ad(!checkpoint_buf); ut_ad(!buf); ut_ad(!flush_buf); + base_lsn.store(0, std::memory_order_relaxed); latch.destroy(); - lsn_lock.destroy(); +#ifdef HAVE_PMEM + resize_wrap_mutex.destroy(); +#endif recv_sys.close(); - - max_buf_free= 0; } std::string get_log_file_path(const char *filename) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 4834fab629f..cd17da65b4f 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1174,6 +1174,13 @@ got_deleted: } else if (p.second // the first FILE_MODIFY or FILE_RENAME || f.name != fname.name) { reload: + if (f.name.size() == 0) { + /* Augment the recv_spaces.emplace_hint() for the + FILE_MODIFY record that had been added by + recv_sys_t::parse() */ + f.name = fname.name; + } + fil_space_t* space; /* Check if the tablespace file exists and contains @@ -1375,6 +1382,7 @@ void recv_sys_t::debug_free() mysql_mutex_lock(&mutex); recovery_on= false; + recv_needed_recovery= false; pages.clear(); pages_it= pages.end(); @@ -1382,7 +1390,6 @@ void recv_sys_t::debug_free() log_sys.clear_mmap(); } - /** Free a redo log snippet. @param data buffer allocated in add() */ inline void recv_sys_t::free(const void *data) @@ -2624,8 +2631,8 @@ restart: if (i != recv_spaces.end() && i->first == space_id); else if (lsn < file_checkpoint) /* We have not seen all records between the checkpoint and - FILE_CHECKPOINT. There should be a FILE_DELETE for this - tablespace later. */ + FILE_CHECKPOINT. There should be a FILE_DELETE or FILE_MODIFY + for this tablespace later, to be handled in fil_name_process(). */ recv_spaces.emplace_hint(i, space_id, file_name_t("", false)); else { @@ -2889,7 +2896,7 @@ restart: l - recs + rlen))) { lsn= start_lsn; - if (lsn > log_sys.get_lsn()) + if (lsn > log_sys.get_flushed_lsn(std::memory_order_relaxed)) log_sys.set_recovered_lsn(start_lsn); l+= rlen; offset= begin.ptr - log_sys.buf; @@ -3462,13 +3469,14 @@ void recv_sys_t::report_progress() const } else { + const lsn_t end{std::max(recv_sys.scanned_lsn, recv_sys.file_checkpoint)}; sql_print_information("InnoDB: To recover: LSN " LSN_PF "/" LSN_PF "; %zu pages", - recv_sys.lsn, recv_sys.scanned_lsn, n); + recv_sys.lsn, end, n); service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, "To recover: LSN " LSN_PF "/" LSN_PF "; %zu pages", - recv_sys.lsn, recv_sys.scanned_lsn, n); + recv_sys.lsn, end, n); } } @@ -4060,8 +4068,8 @@ static bool recv_scan_log(bool last_phase) {log_sys.buf + recv_sys.len, size})) { mysql_mutex_unlock(&recv_sys.mutex); - ib::error() << "Failed to read log at " << source_offset - << ": " << err; + sql_print_error("InnoDB: Failed to read log at %" PRIu64 ": %s", + source_offset, ut_strerr(err)); recv_sys.set_corrupt_log(); mysql_mutex_lock(&recv_sys.mutex); } @@ -4241,7 +4249,7 @@ recv_init_missing_space(dberr_t err, const recv_spaces_t::const_iterator& i) break; case SRV_OPERATION_RESTORE: case SRV_OPERATION_RESTORE_EXPORT: - if (i->second.name.find("/#sql") != std::string::npos) { + if (i->second.name.find("/#sql") == std::string::npos) { sql_print_warning("InnoDB: Tablespace " UINT32PF " was not found at %.*s when" " restoring a (partial?) backup." @@ -4535,19 +4543,19 @@ dberr_t recv_recovery_read_checkpoint() inline void log_t::set_recovered() noexcept { ut_ad(get_flushed_lsn() == get_lsn()); - ut_ad(recv_sys.lsn == get_lsn()); - size_t offset{recv_sys.offset}; + ut_ad(recv_sys.lsn == get_flushed_lsn()); if (!is_mmap()) { const size_t bs{log_sys.write_size}, bs_1{bs - 1}; - memmove_aligned<512>(buf, buf + (offset & ~bs_1), bs); - offset&= bs_1; + memmove_aligned<512>(buf, buf + (recv_sys.offset & ~bs_1), bs); } -#ifndef _WIN32 +#ifdef HAVE_PMEM else + { + buf_size= unsigned(std::min(capacity(), buf_size_max)); mprotect(buf, size_t(file_size), PROT_READ | PROT_WRITE); + } #endif - set_buf_free(offset); } inline bool recv_sys_t::validate_checkpoint() const noexcept @@ -4621,7 +4629,7 @@ read_only_recovery: goto err_exit; } ut_ad(recv_sys.file_checkpoint); - ut_ad(log_sys.get_lsn() >= recv_sys.scanned_lsn); + ut_ad(log_sys.get_flushed_lsn() >= recv_sys.scanned_lsn); if (rewind) { recv_sys.lsn = log_sys.next_checkpoint_lsn; recv_sys.offset = 0; @@ -4683,7 +4691,7 @@ read_only_recovery: tablespaces (not individual pages), while retaining the initial recv_sys.pages. */ mysql_mutex_lock(&recv_sys.mutex); - ut_ad(log_sys.get_lsn() >= recv_sys.lsn); + ut_ad(log_sys.get_flushed_lsn() >= recv_sys.lsn); recv_sys.clear(); recv_sys.lsn = log_sys.next_checkpoint_lsn; mysql_mutex_unlock(&recv_sys.mutex); @@ -4691,7 +4699,8 @@ read_only_recovery: if (srv_operation <= SRV_OPERATION_EXPORT_RESTORED) { mysql_mutex_lock(&recv_sys.mutex); - deferred_spaces.deferred_dblwr(log_sys.get_lsn()); + deferred_spaces.deferred_dblwr( + log_sys.get_flushed_lsn()); buf_dblwr.recover(); mysql_mutex_unlock(&recv_sys.mutex); } @@ -4724,16 +4733,6 @@ err_exit: if (!srv_read_only_mode && log_sys.is_latest()) { log_sys.set_recovered(); - if (recv_needed_recovery - && srv_operation <= SRV_OPERATION_EXPORT_RESTORED - && recv_sys.lsn - log_sys.next_checkpoint_lsn - < log_sys.log_capacity) { - /* Write a FILE_CHECKPOINT marker as the first thing, - before generating any other redo log. This ensures - that subsequent crash recovery will be possible even - if the server were killed soon after this. */ - fil_names_clear(log_sys.next_checkpoint_lsn); - } } DBUG_EXECUTE_IF("before_final_redo_apply", goto err_exit;); diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 095693107f4..587a2240000 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -44,7 +44,6 @@ void (*mtr_t::commit_logger)(mtr_t *, std::pair); #endif std::pair (*mtr_t::finisher)(mtr_t *, size_t); -unsigned mtr_t::spin_wait_delay; void mtr_t::finisher_update() { @@ -53,15 +52,12 @@ void mtr_t::finisher_update() if (log_sys.is_mmap()) { commit_logger= mtr_t::commit_log; - finisher= spin_wait_delay - ? mtr_t::finish_writer : mtr_t::finish_writer; + finisher= mtr_t::finish_writer; return; } commit_logger= mtr_t::commit_log; #endif - finisher= - (spin_wait_delay - ? mtr_t::finish_writer : mtr_t::finish_writer); + finisher= mtr_t::finish_writer; } void mtr_memo_slot_t::release() const @@ -256,7 +252,7 @@ static void insert_imported(buf_block_t *block) { if (block->page.oldest_modification() <= 1) { - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); /* For unlogged mtrs (MTR_LOG_NO_REDO), we use the current system LSN. The mtr that generated the LSN is either already committed or in mtr_t::commit. Shared latch and relaxed atomics should be fine here as it is guaranteed @@ -268,7 +264,7 @@ static void insert_imported(buf_block_t *block) mysql_mutex_lock(&buf_pool.flush_list_mutex); buf_pool.insert_into_flush_list (buf_pool.prepare_insert_into_flush_list(lsn), block, lsn); - log_sys.latch.rd_unlock(); + log_sys.latch.wr_unlock(); mysql_mutex_unlock(&buf_pool.flush_list_mutex); } } @@ -338,24 +334,11 @@ void mtr_t::release() m_memo.clear(); } -inline lsn_t log_t::get_write_target() const -{ - ut_ad(latch_have_any()); - if (UNIV_LIKELY(buf_free_ok())) - return 0; - /* The LSN corresponding to the end of buf is - write_lsn - (first_lsn & 4095) + buf_free, - but we use simpler arithmetics to return a smaller write target in - order to minimize waiting in log_write_up_to(). */ - ut_ad(max_buf_free >= 4096 * 4); - return write_lsn + max_buf_free / 2; -} - template void mtr_t::commit_log(mtr_t *mtr, std::pair lsns) + noexcept { size_t modified= 0; - const lsn_t write_lsn= mmap ? 0 : log_sys.get_write_target(); if (mtr->m_made_dirty) { @@ -474,9 +457,6 @@ void mtr_t::commit_log(mtr_t *mtr, std::pair lsns) if (UNIV_UNLIKELY(lsns.second != PAGE_FLUSH_NO)) buf_flush_ahead(mtr->m_commit_lsn, lsns.second == PAGE_FLUSH_SYNC); - - if (!mmap && UNIV_UNLIKELY(write_lsn != 0)) - log_write_up_to(write_lsn, false); } /** Commit a mini-transaction. */ @@ -693,7 +673,7 @@ bool mtr_t::commit_file(fil_space_t &space, const char *name) /* We will not encrypt any FILE_ records, but we will reserve a nonce at the end. */ size+= 8; - m_commit_lsn= log_sys.get_lsn(); + m_commit_lsn= log_sys.get_flushed_lsn(); } else m_commit_lsn= 0; @@ -777,7 +757,7 @@ ATTRIBUTE_COLD lsn_t mtr_t::commit_files(lsn_t checkpoint_lsn) /* We will not encrypt any FILE_ records, but we will reserve a nonce at the end. */ size+= 8; - m_commit_lsn= log_sys.get_lsn(); + m_commit_lsn= log_sys.get_flushed_lsn(); } else m_commit_lsn= 0; @@ -899,181 +879,110 @@ ATTRIBUTE_COLD static void log_overwrite_warning(lsn_t lsn) ? ". Shutdown is in progress" : ""); } -static ATTRIBUTE_NOINLINE void lsn_delay(size_t delay, size_t mult) noexcept +ATTRIBUTE_COLD void log_t::append_prepare_wait(bool late, bool ex) noexcept { - delay*= mult * 2; // GCC 13.2.0 -O2 targeting AMD64 wants to unroll twice - HMT_low(); - do - MY_RELAX_CPU(); - while (--delay); - HMT_medium(); -} - -#if defined __clang_major__ && __clang_major__ < 10 -/* Only clang-10 introduced support for asm goto */ -#elif defined __APPLE__ -/* At least some versions of Apple Xcode do not support asm goto */ -#elif defined __GNUC__ && (defined __i386__ || defined __x86_64__) -# if SIZEOF_SIZE_T == 8 -# define LOCK_TSET \ - __asm__ goto("lock btsq $63, %0\n\t" "jnc %l1" \ - : : "m"(buf_free) : "cc", "memory" : got) -# else -# define LOCK_TSET \ - __asm__ goto("lock btsl $31, %0\n\t" "jnc %l1" \ - : : "m"(buf_free) : "cc", "memory" : got) -# endif -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) -# if SIZEOF_SIZE_T == 8 -# define LOCK_TSET \ - if (!_interlockedbittestandset64 \ - (reinterpret_cast(&buf_free), 63)) return -# else -# define LOCK_TSET \ - if (!_interlockedbittestandset \ - (reinterpret_cast(&buf_free), 31)) return -# endif -#endif - -#ifdef LOCK_TSET -ATTRIBUTE_NOINLINE -void log_t::lsn_lock_bts() noexcept -{ - LOCK_TSET; + if (UNIV_LIKELY(!ex)) { - const size_t m= mtr_t::spin_wait_delay; - constexpr size_t DELAY= 10, MAX_ITERATIONS= 10; - for (size_t delay_count= DELAY, delay_iterations= 1;; - lsn_delay(delay_iterations, m)) + latch.rd_unlock(); + if (!late) { - if (!(buf_free.load(std::memory_order_relaxed) & buf_free_LOCK)) - LOCK_TSET; - if (!delay_count); - else if (delay_iterations < MAX_ITERATIONS) - delay_count= DELAY, delay_iterations++; - else - delay_count--; + /* Wait for all threads to back off. */ + latch.wr_lock(SRW_LOCK_CALL); + goto got_ex; + } + + const auto delay= my_cpu_relax_multiplier / 4 * srv_spin_wait_delay; + const auto rounds= srv_n_spin_wait_rounds; + + for (;;) + { + HMT_low(); + for (auto r= rounds + 1; r--; ) + { + if (write_lsn_offset.load(std::memory_order_relaxed) & WRITE_BACKOFF) + { + for (auto d= delay; d--; ) + MY_RELAX_CPU(); + } + else + { + HMT_medium(); + goto done; + } + } + HMT_medium(); + std::this_thread::sleep_for(std::chrono::microseconds(100)); + } + } + else + { + got_ex: + const uint64_t l= write_lsn_offset.load(std::memory_order_relaxed); + const lsn_t lsn{base_lsn.load(std::memory_order_relaxed)}; + ut_d(lsn_t ll= lsn + (l & (WRITE_BACKOFF - 1))); + ut_ad(is_mmap() + ? ll - get_flushed_lsn(std::memory_order_relaxed) < capacity() + : ll - write_lsn - ((write_size - 1) & (write_lsn - first_lsn)) < + buf_size); + waits++; +#ifdef HAVE_PMEM + const bool is_pmem{is_mmap()}; + if (is_pmem) + persist(lsn + (l & (WRITE_BACKOFF - 1))); +#endif + latch.wr_unlock(); + /* write_buf() or persist() will clear the WRITE_BACKOFF flag, + which our caller will recheck. */ +#ifdef HAVE_PMEM + if (!is_pmem) +#endif + log_write_up_to(lsn + (l & (WRITE_BACKOFF - 1)), false); + if (ex) + { + latch.wr_lock(SRW_LOCK_CALL); + return; } } -# ifdef __GNUC__ - got: - return; -# endif -} - -inline -#else -ATTRIBUTE_NOINLINE -#endif -size_t log_t::lock_lsn() noexcept -{ -#ifdef LOCK_TSET - lsn_lock_bts(); - return ~buf_free_LOCK & buf_free.load(std::memory_order_relaxed); -# undef LOCK_TSET -#else - size_t b= buf_free.fetch_or(buf_free_LOCK, std::memory_order_acquire); - if (b & buf_free_LOCK) - { - const size_t m= mtr_t::spin_wait_delay; - constexpr size_t DELAY= 10, MAX_ITERATIONS= 10; - for (size_t delay_count= DELAY, delay_iterations= 1; - ((b= buf_free.load(std::memory_order_relaxed)) & buf_free_LOCK) || - (buf_free_LOCK & (b= buf_free.fetch_or(buf_free_LOCK, - std::memory_order_acquire))); - lsn_delay(delay_iterations, m)) - if (!delay_count); - else if (delay_iterations < MAX_ITERATIONS) - delay_count= DELAY, delay_iterations++; - else - delay_count--; - } - return b; -#endif -} - -template -ATTRIBUTE_COLD size_t log_t::append_prepare_wait(size_t b, bool ex, lsn_t lsn) - noexcept -{ - waits++; - ut_ad(buf_free.load(std::memory_order_relaxed) == - (spin ? (b | buf_free_LOCK) : b)); - if (spin) - buf_free.store(b, std::memory_order_release); - else - lsn_lock.wr_unlock(); - - if (ex) - latch.wr_unlock(); - else - latch.rd_unlock(); - - log_write_up_to(lsn, is_mmap()); - - if (ex) - latch.wr_lock(SRW_LOCK_CALL); - else - latch.rd_lock(SRW_LOCK_CALL); - - if (spin) - return lock_lsn(); - - lsn_lock.wr_lock(); - return buf_free.load(std::memory_order_relaxed); +done: + latch.rd_lock(SRW_LOCK_CALL); } /** Reserve space in the log buffer for appending data. -@tparam spin whether to use the spin-only lock_lsn() @tparam mmap log_sys.is_mmap() @param size total length of the data to append(), in bytes @param ex whether log_sys.latch is exclusively locked @return the start LSN and the buffer position for append() */ -template +template inline std::pair log_t::append_prepare(size_t size, bool ex) noexcept { ut_ad(ex ? latch_have_wr() : latch_have_rd()); ut_ad(mmap == is_mmap()); - if (!spin) - lsn_lock.wr_lock(); - size_t b{spin ? lock_lsn() : buf_free.load(std::memory_order_relaxed)}; - write_to_buf++; - - lsn_t l{lsn.load(std::memory_order_relaxed)}, end_lsn{l + size}; - - if (UNIV_UNLIKELY(mmap - ? (end_lsn - - get_flushed_lsn(std::memory_order_relaxed)) > capacity() - : b + size >= buf_size)) + ut_ad(!mmap || buf_size == std::min(capacity(), buf_size_max)); + const size_t buf_size{this->buf_size - size}; + uint64_t l; + static_assert(WRITE_TO_BUF == WRITE_BACKOFF << 1, ""); + while (UNIV_UNLIKELY((l= write_lsn_offset.fetch_add(size + WRITE_TO_BUF) & + (WRITE_TO_BUF - 1)) >= buf_size)) { - b= append_prepare_wait(b, ex, l); - /* While flushing log, we had released the lsn lock and LSN could have - progressed in the meantime. */ - l= lsn.load(std::memory_order_relaxed); - end_lsn= l + size; + /* The following is inlined here instead of being part of + append_prepare_wait(), in order to increase the locality of reference + and to set the WRITE_BACKOFF flag as soon as possible. */ + bool late(write_lsn_offset.fetch_or(WRITE_BACKOFF) & WRITE_BACKOFF); + /* Subtract our LSN overshoot. */ + write_lsn_offset.fetch_sub(size); + append_prepare_wait(late, ex); } - size_t new_buf_free= b + size; - if (mmap && new_buf_free >= file_size) - new_buf_free-= size_t(capacity()); - - lsn.store(end_lsn, std::memory_order_relaxed); + const lsn_t lsn{l + base_lsn.load(std::memory_order_relaxed)}, + end_lsn{lsn + size}; if (UNIV_UNLIKELY(end_lsn >= last_checkpoint_lsn + log_capacity)) set_check_for_checkpoint(true); - byte *our_buf= buf; - if (spin) - buf_free.store(new_buf_free, std::memory_order_release); - else - { - buf_free.store(new_buf_free, std::memory_order_relaxed); - lsn_lock.wr_unlock(); - } - - return {l, our_buf + b}; + return {lsn, + buf + size_t(mmap ? FIRST_LSN + (lsn - first_lsn) % capacity() : l)}; } /** Finish appending data to the log. @@ -1218,7 +1127,7 @@ inline void log_t::resize_write(lsn_t lsn, const byte *end, size_t len, if (!resize_flush_buf) { ut_ad(is_mmap()); - lsn_lock.wr_lock(); + resize_wrap_mutex.wr_lock(); const size_t resize_capacity{resize_target - START_OFFSET}; { const lsn_t resizing{resize_in_progress()}; @@ -1229,7 +1138,7 @@ inline void log_t::resize_write(lsn_t lsn, const byte *end, size_t len, if (UNIV_UNLIKELY(lsn < resizing)) { /* This function may execute in multiple concurrent threads - that hold a shared log_sys.latch. Before we got lsn_lock, + that hold a shared log_sys.latch. Before we got resize_wrap_mutex, another thread could have executed resize_lsn.store(lsn) below with a larger lsn than ours. @@ -1279,7 +1188,7 @@ inline void log_t::resize_write(lsn_t lsn, const byte *end, size_t len, ut_ad(resize_buf[s] <= 1); resize_buf[s]= 1; mmap_done: - lsn_lock.wr_unlock(); + resize_wrap_mutex.wr_unlock(); } else #endif @@ -1306,7 +1215,7 @@ inline void log_t::append(byte *&d, const void *s, size_t size) noexcept d+= size; } -template +template std::pair mtr_t::finish_writer(mtr_t *mtr, size_t len) { @@ -1317,7 +1226,7 @@ mtr_t::finish_writer(mtr_t *mtr, size_t len) const size_t size{mtr->m_commit_lsn ? 5U + 8U : 5U}; std::pair start= - log_sys.append_prepare(len, mtr->m_latch_ex); + log_sys.append_prepare(len, mtr->m_latch_ex); if (!mmap) { diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 61aff0eece1..236d05c2166 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -2287,8 +2287,20 @@ os_file_rename_func( ut_ad(exists); #endif /* UNIV_DEBUG */ - if (MoveFileEx(oldpath, newpath, MOVEFILE_REPLACE_EXISTING)) { - return(true); + for (int retry= 50;; retry--){ + if (MoveFileEx(oldpath, newpath, MOVEFILE_REPLACE_EXISTING)) + return true; + + if (!retry) + break; + + if (GetLastError() != ERROR_SHARING_VIOLATION) + break; + + // oldpath was opened by someone else (antivirus?) + //without FILE_SHARE_DELETE flag. Retry operation + + Sleep(10); } os_file_handle_rename_error(oldpath, newpath); diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index ef6916aad15..7c1988c6a5b 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2772,16 +2772,16 @@ err_exit: && !index->table->has_spatial_index()) { ut_ad(!index->table->skip_alter_undo); - trx->bulk_insert = true; + trx->bulk_insert = TRX_DML_BULK; err = lock_table(index->table, NULL, LOCK_X, thr); if (err != DB_SUCCESS) { trx->error_state = err; - trx->bulk_insert = false; + trx->bulk_insert = TRX_NO_BULK; goto err_exit; } if (index->table->n_rec_locks) { avoid_bulk: - trx->bulk_insert = false; + trx->bulk_insert = TRX_NO_BULK; goto row_level_insert; } #ifdef WITH_WSREP @@ -2841,7 +2841,7 @@ avoid_bulk: bulk buffer and doesn't check for constraint validity of foreign key relationship. */ trx_start_if_not_started(trx, true); - trx->bulk_insert = true; + trx->bulk_insert = TRX_DDL_BULK; auto m = trx->mod_tables.emplace(index->table, 0); m.first->second.start_bulk_insert(index->table, true); err = m.first->second.bulk_insert_buffered( diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index c353b1b8bd9..414dbf2e5fc 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -68,7 +68,7 @@ Created 9/17/2000 Heikki Tuuri /** Delay an INSERT, DELETE or UPDATE operation if the purge is lagging. */ -static void row_mysql_delay_if_needed() +static void row_mysql_delay_if_needed() noexcept { const auto delay= srv_dml_needed_delay; if (UNIV_UNLIKELY(delay != 0)) @@ -77,8 +77,8 @@ static void row_mysql_delay_if_needed() log_sys.latch.rd_lock(SRW_LOCK_CALL); const lsn_t last= log_sys.last_checkpoint_lsn, max_age= log_sys.max_checkpoint_age; + const lsn_t lsn= log_sys.get_flushed_lsn(); log_sys.latch.rd_unlock(); - const lsn_t lsn= log_sys.get_lsn(); if ((lsn - last) / 4 >= max_age / 5) buf_flush_ahead(last + max_age / 5, false); purge_sys.wake_if_not_active(); @@ -686,8 +686,12 @@ handle_new_error: /* MariaDB will roll back the latest SQL statement */ break; } - /* MariaDB will roll back the entire transaction. */ - trx->bulk_insert = false; + /* For DML, InnoDB does partial rollback and clear + bulk buffer in row_mysql_handle_errors(). + For ALTER TABLE ALGORITHM=COPY & CREATE TABLE...SELECT, + the bulk insert transaction will be rolled back inside + ha_innobase::extra(HA_EXTRA_ABORT_ALTER_COPY) */ + trx->bulk_insert &= TRX_DDL_BULK; trx->last_stmt_start = 0; break; case DB_LOCK_WAIT: diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 5234dd10a8d..e7ed048e91c 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1376,7 +1376,7 @@ srv_mon_process_existing_counter( /* innodb_os_log_written */ case MONITOR_OVLD_OS_LOG_WRITTEN: - value = log_sys.get_lsn() - recv_sys.lsn; + value = log_get_lsn() - recv_sys.lsn; break; /* innodb_log_waits */ @@ -1477,7 +1477,7 @@ srv_mon_process_existing_counter( break; case MONITOR_OVLD_LSN_CURRENT: - value = log_sys.get_lsn(); + value = log_get_lsn(); break; case MONITOR_OVLD_CHECKPOINTS: @@ -1485,10 +1485,10 @@ srv_mon_process_existing_counter( break; case MONITOR_LSN_CHECKPOINT_AGE: - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); value = static_cast(log_sys.get_lsn() - log_sys.last_checkpoint_lsn); - log_sys.latch.rd_unlock(); + log_sys.latch.wr_unlock(); break; case MONITOR_OVLD_BUF_OLDEST_LSN: diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index a4cfff5aff0..0b2a279bd22 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -943,13 +943,13 @@ srv_export_innodb_status(void) mysql_mutex_unlock(&srv_innodb_monitor_mutex); - log_sys.latch.rd_lock(SRW_LOCK_CALL); + log_sys.latch.wr_lock(SRW_LOCK_CALL); export_vars.innodb_lsn_current = log_sys.get_lsn(); export_vars.innodb_lsn_flushed = log_sys.get_flushed_lsn(); export_vars.innodb_lsn_last_checkpoint = log_sys.last_checkpoint_lsn; export_vars.innodb_checkpoint_max_age = static_cast( log_sys.max_checkpoint_age); - log_sys.latch.rd_unlock(); + log_sys.latch.wr_unlock(); export_vars.innodb_os_log_written = export_vars.innodb_lsn_current - recv_sys.lsn; @@ -1036,7 +1036,7 @@ void srv_monitor_task(void*) /* Try to track a strange bug reported by Harald Fuchs and others, where the lsn seems to decrease at times */ - lsn_t new_lsn = log_sys.get_lsn(); + lsn_t new_lsn = log_get_lsn(); ut_a(new_lsn >= old_lsn); old_lsn = new_lsn; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 168bb022d9a..2f352006488 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1077,7 +1077,7 @@ srv_init_abort_low( /** Prepare to delete the redo log file. Flush the dirty pages from all the buffer pools. Flush the redo log buffer to the redo log file. @return lsn upto which data pages have been flushed. */ -ATTRIBUTE_COLD static lsn_t srv_prepare_to_delete_redo_log_file() +ATTRIBUTE_COLD static lsn_t srv_prepare_to_delete_redo_log_file() noexcept { DBUG_ENTER("srv_prepare_to_delete_redo_log_file"); @@ -1091,7 +1091,7 @@ ATTRIBUTE_COLD static lsn_t srv_prepare_to_delete_redo_log_file() log_sys.latch.wr_lock(SRW_LOCK_CALL); const bool latest_format{log_sys.is_latest()}; - lsn_t flushed_lsn{log_sys.get_lsn()}; + lsn_t flushed_lsn{log_sys.get_flushed_lsn(std::memory_order_relaxed)}; if (latest_format && !(log_sys.file_size & 4095) && flushed_lsn != log_sys.next_checkpoint_lsn + @@ -1099,6 +1099,11 @@ ATTRIBUTE_COLD static lsn_t srv_prepare_to_delete_redo_log_file() ? SIZE_OF_FILE_CHECKPOINT + 8 : SIZE_OF_FILE_CHECKPOINT)) { +#ifdef HAVE_PMEM + if (!log_sys.is_opened()) + log_sys.buf_size= unsigned(std::min(log_sys.capacity(), + log_sys.buf_size_max)); +#endif fil_names_clear(flushed_lsn); flushed_lsn= log_sys.get_lsn(); } @@ -1139,7 +1144,7 @@ same_size: if (latest_format) log_write_up_to(flushed_lsn, false); - ut_ad(flushed_lsn == log_sys.get_lsn()); + ut_ad(flushed_lsn == log_get_lsn()); ut_ad(!os_aio_pending_reads()); ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex)); ut_ad(!buf_pool.get_oldest_modification(0)); @@ -1228,6 +1233,18 @@ static tpool::task rollback_all_recovered_task(trx_rollback_all_recovered, nullptr, &rollback_all_recovered_group); +inline lsn_t log_t::init_lsn() noexcept +{ + latch.wr_lock(SRW_LOCK_CALL); + ut_ad(!write_lsn_offset); + write_lsn_offset= 0; + const lsn_t lsn{base_lsn.load(std::memory_order_relaxed)}; + flushed_to_disk_lsn.store(lsn, std::memory_order_relaxed); + write_lsn= lsn; + latch.wr_unlock(); + return lsn; +} + /** Start InnoDB. @param[in] create_new_db whether to create a new database @return DB_SUCCESS or error code */ diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 53acf06fae6..0786b539ffd 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -152,7 +152,9 @@ trx_undo_log_v_idx( ulint n_idx = 0; for (const auto& v_index : vcol->v_indexes) { n_idx++; - /* FIXME: index->id is 64 bits! */ + if (uint32_t hi= uint32_t(v_index.index->id >> 32)) { + size += 1 + mach_get_compressed_size(hi); + } size += mach_get_compressed_size(uint32_t(v_index.index->id)); size += mach_get_compressed_size(v_index.nth_field); } @@ -179,10 +181,14 @@ trx_undo_log_v_idx( ptr += mach_write_compressed(ptr, n_idx); for (const auto& v_index : vcol->v_indexes) { - ptr += mach_write_compressed( - /* FIXME: index->id is 64 bits! */ - ptr, uint32_t(v_index.index->id)); - + /* This is compatible with + ptr += mach_u64_write_much_compressed(ptr, v_index.index-id) + (the added "if" statement is fixing an old regression). */ + if (uint32_t hi= uint32_t(v_index.index->id >> 32)) { + *ptr++ = 0xff; + ptr += mach_write_compressed(ptr, hi); + } + ptr += mach_write_compressed(ptr, uint32_t(v_index.index->id)); ptr += mach_write_compressed(ptr, v_index.nth_field); } @@ -221,7 +227,15 @@ trx_undo_read_v_idx_low( dict_index_t* clust_index = dict_table_get_first_index(table); for (ulint i = 0; i < num_idx; i++) { - index_id_t id = mach_read_next_compressed(&ptr); + index_id_t id = 0; + /* This is like mach_u64_read_much_compressed(), + but advancing ptr to the next field. */ + if (*ptr == 0xff) { + ptr++; + id = mach_read_next_compressed(&ptr); + id <<= 32; + } + id |= mach_read_next_compressed(&ptr); ulint pos = mach_read_next_compressed(&ptr); dict_index_t* index = dict_table_get_next_index(clust_index); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 192009ae183..8d3eeafe8e3 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -134,8 +134,6 @@ trx_init( trx->will_lock = false; - trx->bulk_insert = false; - trx->apply_online_log = false; ut_d(trx->start_file = 0); @@ -1513,6 +1511,7 @@ bool trx_t::commit_cleanup() noexcept *detailed_error= '\0'; mod_tables.clear(); + bulk_insert= TRX_NO_BULK; check_foreigns= true; check_unique_secondary= true; assert_freed(); diff --git a/storage/mroonga/CMakeLists.txt b/storage/mroonga/CMakeLists.txt index 399201a2ef6..bdda7716c0c 100644 --- a/storage/mroonga/CMakeLists.txt +++ b/storage/mroonga/CMakeLists.txt @@ -17,7 +17,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8...3.12) project(mroonga) if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 0985d7459fc..8c8465bdb98 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -558,6 +558,9 @@ static const char *mrn_inspect_extra_function(enum ha_extra_function operation) case HA_EXTRA_END_ALTER_COPY: inspected = "HA_EXTRA_END_ALTER_COPY"; break; + case HA_EXTRA_ABORT_ALTER_COPY: + inspected = "HA_EXTRA_ABORT_ALTER_COPY"; + break; #ifdef MRN_HAVE_HA_EXTRA_EXPORT case HA_EXTRA_EXPORT: inspected = "HA_EXTRA_EXPORT"; @@ -593,6 +596,11 @@ static const char *mrn_inspect_extra_function(enum ha_extra_function operation) inspected = "HA_EXTRA_END_ALTER_COPY"; break; #endif +#ifdef MRN_HAVE_HA_EXTRA_ABORT_ALTER_COPY + case HA_EXTRA_ABORT_ALTER_COPY: + inspected = "HA_EXTRA_ABORT_ALTER_COPY"; + break; +#endif #ifdef MRN_HAVE_HA_EXTRA_NO_AUTOINC_LOCKING case HA_EXTRA_NO_AUTOINC_LOCKING: inspected = "HA_EXTRA_NO_AUTOINC_LOCKING"; diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt index cdbfb8f160b..7364853caef 100644 --- a/storage/mroonga/vendor/groonga/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/CMakeLists.txt @@ -15,7 +15,7 @@ # https://buildbot.askmonty.org/buildbot/builders/work-amd64-valgrind/builds/5263/steps/compile/logs/stdio # says CMake 2.6.2... We want to drop old software support... -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8...3.12) # cmake_minimum_required(VERSION 2.6.4) # CentOS 5 set(GRN_PROJECT_NAME "groonga") set(GRN_PROJECT_LABEL "Groonga") diff --git a/storage/mroonga/vendor/groonga/lib/db.c b/storage/mroonga/vendor/groonga/lib/db.c index 65463bdad20..3c2f98e4cde 100644 --- a/storage/mroonga/vendor/groonga/lib/db.c +++ b/storage/mroonga/vendor/groonga/lib/db.c @@ -969,8 +969,8 @@ calc_rec_size(grn_table_flags flags, uint32_t max_n_subrecs, uint32_t range_size *subrec_size = range_size + sizeof(uint32_t) + sizeof(uint32_t); break; } - *value_size = (uintptr_t)GRN_RSET_SUBRECS_NTH((((grn_rset_recinfo *)0)->subrecs), - *subrec_size, max_n_subrecs); + *value_size = (uintptr_t) GRN_RSET_SUBRECS_NTH(offsetof(grn_rset_recinfo, subrecs), + *subrec_size, max_n_subrecs); } else { *value_size = range_size; } diff --git a/storage/mroonga/vendor/groonga/lib/hash.c b/storage/mroonga/vendor/groonga/lib/hash.c index 8cdae7bad5e..a2254d2ea2f 100644 --- a/storage/mroonga/vendor/groonga/lib/hash.c +++ b/storage/mroonga/vendor/groonga/lib/hash.c @@ -1727,15 +1727,15 @@ grn_io_hash_calculate_entry_size(uint32_t key_size, uint32_t value_size, { if (flags & GRN_OBJ_KEY_VAR_SIZE) { if (flags & GRN_OBJ_KEY_LARGE) { - return (uintptr_t)((grn_io_hash_entry_large *)0)->value + value_size; + return offsetof(grn_io_hash_entry_large, value) + value_size; } else { - return (uintptr_t)((grn_io_hash_entry_normal *)0)->value + value_size; + return offsetof(grn_io_hash_entry_normal, value) + value_size; } } else { if (key_size == sizeof(uint32_t)) { - return (uintptr_t)((grn_plain_hash_entry *)0)->value + value_size; + return offsetof(grn_plain_hash_entry, value) + value_size; } else { - return (uintptr_t)((grn_rich_hash_entry *)0)->key_and_value + return offsetof(grn_rich_hash_entry, key_and_value) + key_size + value_size; } } @@ -1865,12 +1865,12 @@ grn_tiny_hash_calculate_entry_size(uint32_t key_size, uint32_t value_size, { uint32_t entry_size; if (flags & GRN_OBJ_KEY_VAR_SIZE) { - entry_size = (uintptr_t)((grn_tiny_hash_entry *)0)->value + value_size; + entry_size = offsetof(grn_tiny_hash_entry, value) + value_size; } else { if (key_size == sizeof(uint32_t)) { - entry_size = (uintptr_t)((grn_plain_hash_entry *)0)->value + value_size; + entry_size = offsetof(grn_plain_hash_entry, value) + value_size; } else { - entry_size = (uintptr_t)((grn_rich_hash_entry *)0)->key_and_value + entry_size = offsetof(grn_rich_hash_entry, key_and_value) + key_size + value_size; } } diff --git a/storage/mroonga/vendor/groonga/lib/ii.c b/storage/mroonga/vendor/groonga/lib/ii.c index 3e402e15e7e..8ce4857bfc2 100644 --- a/storage/mroonga/vendor/groonga/lib/ii.c +++ b/storage/mroonga/vendor/groonga/lib/ii.c @@ -2049,7 +2049,7 @@ grn_p_decv(grn_ctx *ctx, uint8_t *data, uint32_t data_size, datavec *dv, uint32_ if ((df & 1)) { df >>= 1; size = nreq == dvlen ? data_size : df * nreq; - if (dv[dvlen].data < dv[0].data + size) { + if (!dv[0].data || dv[dvlen].data < dv[0].data + size) { if (dv[0].data) { GRN_FREE(dv[0].data); } if (!(rp = GRN_MALLOC(size * sizeof(uint32_t)))) { return 0; } dv[dvlen].data = rp + size; @@ -10653,7 +10653,7 @@ grn_ii_builder_options_fix(grn_ii_builder_options *options) } #define GRN_II_BUILDER_TERM_INPLACE_SIZE\ - (sizeof(grn_ii_builder_term) - (uintptr_t)&((grn_ii_builder_term *)0)->dummy) + (sizeof(grn_ii_builder_term) - offsetof(grn_ii_builder_term, dummy)) typedef struct { grn_id rid; /* Last record ID */ diff --git a/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt b/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt index 96f9b3e6bbf..a555bdf6ac2 100644 --- a/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt @@ -15,7 +15,7 @@ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1335 USA -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8...3.12) if(NOT DEFINED GROONGA_NORMALIZER_MYSQL_PROJECT_NAME) set(GROONGA_NORMALIZER_MYSQL_PROJECT_NAME "groonga-normalizer-mysql") endif() diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake index e89dbfc0627..3bb05c06caf 100644 --- a/storage/rocksdb/build_rocksdb.cmake +++ b/storage/rocksdb/build_rocksdb.cmake @@ -176,35 +176,53 @@ set(LIBS ${ROCKSDB_LIBS} ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) # - *_test.cc # - *_bench.cc set(ROCKSDB_SOURCES + cache/cache.cc + cache/cache_entry_roles.cc + cache/cache_key.cc + cache/cache_reservation_manager.cc cache/clock_cache.cc cache/lru_cache.cc cache/sharded_cache.cc db/arena_wrapped_db_iter.cc + db/blob/blob_fetcher.cc + db/blob/blob_file_addition.cc + db/blob/blob_file_builder.cc + db/blob/blob_file_builder.cc + db/blob/blob_file_cache.cc + db/blob/blob_file_garbage.cc + db/blob/blob_file_meta.cc + db/blob/blob_file_reader.cc + db/blob/blob_garbage_meter.cc + db/blob/blob_log_format.cc + db/blob/blob_log_sequential_reader.cc + db/blob/blob_log_writer.cc + db/blob/prefetch_buffer_collection.cc db/builder.cc db/c.cc db/column_family.cc - db/compacted_db_impl.cc db/compaction/compaction.cc db/compaction/compaction_iterator.cc - db/compaction/compaction_picker.cc db/compaction/compaction_job.cc + db/compaction/compaction_picker.cc db/compaction/compaction_picker_fifo.cc db/compaction/compaction_picker_level.cc db/compaction/compaction_picker_universal.cc + db/compaction/sst_partitioner.cc db/convenience.cc db/db_filesnapshot.cc + db/dbformat.cc + db/db_impl/compacted_db_impl.cc db/db_impl/db_impl.cc - db/db_impl/db_impl_write.cc db/db_impl/db_impl_compaction_flush.cc - db/db_impl/db_impl_files.cc - db/db_impl/db_impl_open.cc db/db_impl/db_impl_debug.cc db/db_impl/db_impl_experimental.cc + db/db_impl/db_impl_files.cc + db/db_impl/db_impl_open.cc db/db_impl/db_impl_readonly.cc db/db_impl/db_impl_secondary.cc + db/db_impl/db_impl_write.cc db/db_info_dumper.cc db/db_iter.cc - db/dbformat.cc db/error_handler.cc db/event_helpers.cc db/experimental.cc @@ -215,14 +233,16 @@ set(ROCKSDB_SOURCES db/forward_iterator.cc db/import_column_family_job.cc db/internal_stats.cc - db/logs_with_prep_tracker.cc db/log_reader.cc + db/logs_with_prep_tracker.cc db/log_writer.cc db/malloc_stats.cc db/memtable.cc db/memtable_list.cc db/merge_helper.cc db/merge_operator.cc + db/output_validator.cc + db/periodic_work_scheduler.cc db/range_del_aggregator.cc db/range_tombstone_fragmenter.cc db/repair.cc @@ -233,25 +253,32 @@ set(ROCKSDB_SOURCES db/trim_history_scheduler.cc db/version_builder.cc db/version_edit.cc + db/version_edit_handler.cc db/version_set.cc + db/wal_edit.cc db/wal_manager.cc - db/write_batch.cc db/write_batch_base.cc + db/write_batch.cc db/write_controller.cc db/write_thread.cc + env/composite_env.cc env/env.cc env/env_chroot.cc env/env_encryption.cc env/env_hdfs.cc env/file_system.cc + env/file_system_tracer.cc + env/fs_remap.cc env/mock_env.cc + env/unique_id_gen.cc file/delete_scheduler.cc + file/filename.cc file/file_prefetch_buffer.cc file/file_util.cc - file/filename.cc + file/line_file_reader.cc file/random_access_file_reader.cc - file/read_write_util.cc file/readahead_raf.cc + file/read_write_util.cc file/sequence_file_reader.cc file/sst_file_manager_impl.cc file/writable_file_writer.cc @@ -281,29 +308,38 @@ set(ROCKSDB_SOURCES monitoring/thread_status_util.cc monitoring/thread_status_util_debug.cc options/cf_options.cc + options/configurable.cc + options/customizable.cc options/db_options.cc options/options.cc options/options_helper.cc options/options_parser.cc - options/options_sanity_check.cc port/stack_trace.cc table/adaptive/adaptive_table_factory.cc - table/block_based/block.cc + table/block_based/binary_search_index_reader.cc table/block_based/block_based_filter_block.cc table/block_based/block_based_table_builder.cc table/block_based/block_based_table_factory.cc + table/block_based/block_based_table_iterator.cc table/block_based/block_based_table_reader.cc table/block_based/block_builder.cc + table/block_based/block.cc + table/block_based/block_prefetcher.cc table/block_based/block_prefix_index.cc - table/block_based/data_block_hash_index.cc table/block_based/data_block_footer.cc + table/block_based/data_block_hash_index.cc table/block_based/filter_block_reader_common.cc table/block_based/filter_policy.cc table/block_based/flush_block_policy.cc table/block_based/full_filter_block.cc + table/block_based/hash_index_reader.cc table/block_based/index_builder.cc + table/block_based/index_reader_common.cc table/block_based/parsed_full_filter_block.cc table/block_based/partitioned_filter_block.cc + table/block_based/partitioned_index_iterator.cc + table/block_based/partitioned_index_reader.cc + table/block_based/reader_common.cc table/block_based/uncompression_dict_reader.cc table/block_fetcher.cc table/cuckoo/cuckoo_table_builder.cc @@ -321,10 +357,13 @@ set(ROCKSDB_SOURCES table/plain/plain_table_index.cc table/plain/plain_table_key_coding.cc table/plain/plain_table_reader.cc + table/sst_file_dumper.cc table/sst_file_reader.cc table/sst_file_writer.cc + table/table_factory.cc table/table_properties.cc table/two_level_iterator.cc + table/unique_id.cc test_util/sync_point.cc test_util/sync_point_impl.cc test_util/testutil.cc @@ -335,8 +374,12 @@ set(ROCKSDB_SOURCES tools/ldb_tool.cc tools/sst_dump_tool.cc tools/trace_analyzer_tool.cc - trace_replay/trace_replay.cc trace_replay/block_cache_tracer.cc + trace_replay/io_tracer.cc + trace_replay/trace_record.cc + trace_replay/trace_record_handler.cc + trace_replay/trace_record_result.cc + trace_replay/trace_replay.cc util/coding.cc util/compaction_job_stats_impl.cc util/comparator.cc @@ -344,17 +387,8 @@ set(ROCKSDB_SOURCES util/concurrent_task_limiter_impl.cc util/crc32c.cc util/dynamic_bloom.cc - util/hash.cc - util/murmurhash.cc - util/random.cc - util/rate_limiter.cc - util/slice.cc util/file_checksum_helper.cc - util/status.cc - util/string_util.cc - util/thread_local.cc - util/threadpool_imp.cc - util/xxhash.cc + util/hash.cc utilities/backupable/backupable_db.cc utilities/blob_db/blob_compaction_filter.cc utilities/blob_db/blob_db.cc @@ -362,10 +396,8 @@ set(ROCKSDB_SOURCES utilities/blob_db/blob_db_impl_filesnapshot.cc utilities/blob_db/blob_dump_tool.cc utilities/blob_db/blob_file.cc - utilities/blob_db/blob_log_reader.cc - utilities/blob_db/blob_log_writer.cc - utilities/blob_db/blob_log_format.cc utilities/checkpoint/checkpoint_impl.cc + utilities/compaction_filters.cc utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc utilities/debug.cc utilities/env_mirror.cc @@ -373,11 +405,12 @@ set(ROCKSDB_SOURCES utilities/leveldb_options/leveldb_options.cc utilities/memory/memory_util.cc utilities/merge_operators/bytesxor.cc + utilities/merge_operators.cc utilities/merge_operators/max.cc utilities/merge_operators/put.cc utilities/merge_operators/sortlist.cc - utilities/merge_operators/string_append/stringappend.cc utilities/merge_operators/string_append/stringappend2.cc + utilities/merge_operators/string_append/stringappend.cc utilities/merge_operators/uint64add.cc utilities/object_registry.cc utilities/option_change_migration/option_change_migration.cc @@ -391,22 +424,37 @@ set(ROCKSDB_SOURCES utilities/simulator_cache/sim_cache.cc utilities/table_properties_collectors/compact_on_deletion_collector.cc utilities/trace/file_trace_reader_writer.cc - utilities/transactions/optimistic_transaction_db_impl.cc + utilities/trace/replayer_impl.cc + utilities/transactions/lock/lock_manager.cc + utilities/transactions/lock/point/point_lock_manager.cc + utilities/transactions/lock/point/point_lock_tracker.cc utilities/transactions/optimistic_transaction.cc + utilities/transactions/optimistic_transaction_db_impl.cc utilities/transactions/pessimistic_transaction.cc utilities/transactions/pessimistic_transaction_db.cc utilities/transactions/snapshot_checker.cc utilities/transactions/transaction_base.cc utilities/transactions/transaction_db_mutex_impl.cc - utilities/transactions/transaction_lock_mgr.cc utilities/transactions/transaction_util.cc utilities/transactions/write_prepared_txn.cc utilities/transactions/write_prepared_txn_db.cc utilities/transactions/write_unprepared_txn.cc utilities/transactions/write_unprepared_txn_db.cc utilities/ttl/db_ttl_impl.cc + utilities/wal_filter.cc utilities/write_batch_with_index/write_batch_with_index.cc utilities/write_batch_with_index/write_batch_with_index_internal.cc + util/murmurhash.cc + util/random.cc + util/rate_limiter.cc + util/regex.cc + util/ribbon_config.cc + util/slice.cc + util/status.cc + util/string_util.cc + util/thread_local.cc + util/threadpool_imp.cc + util/xxhash.cc ) @@ -484,8 +532,10 @@ IF(CMAKE_VERSION VERSION_GREATER "2.8.10") STRING(TIMESTAMP GIT_DATE_TIME "%Y-%m-%d %H:%M:%S") ENDIF() +# psergey-added: +SET(GIT_MOD 0) CONFIGURE_FILE(${ROCKSDB_SOURCE_DIR}/util/build_version.cc.in build_version.cc @ONLY) -INCLUDE_DIRECTORIES(${ROCKSDB_SOURCE_DIR}/util) + list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/build_version.cc) ADD_CONVENIENCE_LIBRARY(rocksdblib ${SOURCES}) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 5e8fffcc7cf..792129cf84d 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -1596,7 +1596,7 @@ static MYSQL_SYSVAR_BOOL( "BlockBasedTableOptions::no_block_cache for RocksDB", nullptr, nullptr, rocksdb_tbl_options->no_block_cache); -static MYSQL_SYSVAR_SIZE_T(block_size, rocksdb_tbl_options->block_size, +static MYSQL_SYSVAR_UINT64_T(block_size, rocksdb_tbl_options->block_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "BlockBasedTableOptions::block_size for RocksDB", nullptr, nullptr, rocksdb_tbl_options->block_size, @@ -3992,7 +3992,7 @@ static int rocksdb_commit_by_xid(handlerton *const hton, XID *const xid) { DBUG_ASSERT(xid != nullptr); DBUG_ASSERT(commit_latency_stats != nullptr); - rocksdb::StopWatchNano timer(rocksdb::Env::Default(), true); + rocksdb::StopWatchNano timer(rocksdb::SystemClock::Default().get(), true); const auto name = rdb_xid_to_string(*xid); DBUG_ASSERT(!name.empty()); @@ -4187,7 +4187,7 @@ static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_tx) DBUG_ASSERT(thd != nullptr); DBUG_ASSERT(commit_latency_stats != nullptr); - rocksdb::StopWatchNano timer(rocksdb::Env::Default(), true); + rocksdb::StopWatchNano timer(rocksdb::SystemClock::Default().get(), true); /* note: h->external_lock(F_UNLCK) is called after this function is called) */ Rdb_transaction *tx = get_tx_from_thd(thd); @@ -4732,8 +4732,7 @@ static bool rocksdb_show_status(handlerton *const hton, THD *const thd, if (tf_name.find("BlockBasedTable") != std::string::npos) { const rocksdb::BlockBasedTableOptions *const bbt_opt = - reinterpret_cast( - table_factory->GetOptions()); + table_factory->GetOptions(); if (bbt_opt != nullptr) { if (bbt_opt->block_cache.get() != nullptr) { diff --git a/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result b/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result index 9a12f51e3b5..7fb80995ece 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result @@ -20,7 +20,7 @@ set @tmp1=@@rocksdb_verify_row_debug_checksums; set rocksdb_verify_row_debug_checksums=1; set session debug_dbug= "+d,myrocks_simulate_bad_row_read1"; select * from t1 where pk=1; -ERROR HY000: Got error 205 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 206 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_row_read1"; set rocksdb_verify_row_debug_checksums=@tmp1; select * from t1 where pk=1; @@ -28,11 +28,11 @@ pk col1 1 1 set session debug_dbug= "+d,myrocks_simulate_bad_row_read2"; select * from t1 where pk=1; -ERROR HY000: Got error 205 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 206 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_row_read2"; set session debug_dbug= "+d,myrocks_simulate_bad_row_read3"; select * from t1 where pk=1; -ERROR HY000: Got error 205 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 206 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_row_read3"; insert into t1 values(4,'0123456789'); select * from t1; @@ -56,7 +56,7 @@ pk col1 ABCD 1 set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1"; select * from t2; -ERROR HY000: Got error 205 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 206 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1"; drop table t2; create table t2 ( @@ -69,6 +69,6 @@ pk col1 ABCD 1 set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1"; select * from t2; -ERROR HY000: Got error 205 'Found data corruption.' from ROCKSDB +ERROR HY000: Got error 206 'Found data corruption.' from ROCKSDB set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1"; drop table t2; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result b/storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result index 954e6079bba..de8cbcbcd02 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result @@ -1,12 +1,6 @@ -call mtr.add_suppression("Column family 'cf1' not found"); -call mtr.add_suppression("Column family 'rev:cf2' not found"); DROP TABLE IF EXISTS t1; call mtr.add_suppression("Column family 'cf1' not found"); call mtr.add_suppression("Column family 'rev:cf2' not found"); -set global rocksdb_compact_cf = 'cf1'; -set global rocksdb_compact_cf = 'rev:cf2'; -set global rocksdb_signal_drop_index_thread = 1; -# restart CREATE TABLE t1 ( a int not null, b int not null, @@ -15,6 +9,10 @@ primary key (a,b) comment 'cf1', key (b) comment 'rev:cf2' ) ENGINE=RocksDB; DELETE FROM t1; +set global rocksdb_compact_cf = 'cf1'; +set global rocksdb_compact_cf = 'rev:cf2'; +set global rocksdb_signal_drop_index_thread = 1; +# restart select variable_value into @a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; drop table t1; select case when variable_value-@a < 500000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result index 0c9d29efa28..5e2dec4684a 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result @@ -982,7 +982,7 @@ rocksdb_skip_fill_cache OFF rocksdb_skip_unique_check_tables .* rocksdb_sst_mgr_rate_bytes_per_sec 0 rocksdb_stats_dump_period_sec 600 -rocksdb_stats_level 0 +rocksdb_stats_level 1 rocksdb_stats_recalc_rate 0 rocksdb_store_row_debug_checksums OFF rocksdb_strict_collation_check OFF diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result index 40c53f6fd8a..51f4ecb9684 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result @@ -1,2 +1,2 @@ Check for MANIFEST files -MANIFEST-000006 +MANIFEST-000004 diff --git a/storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result b/storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result index 7c5631a2c97..359124e83ac 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result @@ -1,12 +1,6 @@ -call mtr.add_suppression("Column family 'cf1' not found"); -call mtr.add_suppression("Column family 'rev:cf2' not found"); DROP TABLE IF EXISTS t1; call mtr.add_suppression("Column family 'cf1' not found"); call mtr.add_suppression("Column family 'rev:cf2' not found"); -set global rocksdb_compact_cf = 'cf1'; -set global rocksdb_compact_cf = 'rev:cf2'; -set global rocksdb_signal_drop_index_thread = 1; -# restart CREATE TABLE t1 ( a int not null, b int not null, @@ -15,6 +9,10 @@ primary key (a,b) comment 'cf1', key (b) comment 'rev:cf2' ) ENGINE=RocksDB; DELETE FROM t1; +set global rocksdb_compact_cf = 'cf1'; +set global rocksdb_compact_cf = 'rev:cf2'; +set global rocksdb_signal_drop_index_thread = 1; +# restart select variable_value into @a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; truncate table t1; select case when variable_value-@a < 500000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc index dd9a19a29cb..033166ae946 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc +++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc @@ -1,8 +1,5 @@ --source include/have_rocksdb.inc -call mtr.add_suppression("Column family 'cf1' not found"); -call mtr.add_suppression("Column family 'rev:cf2' not found"); - --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings @@ -10,11 +7,6 @@ DROP TABLE IF EXISTS t1; call mtr.add_suppression("Column family 'cf1' not found"); call mtr.add_suppression("Column family 'rev:cf2' not found"); -# Start from clean slate -set global rocksdb_compact_cf = 'cf1'; -set global rocksdb_compact_cf = 'rev:cf2'; -set global rocksdb_signal_drop_index_thread = 1; ---source include/restart_mysqld.inc CREATE TABLE t1 ( a int not null, @@ -29,6 +21,12 @@ let $max = 50000; let $table = t1; --source drop_table3_repopulate_table.inc +# Start from clean slate +set global rocksdb_compact_cf = 'cf1'; +set global rocksdb_compact_cf = 'rev:cf2'; +set global rocksdb_signal_drop_index_thread = 1; +--source include/restart_mysqld.inc + --disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; --enable_cursor_protocol @@ -49,6 +47,7 @@ let $wait_condition = select count(*) = 0 --source include/wait_condition.inc select case when variable_value-@a < 500000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; +#select variable_value-@a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; # Cleanup DROP TABLE IF EXISTS t1; diff --git a/storage/rocksdb/rdb_i_s.cc b/storage/rocksdb/rdb_i_s.cc index 326d7b450a0..04f1676baa2 100644 --- a/storage/rocksdb/rdb_i_s.cc +++ b/storage/rocksdb/rdb_i_s.cc @@ -588,8 +588,7 @@ static int rdb_i_s_cfoptions_fill_table( cf_option_types.push_back( {"PREFIX_EXTRACTOR", opts.prefix_extractor == nullptr ? "NULL" - : std::string(opts.prefix_extractor->Name())}); - + : std::string(opts.prefix_extractor->AsString())}); // get COMPACTION_STYLE option switch (opts.compaction_style) { case rocksdb::kCompactionStyleLevel: @@ -647,7 +646,7 @@ static int rdb_i_s_cfoptions_fill_table( // get table related options std::vector table_options = - split_into_vector(opts.table_factory->GetPrintableTableOptions(), '\n'); + split_into_vector(opts.table_factory->GetPrintableOptions(), '\n'); for (auto option : table_options) { option.erase(std::remove(option.begin(), option.end(), ' '), diff --git a/storage/rocksdb/rocksdb b/storage/rocksdb/rocksdb index bba5e7bc210..79f08d7ffa6 160000 --- a/storage/rocksdb/rocksdb +++ b/storage/rocksdb/rocksdb @@ -1 +1 @@ -Subproject commit bba5e7bc21093d7cfa765e1280a7c4fdcd284288 +Subproject commit 79f08d7ffa6d34d9ca3357777bcb335884a56cfb diff --git a/storage/spider/CMakeLists.txt b/storage/spider/CMakeLists.txt index bc1387db236..f44fb3f8172 100644 --- a/storage/spider/CMakeLists.txt +++ b/storage/spider/CMakeLists.txt @@ -28,16 +28,5 @@ ELSE() MYSQL_ADD_PLUGIN(spider ${SPIDER_SOURCES} ${extra_options} STORAGE_ENGINE MODULE_ONLY) - IF(NOT TARGET spider) - RETURN() - ENDIF() ENDIF() -IF(MSVC AND (TARGET spider)) - IF (CMAKE_BUILD_TYPE STREQUAL "Debug") - ADD_CUSTOM_COMMAND(TARGET spider - POST_BUILD - COMMAND if not exist ..\\..\\sql\\lib mkdir ..\\..\\sql\\lib\\plugin - COMMAND copy Debug\\ha_spider.dll ..\\..\\sql\\lib\\plugin\\ha_spider.dll) - ENDIF() -ENDIF() diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index b4568a0aafb..22330026d5b 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -4152,10 +4152,6 @@ int ha_spider::rnd_init( } } pushed_pos = NULL; -/* - if (wide_handler->external_lock_type == F_WRLCK) - check_and_start_bulk_update(SPD_BU_START_BY_INDEX_OR_RND_INIT); -*/ rnd_scan_and_first = scan; if ( scan && diff --git a/storage/spider/mysql-test/spider/bg/t/basic_sql.test b/storage/spider/mysql-test/spider/bg/t/basic_sql.test index f680cd438cf..72a9b76cb14 100644 --- a/storage/spider/mysql-test/spider/bg/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/bg/t/basic_sql.test @@ -1039,8 +1039,11 @@ if ($USE_CHILD_GROUP2) } } --connection master_1 +# MDEV-36357 +--disable_view_protocol SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/ha.test b/storage/spider/mysql-test/spider/bg/t/ha.test index f86e98c58af..a518fcd59ff 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha.test +++ b/storage/spider/mysql-test/spider/bg/t/ha.test @@ -398,8 +398,10 @@ if ($USE_CHILD_GROUP3) eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; --disable_ps_protocol +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; --enable_ps_protocol +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/bg/t/ha_part.test b/storage/spider/mysql-test/spider/bg/t/ha_part.test index 9767607a060..1ca4bb24213 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha_part.test +++ b/storage/spider/mysql-test/spider/bg/t/ha_part.test @@ -463,8 +463,10 @@ if ($HAVE_PARTITION) eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; --disable_ps_protocol + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; --enable_ps_protocol + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc index c87af2d02e4..5c5a14bf796 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc @@ -6,6 +6,6 @@ --enable_query_log --enable_warnings let $DIRECT_SQL_COMMAND= - SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"'); + SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"') as exp; --connection child2_1 GRANT ALL ON *.* TO tu@'%' IDENTIFIED BY 'pass,1234'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc index 7b58bd3e726..bb2c7eb3aba 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc @@ -6,4 +6,4 @@ --enable_query_log --enable_warnings let $DIRECT_SQL_COMMAND= - SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"'); + SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"') as exp; diff --git a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result index b485d645619..7d18527351e 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result +++ b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result @@ -15,8 +15,8 @@ CREATE TEMPORARY TABLE tmp_a ( pkey int NOT NULL, PRIMARY KEY (pkey) ) MASTER_1_ENGINE2 -SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"'); -spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"') +SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"') as exp; +exp 1 SELECT pkey FROM tmp_a; pkey diff --git a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result index 65beb8a43dd..467bc0ed6cd 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result +++ b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result @@ -13,8 +13,8 @@ CREATE TEMPORARY TABLE tmp_a ( pkey int NOT NULL, PRIMARY KEY (pkey) ) MASTER_1_ENGINE2 -SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"'); -spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"') +SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"') as exp; +exp 1 SELECT pkey FROM tmp_a; pkey diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result index 962caf7fec7..f50d860389d 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result @@ -17,6 +17,9 @@ insert into t1 VALUES (1,4), (1,2), (2,11); SELECT MIN(b), a FROM t1 WHERE a=1; MIN(b) a 2 1 +select * from (SELECT MIN(b), a FROM t1 WHERE a=1) as v; +MIN(b) a +2 1 SELECT MAX(b), a FROM t1 WHERE a<3; MAX(b) a 11 1 diff --git a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result index 35bd8335b69..75174bbf57a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result +++ b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result @@ -33,8 +33,8 @@ a INT 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 temporary table results (a int); -SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"'); -SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') +SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') as exp; +exp 1 select * from results; a diff --git a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result index 35bd8335b69..75174bbf57a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result +++ b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result @@ -33,8 +33,8 @@ a INT 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 temporary table results (a int); -SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"'); -SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') +SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') as exp; +exp 1 select * from results; a diff --git a/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test index dca9c661765..d49a24ad7fa 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test +++ b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test @@ -54,9 +54,11 @@ TRUNCATE TABLE mysql.general_log; CHECKSUM TABLE tbl_a EXTENDED; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test b/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test index cae39318ef8..70266c71c96 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test +++ b/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test @@ -63,9 +63,11 @@ SET NAMES utf8; --connection child2_1 SET NAMES cp932; +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; SET NAMES utf8; diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc index a4def9b3dc8..6285cf5eae4 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc +++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc @@ -78,9 +78,11 @@ sync_with_master; SET SESSION sql_log_bin= 0; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test b/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test index 2d0de344f00..39dc456bd78 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test +++ b/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test @@ -73,16 +73,22 @@ TRUNCATE TABLE mysql.general_log; set @old_spider_direct_aggregate=@@session.spider_direct_aggregate; set spider_direct_aggregate=1; SHOW STATUS LIKE 'Spider_direct_aggregate'; +--disable_view_protocol SELECT skey, count(*) cnt FROM tbl_a GROUP BY skey ORDER BY cnt DESC, skey DESC LIMIT 5; +--enable_view_protocol SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/insert_select.test b/storage/spider/mysql-test/spider/bugfix/t/insert_select.test index 77a4540c808..ee2fbc4b871 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/insert_select.test +++ b/storage/spider/mysql-test/spider/bugfix/t/insert_select.test @@ -83,9 +83,11 @@ INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FRO INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 5 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY)); --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test index bf4334bab5f..eee517e45f7 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test @@ -73,11 +73,15 @@ SELECT * FROM tbl_a WHERE pkey = 2; SELECT * FROM tbl_a; --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test index c0310d62fb9..ad9a9e348ee 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test @@ -72,7 +72,9 @@ SELECT a, b, c FROM tbl_a PARTITION (pt2,pt3); --connection child2_1 --disable_ps2_protocol +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol --enable_ps2_protocol --disable_ps_protocol eval $CHILD2_1_SELECT_TABLES; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test index 479e1006e42..1765e38500a 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test @@ -51,17 +51,23 @@ TRUNCATE TABLE mysql.general_log; --disable_ps2_protocol --connection master_1 +--disable_view_protocol SELECT id, 0 AS const, val FROM tbl_a; SELECT 1+2, id, 0 AS const, val, val+10, (SELECT tbl_a.val+1 FROM tbl_a) AS sq FROM tbl_a; +--enable_view_protocol INSERT INTO tbl_a (val) VALUES (2), (1); +--disable_view_protocol SELECT val+10, 0 AS const, val, (SELECT tbl_a.val+1 FROM tbl_a LIMIT 1) AS sq FROM tbl_a GROUP BY val; SELECT MAX(id) AS m, 0 AS const, val, (SELECT tbl_a.val+1 FROM tbl_a LIMIT 1) AS sq FROM tbl_a GROUP BY val; +--enable_view_protocol --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test index 71b4725b5ae..42cb625e465 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test @@ -83,9 +83,11 @@ SELECT STRAIGHT_JOIN b.a, b.b FROM tb_l a, tbl_a b WHERE a.a = b.a; --connection child2_1 SET NAMES utf8; +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol --disable_ps_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test index b14df3bf332..e3a0631721d 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test @@ -22,6 +22,7 @@ create table t1 (a int, b int, PRIMARY KEY (a, b)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; insert into t1 VALUES (1,4), (1,2), (2,11); SELECT MIN(b), a FROM t1 WHERE a=1; +select * from (SELECT MIN(b), a FROM t1 WHERE a=1) as v; SELECT MAX(b), a FROM t1 WHERE a<3; drop table t1, t2; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test index 6e506e9ae29..86a92a808ff 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test @@ -54,8 +54,10 @@ eval CREATE TABLE tbl_a ( --disable_ps2_protocol INSERT INTO tbl_a VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +--disable_view_protocol SELECT * FROM tbl_a WHERE greeting = "Aloha!" AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH +--enable_view_protocol # LIKE eval CREATE TABLE tbl_b ( @@ -65,8 +67,10 @@ eval CREATE TABLE tbl_b ( ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_b", srv "s_2_1"'; INSERT INTO tbl_b VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +--disable_view_protocol SELECT * FROM tbl_b WHERE greeting = "Aloha!" AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH +--enable_view_protocol # LIKE eval CREATE TABLE tbl_c ( @@ -76,11 +80,15 @@ eval CREATE TABLE tbl_c ( ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_c", srv "s_2_1"'; INSERT INTO tbl_c VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +--disable_view_protocol SELECT * FROM tbl_c WHERE greeting = "Aloha!" AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH +--enable_view_protocol --connection child2_1 +--disable_view_protocol SELECT argument FROM mysql.general_log WHERE argument LIKE 'select `id`,`greeting` from %'; +--enable_view_protocol --enable_ps2_protocol --connection child2_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test index d1813e6a236..95514ef39a5 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test @@ -31,14 +31,18 @@ eval CREATE TABLE tbl_a ( ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"'; --disable_ps_protocol +--disable_view_protocol SELECT MIN(t2.a) AS f1, t1.b AS f2 FROM tbl_a AS t1 JOIN tbl_a AS t2 GROUP BY f2 ORDER BY f1, f2; +--enable_view_protocol --enable_ps_protocol --connection master_1 DROP DATABASE IF EXISTS auto_test_local; --connection child2_1 --disable_ps_protocol +--disable_view_protocol SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %'; +--enable_view_protocol --enable_ps_protocol set global log_output=@old_log_output; set global general_log=@old_general_log; 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 3a56ae39ee7..4ddf863b2a4 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test @@ -26,10 +26,14 @@ SELECT MAX(a) FROM t1; --enable_ps_protocol SELECT SUM(a) FROM t1; SELECT COUNT(a) FROM t1; +# Spider does not create a GBH with view protocol in these cases which +# would cause extra direct aggregate counts than without view protocol +--disable_view_protocol SELECT MAX(a), SUM(a) FROM t1; SELECT COUNT(a), MAX(a), SUM(a) FROM t1; SELECT MAX(a), COUNT(a), SUM(a) FROM t1; SELECT MAX(a), MAX(COALESCE(a)) FROM t1; +--enable_view_protocol SHOW STATUS LIKE 'Spider_direct_aggregate'; DROP TABLE t, t1; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test index 02df6032887..8a7141e5248 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test @@ -25,7 +25,9 @@ INSERT INTO dst VALUES (555, '1999-12-12'); # possibly a bug, e.g. an unnecessary requirement. evalp CREATE TABLE t (c INT, d DATE, PRIMARY KEY(c)) ENGINE=SPIDER COMMENT='table "src dst", srv "s_2_1 s_1"'; +--disable_view_protocol SELECT spider_copy_tables('t', '0', '1'); +--enable_view_protocol SELECT * FROM dst; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test index ebd08edce24..294675d2f4c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test @@ -7,8 +7,10 @@ CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; +--disable_view_protocol --error ER_CANT_INITIALIZE_UDF SELECT spider_copy_tables ('t', '0', '0'); +--enable_view_protocol # spider_flush_table_mon_cache does not require spider init to function CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; @@ -21,8 +23,10 @@ install soname 'ha_spider'; SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'"); +--disable_view_protocol --error ER_KEY_NOT_FOUND SELECT spider_copy_tables ('t', '0', '0'); +--enable_view_protocol SELECT spider_flush_table_mon_cache (); diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test index 3b1dc206866..330b96db6f9 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test @@ -12,7 +12,10 @@ CREATE TABLE t1 (c INT) ENGINE=MyISAM; CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t1"'; insert into t2 values (456), (123); SELECT * FROM t2 ORDER BY CAST(c AS char(60)); +# extra warnings with view protocol +--disable_view_protocol SELECT * FROM t2 ORDER BY CAST(c AS INET6); +--enable_view_protocol SELECT * FROM t2 GROUP BY CAST(c AS char(60)); SELECT * FROM t2 GROUP BY CAST(c AS INET6); # Cleanup diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test index b50ac793762..9dc2837cacd 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test @@ -83,13 +83,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -108,13 +112,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -134,12 +142,16 @@ SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test index 0d86286aae8..1ec6f6d734e 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test @@ -84,13 +84,17 @@ explain SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -109,13 +113,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -134,13 +142,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test index 84af65f00a9..38d435ae2cf 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test @@ -83,13 +83,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -108,13 +112,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -133,13 +141,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test index 19063b63a57..2fe23dbe557 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test @@ -84,13 +84,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -109,13 +113,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -134,13 +142,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test index 280f362e302..b1b6ee7d43a 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test +++ b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test @@ -58,9 +58,11 @@ exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK - --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; TRUNCATE TABLE mysql.general_log; @@ -71,9 +73,11 @@ exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK - --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; TRUNCATE TABLE mysql.general_log; @@ -84,9 +88,11 @@ exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK - --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test index dd046fcea9a..465bee76776 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test +++ b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test @@ -60,9 +60,11 @@ exec $MYSQL -v -v -u root -h localhost --default-character-set=latin1 -P $MASTER --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test index 9864ac7b0f2..e191367cfb7 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test +++ b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test @@ -56,9 +56,11 @@ SELECT pkey FROM tbl_a WHERE NULL; --enable_ps_protocol --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test b/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test index 3713befa3fc..dfa0f56d55b 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test +++ b/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test @@ -59,7 +59,9 @@ SELECT `pkey`, LEFT(`txt_utf8`, 4) FROM `auto_test_local`.`tbl_a` ORDER BY LEFT( --connection child2_1 SET NAMES utf8; +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test index 3d4280e35e4..66e044a5a5c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test +++ b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test @@ -71,10 +71,12 @@ SET SESSION sql_log_bin= 0; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol --replace_regex /-[0-9a-f]{12}-[0-9a-f]+-/-xxxxxxxxxxxx-xxxxx-/ eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc b/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc index 22173000960..827acb7d974 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc +++ b/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc @@ -51,8 +51,10 @@ TRUNCATE TABLE mysql.general_log; SELECT * FROM tbl_a ORDER BY pkey; --connection child2_1 +--disable_view_protocol --replace_regex /-[0-9a-f]{12}-[0-9a-f]+-/-xxxxxxxxxxxx-xxxxx-/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test b/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test index 3dd9a7404d5..ed41b77335c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test +++ b/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test @@ -82,15 +82,19 @@ SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_2_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test b/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test index 4edff9ca784..5a5fffc3940 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test +++ b/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test @@ -37,7 +37,7 @@ eval CREATE TABLE tbl_a ( create temporary table results (a int); --disable_ps_protocol -SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"'); +SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') as exp; --enable_ps_protocol select * from results; diff --git a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test index 3add8d184dc..dc66aecf807 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test +++ b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test @@ -49,12 +49,14 @@ TRUNCATE TABLE mysql.general_log; --disable_ps2_protocol --connection master_1 +--disable_view_protocol SELECT * FROM tbl_a ORDER BY pkey; +--enable_view_protocol --connection child2_1 -# in --ps a query is logged differently in a general log -replace_regex /order by t0.`pkey`/order by `pkey`/; +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test b/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test index 4039bdafd14..a57c96cbb82 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test +++ b/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test @@ -51,9 +51,11 @@ XA PREPARE 'test'; XA COMMIT 'test'; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/feature/r/pushdown_case.result b/storage/spider/mysql-test/spider/feature/r/pushdown_case.result index bf373874b18..9427ab83e55 100644 --- a/storage/spider/mysql-test/spider/feature/r/pushdown_case.result +++ b/storage/spider/mysql-test/spider/feature/r/pushdown_case.result @@ -13,11 +13,11 @@ COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; 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. insert into t1 values (42), (3), (848), (100); -explain select case c when 3 then "three" when 42 then "answer" else "other" end from t1; +explain select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY -select case c when 3 then "three" when 42 then "answer" else "other" end from t1; -case c when 3 then "three" when 42 then "answer" else "other" end +select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; +exp answer three other @@ -31,11 +31,11 @@ answer three NULL NULL -explain select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; +explain select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY -select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; -case when c = 3 then "three" when c = 42 then "answer" else "other" end +select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; +exp answer three other diff --git a/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc b/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc index 1b1b31a55e6..5cc17e70ae5 100644 --- a/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc +++ b/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc @@ -76,10 +76,12 @@ send_eval $MASTER_1_CHECKSUM_TABLE; --connection child2_1_2 SELECT SLEEP(1); +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --connection child2_2_2 eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol --connection child2_1 UNLOCK TABLES; diff --git a/storage/spider/mysql-test/spider/feature/t/pushdown_case.test b/storage/spider/mysql-test/spider/feature/t/pushdown_case.test index b86edceb615..9a77183d3d5 100644 --- a/storage/spider/mysql-test/spider/feature/t/pushdown_case.test +++ b/storage/spider/mysql-test/spider/feature/t/pushdown_case.test @@ -16,7 +16,7 @@ insert into t1 values (42), (3), (848), (100); # everything let $query= -select case c when 3 then "three" when 42 then "answer" else "other" end from t1; +select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; eval explain $query; eval $query; @@ -28,7 +28,7 @@ eval $query; # no value let $query= -select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; +select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; eval explain $query; eval $query; diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test index a9b48319fc6..0962457d65c 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test +++ b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test @@ -69,7 +69,9 @@ SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; --connection child2_1 --disable_ps_protocol +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps_protocol diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test index 746ff3823e7..efb74d02b7b 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test +++ b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test @@ -69,7 +69,9 @@ SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; --connection child2_1 --disable_ps_protocol +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps_protocol diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc b/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc index ee008424ab5..2fce1890708 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc +++ b/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc @@ -69,9 +69,11 @@ eval LOAD DATA $OPTION_LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $ --remove_file $MYSQLTEST_VARDIR/tmp/spider_outfile.tsv --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test b/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test index d7db0db0e0f..0a36108df51 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test +++ b/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test @@ -73,16 +73,22 @@ TRUNCATE TABLE mysql.general_log; set @old_spider_direct_aggregate=@@session.spider_direct_aggregate; set spider_direct_aggregate=1; SHOW STATUS LIKE 'Spider_direct_aggregate'; +--disable_view_protocol SELECT skey, count(*) cnt FROM tbl_a GROUP BY skey ORDER BY cnt DESC, skey DESC LIMIT 5; +--enable_view_protocol SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc b/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc index c45f47a4f12..3bda08275c1 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc +++ b/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc @@ -86,11 +86,15 @@ eval LOAD DATA $OPTION_LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $ --disable_ps2_protocol --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/t/auto_increment.test b/storage/spider/mysql-test/spider/t/auto_increment.test index e278a12a54e..fe002edfa0b 100644 --- a/storage/spider/mysql-test/spider/t/auto_increment.test +++ b/storage/spider/mysql-test/spider/t/auto_increment.test @@ -157,7 +157,9 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT * FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -168,7 +170,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test b/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test index c6fecb5c7e0..15848cf8f35 100644 --- a/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test +++ b/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test @@ -98,9 +98,11 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_join.test b/storage/spider/mysql-test/spider/t/direct_join.test index 04f28921eb8..c2ebd03e60c 100644 --- a/storage/spider/mysql-test/spider/t/direct_join.test +++ b/storage/spider/mysql-test/spider/t/direct_join.test @@ -170,7 +170,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -321,7 +323,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_CONST_TABLE_JOIN; eval $CHILD2_1_SELECT_CONST_TABLE2_JOIN; diff --git a/storage/spider/mysql-test/spider/t/direct_join_using.test b/storage/spider/mysql-test/spider/t/direct_join_using.test index c16dbc038db..a14c0158549 100644 --- a/storage/spider/mysql-test/spider/t/direct_join_using.test +++ b/storage/spider/mysql-test/spider/t/direct_join_using.test @@ -158,7 +158,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT a.a, c.b, c.c FROM tbl_a a join tbl_b b using(a) join tbl_c c using(a) ORDER BY a.b DESC; +--enable_view_protocol if ($USE_CHILD_GROUP2) { @@ -170,7 +172,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_join.test b/storage/spider/mysql-test/spider/t/direct_left_join.test index 6db2b53ebd7..5b7087a5ce5 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_join.test +++ b/storage/spider/mysql-test/spider/t/direct_left_join.test @@ -158,7 +158,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT a.a, c.b, c.c FROM tbl_a a left join tbl_b b on a.a = b.a left join tbl_c c on a.a = c.a ORDER BY a.b DESC; +--enable_view_protocol if ($USE_CHILD_GROUP2) { @@ -170,7 +172,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test index 1dddf1f858d..7de6e6a2a4d 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test @@ -185,7 +185,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test index d124504dd69..f7f02ec9ea9 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test @@ -185,7 +185,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test index ca3fc2cf998..2e27d0a062c 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test @@ -185,7 +185,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_join.test b/storage/spider/mysql-test/spider/t/direct_right_join.test index 3431a18a395..3a4eb5183b1 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_join.test +++ b/storage/spider/mysql-test/spider/t/direct_right_join.test @@ -158,7 +158,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT a.a, c.b, c.c FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on a.a = c.a ORDER BY a.b DESC; +--enable_view_protocol if ($USE_CHILD_GROUP2) { @@ -170,7 +172,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test index 4a61f3b7cd0..0089f4df4c0 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test @@ -185,7 +185,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test index c18752cd7d3..18ae8eb1c9f 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test @@ -185,7 +185,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test index 1cdf329844a..d6354898b21 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test @@ -185,7 +185,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/ha.test b/storage/spider/mysql-test/spider/t/ha.test index 64ede980c83..dab57bcea1c 100644 --- a/storage/spider/mysql-test/spider/t/ha.test +++ b/storage/spider/mysql-test/spider/t/ha.test @@ -398,8 +398,10 @@ if ($USE_CHILD_GROUP3) eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; --disable_ps_protocol +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; --enable_ps_protocol +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/t/ha_part.test b/storage/spider/mysql-test/spider/t/ha_part.test index 4966d3d6e51..3551c59e51d 100644 --- a/storage/spider/mysql-test/spider/t/ha_part.test +++ b/storage/spider/mysql-test/spider/t/ha_part.test @@ -463,8 +463,10 @@ if ($HAVE_PARTITION) eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; --disable_ps_protocol + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; --enable_ps_protocol + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/t/partition_cond_push.test b/storage/spider/mysql-test/spider/t/partition_cond_push.test index 317026d7d57..6d96831d656 100644 --- a/storage/spider/mysql-test/spider/t/partition_cond_push.test +++ b/storage/spider/mysql-test/spider/t/partition_cond_push.test @@ -168,19 +168,25 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_3_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/partition_fulltext.test b/storage/spider/mysql-test/spider/t/partition_fulltext.test index af42e8ff4d9..5c6a7863fd8 100644 --- a/storage/spider/mysql-test/spider/t/partition_fulltext.test +++ b/storage/spider/mysql-test/spider/t/partition_fulltext.test @@ -172,19 +172,25 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_3_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test b/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test index 84ee3f2e272..0d7f4ab987e 100644 --- a/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test +++ b/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test @@ -171,19 +171,25 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_3_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/pushdown_not_like.test b/storage/spider/mysql-test/spider/t/pushdown_not_like.test index 998ce1cbf6c..7a7154069ca 100644 --- a/storage/spider/mysql-test/spider/t/pushdown_not_like.test +++ b/storage/spider/mysql-test/spider/t/pushdown_not_like.test @@ -107,13 +107,17 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol select * from ta_l where b not like 'a%'; +--enable_view_protocol if ($USE_CHILD_GROUP2) { --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select%'; + --enable_view_protocol } } --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/t/quick_mode_0.test b/storage/spider/mysql-test/spider/t/quick_mode_0.test index 37c6f939efd..33cd271b989 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_0.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_0.test @@ -139,15 +139,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -199,15 +203,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -247,6 +255,7 @@ if ($USE_CHILD_GROUP2) } } --connection master_1 +--disable_view_protocol --disable_ps2_protocol SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; if ($USE_CHILD_GROUP2) @@ -277,6 +286,7 @@ if ($USE_CHILD_GROUP2) } } --enable_ps2_protocol +--enable_view_protocol --echo --echo deinit diff --git a/storage/spider/mysql-test/spider/t/quick_mode_1.test b/storage/spider/mysql-test/spider/t/quick_mode_1.test index 8d19c8dec80..73241457418 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_1.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_1.test @@ -139,15 +139,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -199,15 +203,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -259,15 +267,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/quick_mode_2.test b/storage/spider/mysql-test/spider/t/quick_mode_2.test index cb0167d97d6..2a54b0be3fe 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_2.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_2.test @@ -139,15 +139,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -199,15 +203,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -259,15 +267,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/quick_mode_3.test b/storage/spider/mysql-test/spider/t/quick_mode_3.test index e65b1cd7247..67f0230a34f 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_3.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_3.test @@ -139,15 +139,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -199,15 +203,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -259,15 +267,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/slave_trx_isolation.test b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test index a3a3fad8677..b88d038de46 100644 --- a/storage/spider/mysql-test/spider/t/slave_trx_isolation.test +++ b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test @@ -109,8 +109,10 @@ if ($USE_CHILD_GROUP2) --disable_ps2_protocol if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /-[0-9a-f]{12}-[0-9a-f]+-/-xxxxxxxxxxxx-xxxxx-/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } --enable_ps2_protocol eval $CHILD2_1_SELECT_TABLES; diff --git a/storage/spider/mysql-test/spider/t/timestamp.test b/storage/spider/mysql-test/spider/t/timestamp.test index a76ea2e1f9b..a7d6ce0ae05 100644 --- a/storage/spider/mysql-test/spider/t/timestamp.test +++ b/storage/spider/mysql-test/spider/t/timestamp.test @@ -174,7 +174,9 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -185,7 +187,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -219,7 +223,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 DELETE FROM tbl_a WHERE col_ts='1970-01-01 01:00:01'; --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -230,7 +236,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -263,7 +271,9 @@ SET @@timestamp=1; INSERT INTO tbl_a VALUES (1, now(), now()); SET @@timestamp=0; --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -274,7 +284,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -308,7 +320,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 UPDATE tbl_a SET col_ts=col_dt; --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -319,7 +333,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -352,6 +368,7 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > '2018-01-01'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts < '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE '2018-10-28 02:30:00' > col_ts; @@ -359,6 +376,7 @@ SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts BETWEEN '2018-10-28 01: SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts >= '2018-10-28 01:30:00' AND col_ts <= '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 180325020000; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 19700101010001; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -369,7 +387,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -434,6 +454,7 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > '2018-01-01'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts < '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE '2018-10-28 02:30:00' > col_ts; @@ -441,6 +462,7 @@ SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts BETWEEN '2018-10-28 01: SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts >= '2018-10-28 01:30:00' AND col_ts <= '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 180325020000; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 19700101010001; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -451,7 +473,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -488,11 +512,13 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT * FROM tbl_f; SELECT TIMESTAMP(col_d, col_t) FROM tbl_f; SELECT TIMESTAMP('2018-06-25', col_t) FROM tbl_f; SELECT TIMESTAMP(col_d, '10:43:21') FROM tbl_f; SELECT TIMESTAMP('2018-06-25', '10:43:21') FROM tbl_f; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -503,7 +529,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE_F; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/udf_pushdown.inc b/storage/spider/mysql-test/spider/t/udf_pushdown.inc index df9742a35b8..16f85dfffcd 100644 --- a/storage/spider/mysql-test/spider/t/udf_pushdown.inc +++ b/storage/spider/mysql-test/spider/t/udf_pushdown.inc @@ -2,14 +2,18 @@ --echo ##### test SELECTs ##### --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT * FROM ta_l WHERE id = plusone(1); SELECT * FROM ta_l WHERE id IN (plusone(1), plusone(2)) AND a = plusone(32); +--enable_view_protocol --enable_ps2_protocol if ($USE_CHILD_GROUP2) { --connection child2_1 + --disable_view_protocol SELECT argument FROM mysql.general_log WHERE argument LIKE "%select%" AND argument NOT LIKE "%argument%"; + --enable_view_protocol --disable_query_log TRUNCATE TABLE mysql.general_log; --enable_query_log diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 985e30de49d..71f48949743 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -3039,6 +3039,10 @@ int spider_db_store_result( db_conn = conn->db_conn; if (!result_list->current) { + /* + Point ->current and ->bgs_current to ->first (create ->first + if needed) + */ if (!result_list->first) { if (!(result_list->first = (SPIDER_RESULT *) @@ -3063,11 +3067,15 @@ int spider_db_store_result( } result_list->bgs_current = result_list->current; current = (SPIDER_RESULT*) result_list->current; - } else { + } else { /* result_list->current != NULL */ if ( result_list->bgs_phase > 0 || result_list->quick_phase > 0 ) { + /* + Advance bgs_current to the next result. Create a new result + if needed + */ if (result_list->bgs_current == result_list->last) { if (!(result_list->last = (SPIDER_RESULT *) @@ -3110,6 +3118,10 @@ int spider_db_store_result( } current = (SPIDER_RESULT*) result_list->bgs_current; } else { + /* + Advance current to the next result. Create a new result if + needed + */ if (result_list->current == result_list->last) { if (!(result_list->last = (SPIDER_RESULT *) diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index fa2f59b9af8..19cb0646a40 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -1695,7 +1695,7 @@ typedef struct st_spider_result st_spider_result *next; SPIDER_POSITION *first_position; /* for quick mode */ int pos_page_size; /* for quick mode */ - longlong record_num; + longlong record_num; /* number of rows */ bool finish_flg; bool use_position; bool first_pos_use_position; @@ -1738,7 +1738,7 @@ typedef struct st_spider_result_list bool sorted; bool desc_flg; longlong current_row_num; - longlong record_num; + longlong record_num; /* number of rows */ bool finish_flg; longlong limit_num; longlong internal_offset; diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 4483a5ddf68..423f493262e 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1547,6 +1547,16 @@ group_by_handler *spider_create_group_by_handler( DBUG_PRINT("info",("spider select item=%p", item)); if (item->const_item()) { + /* + Do not create the GBH when a derived table or view is + involved + */ + if (thd->derived_tables != NULL) + { + keep_going= FALSE; + break; + } + /* Do not handle the complex case where there's a const item in the auxiliary fields. It is too unlikely (if at all) to diff --git a/strings/json_lib.c b/strings/json_lib.c index e1203296f6d..4fc8625d668 100644 --- a/strings/json_lib.c +++ b/strings/json_lib.c @@ -1656,15 +1656,7 @@ int json_unescape(CHARSET_INFO *json_cs, } if (c_len == MY_CS_ILUNI) { - /* - Result charset doesn't support the json's character. - Let's replace it with the '?' symbol. - */ - if ((c_len= my_ci_wc_mb(res_cs, '?', res, res_end)) > 0) - { - res+= c_len; - continue; - } + return -1; } /* Result buffer is too small. */ return -1; diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index efd4e5d8cd9..547fc1732fa 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -51,11 +51,6 @@ Group=mysql # These are enabled by default AmbientCapabilities=CAP_IPC_LOCK -# CAP_DAC_OVERRIDE To allow auth_pam_tool (which is SUID root) to read /etc/shadow when it's chmod 0 -# does nothing for non-root, not needed if /etc/shadow is u+r -# CAP_AUDIT_WRITE auth_pam_tool needs it on Debian for whatever reason -CapabilityBoundingSet=CAP_DAC_OVERRIDE CAP_AUDIT_WRITE - # PrivateDevices=true implies NoNewPrivileges=true and # SUID auth_pam_tool suddenly doesn't do setuid anymore PrivateDevices=false diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index 8fda6acbd1a..40d87817c10 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -181,11 +181,6 @@ PrivateNetwork=false # These are enabled by default AmbientCapabilities=CAP_IPC_LOCK -# CAP_DAC_OVERRIDE To allow auth_pam_tool (which is SUID root) to read /etc/shadow when it's chmod 0 -# does nothing for non-root, not needed if /etc/shadow is u+r -# CAP_AUDIT_WRITE auth_pam_tool needs it on Debian for whatever reason -CapabilityBoundingSet=CAP_DAC_OVERRIDE CAP_AUDIT_WRITE - # PrivateDevices=true implies NoNewPrivileges=true and # SUID auth_pam_tool suddenly doesn't do setuid anymore PrivateDevices=false diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index 9f0faf85021..1c71ac8844b 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -1442,7 +1442,9 @@ int main(int argc, char **argv) this limited check is enough, if sizeof(MYSQL) changes, it changes everywhere */ -#if defined __x86_64__ +#if defined _M_AMD64 + compile_time_assert(sizeof(MYSQL) == 1208); +#elif defined __x86_64__ compile_time_assert(sizeof(MYSQL) == 1272); #elif defined __i386__ compile_time_assert(sizeof(MYSQL) == 964); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index a20ef154d80..9ffeaa07b19 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -22629,6 +22629,164 @@ static void test_mdev_34958() rc= mysql_query(mysql, "DROP TABLE t1, t2"); myquery(rc); } + +/* Server crash when inserting from derived table containing insert target table */ +static void test_mdev_32086() +{ + int rc; + MYSQL_STMT *stmt_insert; + MYSQL_BIND bind[2]; + MYSQL_RES *result; + MYSQL_ROW row; + unsigned int vals[] = { 123, 124}; + unsigned int vals_array_len = 2; + const char *insert_stmt= "\ +insert into t1 values(\ + (select 101+count(*)\ + from\ + (\ + select dt2.id\ + from (select id from t1) dt2, t1 t where t.id=dt2.id\ + ) dt\ + where dt.id<1000\ + ), ?\ +)"; + + /* Set up test's environment */ + + + rc= mysql_query(mysql, "create table t1 (pk int, id int);"); + myquery(rc); + + rc= mysql_query(mysql, "insert into t1 values (2,2), (3,3), (4,4);"); + myquery(rc); + + stmt_insert = mysql_stmt_init(mysql); + if (!stmt_insert) + { + fprintf(stderr, "mysql_stmt_init failed: Error: %s\n", + mysql_error(mysql)); + exit(1); + } + + rc= mysql_stmt_prepare(stmt_insert, insert_stmt, strlen(insert_stmt)); + if (rc) + { + fprintf(stderr, "mysql_stmt_prepare failed: %s\n", + mysql_stmt_error(stmt_insert)); + exit(1); + } + + memset(&bind[0], 0, sizeof(MYSQL_BIND)); + + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= vals; + + rc= mysql_stmt_attr_set(stmt_insert, STMT_ATTR_ARRAY_SIZE, &vals_array_len); + if (rc) + { + fprintf(stderr, "mysql_stmt_prepare failed: %s\n", + mysql_stmt_error(stmt_insert)); + exit(1); + } + + rc= mysql_stmt_bind_param(stmt_insert, bind); + if (rc) + { + fprintf(stderr, "mysql_stmt_bind_param failed: %s\n", + mysql_stmt_error(stmt_insert)); + exit(1); + } + + rc= mysql_stmt_execute(stmt_insert); + if (rc) + { + fprintf(stderr, "mysql_stmt_execute failed: %s\n", + mysql_stmt_error(stmt_insert)); + exit(1); + } + + /* + pk id + 2 2 + 3 3 + 4 4 + 104 123 + 104 124 + */ + rc= mysql_query(mysql, "select * from t1"); + if (rc) + { + fprintf(stderr, "Query failed: %s\n", mysql_error(mysql)); + } + result= mysql_store_result(mysql); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 2 && atoi(row[1]) == 2); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 3 && atoi(row[1]) == 3); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 4 && atoi(row[1]) == 4); + row= mysql_fetch_row(result); + printf("\n %d, %d \n", atoi(row[0]), atoi(row[1])); + DIE_UNLESS(atoi(row[0]) == 104 && atoi(row[1]) == 123); + row= mysql_fetch_row(result); + printf("\n %d, %d \n", atoi(row[0]), atoi(row[1])); + DIE_UNLESS(atoi(row[0]) == 104 && atoi(row[1]) == 124); + row= mysql_fetch_row(result); + DIE_UNLESS(row == NULL); + + mysql_free_result(result); + + rc= mysql_stmt_execute(stmt_insert); + if (rc) + { + fprintf(stderr, "mysql_stmt_execute failed: %s\n", + mysql_stmt_error(stmt_insert)); + exit(1); + } + /* + pk id + 2 2 + 3 3 + 4 4 + 104 123 + 104 124 + 106 123 + 106 124 + */ + rc= mysql_query(mysql, "select * from t1"); + if (rc) + { + fprintf(stderr, "Query failed: %s\n", mysql_error(mysql)); + } + result= mysql_store_result(mysql); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 2 && atoi(row[1]) == 2); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 3 && atoi(row[1]) == 3); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 4 && atoi(row[1]) == 4); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 104 && atoi(row[1]) == 123); + row= mysql_fetch_row(result); + DIE_UNLESS(atoi(row[0]) == 104 && atoi(row[1]) == 124); + row= mysql_fetch_row(result); + printf("\n %d, %d \n", atoi(row[0]), atoi(row[1])); + DIE_UNLESS(atoi(row[0]) == 106 && atoi(row[1]) == 123); + row= mysql_fetch_row(result); + printf("\n %d, %d \n", atoi(row[0]), atoi(row[1])); + DIE_UNLESS(atoi(row[0]) == 106 && atoi(row[1]) == 124); + row= mysql_fetch_row(result); + DIE_UNLESS(row == NULL); + + mysql_free_result(result); + + mysql_stmt_close(stmt_insert); + + /* Clean up */ + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); +} #endif // EMBEDDED_LIBRARY /* @@ -23254,6 +23412,7 @@ static struct my_tests_st my_tests[]= { { "test_mdev_34718_bd", test_mdev_34718_bd }, { "test_mdev_34718_ad", test_mdev_34718_ad }, { "test_mdev_34958", test_mdev_34958 }, + { "test_mdev_32086", test_mdev_32086 }, #endif { "test_mdev_10075", test_mdev_10075}, { "test_mdev35953", test_mdev35953 }, diff --git a/tpool/aio_liburing.cc b/tpool/aio_liburing.cc index 447c2335c74..acc1c6174e2 100644 --- a/tpool/aio_liburing.cc +++ b/tpool/aio_liburing.cc @@ -34,9 +34,9 @@ class aio_uring final : public tpool::aio public: aio_uring(tpool::thread_pool *tpool, int max_aio) : tpool_(tpool) { - if (io_uring_queue_init(max_aio, &uring_, 0) != 0) + if (const auto e= io_uring_queue_init(max_aio, &uring_, 0)) { - switch (const auto e= errno) { + switch (-e) { case ENOMEM: my_printf_error(ER_UNKNOWN_ERROR, "io_uring_queue_init() failed with ENOMEM:" @@ -57,6 +57,12 @@ public: "(newer than 5.1 required)", ME_ERROR_LOG | ME_WARNING); break; + case EPERM: + my_printf_error(ER_UNKNOWN_ERROR, + "io_uring_queue_init() failed with EPERM:" + " sysctl kernel.io_uring_disabled has the value 2, or 1 and the user of the process is not a member of sysctl kernel.io_uring_group. (see man 2 io_uring_setup).", + ME_ERROR_LOG | ME_WARNING); + break; default: my_printf_error(ER_UNKNOWN_ERROR, "io_uring_queue_init() failed with errno %d", diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc index c86fcf277cf..8d7e6a754bc 100644 --- a/tpool/tpool_generic.cc +++ b/tpool/tpool_generic.cc @@ -218,7 +218,6 @@ class thread_pool_generic : public thread_pool /** Overall number of enqueues*/ unsigned long long m_tasks_enqueued; - unsigned long long m_group_enqueued; /** Overall number of dequeued tasks. */ unsigned long long m_tasks_dequeued; diff --git a/win/packaging/ca/CMakeLists.txt b/win/packaging/ca/CMakeLists.txt index 368a844f830..652b76de11f 100644 --- a/win/packaging/ca/CMakeLists.txt +++ b/win/packaging/ca/CMakeLists.txt @@ -18,7 +18,8 @@ SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_CURRENT_SOURCE_DIR} ${WIX_INCLUDE_DIR}) # Custom action should not depend on C runtime, since we do not know if CRT is installed. -FORCE_STATIC_CRT() ADD_VERSION_INFO(wixca SHARED WIXCA_SOURCES) ADD_LIBRARY(wixca SHARED EXCLUDE_FROM_ALL ${WIXCA_SOURCES} ${CMAKE_SOURCE_DIR}/sql/winservice.c) -TARGET_LINK_LIBRARIES(wixca ${WIX_WCAUTIL_LIBRARY} ${WIX_DUTIL_LIBRARY} msi version) +# Static linking with CRT, because it is called when MSVC libraries are not yet there, +SET_TARGET_PROPERTIES(wixca PROPERTIES MSVC_RUNTIME_LIBRARY MultiThreaded) +TARGET_LINK_LIBRARIES(wixca ${WIX_WCAUTIL_LIBRARY} ${WIX_DUTIL_LIBRARY} msi version ws2_32) diff --git a/win/upgrade_wizard/CMakeLists.txt b/win/upgrade_wizard/CMakeLists.txt index fd3560e1ee6..d849550e505 100644 --- a/win/upgrade_wizard/CMakeLists.txt +++ b/win/upgrade_wizard/CMakeLists.txt @@ -4,7 +4,6 @@ ENDIF() # We need MFC # /permissive- flag does not play well with MFC, disable it. -STRING(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") REMOVE_DEFINITIONS(-DNOSERVICE) # fixes "already defined" warning in an AFX header FIND_PACKAGE(MFC) @@ -17,31 +16,22 @@ IF(NOT MFC_FOUND) RETURN() ENDIF() -IF(MSVC_CRT_TYPE MATCHES "/MD") - # FORCE static CRT and MFC for upgrade wizard, - # so we do not have to redistribute MFC. - FORCE_STATIC_CRT() - SET(UPGRADE_WIZARD_SOURCES ${CMAKE_SOURCE_DIR}/sql/winservice.c) -ELSE() - SET(UPGRADE_WIZARD_LINK_LIBRARIES winservice) -ENDIF() - # MFC should be statically linked SET(CMAKE_MFC_FLAG 1) # Enable exception handling (avoids warnings) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -DNO_WARN_MBCS_MFC_DEPRECATION") - +ADD_DEFINITIONS(-DNO_WARN_MBCS_MFC_DEPRECATION) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql) MYSQL_ADD_EXECUTABLE(mariadb-upgrade-wizard - upgrade.cpp upgradeDlg.cpp upgrade.rc ${UPGRADE_WIZARD_SOURCES} + upgrade.cpp upgradeDlg.cpp + ${CMAKE_SOURCE_DIR}/sql/winservice.c + upgrade.rc COMPONENT Server) - -TARGET_LINK_LIBRARIES(mariadb-upgrade-wizard ${UPGRADE_WIZARD_LINK_LIBRARIES}) # upgrade_wizard is Windows executable, set WIN32_EXECUTABLE so it does not # create a console. SET_TARGET_PROPERTIES(mariadb-upgrade-wizard PROPERTIES WIN32_EXECUTABLE 1 LINK_FLAGS "/MANIFESTUAC:level='requireAdministrator'" + MSVC_RUNTIME_LIBRARY MultiThreaded ) diff --git a/wsrep-lib b/wsrep-lib index 70cd967f5e2..e55f01ce1ee 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit 70cd967f5e249b53d6cce90e2e4198641c564381 +Subproject commit e55f01ce1eed02e0781bc53bb23456c936667ccf