1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-24 19:42:23 +03:00

Merge remote-tracking branch 'github/bb-11.4-release' into bb-11.8-serg

This commit is contained in:
Sergei Golubchik
2025-04-27 11:33:27 +02:00
committed by Oleksandr Byelkin
430 changed files with 14769 additions and 6751 deletions

View File

@ -31,7 +31,7 @@ ENDIF()
# in RPM's: # in RPM's:
#set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true") #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}) IF(POLICY ${p})
CMAKE_POLICY(SET ${p} NEW) CMAKE_POLICY(SET ${p} NEW)
ENDIF() ENDIF()
@ -119,6 +119,18 @@ ENDIF()
FIND_PACKAGE(Git) FIND_PACKAGE(Git)
IF(WIN32 AND (CMAKE_VERSION VERSION_GREATER "3.21"))
# Install runtime dependency by default, when using vcpkg
IF(NOT DEFINED INSTALL_RUNTIME_DEPENDENCIES_DEFAULT)
IF("${VCPKG_INSTALLED_DIR}")
SET(INSTALL_RUNTIME_DEPENDENCIES_DEFAULT OFF)
ELSE()
SET(INSTALL_RUNTIME_DEPENDENCIES_DEFAULT ON)
ENDIF()
ENDIF()
OPTION(INSTALL_RUNTIME_DEPENDENCIES "Install runtime dependencies" "${INSTALL_RUNTIME_DEPENDENCIES_DEFAULT}")
ENDIF()
# Following autotools tradition, add preprocessor definitions # Following autotools tradition, add preprocessor definitions
# specified in environment variable CPPFLAGS # specified in environment variable CPPFLAGS
IF(DEFINED ENV{CPPFLAGS}) IF(DEFINED ENV{CPPFLAGS})

View File

@ -1,6 +1,42 @@
version: build-{build}~branch-{branch} 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: environment:
OPENSSL_ROOT_DIR: C:/OpenSSL-v32-Win64 OPENSSL_ROOT_DIR: C:/OpenSSL-v32-Win64

View File

@ -160,9 +160,15 @@ static Server_gtid_event_filter *server_id_gtid_filter= NULL;
static char *start_datetime_str, *stop_datetime_str; static char *start_datetime_str, *stop_datetime_str;
static my_time_t start_datetime= 0, stop_datetime= 0; static my_time_t start_datetime= 0, stop_datetime= 0;
static my_time_t last_processed_datetime= MY_TIME_T_MAX;
static bool stop_datetime_given= false; static bool stop_datetime_given= false;
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 ulonglong rec_count= 0;
static MYSQL* mysql = NULL; static MYSQL* mysql = NULL;
static const char* dirname_for_local_load= 0; static const char* dirname_for_local_load= 0;
@ -1369,7 +1375,19 @@ err:
end: end:
rec_count++; rec_count++;
end_skip_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")); DBUG_PRINT("info", ("end event processing"));
/* /*
@ -2660,6 +2678,9 @@ static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info,
if (old_off != BIN_LOG_HEADER_SIZE) if (old_off != BIN_LOG_HEADER_SIZE)
*len= 1; // fake event, don't increment old_off *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); Exit_status retval= process_event(print_event_info, ev, old_off, logname);
if (retval != OK_CONTINUE) if (retval != OK_CONTINUE)
DBUG_RETURN(retval); DBUG_RETURN(retval);
@ -3034,6 +3055,8 @@ static Exit_status check_header(IO_CACHE* file,
the new one, so we should not do it ourselves in this the new one, so we should not do it ourselves in this
case. case.
*/ */
DBUG_ASSERT(tmp_pos + new_description_event->data_written ==
my_b_tell(file));
Exit_status retval= process_event(print_event_info, Exit_status retval= process_event(print_event_info,
new_description_event, tmp_pos, new_description_event, tmp_pos,
logname); logname);
@ -3187,20 +3210,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 // 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; 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)) != if ((retval= process_event(print_event_info, ev, old_off, logname)) !=
OK_CONTINUE) OK_CONTINUE)
goto end; goto end;
@ -3379,9 +3399,17 @@ int main(int argc, char** argv)
start_position= BIN_LOG_HEADER_SIZE; start_position= BIN_LOG_HEADER_SIZE;
} }
if (stop_datetime_given && stop_datetime > last_processed_datetime) /*
Emit a warning if we finished processing input before reaching the stop
boundaries indicated by --stop-datetime or --stop-position.
*/
if (stop_datetime_given && stop_datetime > last_processed_ev.datetime)
warning("Did not reach stop datetime '%s' before end of input", warning("Did not reach stop datetime '%s' before end of input",
stop_datetime_str); stop_datetime_str);
if ((static_cast<longlong>(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 If enable flashback, need to print the events from the end to the

View File

@ -264,7 +264,7 @@ IF(WITH_WSREP)
"galera-4" "rsync" "grep" "gawk" "iproute" "galera-4" "rsync" "grep" "gawk" "iproute"
"coreutils" "findutils" "tar") "coreutils" "findutils" "tar")
SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof" "socat" "pv") 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() ENDIF()
SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh) SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)
@ -311,7 +311,7 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7")
ALTERNATIVE_NAME("server" "mariadb-server") ALTERNATIVE_NAME("server" "mariadb-server")
ALTERNATIVE_NAME("server" "mysql-compat-server") ALTERNATIVE_NAME("server" "mysql-compat-server")
ALTERNATIVE_NAME("test" "mariadb-test") ALTERNATIVE_NAME("test" "mariadb-test")
ELSEIF(RPM MATCHES "(rhel|centos|rocky)[89]") ELSEIF(RPM MATCHES "(rhel|centos|rocky)")
SET(epoch 3:) SET(epoch 3:)
ALTERNATIVE_NAME("backup" "mariadb-backup") ALTERNATIVE_NAME("backup" "mariadb-backup")
ALTERNATIVE_NAME("client" "mariadb") ALTERNATIVE_NAME("client" "mariadb")
@ -343,53 +343,6 @@ ENDIF()
SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang") SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang")
# If we want to build build MariaDB-shared-compat,
# extract compat libraries from MariaDB-shared-5.3 rpm
FILE(GLOB compat53 RELATIVE ${CMAKE_SOURCE_DIR}
"${CMAKE_SOURCE_DIR}/../MariaDB-shared-5.3.*.rpm")
FILE(GLOB compat101 RELATIVE ${CMAKE_SOURCE_DIR}
"${CMAKE_SOURCE_DIR}/../MariaDB-shared-10.1.*.rpm")
IF(compat53 AND compat101)
FOREACH(compat_rpm "${compat53}" "${compat101}")
MESSAGE(STATUS "Using ${compat_rpm} to build MariaDB-compat")
INSTALL(CODE "EXECUTE_PROCESS(
COMMAND rpm2cpio ${CMAKE_SOURCE_DIR}/${compat_rpm}
COMMAND cpio --extract --make-directories */libmysqlclient*.so.* -
WORKING_DIRECTORY \$ENV{DESTDIR})
EXECUTE_PROCESS(
COMMAND chmod -R a+rX .
WORKING_DIRECTORY \$ENV{DESTDIR})"
COMPONENT Compat)
ENDFOREACH()
EXECUTE_PROCESS(
COMMAND rpm -q --provides -p "${CMAKE_SOURCE_DIR}/${compat101}"
ERROR_QUIET
OUTPUT_VARIABLE compat_provides)
EXECUTE_PROCESS(
COMMAND rpm -q --obsoletes -p "${CMAKE_SOURCE_DIR}/${compat101}"
ERROR_QUIET
OUTPUT_VARIABLE compat_obsoletes)
STRING(REPLACE "\n" " " compat_provides "${compat_provides}")
STRING(REPLACE "\n" " " compat_obsoletes "${compat_obsoletes}")
STRING(REGEX REPLACE "[^ ]+\\([^ ]+ *" "" compat_obsoletes "${compat_obsoletes}")
SETA(CPACK_RPM_compat_PACKAGE_PROVIDES "${compat_provides}")
SETA(CPACK_RPM_compat_PACKAGE_OBSOLETES "${compat_obsoletes}")
SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} Compat)
# RHEL6/CentOS6 install Postfix by default, and it requires
# libmysqlclient.so.16 that pulls in mysql-libs-5.1.x
# And the latter conflicts with our rpms.
# Make sure that for these distributions all our rpms require
# MariaDB-compat, that will replace mysql-libs-5.1
IF(RPM MATCHES "(rhel|centos)[67]")
SET(CPACK_RPM_common_PACKAGE_REQUIRES "MariaDB-compat")
SET(CPACK_RPM_compat_PACKAGE_CONFLICTS "mariadb-libs < 1:10.1.0")
ENDIF()
ENDIF()
################ ################
IF(CMAKE_VERSION VERSION_GREATER "3.9.99") IF(CMAKE_VERSION VERSION_GREATER "3.9.99")

View File

@ -199,7 +199,7 @@ FUNCTION(SIGN_TARGET target)
ENDFUNCTION() ENDFUNCTION()
# Installs targets, also installs pdbs on Windows. # Installs targets, also installs pdbs on Windows.
# # Also installs runtime dependencies
# #
FUNCTION(MYSQL_INSTALL_TARGETS) FUNCTION(MYSQL_INSTALL_TARGETS)
@ -230,9 +230,34 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP}) IF(WIN32 AND INSTALL_RUNTIME_DEPENDENCIES)
STRING(JOIN "." runtime_deps_set_name ${TARGETS})
SET(RUNTIME_DEPS RUNTIME_DEPENDENCY_SET "${runtime_deps_set_name}")
ENDIF()
INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP} ${RUNTIME_DEPS})
INSTALL_DEBUG_SYMBOLS(${TARGETS} ${COMP} INSTALL_LOCATION ${ARG_DESTINATION}) INSTALL_DEBUG_SYMBOLS(${TARGETS} ${COMP} INSTALL_LOCATION ${ARG_DESTINATION})
IF(WIN32 AND INSTALL_RUNTIME_DEPENDENCIES)
INSTALL(
RUNTIME_DEPENDENCY_SET
"${runtime_deps_set_name}"
COMPONENT RuntimeDeps
DESTINATION ${INSTALL_BINDIR}
PRE_EXCLUDE_REGEXES
"api-ms-" # Windows stuff
"ext-ms-"
"server\\.dll" # main server DLL, installed separately
"clang_rt" # ASAN libraries
"vcruntime"
POST_EXCLUDE_REGEXES
".*system32/.*\\.dll" # Windows stuff
POST_INCLUDE_REGEXES
DIRECTORIES
${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin
$<$<CONFIG:Debug>:${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin>
)
ENDIF()
ENDFUNCTION() ENDFUNCTION()
# Optionally install mysqld/client/embedded from debug build run. outside of the current build dir # Optionally install mysqld/client/embedded from debug build run. outside of the current build dir

View File

@ -15,8 +15,8 @@ MACRO(BUNDLE_LIBFMT)
ExternalProject_Add( ExternalProject_Add(
libfmt libfmt
PREFIX "${dir}" PREFIX "${dir}"
URL "https://github.com/fmtlib/fmt/releases/download/11.0.2/fmt-11.0.2.zip" URL "https://github.com/fmtlib/fmt/releases/download/11.1.4/fmt-11.1.4.zip"
URL_MD5 c622dca45ec3fc95254c48370a9f7a1d URL_MD5 ad6a56b15cddf4aad2a234e7cfc9e8c9
INSTALL_COMMAND "" INSTALL_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""

View File

@ -48,9 +48,9 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
ENDIF() ENDIF()
IF (ARG_WIN32) IF (ARG_WIN32)
SET(WIN32 WIN32) SET(ARG_WIN32 WIN32)
ELSE() ELSE()
UNSET(WIN32) UNSET(ARG_WIN32)
ENDIF() ENDIF()
IF (ARG_MACOSX_BUNDLE) IF (ARG_MACOSX_BUNDLE)
SET(MACOSX_BUNDLE MACOSX_BUNDLE) SET(MACOSX_BUNDLE MACOSX_BUNDLE)
@ -63,7 +63,7 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
UNSET(EXCLUDE_FROM_ALL) UNSET(EXCLUDE_FROM_ALL)
ENDIF() ENDIF()
ADD_EXECUTABLE(${target} ${WIN32} ${MACOSX_BUNDLE} ${EXCLUDE_FROM_ALL} ${sources}) ADD_EXECUTABLE(${target} ${ARG_WIN32} ${MACOSX_BUNDLE} ${EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install # tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL) IF(NOT ARG_EXCLUDE_FROM_ALL)

View File

@ -15,372 +15,212 @@
# This file includes Windows specific hacks, mostly around compiler flags # 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(MSVC)
IF(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL ARM64) if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL ARM64)
SET(MSVC_ARM64 1) set(MSVC_ARM64 1)
SET(MSVC_INTEL 0) set(MSVC_INTEL 0)
ELSE() else()
SET(MSVC_INTEL 1) set(MSVC_INTEL 1)
ENDIF() endif()
ENDIF() if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(CLANG_CL TRUE)
endif()
endif()
# avoid running system checks by using pre-cached check results # 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 # system checks are expensive on VS since every tiny program is to be compiled in
# a VC solution. # a VC solution.
GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) get_filename_component(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake) include(${_SCRIPT_DIR}/WindowsCache.cmake)
# OS display name (version_compile_os etc). # OS display name (version_compile_os etc).
# Used by the test suite to ignore bugs on some platforms, # Used by the test suite to ignore bugs on some platforms
IF(CMAKE_SIZEOF_VOID_P MATCHES 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(SYSTEM_TYPE "Win64") set(SYSTEM_TYPE "Win64")
ELSE() else()
SET(SYSTEM_TYPE "Win32") set(SYSTEM_TYPE "Win32")
ENDIF() endif()
# Intel compiler is almost Visual C++ function(find_asan_runtime result_list)
# (same compile flags etc). Set MSVC flag set(${result_list} "" PARENT_SCOPE)
IF(CMAKE_C_COMPILER MATCHES "icl") if(CMAKE_C_COMPILER_VERSION)
SET(MSVC TRUE) set(CLANG_VERSION "${CMAKE_C_COMPILER_VERSION}")
ENDIF() else()
return()
endif()
IF(MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang) get_filename_component(CLANG_BIN_DIR "${CMAKE_C_COMPILER}" DIRECTORY)
SET(CLANG_CL TRUE) get_filename_component(LLVM_ROOT "${CLANG_BIN_DIR}" DIRECTORY)
ENDIF()
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) # Determine target architecture
ADD_DEFINITIONS(-D_WIN32_WINNT=0x0A00) execute_process(
# We do not want the windows.h , or winsvc.h macros min/max COMMAND "${CMAKE_C_COMPILER}" --version
ADD_DEFINITIONS(-DNOMINMAX -DNOSERVICE) OUTPUT_VARIABLE CLANG_VERSION_OUTPUT
# Speed up build process excluding unused header files OUTPUT_STRIP_TRAILING_WHITESPACE
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN) ERROR_QUIET
# 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)"
) )
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 if(CLANG_VERSION_OUTPUT MATCHES "x86_64")
# variable for our MSVC_CRT_TYPE. set(ARCH_SUFFIX "x86_64")
# Set CMAKE_MSVC_RUNTIME_LIBRARY and pass to external projects elseif(CLANG_VERSION_OUTPUT MATCHES "i686|i386")
# it is important to keep the same CRT type when linking set(ARCH_SUFFIX "i386")
# elseif(CLANG_VERSION_OUTPUT MATCHES "aarch64")
# Translation rules MSVC_CRT_TYPE -> CMAKE_MSVC_RUNTIME_LIBRARY set(ARCH_SUFFIX "aarch64")
# /MT -> MultiThreaded else()
# /MTd -> MultiThreadedDebug message(FATAL_ERROR "unknown arch")
# /MD -> MultiThreadedDLL endif()
# /MDd -> MultiThreadedDebugDLL
SET(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) string(REGEX MATCH "^[0-9]+" CLANG_MAJOR_VERSION "${CMAKE_C_COMPILER_VERSION}")
IF(MSVC_CRT_TYPE MATCHES "d$") set(CLANG_VERSION_DIR "${LLVM_ROOT}/lib/clang/${CLANG_MAJOR_VERSION}")
STRING(APPEND CMAKE_MSVC_RUNTIME_LIBRARY Debug)
ENDIF()
IF(MSVC_CRT_TYPE MATCHES "D")
STRING(APPEND CMAKE_MSVC_RUNTIME_LIBRARY DLL)
ENDIF()
IF(MSVC_CRT_TYPE MATCHES "/MD") set(out)
# Dynamic runtime (DLLs), need to install CRT libraries. foreach(name clang_rt.asan_dynamic-${ARCH_SUFFIX}.lib
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT VCCRT) clang_rt.asan_dynamic_runtime_thunk-${ARCH_SUFFIX}.lib)
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS TRUE) set(path "${CLANG_VERSION_DIR}/lib/windows/${name}")
IF(MSVC_CRT_TYPE STREQUAL "/MDd") if(EXISTS "${path}")
SET (CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE) list(APPEND out ${path})
ENDIF() else()
INCLUDE(InstallRequiredSystemLibraries) message(FATAL_ERROR "expected library ${path} not found")
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 ")
ENDIF() ENDIF()
STRING(APPEND CMAKE_C_FLAGS " ${CLANG_CL_FLAGS} ${MSVC_CRT_TYPE}") endforeach()
STRING(APPEND CMAKE_CXX_FLAGS " ${CLANG_CL_FLAGS} ${MSVC_CRT_TYPE}") set(${result_list} ${out} PARENT_SCOPE)
ENDIF() endfunction()
FOREACH(type EXE SHARED MODULE) macro(enable_sanitizers)
STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}") # Remove the runtime checks from the compiler flags
IF(WITH_ASAN) # ASAN does the same thing, in many cases better
SET(build_types RELWITHDEBINFO DEBUG) foreach(lang C CXX)
ELSE() foreach(suffix "_DEBUG" "_DEBUG_INIT")
SET(build_types RELWITHDEBINFO) string(REGEX REPLACE "/RTC[1su]" "" CMAKE_${lang}_FLAGS${suffix} "${CMAKE_${lang}_FLAGS${suffix}}")
ENDIF() endforeach()
FOREACH(btype ${build_types}) endforeach()
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}}") if(WITH_ASAN)
ENDFOREACH() add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/fsanitize=address>)
IF(NOT CLANG_CL) endif()
STRING(APPEND CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO " /release /OPT:REF,ICF") if(WITH_UBSAN)
ENDIF() include(CheckCCompilerFlag)
IF(DYNAMIC_UCRT_LINK AND (MSVC_CRT_TYPE STREQUAL "/MT")) check_c_compiler_flag(/fsanitize=undefined HAVE_fsanitize_undefined)
FOREACH(config RELEASE RELWITHDEBINFO DEBUG MINSIZEREL) if (HAVE_fsanitize_undefined)
STRING(APPEND CMAKE_${type}_LINKER_FLAGS_${config} ${DYNAMIC_UCRT_LINKER_OPTION}) add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/fsanitize=undefined>)
ENDFOREACH() else()
ENDIF() message(FATAL_ERROR "UBSAN not supported by this compiler yet")
ENDFOREACH() 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 # Mark 32 bit executables large address aware so they can
# use > 2GB address space # use > 2GB address space
IF(CMAKE_SIZEOF_VOID_P MATCHES 4) if(CMAKE_SIZEOF_VOID_P MATCHES 4)
STRING(APPEND CMAKE_EXE_LINKER_FLAGS " /LARGEADDRESSAWARE") add_link_options(/LARGEADDRESSAWARE)
ENDIF() 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(FAST_BUILD) # RelWithDebInfo is deoptimized wrt inlining.
STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Fix it to default
ELSEIF (NOT CLANG_CL) foreach(lang C CXX)
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " /d2OptimizeHugeFunctions") foreach(suffix "_RELWITHDEBINFO" "_RELWITHDEBINFO_INIT")
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " /d2OptimizeHugeFunctions") string(REGEX REPLACE "/Ob[0-1]" "" CMAKE_${lang}_FLAGS${suffix} "${CMAKE_${lang}_FLAGS${suffix}}")
ENDIF() endforeach()
ADD_COMPILE_OPTIONS($<$<COMPILE_LANGUAGE:C,CXX>:/utf-8>) endforeach()
ENDIF()
# Always link with socket/synchronization libraries if(NOT CLANG_CL)
STRING(APPEND CMAKE_C_STANDARD_LIBRARIES " ws2_32.lib synchronization.lib") add_link_options("$<$<CONFIG:Release,RelWithDebInfo>:/INCREMENTAL:NO;/RELEASE;/OPT:REF,ICF>")
STRING(APPEND CMAKE_CXX_STANDARD_LIBRARIES " ws2_32.lib synchronization.lib") add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:$<$<CONFIG:Release,RelWithDebInfo>:/Gw>>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/MP>)
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/we4099;/we4700;/we4311;/we4477;/we4302;/we4090>")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/permissive->)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/diagnostics:caret>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/utf-8>)
if(NOT FAST_BUILD)
add_compile_options($<$<CONFIG:Release,RelWithDebInfo>:$<$<COMPILE_LANGUAGE:C,CXX>:/d2OptimizeHugeFunctions>>)
endif()
endif()
# System checks if(MYSQL_MAINTAINER_MODE MATCHES "ERR")
SET(SIGNAL_WITH_VIO_CLOSE 1) # Something that runtime team needs set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
SET(HAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT 1) add_link_options(/WX)
endif()
endif()
# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are # avoid running system checks by using pre-cached check results
# not in headers, to handle dual mode sockets correctly. # system checks are expensive on VS generator
CHECK_SYMBOL_EXISTS(IPPROTO_IPV6 "winsock2.h" HAVE_IPPROTO_IPV6) get_filename_component(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
IF(NOT HAVE_IPPROTO_IPV6) include(${_SCRIPT_DIR}/WindowsCache.cmake)
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()
# Some standard functions exist there under different # this is out of place, not really a system check
# names (e.g popen is _popen or strok_r is _strtok_s) set(FN_NO_CASE_SENSE 1)
# If a replacement function exists, HAVE_FUNCTION is set(USE_SYMDIR 1)
# defined to 1. CMake variable <function_name> will also set(HAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT 1)
# 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
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()

View File

@ -202,10 +202,10 @@ SET(HAVE_STRING_H 1 CACHE INTERNAL "")
SET(HAVE_STRNDUP CACHE INTERNAL "") SET(HAVE_STRNDUP CACHE INTERNAL "")
SET(HAVE_STRNLEN 1 CACHE INTERNAL "") SET(HAVE_STRNLEN 1 CACHE INTERNAL "")
SET(HAVE_STRPBRK 1 CACHE INTERNAL "") SET(HAVE_STRPBRK 1 CACHE INTERNAL "")
SET(HAVE_STRTOK_R CACHE INTERNAL "") SET(HAVE_STRTOK_R 1 CACHE INTERNAL "")
SET(HAVE_STRTOLL CACHE INTERNAL "") SET(HAVE_STRTOLL 1 CACHE INTERNAL "")
SET(HAVE_STRTOUL 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_SYNCH_H CACHE INTERNAL "")
SET(HAVE_SYSENT_H CACHE INTERNAL "") SET(HAVE_SYSENT_H CACHE INTERNAL "")
SET(HAVE_SYS_DIR_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_LINUX_UNISTD_H CACHE INTERNAL "")
SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "") SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "")
SET(HAVE_PTHREAD_GETATTR_NP CACHE INTERNAL "")
SET(HAVE_SOCKPEERCRED CACHE INTERNAL "") SET(HAVE_SOCKPEERCRED CACHE INTERNAL "")
SET(HAVE_ABI_CXA_DEMANGLE CACHE INTERNAL "") SET(HAVE_ABI_CXA_DEMANGLE CACHE INTERNAL "")
SET(HAVE_GCC_C11_ATOMICS 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_GETPAGESIZES CACHE INTERNAL "")
SET(HAVE_LINUX_LIMITS_H CACHE INTERNAL "") SET(HAVE_LINUX_LIMITS_H CACHE INTERNAL "")
SET(HAVE_FILE_UCONTEXT_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) ENDIF(MSVC)

View File

@ -214,6 +214,11 @@ MACRO(MYSQL_ADD_PLUGIN)
TARGET_LINK_LIBRARIES (${target} mysqlservices ${ARG_LINK_LIBRARIES}) 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) IF(CMAKE_SYSTEM_NAME MATCHES AIX)
TARGET_LINK_OPTIONS(${target} PRIVATE "-Wl,-bE:${CMAKE_SOURCE_DIR}/libservices/mysqlservices_aix.def") TARGET_LINK_OPTIONS(${target} PRIVATE "-Wl,-bE:${CMAKE_SOURCE_DIR}/libservices/mysqlservices_aix.def")
ENDIF() ENDIF()

View File

@ -402,38 +402,27 @@
#cmakedefine SIGNAL_WITH_VIO_CLOSE 1 #cmakedefine SIGNAL_WITH_VIO_CLOSE 1
/* Windows stuff, mostly functions, that have Posix analogs but named differently */ /* Windows stuff, mostly functions, that have Posix analogs but named differently */
#cmakedefine S_IROTH @S_IROTH@ #ifdef _WIN32
#cmakedefine S_IFIFO @S_IFIFO@ #define S_IROTH _S_IREAD
#cmakedefine IPPROTO_IPV6 @IPPROTO_IPV6@ #define S_IFIFO _S_IFIFO
#cmakedefine IPV6_V6ONLY @IPV6_V6ONLY@ #define SIGQUIT SIGTERM
#cmakedefine sigset_t @sigset_t@ #define SIGPIPE SIGINT
#cmakedefine mode_t @mode_t@ #define sigset_t int
#cmakedefine SIGQUIT @SIGQUIT@ #define mode_t int
#cmakedefine SIGPIPE @SIGPIPE@ #define popen _popen
#cmakedefine popen @popen@ #define pclose _pclose
#cmakedefine pclose @pclose@ #define ssize_t SSIZE_T
#cmakedefine ssize_t @ssize_t@ #define strcasecmp _stricmp
#cmakedefine strcasecmp @strcasecmp@ #define strncasecmp _strnicmp
#cmakedefine strncasecmp @strncasecmp@ #define strtok_r strtok_s
#cmakedefine snprintf @snprintf@
#cmakedefine strtok_r @strtok_r@
#cmakedefine strtoll @strtoll@
#cmakedefine strtoull @strtoull@
#cmakedefine vsnprintf @vsnprintf@
#if defined(_MSC_VER) && (_MSC_VER > 1800)
#define tzname _tzname #define tzname _tzname
#define P_tmpdir "C:\\TEMP" #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) #define setenv(a,b,c) _putenv_s(a,b)
#endif
#define PSAPI_VERSION 1 /* for GetProcessMemoryInfo() */
/* We don't want the min/max macros */ #define HAVE_SETENV
#ifdef _WIN32
#define NOMINMAX 1 #define NOMINMAX 1
#endif #define PSAPI_VERSION 2 /* for GetProcessMemoryInfo() */
#endif /* _WIN32 */
/* /*
MySQL features MySQL features

View File

@ -110,7 +110,7 @@ in
replace_uring_with_aio replace_uring_with_aio
fi fi
;& ;&
"trixie"|"sid") "trixie"|"forky"|"sid")
# The default packaging should always target Debian Sid, so in this case # The default packaging should always target Debian Sid, so in this case
# there is intentionally no customizations whatsoever. # there is intentionally no customizations whatsoever.
;; ;;
@ -129,7 +129,7 @@ in
replace_uring_with_aio replace_uring_with_aio
fi fi
;& ;&
"noble"|"oracular") "noble"|"oracular"|"plucky"|"questing")
# mariadb-plugin-rocksdb s390x not supported by us (yet) # mariadb-plugin-rocksdb s390x not supported by us (yet)
# ubuntu doesn't support mips64el yet, so keep this just # ubuntu doesn't support mips64el yet, so keep this just
# in case something changes. # in case something changes.

View File

@ -1790,11 +1790,6 @@ uint xb_client_options_count = array_elements(xb_client_options);
static const char *dbug_option; static const char *dbug_option;
#endif #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; static my_bool innodb_log_checkpoint_now;
struct my_option xb_server_options[] = struct my_option xb_server_options[] =
@ -1942,12 +1937,7 @@ struct my_option xb_server_options[] =
"Use native AIO if supported on this platform.", "Use native AIO if supported on this platform.",
(G_PTR*) &srv_use_native_aio, (G_PTR*) &srv_use_native_aio,
(G_PTR*) &srv_use_native_aio, 0, GET_BOOL, NO_ARG, (G_PTR*) &srv_use_native_aio, 0, GET_BOOL, NO_ARG,
#ifdef HAVE_URING TRUE, 0, 0, 0, 0, 0},
innodb_use_native_aio_default(),
#else
TRUE,
#endif
0, 0, 0, 0, 0},
{"innodb_page_size", OPT_INNODB_PAGE_SIZE, {"innodb_page_size", OPT_INNODB_PAGE_SIZE,
"The universal page size of the database.", "The universal page size of the database.",
(G_PTR*) &innobase_page_size, (G_PTR*) &innobase_page_size, 0, (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"); msg("InnoDB: Using Linux native AIO");
} }
#elif defined(HAVE_URING) #elif defined(HAVE_URING)
if (!srv_use_native_aio) {
} else if (io_uring_may_be_unsafe) { if (srv_use_native_aio) {
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 {
msg("InnoDB: Using liburing"); msg("InnoDB: Using liburing");
} }
#else #else
@ -2672,7 +2658,7 @@ static bool innodb_init()
} }
recv_sys.lsn= log_sys.next_checkpoint_lsn= 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_sys.set_latest_format(false); // not encrypted
log_hdr_init(); log_hdr_init();
byte *b= &log_hdr_buf[log_t::START_OFFSET]; byte *b= &log_hdr_buf[log_t::START_OFFSET];

View File

@ -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, Returns negative integer in the case of an error,
the length of the result otherwise. 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, const uchar *json_str, const uchar *json_end,
CHARSET_INFO *res_cs, CHARSET_INFO *res_cs,
uchar *res, uchar *res_end); 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_OUT_OF_SPACE Not enough space in the provided buffer
JSON_ERROR_ILLEGAL_SYMBOL Source symbol cannot be represented in JSON 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); CHARSET_INFO *json_cs, uchar *json, uchar *json_end);

View File

@ -593,6 +593,22 @@ struct my_collation_handler_st
uint (*get_id)(CHARSET_INFO *cs, my_collation_id_type_t type); uint (*get_id)(CHARSET_INFO *cs, my_collation_id_type_t type);
LEX_CSTRING (*get_collation_name)(CHARSET_INFO *cs, LEX_CSTRING (*get_collation_name)(CHARSET_INFO *cs,
my_collation_name_mode_t mode); my_collation_name_mode_t mode);
/*
Check if two collations are equally defined, so DTCollation aggregation
code considers them as equal. This is useful for collation aliases,
e.g. for MySQL 0900 collation aliases for 1400 MariaDB collations.
For example, these queries work without raising "Illegal mix of collations":
SELECT _utf8mb4'a' COLLATE utf8mb4_uca1400_nopad_ai_ci =
_utf8mb4'a' COLLATE utf8mb4_0900_ai_ci;
SELECT ... WHERE column_with_collation_utf8mb4_uca1400_nopad_ai_ci =
column_with_collation_tf8mb4_0900_ai_ci;
@return 0 Different
@return 1 Identical
*/
my_bool (*eq_collation)(CHARSET_INFO *self, CHARSET_INFO *other);
}; };
@ -1195,6 +1211,19 @@ struct charset_info_st
{ {
return (coll->get_collation_name)(this, mode); return (coll->get_collation_name)(this, mode);
} }
/*
Check if two collations are equally defined. For details
see the definition of eq_collation() in my_collation_handler_st.
@return 0 Different
@return 1 Identical
*/
my_bool eq_collation(CHARSET_INFO *rhs) const
{
return this == rhs || (coll->eq_collation)(this, rhs);
}
#endif /* __cplusplus */ #endif /* __cplusplus */
}; };
@ -1753,7 +1782,6 @@ my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
uint my_ci_get_id_generic(CHARSET_INFO *cs, my_collation_id_type_t type); uint my_ci_get_id_generic(CHARSET_INFO *cs, my_collation_id_type_t type);
LEX_CSTRING my_ci_get_collation_name_generic(CHARSET_INFO *cs, LEX_CSTRING my_ci_get_collation_name_generic(CHARSET_INFO *cs,
my_collation_name_mode_t mode); my_collation_name_mode_t mode);
my_bool compare_collations(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
typedef struct typedef struct
{ {

View File

@ -223,7 +223,10 @@ enum ha_extra_function {
/** Start writing rows during ALTER TABLE...ALGORITHM=COPY. */ /** Start writing rows during ALTER TABLE...ALGORITHM=COPY. */
HA_EXTRA_BEGIN_ALTER_COPY, HA_EXTRA_BEGIN_ALTER_COPY,
/** Finish writing rows during ALTER TABLE...ALGORITHM=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 */ /* Compatible option, to be deleted in 6.0 */

View File

@ -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(__GNUC__) || defined(__clang__) /* GCC and Clang compilers */
#if defined(__i386__) /* Intel x86 (32-bit) */ #if defined(__i386__) /* Intel x86 (32-bit) */
__asm__ volatile ("movl %%esp, %0" : "=r" (stack_ptr)); __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) */ #elif defined(__x86_64__) /* Intel x86-64 (64-bit) */
__asm__ volatile ("movq %%rsp, %0" : "=r" (stack_ptr)); __asm__ volatile ("movq %%rsp, %0" : "=r" (stack_ptr));
#elif defined(__powerpc__) /* PowerPC (32-bit) */ #elif defined(__powerpc__) /* PowerPC (32-bit) */

View File

@ -165,6 +165,7 @@ extern my_thread_id (*sf_malloc_dbug_id)(void);
typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific); typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific);
extern void set_malloc_size_cb(MALLOC_SIZE_CB func); extern void set_malloc_size_cb(MALLOC_SIZE_CB func);
extern MALLOC_SIZE_CB update_malloc_size; extern MALLOC_SIZE_CB update_malloc_size;
extern int64 my_malloc_init_memory_allocated;
/* defines when allocating data */ /* defines when allocating data */
extern void *my_malloc(PSI_memory_key key, size_t size, myf MyFlags); extern void *my_malloc(PSI_memory_key key, size_t size, myf MyFlags);
@ -1148,11 +1149,8 @@ static inline my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2)
return (cs1->cs_name.str == cs2->cs_name.str); return (cs1->cs_name.str == cs2->cs_name.str);
} }
extern my_bool init_compiled_charsets(myf flags); extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(struct charset_info_st *cs); extern int add_compiled_collation(struct charset_info_st *cs);
extern void add_compiled_extra_collation(struct charset_info_st *cs); extern void add_compiled_extra_collation(struct charset_info_st *cs);
extern my_bool add_alias_for_collation(LEX_CSTRING *collation_name,
uint collation_id,
LEX_CSTRING *alias, uint alias_id);
extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info, extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length, char *to, size_t to_length,
const char *from, size_t length, const char *from, size_t length,

View File

@ -138,6 +138,7 @@ sub new {
my $error = delete($opts{'error'}); my $error = delete($opts{'error'});
my $verbose = delete($opts{'verbose'}) || $::opt_verbose; my $verbose = delete($opts{'verbose'}) || $::opt_verbose;
my $nocore = delete($opts{'nocore'}); my $nocore = delete($opts{'nocore'});
my $open_files_limit = delete($opts{'open_files_limit'});
my $host = delete($opts{'host'}); my $host = delete($opts{'host'});
my $shutdown = delete($opts{'shutdown'}); my $shutdown = delete($opts{'shutdown'});
my $user_data= delete($opts{'user_data'}); my $user_data= delete($opts{'user_data'});
@ -161,6 +162,8 @@ sub new {
push(@safe_args, "--verbose") if $verbose > 0; push(@safe_args, "--verbose") if $verbose > 0;
push(@safe_args, "--nocore") if $nocore; 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 # Point the safe_process at the right parent if running on cygwin
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN; push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;

View File

@ -220,6 +220,7 @@ int main(int argc, char* const argv[] )
pid_t own_pid= getpid(); pid_t own_pid= getpid();
pid_t parent_pid= getppid(); pid_t parent_pid= getppid();
bool nocore = false; bool nocore = false;
int open_files_limit = 1024;
struct sigaction sa,sa_abort; struct sigaction sa,sa_abort;
sa.sa_handler= handle_signal; sa.sa_handler= handle_signal;
@ -268,7 +269,14 @@ int main(int argc, char* const argv[] )
} }
else if ( strncmp (arg, "--env ", 6) == 0 ) 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 else
die("Unknown option: %s", arg); die("Unknown option: %s", arg);
@ -318,11 +326,8 @@ int main(int argc, char* const argv[] )
if (nocore) if (nocore)
setlimit(RLIMIT_CORE, 0, 0); setlimit(RLIMIT_CORE, 0, 0);
/* // Set open files limit
mysqld defaults depend on that. make test results stable and independent setlimit(RLIMIT_NOFILE, open_files_limit, open_files_limit);
from the environment
*/
setlimit(RLIMIT_NOFILE, 1024, 1024);
// Signal that child is ready // Signal that child is ready
buf= 37; buf= 37;

View File

@ -1029,7 +1029,7 @@ ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"r_loops": 0, "r_loops": 0,
"query_block": { "query_block": {
@ -1130,7 +1130,7 @@ ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"r_loops": 0, "r_loops": 0,
"query_block": { "query_block": {

View File

@ -19,7 +19,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`i` int(1) NOT NULL `i` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1; drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go'; set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;; create table t1 select 1 as i;;
@ -36,7 +36,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`i` int(1) NOT NULL `i` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1; drop table t1;
create table t3 (j char(5)); create table t3 (j char(5));
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go'; set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
@ -54,7 +54,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`i` int(1) NOT NULL `i` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1; drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go'; set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;; create table t1 select 1 as i;;
@ -71,7 +71,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`i` int(1) NOT NULL `i` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1; drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go'; set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;; create table t1 select 1 as i;;
@ -88,7 +88,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`i` int(1) NOT NULL `i` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1; drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go'; set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;; create table t1 select 1 as i;;
@ -105,7 +105,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`i` int(1) NOT NULL `i` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1,t3; drop table t1,t3;
set debug_sync='create_table_select_before_open SIGNAL parked WAIT_FOR go'; set debug_sync='create_table_select_before_open SIGNAL parked WAIT_FOR go';
connection default; connection default;
@ -286,7 +286,7 @@ show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`i` int(11) DEFAULT NULL `i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t2; drop table t2;
include/show_binlog_events.inc include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info

View File

@ -199,6 +199,153 @@ CREATE OR REPLACE TABLE t1 (p int primary key auto_increment, a VARCHAR(10), key
alter table t1 modify a varchar(10) collate utf8mb4_uca1400_swedish_nopad_ai_ci, algorithm=nocopy; alter table t1 modify a varchar(10) collate utf8mb4_uca1400_swedish_nopad_ai_ci, algorithm=nocopy;
drop table t1; drop table t1;
# #
# Print protocol collation IDs for 0900 collations
# They should be known to libmariadb
# See libmariadb/libmariadb/ma_charset.c
#
FOR rec IN (SELECT COLLATION_NAME
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE CHARACTER_SET_NAME='utf8mb4'
AND COLLATION_NAME RLIKE '_0900_'
ORDER BY ID)
DO
EXECUTE IMMEDIATE CONCAT('SET NAMES utf8mb4 COLLATE ', rec.COLLATION_NAME);
SELECT rec.COLLATION_NAME;
END FOR;
$$
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 18 Y 0 0 255
utf8mb4_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 24 Y 0 0 256
utf8mb4_de_pb_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 257
utf8mb4_is_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 258
utf8mb4_lv_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 259
utf8mb4_ro_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 260
utf8mb4_sl_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 261
utf8mb4_pl_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 262
utf8mb4_et_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 263
utf8mb4_es_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 264
utf8mb4_sv_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 265
utf8mb4_tr_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 266
utf8mb4_cs_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 267
utf8mb4_da_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 268
utf8mb4_lt_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 269
utf8mb4_sk_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 26 Y 0 0 270
utf8mb4_es_trad_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 271
utf8mb4_la_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 273
utf8mb4_eo_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 274
utf8mb4_hu_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 275
utf8mb4_hr_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 277
utf8mb4_vi_0900_ai_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 18 Y 0 0 278
utf8mb4_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 24 Y 0 0 279
utf8mb4_de_pb_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 280
utf8mb4_is_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 281
utf8mb4_lv_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 282
utf8mb4_ro_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 283
utf8mb4_sl_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 284
utf8mb4_pl_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 285
utf8mb4_et_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 286
utf8mb4_es_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 287
utf8mb4_sv_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 288
utf8mb4_tr_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 289
utf8mb4_cs_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 290
utf8mb4_da_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 291
utf8mb4_lt_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 292
utf8mb4_sk_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 26 Y 0 0 293
utf8mb4_es_trad_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 294
utf8mb4_la_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 296
utf8mb4_eo_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 297
utf8mb4_hu_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 298
utf8mb4_hr_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 21 Y 0 0 300
utf8mb4_vi_0900_as_cs
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 18 Y 0 0 305
utf8mb4_0900_as_ci
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def COLLATION_NAME rec.COLLATION_NAME 253 256 16 Y 0 0 309
utf8mb4_0900_bin
#
# MDEV-36361 Wrong utf8mb4_0900_bin alias for utf8mb4_bin (should be utf8mb4_nopad_bin) # MDEV-36361 Wrong utf8mb4_0900_bin alias for utf8mb4_bin (should be utf8mb4_nopad_bin)
# #
SELECT collation_name, id, comment SELECT collation_name, id, comment

View File

@ -84,6 +84,32 @@ CREATE OR REPLACE TABLE t1 (p int primary key auto_increment, a VARCHAR(10), key
alter table t1 modify a varchar(10) collate utf8mb4_uca1400_swedish_nopad_ai_ci, algorithm=nocopy; alter table t1 modify a varchar(10) collate utf8mb4_uca1400_swedish_nopad_ai_ci, algorithm=nocopy;
drop table t1; drop table t1;
--echo #
--echo # Print protocol collation IDs for 0900 collations
--echo # They should be known to libmariadb
--echo # See libmariadb/libmariadb/ma_charset.c
--echo #
--disable_column_names
--disable_ps_protocol
--enable_metadata
DELIMITER $$;
FOR rec IN (SELECT COLLATION_NAME
FROM INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
WHERE CHARACTER_SET_NAME='utf8mb4'
AND COLLATION_NAME RLIKE '_0900_'
ORDER BY ID)
DO
EXECUTE IMMEDIATE CONCAT('SET NAMES utf8mb4 COLLATE ', rec.COLLATION_NAME);
SELECT rec.COLLATION_NAME;
END FOR;
$$
DELIMITER ;$$
--disable_metadata
--enable_ps_protocol
--enable_column_names
--echo # --echo #
--echo # MDEV-36361 Wrong utf8mb4_0900_bin alias for utf8mb4_bin (should be utf8mb4_nopad_bin) --echo # MDEV-36361 Wrong utf8mb4_0900_bin alias for utf8mb4_bin (should be utf8mb4_nopad_bin)
--echo # --echo #

View File

@ -0,0 +1 @@
--init_connect="set @a='ctype_utf8mb4_0900_mem - run a dedicated mariadbd for this test'"

View File

@ -0,0 +1,108 @@
#
# MDEV-36213 Doubled memory usage (11.4.4 <-> 11.4.5)
#
SET NAMES utf8mb4;
CREATE FUNCTION memory_used() RETURNS BIGINT RETURN
(SELECT variable_value
FROM information_schema.global_status
WHERE variable_name='memory_used');
CREATE PROCEDURE p1(cl VARCHAR(64))
BEGIN
DECLARE mem_before BIGINT;
DECLARE mem_after BIGINT;
DECLARE query TEXT DEFAULT CONCAT('SET @a= _utf8mb4 0x20 COLLATE ', cl);
SET mem_before= memory_used();
EXECUTE IMMEDIATE query;
SET mem_after= memory_used();
SELECT
CASE
WHEN mem_after-mem_before >= 1024*1024 THEN '>=1M'
ELSE '<1M'
END AS diff,
CONCAT(query,';') AS query;
END;
/
CREATE PROCEDURE p2(cl VARCHAR(64))
BEGIN
DECLARE mem_before BIGINT;
DECLARE mem_after BIGINT;
DECLARE query TEXT DEFAULT CONCAT(
'SELECT id, full_collation_name'
' FROM information_schema.collation_character_set_applicability'
' WHERE full_collation_name LIKE ''PATTERN'' ORDER BY id');
SET query= REPLACE(query, 'PATTERN', cl);
SELECT query;
SET mem_before= memory_used();
EXECUTE IMMEDIATE query;
SET mem_after=memory_used();
SELECT
CASE
WHEN mem_before-mem_after >= 1024*1024 THEN '>=1M'
ELSE '<1M'
END AS diff;
END;
/
#
# Initialize spanish2 collations, an UCA-14.0.0 collation goes first
#
>=1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_ai_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_ai_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_as_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_as_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_nopad_ai_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_nopad_ai_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_nopad_as_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_spanish2_nopad_as_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_es_trad_0900_ai_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_es_trad_0900_as_cs;
#
# I_S queries for initialized collations should not add memory
#
SELECT id, full_collation_name FROM information_schema.collation_character_set_applicability WHERE full_collation_name LIKE 'utf8mb4_uca1400_spanish2%' ORDER BY id
2416 utf8mb4_uca1400_spanish2_ai_ci
2417 utf8mb4_uca1400_spanish2_ai_cs
2418 utf8mb4_uca1400_spanish2_as_ci
2419 utf8mb4_uca1400_spanish2_as_cs
2420 utf8mb4_uca1400_spanish2_nopad_ai_ci
2421 utf8mb4_uca1400_spanish2_nopad_ai_cs
2422 utf8mb4_uca1400_spanish2_nopad_as_ci
2423 utf8mb4_uca1400_spanish2_nopad_as_cs
<1M
SELECT id, full_collation_name FROM information_schema.collation_character_set_applicability WHERE full_collation_name LIKE 'utf8mb4_%es_trad_0900%' ORDER BY id
270 utf8mb4_es_trad_0900_ai_ci
293 utf8mb4_es_trad_0900_as_cs
<1M
#
# I_S queries for not initialized collations should not add memory
#
SELECT id, full_collation_name FROM information_schema.collation_character_set_applicability WHERE full_collation_name LIKE 'utf8mb4_uca1400_german2%' ORDER BY id
2464 utf8mb4_uca1400_german2_ai_ci
2465 utf8mb4_uca1400_german2_ai_cs
2466 utf8mb4_uca1400_german2_as_ci
2467 utf8mb4_uca1400_german2_as_cs
2468 utf8mb4_uca1400_german2_nopad_ai_ci
2469 utf8mb4_uca1400_german2_nopad_ai_cs
2470 utf8mb4_uca1400_german2_nopad_as_ci
2471 utf8mb4_uca1400_german2_nopad_as_cs
<1M
SELECT id, full_collation_name FROM information_schema.collation_character_set_applicability WHERE full_collation_name LIKE 'utf8mb4_%de_pb_0900%' ORDER BY id
256 utf8mb4_de_pb_0900_ai_ci
279 utf8mb4_de_pb_0900_as_cs
<1M
#
# Initialize german2 collations, an UCA-9.0.0 alias goes first
#
>=1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_de_pb_0900_ai_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_de_pb_0900_as_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_ai_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_ai_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_as_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_as_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_nopad_ai_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_nopad_ai_cs;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_nopad_as_ci;
<1M SET @a= _utf8mb4 0x20 COLLATE utf8mb4_uca1400_german2_nopad_as_cs;
DROP PROCEDURE p2;
DROP PROCEDURE p1;
DROP FUNCTION memory_used;
# End of 11.4 tests

View File

@ -0,0 +1,112 @@
--echo #
--echo # MDEV-36213 Doubled memory usage (11.4.4 <-> 11.4.5)
--echo #
SET NAMES utf8mb4;
CREATE FUNCTION memory_used() RETURNS BIGINT RETURN
(SELECT variable_value
FROM information_schema.global_status
WHERE variable_name='memory_used');
DELIMITER /;
CREATE PROCEDURE p1(cl VARCHAR(64))
BEGIN
DECLARE mem_before BIGINT;
DECLARE mem_after BIGINT;
DECLARE query TEXT DEFAULT CONCAT('SET @a= _utf8mb4 0x20 COLLATE ', cl);
SET mem_before= memory_used();
EXECUTE IMMEDIATE query;
SET mem_after= memory_used();
SELECT
CASE
WHEN mem_after-mem_before >= 1024*1024 THEN '>=1M'
ELSE '<1M'
END AS diff,
CONCAT(query,';') AS query;
END;
/
CREATE PROCEDURE p2(cl VARCHAR(64))
BEGIN
DECLARE mem_before BIGINT;
DECLARE mem_after BIGINT;
DECLARE query TEXT DEFAULT CONCAT(
'SELECT id, full_collation_name'
' FROM information_schema.collation_character_set_applicability'
' WHERE full_collation_name LIKE ''PATTERN'' ORDER BY id');
SET query= REPLACE(query, 'PATTERN', cl);
SELECT query;
SET mem_before= memory_used();
EXECUTE IMMEDIATE query;
SET mem_after=memory_used();
SELECT
CASE
WHEN mem_before-mem_after >= 1024*1024 THEN '>=1M'
ELSE '<1M'
END AS diff;
END;
/
DELIMITER ;/
--disable_column_names
--disable_query_log
--echo #
--echo # Initialize spanish2 collations, an UCA-14.0.0 collation goes first
--echo #
CALL p1('utf8mb4_uca1400_spanish2_ai_ci');
CALL p1('utf8mb4_uca1400_spanish2_ai_cs');
CALL p1('utf8mb4_uca1400_spanish2_as_ci');
CALL p1('utf8mb4_uca1400_spanish2_as_cs');
CALL p1('utf8mb4_uca1400_spanish2_nopad_ai_ci');
CALL p1('utf8mb4_uca1400_spanish2_nopad_ai_cs');
CALL p1('utf8mb4_uca1400_spanish2_nopad_as_ci');
CALL p1('utf8mb4_uca1400_spanish2_nopad_as_cs');
CALL p1('utf8mb4_es_trad_0900_ai_ci');
CALL p1('utf8mb4_es_trad_0900_as_cs');
--echo #
--echo # I_S queries for initialized collations should not add memory
--echo #
CALL p2('utf8mb4_uca1400_spanish2%');
CALL p2('utf8mb4_%es_trad_0900%');
--echo #
--echo # I_S queries for not initialized collations should not add memory
--echo #
CALL p2('utf8mb4_uca1400_german2%');
CALL p2('utf8mb4_%de_pb_0900%');
--echo #
--echo # Initialize german2 collations, an UCA-9.0.0 alias goes first
--echo #
CALL p1('utf8mb4_de_pb_0900_ai_ci');
CALL p1('utf8mb4_de_pb_0900_as_cs');
CALL p1('utf8mb4_uca1400_german2_ai_ci');
CALL p1('utf8mb4_uca1400_german2_ai_cs');
CALL p1('utf8mb4_uca1400_german2_as_ci');
CALL p1('utf8mb4_uca1400_german2_as_cs');
CALL p1('utf8mb4_uca1400_german2_nopad_ai_ci');
CALL p1('utf8mb4_uca1400_german2_nopad_ai_cs');
CALL p1('utf8mb4_uca1400_german2_nopad_as_ci');
CALL p1('utf8mb4_uca1400_german2_nopad_as_cs');
--enable_query_log
--enable_column_names
DROP PROCEDURE p2;
DROP PROCEDURE p1;
DROP FUNCTION memory_used;
--echo # End of 11.4 tests

View File

@ -12926,9 +12926,8 @@ SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL;
EXPLAIN INSERT INTO t1 EXPLAIN INSERT INTO t1
SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 144 Using where 1 PRIMARY <derived4> ALL NULL NULL NULL NULL 12 Using temporary
2 DERIVED <derived4> ALL NULL NULL NULL NULL 12 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
4 DERIVED t1 ALL NULL NULL NULL NULL 12 4 DERIVED t1 ALL NULL NULL NULL NULL 12
EXPLAIN FORMAT=JSON INSERT INTO t1 EXPLAIN FORMAT=JSON INSERT INTO t1
SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL; SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL;
@ -12937,71 +12936,54 @@ EXPLAIN
"query_block": { "query_block": {
"select_id": 1, "select_id": 1,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"nested_loop": [ "temporary_table": {
{ "nested_loop": [
"table": { {
"table_name": "<derived2>", "table": {
"access_type": "ALL", "table_name": "<derived4>",
"loops": 1, "access_type": "ALL",
"rows": 144, "loops": 1,
"cost": "COST_REPLACED", "rows": 12,
"filtered": 100, "cost": "COST_REPLACED",
"attached_condition": "t.f is not null", "filtered": 100,
"materialized": { "materialized": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 4,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"nested_loop": [ "nested_loop": [
{ {
"table": {
"table_name": "<derived4>",
"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": {
"table": { "table": {
"table_name": "t1", "table_name": "t1",
"access_type": "ALL", "access_type": "ALL",
"loops": 12, "loops": 1,
"rows": 12, "rows": 12,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"filtered": 100, "filtered": 100
"attached_condition": "t1.f is not null" }
},
"buffer_type": "flat",
"buffer_size": "64",
"join_type": "BNL"
} }
} ]
] }
} }
} }
},
{
"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; SELECT * FROM t1;
@ -13031,72 +13013,55 @@ EXPLAIN
"query_block": { "query_block": {
"select_id": 1, "select_id": 1,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"nested_loop": [ "temporary_table": {
{ "nested_loop": [
"table": { {
"table_name": "<derived2>", "table": {
"access_type": "ALL", "table_name": "t1",
"loops": 1, "access_type": "ALL",
"rows": 8, "loops": 1,
"cost": "COST_REPLACED", "rows": 8,
"filtered": 100, "cost": "COST_REPLACED",
"attached_condition": "t.f is not null", "filtered": 100,
"materialized": { "attached_condition": "t1.f is not null"
"query_block": { }
"select_id": 2, },
"cost": "COST_REPLACED", {
"nested_loop": [ "table": {
{ "table_name": "<derived4>",
"table": { "access_type": "ref",
"table_name": "t1", "possible_keys": ["key0"],
"access_type": "ALL", "key": "key0",
"loops": 1, "key_length": "4",
"rows": 8, "used_key_parts": ["f"],
"cost": "COST_REPLACED", "ref": ["test.t1.f"],
"filtered": 100, "loops": 8,
"attached_condition": "t1.f is not null" "rows": 1,
} "cost": "COST_REPLACED",
}, "filtered": 100,
{ "materialized": {
"table": { "query_block": {
"table_name": "<derived4>", "select_id": 4,
"access_type": "ref", "cost": "COST_REPLACED",
"possible_keys": ["key0"], "nested_loop": [
"key": "key0", {
"key_length": "4", "table": {
"used_key_parts": ["f"], "table_name": "t1",
"ref": ["test.t1.f"], "access_type": "ALL",
"loops": 8, "loops": 1,
"rows": 1, "rows": 8,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"filtered": 100, "filtered": 100,
"materialized": { "attached_condition": "t1.f is not null"
"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; SELECT * FROM t1;
@ -23641,6 +23606,27 @@ FROM cte2
GROUP BY 1 ; GROUP BY 1 ;
( SELECT 1 FROM ( SELECT 1 FROM cte1) dt GROUP BY x HAVING x= 1 ) ( SELECT 1 FROM ( SELECT 1 FROM cte1) dt GROUP BY x HAVING x= 1 )
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 # End of 10.5 tests
# #
# MDEV-28958: condition pushable into view after simplification # MDEV-28958: condition pushable into view after simplification

View File

@ -4471,6 +4471,28 @@ SELECT
FROM cte2 FROM cte2
GROUP BY 1 ; 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 # End of 10.5 tests
--echo # --echo #

View File

@ -2524,6 +2524,8 @@ SELECT * FROM t1;
a a
1 1
1 1
1
1
drop table t1,t2; drop table t1,t2;
set optimizer_switch=@save968720_optimizer_switch; set optimizer_switch=@save968720_optimizer_switch;
# #

View File

@ -404,7 +404,7 @@ EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
@ -451,7 +451,7 @@ EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
@ -2121,7 +2121,7 @@ EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,

View File

@ -424,7 +424,7 @@ coercibility(json_unquote(json_object('bar', c))) as coer_json_unquote,
coercibility('bar') as coer_literal coercibility('bar') as coer_literal
from t1 limit 1; from t1 limit 1;
coll_json_unquote coer_json_unquote coer_literal coll_json_unquote coer_json_unquote coer_literal
utf8mb3_general_ci 4 6 utf8mb4_bin 4 6
create table t2 as select json_object('foo', json_unquote(json_object('bar', c)),'qux', c) as fld from t1 limit 0; create table t2 as select json_object('foo', json_unquote(json_object('bar', c)),'qux', c) as fld from t1 limit 0;
show create table t2; show create table t2;
Table Create Table Table Create Table
@ -1787,6 +1787,43 @@ FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t;
data data
<root language="de"></root> <root language="de"></root>
# #
# 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_uca1400_ai_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_uca1400_ai_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 # End of 10.6 tests
# #
# #

View File

@ -1206,6 +1206,7 @@ SELECT JSON_EXTRACT('{"a": 1,"b": 2}','$.a');
SET @@collation_connection= @save_collation_connection; SET @@collation_connection= @save_collation_connection;
--echo # --echo #
--echo # End of 10.5 tests --echo # End of 10.5 tests
--echo # --echo #
@ -1243,6 +1244,27 @@ SELECT
data data
FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t; 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 #
--echo # End of 10.6 tests --echo # End of 10.6 tests
--echo # --echo #

View File

@ -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<<c1`,1 like `test`.`t1`.`c1` or `test`.`t1`.`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` 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<<c1`,1 like `test`.`t1`.`c1` or `test`.`t1`.`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 VIEW v1;
DROP TABLE t1; 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;

View File

@ -291,3 +291,18 @@ SELECT * FROM v1;
EXPLAIN EXTENDED SELECT * FROM v1; EXPLAIN EXTENDED SELECT * FROM v1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; 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;

View File

@ -3016,6 +3016,80 @@ UPDATE t1 SET c=1 ORDER BY (SELECT c);
ERROR 42S22: Unknown column 'c' in 'SET' ERROR 42S22: Unknown column 'c' in 'SET'
DROP TABLE t1; 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 # End of 10.5 tests
# #
# #

View File

@ -2162,6 +2162,28 @@ UPDATE t1 SET c=1 ORDER BY (SELECT c);
UPDATE t1 SET c=1 ORDER BY (SELECT c); UPDATE t1 SET c=1 ORDER BY (SELECT c);
DROP TABLE t1; 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 #
--echo # End of 10.5 tests --echo # End of 10.5 tests
--echo # --echo #

View File

@ -808,5 +808,75 @@ a
8 8
drop table t1; 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

View File

@ -671,5 +671,59 @@ select * from t1;
drop table t1; drop table t1;
--echo # --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 # --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

View File

@ -498,6 +498,8 @@ t1 WHERE id1=1)
5 6 5 6
INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); 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 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.*; INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*;
ERROR 42S02: Unknown table 'test.t1' ERROR 42S02: Unknown table 'test.t1'
# #

View File

@ -201,6 +201,8 @@ INSERT INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM
t1 WHERE id1=1); t1 WHERE id1=1);
--error ER_UPDATE_TABLE_USED --error ER_UPDATE_TABLE_USED
INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2); 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 --error ER_BAD_TABLE_ERROR
INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*; INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*;

View File

@ -1030,6 +1030,144 @@ a
3 3
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; 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

View File

@ -591,6 +591,61 @@ SELECT * FROM t1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; 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 #
--echo # End of 10.5 test --echo # MDEV-33139: Crash of INSERT SELECT when preparing structures for
--echo # split optimization
--echo # --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

View File

@ -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 1 SIMPLE t2 ref kp1 kp1 5 test.t1.a 1 Using index condition
drop table t1,t2; 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 # MDEV-30256 Wrong result (missing rows) upon join with empty table
# #
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);

View File

@ -2005,6 +2005,31 @@ where
t2.kp1=t1.a and t2.kp1<=100 and t2.kp2<=20; t2.kp1=t1.a and t2.kp1<=100 and t2.kp2<=20;
drop table t1,t2; 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 #
--echo # MDEV-30256 Wrong result (missing rows) upon join with empty table --echo # MDEV-30256 Wrong result (missing rows) upon join with empty table
--echo # --echo #

View File

@ -185,7 +185,7 @@ create table myUC (i int);
select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES
where TABLE_SCHEMA ='mysqltest_LC2'; where TABLE_SCHEMA ='mysqltest_LC2';
TABLE_SCHEMA TABLE_NAME TABLE_SCHEMA TABLE_NAME
mysqltest_lc2 myUC mysqltest_LC2 myUC
use test; use test;
drop database mysqltest_LC2; drop database mysqltest_LC2;
# #

View File

@ -16,29 +16,17 @@ create view v1Aa as select * from t1aA;
create view v2aA as select * from v1aA; create view v2aA as select * from v1aA;
create view v3Aa as select v2Aa.col1 from v2aA,t2Aa where v2Aa.col1 = t2aA.col1; create view v3Aa as select v2Aa.col1 from v2aA,t2Aa where v2Aa.col1 = t2aA.col1;
insert into v2Aa values ((select max(col1) from v1aA)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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 view v3aA,v2Aa,v1aA;
drop table t1Aa,t2Aa; drop table t1Aa,t2Aa;
create table t1Aa (col1 int); create table t1Aa (col1 int);

View File

@ -23,29 +23,17 @@ create table t2aA (col1 int);
create view v1Aa as select * from t1aA; create view v1Aa as select * from t1aA;
create view v2aA as select * from v1aA; create view v2aA as select * from v1aA;
create view v3Aa as select v2Aa.col1 from v2aA,t2Aa where v2Aa.col1 = t2aA.col1; 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)); insert into v2Aa values ((select max(col1) from v1aA));
-- error 1443
insert into t1aA values ((select max(col1) from v1Aa)); insert into t1aA values ((select max(col1) from v1Aa));
-- error 1443
insert into v2aA values ((select max(col1) from v1aA)); insert into v2aA values ((select max(col1) from v1aA));
-- error 1443
insert into v2Aa values ((select max(col1) from t1Aa)); insert into v2Aa values ((select max(col1) from t1Aa));
-- error 1093
insert into t1aA values ((select max(col1) from t1Aa)); insert into t1aA values ((select max(col1) from t1Aa));
-- error 1443
insert into v2aA values ((select max(col1) from t1aA)); insert into v2aA values ((select max(col1) from t1aA));
-- error 1093
insert into v2Aa values ((select max(col1) from v2aA)); insert into v2Aa values ((select max(col1) from v2aA));
-- error 1443
insert into t1Aa values ((select max(col1) from v2Aa)); insert into t1Aa values ((select max(col1) from v2Aa));
-- error 1093
insert into v2aA values ((select max(col1) from v2Aa)); insert into v2aA values ((select max(col1) from v2Aa));
-- error 1443
insert into v3Aa (col1) values ((select max(col1) from v1Aa)); insert into v3Aa (col1) values ((select max(col1) from v1Aa));
-- error 1443
insert into v3aA (col1) values ((select max(col1) from t1aA)); insert into v3aA (col1) values ((select max(col1) from t1aA));
-- error 1443
insert into v3Aa (col1) values ((select max(col1) from v2aA)); insert into v3Aa (col1) values ((select max(col1) from v2aA));
drop view v3aA,v2Aa,v1aA; drop view v3aA,v2Aa,v1aA;
drop table t1Aa,t2Aa; drop table t1Aa,t2Aa;

View File

@ -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;

View File

@ -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;

View File

@ -2431,9 +2431,6 @@ create table t1 (a int) engine=myisam;
create table t2 (a int) stats_persistent=0, engine=innodb; create table t2 (a int) stats_persistent=0, engine=innodb;
insert into t1 values (1); insert into t1 values (1);
insert into t2 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'; 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; update t1,t2 set t1.a=2,t2.a=3;
connection con2; connection con2;
@ -2456,6 +2453,7 @@ SET DEBUG_SYNC= 'now SIGNAL grlwait';
SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; SET DEBUG_SYNC= 'now WAIT_FOR table_opened';
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait'; SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait';
FLUSH TABLES WITH READ LOCK; 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; SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME
MDL_BACKUP_FTWRL2 Backup lock MDL_BACKUP_FTWRL2 Backup lock
@ -2465,7 +2463,6 @@ connection default;
SET DEBUG_SYNC= 'RESET'; SET DEBUG_SYNC= 'RESET';
drop table t1,t2; drop table t1,t2;
disconnect con2; disconnect con2;
disconnect con1;
# #
# Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null' # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null'
# failed in open_ltable() # failed in open_ltable()

View File

@ -3115,12 +3115,6 @@ create table t2 (a int) stats_persistent=0, engine=innodb;
insert into t1 values (1); insert into t1 values (1);
insert into t2 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'; 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 --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; let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.metadata_lock_info;
--source include/wait_condition.inc --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; SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info;
unlock tables; unlock tables;
@ -3166,7 +3161,6 @@ connection default;
SET DEBUG_SYNC= 'RESET'; SET DEBUG_SYNC= 'RESET';
drop table t1,t2; drop table t1,t2;
disconnect con2; disconnect con2;
disconnect con1;
--echo # --echo #
--echo # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null' --echo # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null'

View File

@ -1385,6 +1385,26 @@ c1 c2 c3
drop table t1,t2,t3,t; drop table t1,t2,t3,t;
# End of 10.4 tests # 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 # MDEV-31150: 2nd execution of multi-update with
# mergeable derived table in WHERE # mergeable derived table in WHERE
# #

View File

@ -1202,6 +1202,34 @@ drop table t1,t2,t3,t;
--echo # End of 10.4 tests --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 #
--echo # MDEV-31150: 2nd execution of multi-update with --echo # MDEV-31150: 2nd execution of multi-update with
--echo # mergeable derived table in WHERE --echo # mergeable derived table in WHERE

View File

@ -4538,7 +4538,7 @@ ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 50, "r_loops": 50,
"r_hit_ratio": 0, "r_hit_ratio": 0,
"query_block": { "query_block": {

View File

@ -2224,6 +2224,29 @@ SET @qc= @@query_cache_size;
set global Query_cache_size=18446744073709547520; set global Query_cache_size=18446744073709547520;
SET GLOBAL query_cache_size= @qc; 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 # End of 10.5 tests
# #
# #

View File

@ -2,6 +2,8 @@
-- source include/long_test.inc -- source include/long_test.inc
-- source include/no_valgrind_without_big.inc -- source include/no_valgrind_without_big.inc
-- source include/no_view_protocol.inc -- source include/no_view_protocol.inc
-- source include/have_partition.inc
-- source include/have_innodb.inc
--disable_ps2_protocol --disable_ps2_protocol
set @save_query_cache_size=@@query_cache_size; set @save_query_cache_size=@@query_cache_size;
@ -1821,6 +1823,26 @@ set global Query_cache_size=18446744073709547520;
SET GLOBAL query_cache_size= @qc; SET GLOBAL query_cache_size= @qc;
--enable_warnings --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 #
--echo # End of 10.5 tests --echo # End of 10.5 tests
--echo # --echo #

View File

@ -654,7 +654,7 @@ SHOW ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"r_loops": 0, "r_loops": 0,
"query_block": { "query_block": {
@ -725,7 +725,7 @@ SHOW ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 2, "r_loops": 2,
"r_hit_ratio": 0, "r_hit_ratio": 0,
"query_block": { "query_block": {
@ -801,7 +801,7 @@ SHOW ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 2, "r_loops": 2,
"r_hit_ratio": 0, "r_hit_ratio": 0,
"query_block": { "query_block": {
@ -1107,7 +1107,7 @@ SHOW ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 1, "r_loops": 1,
"r_hit_ratio": 0, "r_hit_ratio": 0,
"query_block": { "query_block": {
@ -1167,7 +1167,7 @@ SHOW ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 2, "r_loops": 2,
"r_hit_ratio": 0, "r_hit_ratio": 0,
"query_block": { "query_block": {
@ -1228,7 +1228,7 @@ SHOW ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 3, "r_loops": 3,
"r_hit_ratio": 0, "r_hit_ratio": 0,
"query_block": { "query_block": {

View File

@ -421,7 +421,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -476,7 +476,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -531,7 +531,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -942,7 +942,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -987,7 +987,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -1032,7 +1032,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -1092,7 +1092,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -1137,7 +1137,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
@ -1182,7 +1182,7 @@ SHOW EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",

View File

@ -923,4 +923,67 @@ SELECT pkg.f1();
pkg.f1() pkg.f1()
1 2 1 2
DROP PACKAGE pkg; DROP PACKAGE pkg;
#
# MDEV-36462: Crash on `DECLARE spvar1 ROW TYPE OF cursor1` after a table recreation
#
CREATE PROCEDURE p1()
BEGIN
DECLARE c CURSOR FOR SELECT a FROM t1;
BEGIN
DECLARE va ROW TYPE OF c; -- the crash happens here
END;
END;
/
CREATE PROCEDURE p2()
BEGIN
FOR i IN 1..10 DO -- usually it crashes on the third iteration, but not always
SELECT i;
CREATE OR REPLACE TABLE t1 (a INT);
CALL p1;
CALL p1;
END FOR;
END;
/
CALL p2;
i
1
i
2
i
3
i
4
i
5
i
6
i
7
i
8
i
9
i
10
# Clean up
DROP PROCEDURE p1;
DROP PROCEDURE p2;
DROP TABLE t1;
# The following test is taken from the task MDEV-36114 which is
# partially a duplicate of the task MDEV-36462
CREATE PROCEDURE p()
BEGIN
DECLARE cur1 CURSOR FOR SELECT * FROM t;
BEGIN
DECLARE rec1 ROW TYPE OF cur1;
END;
END;
/
CREATE TABLE t (id INT);
CALL p();
CREATE OR REPLACE TABLE t (id INT);
CALL p();
# Clean up
DROP PROCEDURE p;
DROP TABLE t;
# End of 11.4 tests # End of 11.4 tests

View File

@ -891,4 +891,60 @@ DROP PACKAGE pkg;
SELECT pkg.f1(); SELECT pkg.f1();
DROP PACKAGE pkg; DROP PACKAGE pkg;
--echo #
--echo # MDEV-36462: Crash on `DECLARE spvar1 ROW TYPE OF cursor1` after a table recreation
--echo #
--delimiter /
CREATE PROCEDURE p1()
BEGIN
DECLARE c CURSOR FOR SELECT a FROM t1;
BEGIN
DECLARE va ROW TYPE OF c; -- the crash happens here
END;
END;
/
CREATE PROCEDURE p2()
BEGIN
FOR i IN 1..10 DO -- usually it crashes on the third iteration, but not always
SELECT i;
CREATE OR REPLACE TABLE t1 (a INT);
CALL p1;
CALL p1;
END FOR;
END;
/
--delimiter ;
CALL p2;
--echo # Clean up
DROP PROCEDURE p1;
DROP PROCEDURE p2;
DROP TABLE t1;
--echo # The following test is taken from the task MDEV-36114 which is
--echo # partially a duplicate of the task MDEV-36462
--delimiter /
CREATE PROCEDURE p()
BEGIN
DECLARE cur1 CURSOR FOR SELECT * FROM t;
BEGIN
DECLARE rec1 ROW TYPE OF cur1;
END;
END;
/
--delimiter ;
CREATE TABLE t (id INT);
CALL p();
CREATE OR REPLACE TABLE t (id INT);
CALL p();
--echo # Clean up
DROP PROCEDURE p;
DROP TABLE t;
--echo # End of 11.4 tests --echo # End of 11.4 tests

View File

@ -688,22 +688,24 @@ create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); 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)); INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
insert into t2 values (1); insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -711,6 +713,7 @@ x
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -720,6 +723,7 @@ x
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -736,7 +740,7 @@ insert into t3 values (1),(2);
select * from t1; select * from t1;
x y x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); 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)); replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@ -804,13 +808,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id id
2 2
INSERT INTO t2 VALUES ((SELECT * FROM t2)); 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)); 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; SELECT * FROM t2;
id id
1 1
2 2
2
2
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);
UPDATE t2 SET id=(SELECT * FROM t1); UPDATE t2 SET id=(SELECT * FROM t1);

View File

@ -421,7 +421,6 @@ create table t2 (a int) ENGINE=MyISAM;
create table t3 (b int); create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
-- error ER_UPDATE_TABLE_USED
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
-- error ER_SUBQUERY_NO_1_ROW -- error ER_SUBQUERY_NO_1_ROW
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
@ -456,7 +455,7 @@ create table t3 (a int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
select * from t1; 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)); replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
-- error ER_SUBQUERY_NO_1_ROW -- error ER_SUBQUERY_NO_1_ROW
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
@ -496,10 +495,13 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
--disable_prepare_warnings --disable_prepare_warnings
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); 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)); 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)); 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; SELECT * FROM t2;
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);

View File

@ -2912,7 +2912,7 @@ ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "disabled", "state": "disabled",
"r_loops": 0, "r_loops": 0,
"query_block": { "query_block": {

View File

@ -74,7 +74,7 @@ ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 10, "r_loops": 10,
"r_hit_ratio": 60, "r_hit_ratio": 60,
"query_block": { "query_block": {
@ -141,7 +141,7 @@ ANALYZE
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 10, "r_loops": 10,
"r_hit_ratio": 60, "r_hit_ratio": 60,
"query_block": { "query_block": {
@ -194,7 +194,7 @@ ANALYZE
} }
}, },
{ {
"expression_cache": { "subquery_cache": {
"r_loops": 10, "r_loops": 10,
"r_hit_ratio": 60, "r_hit_ratio": 60,
"query_block": { "query_block": {
@ -249,7 +249,7 @@ EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,
@ -294,7 +294,7 @@ EXPLAIN
], ],
"subqueries": [ "subqueries": [
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"query_block": { "query_block": {
"union_result": { "union_result": {
@ -335,7 +335,7 @@ EXPLAIN
} }
}, },
{ {
"expression_cache": { "subquery_cache": {
"state": "uninitialized", "state": "uninitialized",
"query_block": { "query_block": {
"select_id": 2, "select_id": 2,

View File

@ -136,12 +136,22 @@ DROP TABLE t1;
# access within null pointer # access within null pointer
CREATE TABLE x (x INT) ENGINE=InnoDB; CREATE TABLE x (x INT) ENGINE=InnoDB;
INSERT INTO x (x) VALUES (0); 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 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 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 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) (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 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; DROP TABLE x;
# MDEV-28622: Item_subselect eliminated flag set but Item still # MDEV-28622: Item_subselect eliminated flag set but Item still
# evaluated/used. # evaluated/used.

View File

@ -133,12 +133,17 @@ DROP TABLE t1;
CREATE TABLE x (x INT) ENGINE=InnoDB; CREATE TABLE x (x INT) ENGINE=InnoDB;
INSERT INTO x (x) VALUES (0); 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 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 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 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) (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 x) IN (SELECT 0 AS x) AS x FROM x));
select * from x;
DROP TABLE x; DROP TABLE x;
--echo # MDEV-28622: Item_subselect eliminated flag set but Item still --echo # MDEV-28622: Item_subselect eliminated flag set but Item still

View File

@ -692,22 +692,24 @@ create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); 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)); INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
insert into t2 values (1); insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -715,6 +717,7 @@ x
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -724,6 +727,7 @@ x
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -740,7 +744,7 @@ insert into t3 values (1),(2);
select * from t1; select * from t1;
x y x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); 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)); replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@ -808,13 +812,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id id
2 2
INSERT INTO t2 VALUES ((SELECT * FROM t2)); 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)); 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; SELECT * FROM t2;
id id
1 1
2 2
2
2
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);
UPDATE t2 SET id=(SELECT * FROM t1); UPDATE t2 SET id=(SELECT * FROM t1);

View File

@ -695,22 +695,24 @@ create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); 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)); INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
insert into t2 values (1); insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -718,6 +720,7 @@ x
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -727,6 +730,7 @@ x
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -743,7 +747,7 @@ insert into t3 values (1),(2);
select * from t1; select * from t1;
x y x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); 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)); replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@ -811,13 +815,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id id
2 2
INSERT INTO t2 VALUES ((SELECT * FROM t2)); 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)); 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; SELECT * FROM t2;
id id
1 1
2 2
2
2
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);
UPDATE t2 SET id=(SELECT * FROM t1); UPDATE t2 SET id=(SELECT * FROM t1);

View File

@ -691,22 +691,24 @@ create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); 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)); INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
insert into t2 values (1); insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -714,6 +716,7 @@ x
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -723,6 +726,7 @@ x
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -739,7 +743,7 @@ insert into t3 values (1),(2);
select * from t1; select * from t1;
x y x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); 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)); replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@ -807,13 +811,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id id
2 2
INSERT INTO t2 VALUES ((SELECT * FROM t2)); 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)); 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; SELECT * FROM t2;
id id
1 1
2 2
2
2
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);
UPDATE t2 SET id=(SELECT * FROM t1); UPDATE t2 SET id=(SELECT * FROM t1);

View File

@ -694,22 +694,24 @@ create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); 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)); INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
insert into t2 values (1); insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -717,6 +719,7 @@ x
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -726,6 +729,7 @@ x
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -742,7 +746,7 @@ insert into t3 values (1),(2);
select * from t1; select * from t1;
x y x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); 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)); replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); 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 id
2 2
INSERT INTO t2 VALUES ((SELECT * FROM t2)); 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)); 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; SELECT * FROM t2;
id id
1 1
2 2
2
2
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);
UPDATE t2 SET id=(SELECT * FROM t1); UPDATE t2 SET id=(SELECT * FROM t1);

View File

@ -691,22 +691,24 @@ create table t3 (b int);
insert into t2 values (1); insert into t2 values (1);
insert into t3 values (1),(2); insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); 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)); INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
insert into t2 values (1); insert into t2 values (1);
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -714,6 +716,7 @@ x
INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2; INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -723,6 +726,7 @@ x
INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2)); INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
select * from t1; select * from t1;
x x
NULL
1 1
2 2
3 3
@ -739,7 +743,7 @@ insert into t3 values (1),(2);
select * from t1; select * from t1;
x y x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); 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)); replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@ -807,13 +811,21 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id id
2 2
INSERT INTO t2 VALUES ((SELECT * FROM t2)); 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)); 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; SELECT * FROM t2;
id id
1 1
2 2
2
2
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);
UPDATE t2 SET id=(SELECT * FROM t1); UPDATE t2 SET id=(SELECT * FROM t1);

View File

@ -397,3 +397,61 @@ indexed_col not_indexed_col
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; DROP TABLE t1;
SET note_verbosity=DEFAULT; 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;

View File

@ -178,3 +178,14 @@ DELIMITER ;$$
--source unusable_keys_joins.inc --source unusable_keys_joins.inc
DROP TABLE t1; DROP TABLE t1;
SET note_verbosity=DEFAULT; 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;

View File

@ -1419,3 +1419,193 @@ Note 1105 Cannot use key parts with `test`.`t1`.`indexed_col` in the rewritten c
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; DROP TABLE t1;
SET note_verbosity=DEFAULT; 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;

View File

@ -808,3 +808,48 @@ DELIMITER ;$$
--source unusable_keys_joins.inc --source unusable_keys_joins.inc
DROP TABLE t1; DROP TABLE t1;
SET note_verbosity=DEFAULT; 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;

View File

@ -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;

View File

@ -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;

View File

@ -263,9 +263,14 @@ ERROR 21000: Subquery returns more than 1 row
set global userstat= 0; set global userstat= 0;
drop function f; drop function f;
drop table t1; drop table t1;
#
# End of 10.2 tests # 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
# #
# MDEV-33901 INDEX_STATISTICS.QUERIES is incremented additionally for # MDEV-33901 INDEX_STATISTICS.QUERIES is incremented additionally for
# subqueries # subqueries

View File

@ -139,9 +139,14 @@ drop function f;
drop table t1; drop table t1;
--enable_ps2_protocol --enable_ps2_protocol
--echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --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
--echo # --echo #
--echo # MDEV-33901 INDEX_STATISTICS.QUERIES is incremented additionally for --echo # MDEV-33901 INDEX_STATISTICS.QUERIES is incremented additionally for

View File

@ -945,31 +945,19 @@ create view v1 as select * from t1;
create view v2 as select * from v1; create view v2 as select * from v1;
create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1;
insert into v2 values ((select max(col1) from v1)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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 LIMIT 1));
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); ERROR 22003: Out of range value for column 'col1' at row 3
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 t2)); 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)); insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
ERROR 23000: Column 'col1' cannot be null ERROR 23000: Column 'col1' cannot be null
@ -979,6 +967,18 @@ insert into t1 (col1) values ((select max(col1) from v4));
select * from t1; select * from t1;
col1 col1
NULL NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
1 1
2 2
3 3
@ -1340,9 +1340,26 @@ create view v3 as select * from t1 where 20 < (select (s1) from v2);
insert into v3 values (30); insert into v3 values (30);
ERROR HY000: The target table v3 of the INSERT is not insertable-into 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); create view v4 as select * from v2 where 20 < (select (s1) from t1);
select * from t1;
s1
insert into v4 values (30); insert into v4 values (30);
ERROR HY000: The target table v4 of the INSERT is not insertable-into select * from t1;
drop view v4, v3, v2, v1; 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; drop table t1;
create table t1 (a int); create table t1 (a int);
create view v1 as select * from t1; create view v1 as select * from t1;

View File

@ -867,33 +867,21 @@ create table t3 (col1 datetime not null);
create view v1 as select * from t1; create view v1 as select * from t1;
create view v2 as select * from v1; create view v2 as select * from v1;
create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; 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)); insert into v2 values ((select max(col1) from v1));
-- error ER_VIEW_PREVENT_UPDATE
insert into t1 values ((select max(col1) from v1)); insert into t1 values ((select max(col1) from v1));
-- error ER_VIEW_PREVENT_UPDATE
insert into v2 values ((select max(col1) from v1)); insert into v2 values ((select max(col1) from v1));
-- error ER_VIEW_PREVENT_UPDATE
insert into v2 values ((select max(col1) from t1)); insert into v2 values ((select max(col1) from t1));
-- error ER_UPDATE_TABLE_USED
insert into t1 values ((select max(col1) from t1)); insert into t1 values ((select max(col1) from t1));
-- error ER_VIEW_PREVENT_UPDATE
insert into v2 values ((select max(col1) from t1)); insert into v2 values ((select max(col1) from t1));
-- error ER_UPDATE_TABLE_USED
insert into v2 values ((select max(col1) from v2)); insert into v2 values ((select max(col1) from v2));
-- error ER_VIEW_PREVENT_UPDATE
insert into t1 values ((select max(col1) from v2)); insert into t1 values ((select max(col1) from v2));
-- error ER_UPDATE_TABLE_USED
insert into v2 values ((select max(col1) from v2)); insert into v2 values ((select max(col1) from v2));
-- error ER_VIEW_PREVENT_UPDATE
insert into v3 (col1) values ((select max(col1) from v1)); 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)); 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)); insert into v3 (col1) values ((select max(col1) from v2));
# check with TZ tables in list # check with TZ tables in list
-- error ER_VIEW_PREVENT_UPDATE --error ER_WARN_DATA_OUT_OF_RANGE
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); 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)); insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
-- error ER_BAD_NULL_ERROR -- error ER_BAD_NULL_ERROR
insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
@ -1213,9 +1201,19 @@ create view v3 as select * from t1 where 20 < (select (s1) from v2);
-- error ER_NON_INSERTABLE_TABLE -- error ER_NON_INSERTABLE_TABLE
insert into v3 values (30); insert into v3 values (30);
create view v4 as select * from v2 where 20 < (select (s1) from t1); 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); 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; drop table t1;
# #

View File

@ -1979,6 +1979,52 @@ connection default;
DROP VIEW v1; DROP VIEW v1;
DROP USER foo; DROP USER foo;
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 # End of 10.5 tests
# Check that a user without access to the schema 'foo' cannot query # Check that a user without access to the schema 'foo' cannot query
# a JSON_TABLE view in that schema. # a JSON_TABLE view in that schema.

View File

@ -2238,6 +2238,53 @@ DROP VIEW v1;
DROP USER foo; DROP USER foo;
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 # End of 10.5 tests
--echo # Check that a user without access to the schema 'foo' cannot query --echo # Check that a user without access to the schema 'foo' cannot query

View File

@ -1320,5 +1320,17 @@ f
foo foo
<b></b> <b></b>
# #
# Start of 10.5 tests # End of 10.5 tests
# #
# Start of 11.4 tests
#
# MDEV-36565 Assertion `src != ((void *)0)' failed in my_casedn_8bit
#
SET NAMES latin1;
SELECT lcase((extractvalue('a', 'a'))) a FROM (select 1) dt;
a
SELECT ucase((extractvalue('a', 'a'))) a FROM (select 1) dt;
a
# End of 11.4 tests

View File

@ -822,5 +822,17 @@ DROP TABLE t1;
SELECT 'foo' AS f UNION SELECT BINARY( UpdateXML('<a></a>', '/a', '<b></b>')) AS f; SELECT 'foo' AS f UNION SELECT BINARY( UpdateXML('<a></a>', '/a', '<b></b>')) AS f;
--echo # --echo #
--echo # Start of 10.5 tests --echo # End of 10.5 tests
--echo # --echo #
--echo # Start of 11.4 tests
--echo #
--echo # MDEV-36565 Assertion `src != ((void *)0)' failed in my_casedn_8bit
--echo #
SET NAMES latin1;
SELECT lcase((extractvalue('a', 'a'))) a FROM (select 1) dt;
SELECT ucase((extractvalue('a', 'a'))) a FROM (select 1) dt;
--echo # End of 11.4 tests

View File

@ -130,6 +130,8 @@ our $path_language;
our $path_current_testlog; our $path_current_testlog;
our $path_testlog; our $path_testlog;
our $opt_open_files_limit;
our $default_vardir; our $default_vardir;
our $opt_vardir; # Path to use for var/ dir our $opt_vardir; # Path to use for var/ dir
our $plugindir; our $plugindir;
@ -1279,6 +1281,7 @@ sub command_line_setup {
'list-options' => \$opt_list_options, 'list-options' => \$opt_list_options,
'skip-test-list=s' => \@opt_skip_test_list, 'skip-test-list=s' => \@opt_skip_test_list,
'xml-report=s' => \$opt_xml_report, 'xml-report=s' => \$opt_xml_report,
'open-files-limit=i', => \$opt_open_files_limit,
My::Debugger::options(), My::Debugger::options(),
My::CoreDump::options(), My::CoreDump::options(),
@ -5779,6 +5782,7 @@ sub start_mysqltest ($) {
append => 1, append => 1,
error => $path_current_testlog, error => $path_current_testlog,
verbose => $opt_verbose, verbose => $opt_verbose,
open_files_limit => $opt_open_files_limit,
); );
mtr_verbose("Started $proc"); mtr_verbose("Started $proc");
return $proc; return $proc;
@ -6077,6 +6081,8 @@ Misc options
timediff With --timestamp, also print time passed since timediff With --timestamp, also print time passed since
*previous* test started *previous* test started
max-connections=N Max number of open connection to server in mysqltest 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 report-times Report how much time has been spent on different
phases of test execution. phases of test execution.
stress=ARGS Run stress test, providing options to stress=ARGS Run stress test, providing options to

View File

@ -1,6 +1,7 @@
--source include/big_test.inc --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_valgrind.inc
--source include/not_msan.inc
--source include/have_archive.inc --source include/have_archive.inc
CREATE TABLE t1(a BLOB) ENGINE=ARCHIVE; CREATE TABLE t1(a BLOB) ENGINE=ARCHIVE;
--disable_query_log --disable_query_log

View File

@ -3,7 +3,7 @@ the following:
- Add # before --exec echo "restart" ... - Add # before --exec echo "restart" ...
- Force $e (engine), $c (crash point) and $r (crash position) to the values - 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 - start mariadbd in a debugger
run the following in the debugger run the following in the debugger

View File

@ -1,6 +1,5 @@
--source include/long_test.inc --source include/long_test.inc
--source include/have_debug.inc --source include/have_debug.inc
--source include/have_innodb.inc
--source include/have_log_bin.inc --source include/have_log_bin.inc
--source include/default_charset.inc --source include/default_charset.inc
--source include/test_db_charset_latin1.inc --source include/test_db_charset_latin1.inc

View File

@ -4,4 +4,4 @@
let $engine_count=1; let $engine_count=1;
let $engines='aria'; let $engines='aria';
let $extra_engine=myisam; let $extra_engine=myisam;
--source alter_table.test --source alter_table.inc

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -0,0 +1,6 @@
#
# Test atomic alter table with MyISAM
let $engine_count=1;
let $engines='myisam';
--source alter_table.inc

View File

@ -4,4 +4,4 @@ let $engine_count=1;
let $engines='rocksdb'; let $engines='rocksdb';
let $skip_vector=1; let $skip_vector=1;
set global rocksdb_flush_log_at_trx_commit=1; set global rocksdb_flush_log_at_trx_commit=1;
--source alter_table.test --source alter_table.inc

View File

@ -7,7 +7,7 @@
# #
# Testing of atomic create table with crashes in a lot of different places # 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. # triggers in with ALTER TABLE .. RENAME.
# #

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More