1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä
2018-08-16 10:08:30 +03:00
335 changed files with 7445 additions and 2293 deletions

1
.gitignore vendored
View File

@ -94,7 +94,6 @@ packaging/rpm-oel/mysql.spec
packaging/rpm-uln/mysql.10.0.11.spec
packaging/solaris/postinstall-solaris
pcre/config.h
pcre/pcre*test.sh
pcre/pcre.h
pcre/pcre_chartables.c
pcre/pcregrep

View File

@ -14,22 +14,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
# explicitly set the policy to OLD
# (cannot use NEW, not everyone is on cmake-2.8.12 yet)
IF(POLICY CMP0022)
CMAKE_POLICY(SET CMP0022 OLD)
ENDIF()
# We use the LOCATION target property (CMP0026)
# and get_target_property() for non-existent targets (CMP0045)
# and INSTALL_NAME_DIR (CMP0042)
IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
CMAKE_VERSION VERSION_GREATER "3.0.0")
CMAKE_POLICY(SET CMP0026 OLD)
CMAKE_POLICY(SET CMP0045 OLD)
CMAKE_POLICY(SET CMP0042 OLD)
CMAKE_POLICY(SET CMP0022 NEW)
ENDIF()
IF(POLICY CMP0054)
CMAKE_POLICY(SET CMP0054 NEW)
@ -181,6 +169,12 @@ IF(UNIX)
ENDIF()
OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
IF (WITHOUT_SERVER)
SET (SKIP_COMPONENTS "Server|IniFiles|SuportFiles|Readme")
ELSE()
SET (SKIP_COMPONENTS "N-O-N-E")
ENDIF()
OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF)
INCLUDE(check_compiler_flag)
@ -445,7 +439,7 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc)
IF(GIT_EXECUTABLE)
IF(GIT_EXECUTABLE AND EXISTS ${PROJECT_SOURCE_DIR}/.git)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}

View File

@ -82,7 +82,7 @@ ulong bytes_sent = 0L, bytes_received = 0L;
ulong mysqld_net_retry_count = 10L;
ulong open_files_limit;
ulong opt_binlog_rows_event_max_size;
uint test_flags = 0;
ulonglong test_flags = 0;
static uint opt_protocol= 0;
static FILE *result_file;
static char *result_file_name= 0;

View File

@ -1,18 +0,0 @@
find_path(
ZSTD_INCLUDE_DIR
NAMES "zstd.h"
)
find_library(
ZSTD_LIBRARY
NAMES zstd
)
set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
ZSTD DEFAULT_MSG ZSTD_INCLUDE_DIR ZSTD_LIBRARIES)
mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARIES ZSTD_FOUND)

25
cmake/Findzstd.cmake Normal file
View File

@ -0,0 +1,25 @@
# - Find zstd
# Find the zstd compression library and includes
#
# ZSTD_INCLUDE_DIR - where to find zstd.h, etc.
# ZSTD_LIBRARIES - List of libraries when using zstd.
# ZSTD_FOUND - True if zstd found.
if (DEFINED ZSTD_LIBRARIES)
return()
endif()
find_path(ZSTD_INCLUDE_DIR
NAMES zstd.h
HINTS ${ZSTD_ROOT_DIR}/include)
find_library(ZSTD_LIBRARIES
NAMES zstd
HINTS ${ZSTD_ROOT_DIR}/lib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(zstd DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIR)
mark_as_advanced(
ZSTD_LIBRARIES
ZSTD_INCLUDE_DIR)

View File

@ -14,11 +14,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This script creates initial database for packaging on Windows
SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
SET(MYSQLD_EXECUTABLE "@MYSQLD_EXECUTABLE@")
SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@")
SET(WIN32 "@WIN32@")
# Force Visual Studio to output to stdout
IF(ENV{VS_UNICODE_OUTPUT})
SET ($ENV{VS_UNICODE_OUTPUT})
@ -32,30 +27,27 @@ ENDIF()
# Create bootstrapper SQL script
FILE(WRITE bootstrap.sql "use mysql;\n" )
FOREACH(FILENAME mysql_system_tables.sql mysql_system_tables_data.sql mysql_performance_tables.sql)
FILE(STRINGS ${CMAKE_SOURCE_DIR}/scripts/${FILENAME} CONTENTS)
FILE(STRINGS ${TOP_SRCDIR}/scripts/${FILENAME} CONTENTS)
FOREACH(STR ${CONTENTS})
IF(NOT STR MATCHES "@current_hostname")
FILE(APPEND bootstrap.sql "${STR}\n")
ENDIF()
ENDFOREACH()
ENDFOREACH()
FILE(READ ${CMAKE_SOURCE_DIR}/scripts/fill_help_tables.sql CONTENTS)
FILE(READ ${TOP_SRCDIR}/scripts/fill_help_tables.sql CONTENTS)
FILE(APPEND bootstrap.sql "${CONTENTS}")
FILE(REMOVE_RECURSE mysql performance_schema)
FILE(REMOVE ibdata1 ib_logfile0 ib_logfile1)
MAKE_DIRECTORY(mysql)
IF(WIN32)
SET(CONSOLE --console)
ENDIF()
SET(BOOTSTRAP_COMMAND
${MYSQLD_EXECUTABLE}
--no-defaults
${CONSOLE}
--console
--bootstrap
--lc-messages-dir=${CMAKE_CURRENT_BINARY_DIR}/share
--lc-messages-dir=${BINDIR}/share
--basedir=.
--datadir=.
--default-storage-engine=MyISAM
@ -65,10 +57,10 @@ SET(BOOTSTRAP_COMMAND
GET_FILENAME_COMPONENT(CWD . ABSOLUTE)
EXECUTE_PROCESS(
COMMAND "@CMAKE_COMMAND@" -E echo Executing ${BOOTSTRAP_COMMAND}
COMMAND "${CMAKE_COMMAND}" -E echo Executing ${BOOTSTRAP_COMMAND}
)
EXECUTE_PROCESS (
COMMAND "@CMAKE_COMMAND@" -E
COMMAND "${CMAKE_COMMAND}" -E
echo input file bootstrap.sql, current directory ${CWD}
)
EXECUTE_PROCESS (

View File

@ -46,6 +46,10 @@ MACRO(CHECK_DTRACE)
AND NOT CMAKE_SYSTEM_NAME MATCHES "SunOS")
SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
ENDIF()
# On GNU/Hurd, dtrace is not supported
IF(DTRACE AND CMAKE_SYSTEM_NAME MATCHES "GNU")
SET(ENABLE_DTRACE OFF CACHE BOOL "Disable dtrace")
ENDIF()
SET(HAVE_DTRACE ${ENABLE_DTRACE})
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)

View File

@ -11,9 +11,6 @@ SET(LIBS "")
IF(POLICY CMP0011)
CMAKE_POLICY(SET CMP0011 NEW)
ENDIF()
IF(POLICY CMP0007)
CMAKE_POLICY(SET CMP0007 OLD)
ENDIF()
# Extract dependencies using CMake's internal ${target}_LIB_DEPENDS variable
# returned string in ${var} is can be passed to linker's command line

View File

@ -115,7 +115,12 @@ FUNCTION(INSTALL_SCRIPT)
SET(COMP)
ENDIF()
IF (COMP MATCHES ${SKIP_COMPONENTS})
RETURN()
ENDIF()
INSTALL(PROGRAMS ${script} DESTINATION ${ARG_DESTINATION} ${COMP})
INSTALL_MANPAGE(${script})
ENDFUNCTION()
@ -132,6 +137,10 @@ FUNCTION(INSTALL_DOCUMENTATION)
SET(destination ${INSTALL_DOCDIR})
ENDIF()
IF (ARG_COMPONENT MATCHES ${SKIP_COMPONENTS})
RETURN()
ENDIF()
STRING(TOUPPER ${ARG_COMPONENT} COMPUP)
IF(CPACK_COMPONENT_${COMPUP}_GROUP)
SET(group ${CPACK_COMPONENT_${COMPUP}_GROUP})
@ -150,21 +159,17 @@ ENDFUNCTION()
# Install symbolic link to CMake target.
# the link is created in the same directory as target
# the link is created in the current build directory
# and extension will be the same as for target file.
MACRO(INSTALL_SYMLINK linkname target destination component)
IF(UNIX)
GET_TARGET_PROPERTY(location ${target} LOCATION)
GET_FILENAME_COMPONENT(path ${location} PATH)
GET_FILENAME_COMPONENT(name ${location} NAME)
SET(output ${path}/${linkname})
SET(output ${CMAKE_CURRENT_BINARY_DIR}/${linkname})
ADD_CUSTOM_COMMAND(
OUTPUT ${output}
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output}
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${linkname}
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
${name}
$<TARGET_FILE_NAME:${target}>
${linkname}
WORKING_DIRECTORY ${path}
DEPENDS ${target}
)
@ -250,8 +255,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
ENDIF()
# Install man pages on Unix
IF(UNIX)
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
INSTALL_MANPAGE(${target_location})
INSTALL_MANPAGE($<TARGET_FILE:${target}>)
ENDIF()
ENDFOREACH()
@ -268,6 +272,7 @@ SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug
FUNCTION(INSTALL_DEBUG_TARGET target)
RETURN() # XXX unused?
CMAKE_PARSE_ARGUMENTS(ARG
""
"DESTINATION;RENAME;PDB_DESTINATION;COMPONENT"

View File

@ -139,17 +139,17 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
SET(OSLIBS)
FOREACH(LIB ${LIBS_TO_MERGE})
GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION)
GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE)
IF(NOT LIB_LOCATION)
IF(NOT TARGET ${LIB})
# 3rd party library like libz.so. Make sure that everything
# that links to our library links to this one as well.
LIST(APPEND OSLIBS ${LIB})
ELSE()
GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE)
# This is a target in current project
# (can be a static or shared lib)
IF(LIB_TYPE STREQUAL "STATIC_LIBRARY")
SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION})
SET(STATIC_TGTS ${STATIC_TGTS} ${LIB})
SET(STATIC_LIBS ${STATIC_LIBS} $<TARGET_FILE:${LIB}>)
ADD_DEPENDENCIES(${TARGET} ${LIB})
# Extract dependent OS libraries
GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS)
@ -171,7 +171,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
ADD_CUSTOM_COMMAND(
OUTPUT ${SOURCE_FILE}
COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE}
DEPENDS ${STATIC_LIBS})
DEPENDS ${STATIC_TGTS})
IF(MSVC)
# To merge libs, just pass them to lib.exe command line.
@ -182,29 +182,27 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS
"${LINKER_EXTRA_FLAGS}")
ELSE()
GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION)
IF(APPLE)
# Use OSX's libtool to merge archives (ihandles universal
# binaries properly)
ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
COMMAND rm ${TARGET_LOCATION}
COMMAND libtool -static -o ${TARGET_LOCATION}
COMMAND rm $<TARGET_FILE:${TARGET}>
COMMAND libtool -static -o $<TARGET_FILE:${TARGET}>
${STATIC_LIBS}
)
ELSE()
# Generic Unix, Cygwin or MinGW. In post-build step, call
# script, that extracts objects from archives with "ar x"
# and repacks them with "ar r"
SET(TARGET ${TARGET})
CONFIGURE_FILE(
${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake
@ONLY
)
ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
COMMAND rm ${TARGET_LOCATION}
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake
COMMAND ${CMAKE_COMMAND}
-DTARGET_LOCATION="$<TARGET_FILE:${TARGET}>"
-DTARGET="${TARGET}"
-DSTATIC_LIBS="${STATIC_LIBS}"
-DCMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
-DCMAKE_AR="${CMAKE_AR}"
-DCMAKE_RANLIB="${CMAKE_RANLIB}"
-P "${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake"
)
ENDIF()
ENDIF()
@ -269,7 +267,7 @@ MACRO(MERGE_LIBRARIES)
IF (ARG_SOVERSION)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${ARG_VERSION})
ENDIF()
TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})
TARGET_LINK_LIBRARIES(${TARGET} LINK_PRIVATE ${LIBS})
IF(ARG_OUTPUT_NAME)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME "${ARG_OUTPUT_NAME}")
ENDIF()
@ -282,7 +280,6 @@ MACRO(MERGE_LIBRARIES)
ENDIF()
MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP})
ENDIF()
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_INTERFACE_LIBRARIES "")
IF(ARG_SHARED AND LINK_FLAG_NO_UNDEFINED)
# Do not allow undefined symbols in shared libraries
GET_TARGET_PROPERTY(TARGET_LINK_FLAGS ${TARGET} LINK_FLAGS)
@ -295,18 +292,11 @@ MACRO(MERGE_LIBRARIES)
ENDMACRO()
FUNCTION(GET_DEPENDEND_OS_LIBS target result)
SET(deps ${${target}_LIB_DEPENDS})
IF(deps)
FOREACH(lib ${deps})
# Filter out keywords for used for debug vs optimized builds
IF(NOT lib MATCHES "general" AND NOT lib MATCHES "debug" AND NOT lib MATCHES "optimized")
GET_TARGET_PROPERTY(lib_location ${lib} LOCATION)
IF(NOT lib_location)
SET(ret ${ret} ${lib})
ENDIF()
FOREACH(lib ${${target}_LIB_DEPENDS})
IF(NOT TARGET ${lib})
SET(ret ${ret} ${lib})
ENDIF()
ENDFOREACH()
ENDIF()
ENDFOREACH()
SET(${result} ${ret} PARENT_SCOPE)
ENDFUNCTION()

View File

@ -14,19 +14,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This script merges many static libraries into
# one big library on Unix.
SET(TARGET_LOCATION "@TARGET_LOCATION@")
SET(TARGET "@TARGET@")
SET(STATIC_LIBS "@STATIC_LIBS@")
SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
SET(CMAKE_AR "@CMAKE_AR@")
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
FILE(REMOVE "${TARGET_LOCATION}")
SET(TEMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET})
MAKE_DIRECTORY(${TEMP_DIR})
# Extract each archive to its own subdirectory(avoid object filename clashes)
SEPARATE_ARGUMENTS(STATIC_LIBS UNIX_COMMAND "${STATIC_LIBS}")
FOREACH(LIB ${STATIC_LIBS})
GET_FILENAME_COMPONENT(NAME_NO_EXT ${LIB} NAME_WE)
SET(TEMP_SUBDIR ${TEMP_DIR}/${NAME_NO_EXT})

View File

@ -75,6 +75,9 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
ELSE()
SET(COMP COMPONENT Client)
ENDIF()
IF (COMP MATCHES ${SKIP_COMPONENTS})
RETURN()
ENDIF()
MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION} ${COMP})
ENDIF()
ENDFUNCTION()

View File

@ -77,6 +77,9 @@ IF(NOT VERSION)
SET(DEFAULT_MACHINE "i386")
ENDIF()
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "GNU")
SET(DEFAULT_PLATFORM "GNU")
SET(DEFAULT_MACHINE "i386")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
IF(CMAKE_OSX_DEPLOYMENT_TARGET)
SET(DEFAULT_PLATFORM "osx${CMAKE_OSX_DEPLOYMENT_TARGET}")
@ -132,7 +135,7 @@ IF(NOT VERSION)
SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
MESSAGE(STATUS "Packaging as: ${package_name}")
MESSAGE_ONCE(package_name "Packaging as: ${package_name}")
# Sometimes package suffix is added (something like "-icc-glibc23")
IF(PACKAGE_SUFFIX)

View File

@ -20,10 +20,12 @@ MACRO(CHECK_SYSTEMD)
SET(WITH_SYSTEMD "auto" CACHE STRING "Enable systemd scripts and notification support")
IF(WITH_SYSTEMD STREQUAL "yes" OR WITH_SYSTEMD STREQUAL "auto")
IF(PKG_CONFIG_FOUND)
IF(WITH_SYSTEMD STREQUAL "yes")
pkg_search_module(LIBSYSTEMD REQUIRED libsystemd libsystemd-daemon)
ELSE()
pkg_search_module(LIBSYSTEMD libsystemd libsystemd-daemon)
IF (NOT DEFINED LIBSYSTEMD_FOUND)
IF(WITH_SYSTEMD STREQUAL "yes")
pkg_search_module(LIBSYSTEMD REQUIRED libsystemd libsystemd-daemon)
ELSE()
pkg_search_module(LIBSYSTEMD libsystemd libsystemd-daemon)
ENDIF()
ENDIF()
IF(HAVE_DLOPEN)
SET(LIBSYSTEMD ${LIBSYSTEMD_LIBRARIES})

View File

@ -77,7 +77,7 @@ Changelog for innotop:
* remove cxn from $meta->{group_by} if there's only one connection displayed
* fix for issue 19 - cxn column won't become visible when viewing two
connections after having viewed one connection
* supress errors resulting from the addition of a 'BACKGROUND THREAD'
* suppress errors resulting from the addition of a 'BACKGROUND THREAD'
section in the output of 'show innodb status'
* possible fix for issue 22 - Useless use of a constant in void context
* small change to set_to_tbl() around hiding the cxn column if there

View File

@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301 USA
# Street, Fifth Floor, Boston, MA 02111-1301 USA
use strict;
use warnings FATAL => 'all';
@ -1438,8 +1438,8 @@ systems, you can issue `man perlgpl' or `man perlartistic' to read these
licenses.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA.
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02111-1301 USA.
LICENSE
# Configuration information and global setup {{{1
@ -4657,7 +4657,7 @@ my %stmt_maker_for = (
my $sth;
eval { # This can fail if the table doesn't exist, INFORMATION_SCHEMA doesn't exist, etc.
my $cols = $dbh->selectall_arrayref(q{SHOW /*innotop*/ COLUMNS FROM INFORMATION_SCHEMA.PROCESSLIST LIKE 'TIME_MS'});
if ( @$cols ) { # The TIME_MS colum exists
if ( @$cols ) { # The TIME_MS column exists
$sth = $dbh->prepare(q{SELECT /*innotop*/ ID, USER, HOST, DB, COMMAND, CASE WHEN TIME_MS/1000 > 365*86400 THEN TIME ELSE TIME_MS/1000 END AS TIME, STATE, INFO FROM INFORMATION_SCHEMA.PROCESSLIST});
}
};
@ -11653,7 +11653,7 @@ show you something like this:
pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m
buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo
total_mem_alloc Memory Total memory allocate IB_bp_total_m
add_pool_alloc Add'l Pool Additonal pool alloca IB_bp_add_poo
add_pool_alloc Add'l Pool Additional pool alloca IB_bp_add_poo
The first line shows which table you're editing, and reminds you again to press
'?' for a list of key mappings. The rest is a tabular representation of the
@ -12233,8 +12233,8 @@ systems, you can issue `man perlgpl' or `man perlartistic' to read these
licenses.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA.
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02111-1301 USA.
Execute innotop and press '!' to see this information at any time.

View File

@ -1678,7 +1678,7 @@ show you something like this:
\& pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m
\& buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo
\& total_mem_alloc Memory Total memory allocate IB_bp_total_m
\& add_pool_alloc Add\*(Aql Pool Additonal pool alloca IB_bp_add_poo
\& add_pool_alloc Add\*(Aql Pool Additional pool alloca IB_bp_add_poo
.Ve
.PP
The first line shows which table you're editing, and reminds you again to press
@ -2183,8 +2183,8 @@ systems, you can issue `man perlgpl' or `man perlartistic' to read these
licenses.
.PP
You should have received a copy of the \s-1GNU\s0 General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, \s-1MA 02111\-1307 USA.\s0
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, \s-1MA\s0 02111\-1301 \s-1USA\s0.
.PP
Execute innotop and press '!' to see this information at any time.
.SH "AUTHOR"

View File

@ -471,6 +471,21 @@ struct datafile_cur_t {
size_t buf_size;
size_t buf_read;
size_t buf_offset;
explicit datafile_cur_t(const char* filename = NULL) :
file(), thread_n(0), orig_buf(NULL), buf(NULL), buf_size(0),
buf_read(0), buf_offset(0)
{
memset(rel_path, 0, sizeof rel_path);
if (filename) {
strncpy(abs_path, filename, sizeof abs_path);
abs_path[(sizeof abs_path) - 1] = 0;
} else {
abs_path[0] = '\0';
}
rel_path[0] = '\0';
memset(&statinfo, 0, sizeof statinfo);
}
};
static
@ -489,9 +504,7 @@ datafile_open(const char *file, datafile_cur_t *cursor, uint thread_n)
{
bool success;
memset(cursor, 0, sizeof(datafile_cur_t));
strncpy(cursor->abs_path, file, sizeof(cursor->abs_path));
new (cursor) datafile_cur_t(file);
/* Get the relative path for the destination tablespace name, i.e. the
one that can be appended to the backup root directory. Non-system
@ -630,32 +643,36 @@ static
int
mkdirp(const char *pathname, int Flags, myf MyFlags)
{
char parent[PATH_MAX], *p;
char *parent, *p;
/* make a parent directory path */
strncpy(parent, pathname, sizeof(parent));
parent[sizeof(parent) - 1] = 0;
if (!(parent= strdup(pathname)))
return(-1);
for (p = parent + strlen(parent);
!is_path_separator(*p) && p != parent; p--);
!is_path_separator(*p) && p != parent; p--) ;
*p = 0;
/* try to make parent directory */
if (p != parent && mkdirp(parent, Flags, MyFlags) != 0) {
free(parent);
return(-1);
}
/* make this one if parent has been made */
if (my_mkdir(pathname, Flags, MyFlags) == 0) {
free(parent);
return(0);
}
/* if it already exists that is fine */
if (errno == EEXIST) {
free(parent);
return(0);
}
free(parent);
return(-1);
}
@ -665,17 +682,24 @@ bool
equal_paths(const char *first, const char *second)
{
#ifdef HAVE_REALPATH
char real_first[PATH_MAX];
char real_second[PATH_MAX];
char *real_first, *real_second;
int result;
if (realpath(first, real_first) == NULL) {
return false;
}
if (realpath(second, real_second) == NULL) {
real_first = realpath(first, 0);
if (real_first == NULL) {
return false;
}
return (strcmp(real_first, real_second) == 0);
real_second = realpath(second, 0);
if (real_second == NULL) {
free(real_first);
return false;
}
result = strcmp(real_first, real_second);
free(real_first);
free(real_second);
return result == 0;
#else
return strcmp(first, second) == 0;
#endif
@ -1360,6 +1384,30 @@ out:
return(ret);
}
void backup_fix_ddl(void);
#define LSN_PREFIX_IN_SHOW_STATUS "\nLog sequence number "
static lsn_t get_current_lsn(MYSQL *connection) {
MYSQL_RES *res = xb_mysql_query(connection, "SHOW ENGINE INNODB STATUS", true, false);
if (!res)
return 0;
MYSQL_ROW row = mysql_fetch_row(res);
DBUG_ASSERT(row);
if (row) {
const char *p = strstr(row[2],LSN_PREFIX_IN_SHOW_STATUS);
DBUG_ASSERT(p);
if (p)
{
p += sizeof(LSN_PREFIX_IN_SHOW_STATUS) - 1;
return (lsn_t)strtoll(p, NULL, 10);
}
}
mysql_free_result(res);
return 0;
}
lsn_t server_lsn_after_lock;
extern void backup_wait_for_lsn(lsn_t lsn);
/** Start --backup */
bool backup_start()
{
@ -1379,6 +1427,7 @@ bool backup_start()
if (!lock_tables(mysql_connection)) {
return(false);
}
server_lsn_after_lock = get_current_lsn(mysql_connection);
}
if (!backup_files(fil_path_to_mysql_datadir, false)) {
@ -1393,6 +1442,10 @@ bool backup_start()
rocksdb_create_checkpoint();
}
msg_ts("Waiting for log copy thread to read lsn %llu\n", (ulonglong)server_lsn_after_lock);
backup_wait_for_lsn(server_lsn_after_lock);
backup_fix_ddl();
// There is no need to stop slave thread before coping non-Innodb data when
// --no-lock option is used because --no-lock option requires that no DDL or
// DML to non-transaction tables can occur.
@ -2202,6 +2255,7 @@ static void rocksdb_lock_checkpoint()
msg_ts("Could not obtain rocksdb checkpont lock\n");
exit(EXIT_FAILURE);
}
mysql_free_result(res);
}
static void rocksdb_unlock_checkpoint()

View File

@ -1795,7 +1795,12 @@ mdl_lock_table(ulint space_id)
std::ostringstream lock_query;
lock_query << "SELECT 1 FROM " << full_table_name << " LIMIT 0";
msg_ts("Locking MDL for %s\n", full_table_name.c_str());
xb_mysql_query(mdl_con, lock_query.str().c_str(), false, true);
if (mysql_query(mdl_con, lock_query.str().c_str())) {
msg_ts("Warning : locking MDL failed for space id %zu, name %s\n", space_id, full_table_name.c_str());
} else {
MYSQL_RES *r = mysql_store_result(mdl_con);
mysql_free_result(r);
}
}
pthread_mutex_unlock(&mdl_lock_con_mutex);

View File

@ -109,6 +109,9 @@ Write to a datasink file.
int
ds_write(ds_file_t *file, const void *buf, size_t len)
{
if (len == 0) {
return 0;
}
return file->datasink->write(file, (const uchar *)buf, len);
}

View File

@ -130,14 +130,15 @@ Open a source file cursor and initialize the associated read filter.
be skipped and XB_FIL_CUR_ERROR on error. */
xb_fil_cur_result_t
xb_fil_cur_open(
/*============*/
/*============*/
xb_fil_cur_t* cursor, /*!< out: source file cursor */
xb_read_filt_t* read_filter, /*!< in/out: the read filter */
fil_node_t* node, /*!< in: source tablespace node */
uint thread_n) /*!< thread number for diagnostics */
uint thread_n, /*!< thread number for diagnostics */
ulonglong max_file_size)
{
bool success;
int err;
/* Initialize these first so xb_fil_cur_close() handles them correctly
in case of error */
cursor->orig_buf = NULL;
@ -172,7 +173,7 @@ xb_fil_cur_open(
"tablespace %s\n",
thread_n, cursor->abs_path);
return(XB_FIL_CUR_ERROR);
return(XB_FIL_CUR_SKIP);
}
mutex_enter(&fil_system.mutex);
@ -193,14 +194,31 @@ xb_fil_cur_open(
cursor->node = node;
cursor->file = node->handle;
if (stat(cursor->abs_path, &cursor->statinfo)) {
msg("[%02u] mariabackup: error: cannot stat %s\n",
#ifdef _WIN32
HANDLE hDup;
DuplicateHandle(GetCurrentProcess(),cursor->file.m_file,
GetCurrentProcess(), &hDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
int filenr = _open_osfhandle((intptr_t)hDup, 0);
if (filenr < 0) {
err = EINVAL;
}
else {
err = _fstat64(filenr, &cursor->statinfo);
close(filenr);
}
#else
err = fstat(cursor->file.m_file, &cursor->statinfo);
#endif
if (max_file_size < (ulonglong)cursor->statinfo.st_size) {
cursor->statinfo.st_size = (ulonglong)max_file_size;
}
if (err) {
msg("[%02u] mariabackup: error: cannot fstat %s\n",
thread_n, cursor->abs_path);
xb_fil_cur_close(cursor);
return(XB_FIL_CUR_ERROR);
return(XB_FIL_CUR_SKIP);
}
if (srv_file_flush_method == SRV_O_DIRECT
@ -373,7 +391,9 @@ xb_fil_cur_close(
/*=============*/
xb_fil_cur_t *cursor) /*!< in/out: source file cursor */
{
cursor->read_filter->deinit(&cursor->read_filter_ctxt);
if (cursor->read_filter) {
cursor->read_filter->deinit(&cursor->read_filter_ctxt);
}
free(cursor->orig_buf);

View File

@ -58,7 +58,7 @@ struct xb_fil_cur_t {
ulint space_size; /*!< space size in pages */
/** TODO: remove this default constructor */
xb_fil_cur_t() : page_size(0), read_filter_ctxt() {}
xb_fil_cur_t() : page_size(0), read_filter(0), read_filter_ctxt() {}
/** @return whether this is not a file-per-table tablespace */
bool is_system() const
@ -87,7 +87,8 @@ xb_fil_cur_open(
xb_fil_cur_t* cursor, /*!< out: source file cursor */
xb_read_filt_t* read_filter, /*!< in/out: the read filter */
fil_node_t* node, /*!< in: source tablespace node */
uint thread_n); /*!< thread number for diagnostics */
uint thread_n, /*!< thread number for diagnostics */
ulonglong max_file_size = ULLONG_MAX);
/************************************************************************
Reads and verifies the next block of pages from the source

View File

@ -75,8 +75,7 @@ xb_write_galera_info(bool incremental_prepare)
return;
}
memset(&xid, 0, sizeof(xid));
xid.formatID = -1;
xid.null();
if (!trx_rseg_read_wsrep_checkpoint(xid)) {

View File

@ -344,6 +344,25 @@ const char *opt_history = NULL;
char mariabackup_exe[FN_REFLEN];
char orig_argv1[FN_REFLEN];
pthread_mutex_t backup_mutex;
pthread_cond_t scanned_lsn_cond;
typedef std::map<space_id_t,std::string> space_id_to_name_t;
struct ddl_tracker_t {
/** Tablspaces with their ID and name, as they were copied to backup.*/
space_id_to_name_t tables_in_backup;
/** Tablespaces for that optimized DDL without redo log was found.*/
std::set<space_id_t> optimized_ddl;
/** Drop operations found in redo log. */
std::set<space_id_t> drops;
/* For DDL operation found in redo log, */
space_id_to_name_t id_to_name;
};
const space_id_t REMOVED_SPACE_ID = ULINT_MAX;
static ddl_tracker_t ddl_tracker;
/* Whether xtrabackup_binlog_info should be created on recovery */
static bool recover_binlog_info;
@ -536,49 +555,79 @@ void mdl_lock_all()
mdl_lock_table(node->space->id);
}
datafiles_iter_free(it);
DBUG_EXECUTE_IF("check_mdl_lock_works",
dbug_alter_thread_done =
dbug_start_query_thread("ALTER TABLE test.t ADD COLUMN mdl_lock_column int",
"Waiting for table metadata lock",1, ER_QUERY_INTERRUPTED););
}
/** Check if the space id belongs to the table which name should
be skipped based on the --tables, --tables-file and --table-exclude
options.
@param[in] space_id space id to check
@return true if the space id belongs to skip table/database list. */
static bool backup_includes(space_id_t space_id)
// Convert non-null terminated filename to space name
std::string filename_to_spacename(const byte *filename, size_t len)
{
datafiles_iter_t *it = datafiles_iter_new();
if (!it)
return true;
// null- terminate filename
char *f = (char *)malloc(len + 1);
ut_a(f);
memcpy(f, filename, len);
f[len] = 0;
for (size_t i = 0; i < len; i++)
if (f[i] == '\\')
f[i] = '/';
char *p = strrchr(f, '.');
ut_a(p);
*p = 0;
char *table = strrchr(f, '/');
ut_a(table);
*table = 0;
char *db = strrchr(f, '/');
ut_a(db);
*table = '/';
return std::string(db+1);
}
while (fil_node_t *node = datafiles_iter_next(it)){
if (space_id == 0
|| (node->space->id == space_id
&& !check_if_skip_table(node->space->name))) {
/** Report an operation to create, delete, or rename a file during backup.
@param[in] space_id tablespace identifier
@param[in] flags tablespace flags (NULL if not create)
@param[in] name file name (not NUL-terminated)
@param[in] len length of name, in bytes
@param[in] new_name new file name (NULL if not rename)
@param[in] new_len length of new_name, in bytes (0 if NULL) */
void backup_file_op(ulint space_id, const byte* flags,
const byte* name, ulint len,
const byte* new_name, ulint new_len)
{
msg("mariabackup: Unsupported redo log detected "
"and it belongs to %s\n",
space_id ? node->name: "the InnoDB system tablespace");
ut_ad(!flags || !new_name);
ut_ad(name);
ut_ad(len);
ut_ad(!new_name == !new_len);
pthread_mutex_lock(&backup_mutex);
msg("mariabackup: ALTER TABLE or OPTIMIZE TABLE "
"was being executed during the backup.\n");
if (!opt_lock_ddl_per_table) {
msg("mariabackup: Use --lock-ddl-per-table "
"parameter to lock all the table before "
"backup operation.\n");
}
datafiles_iter_free(it);
return false;
}
if (flags) {
ddl_tracker.id_to_name[space_id] = filename_to_spacename(name, len);
msg("DDL tracking : create %zu \"%.*s\": %x\n",
space_id, int(len), name, mach_read_from_4(flags));
}
else if (new_name) {
ddl_tracker.id_to_name[space_id] = filename_to_spacename(new_name, new_len);
msg("DDL tracking : rename %zu \"%.*s\",\"%.*s\"\n",
space_id, int(len), name, int(new_len), new_name);
} else {
ddl_tracker.drops.insert(space_id);
msg("DDL tracking : delete %zu \"%.*s\"\n", space_id, int(len), name);
}
pthread_mutex_unlock(&backup_mutex);
}
datafiles_iter_free(it);
return true;
/** Callback whenever MLOG_INDEX_LOAD happens.
@param[in] space_id space id to check
@return false */
void backup_optimized_ddl_op(ulint space_id)
{
// TODO : handle incremental
if (xtrabackup_incremental)
return;
pthread_mutex_lock(&backup_mutex);
ddl_tracker.optimized_ddl.insert(space_id);
pthread_mutex_unlock(&backup_mutex);
}
/* ======== Date copying thread context ======== */
@ -1363,7 +1412,7 @@ static int prepare_export()
// which is* unfortunately* still necessary to get mysqld up
if (strncmp(orig_argv1,"--defaults-file=",16) == 0)
{
sprintf(cmdline,
snprintf(cmdline, sizeof cmdline,
IF_WIN("\"","") "\"%s\" --mysqld \"%s\" "
" --defaults-extra-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=."
" --innodb --innodb-fast-shutdown=0"
@ -2326,7 +2375,7 @@ xb_get_copy_action(const char *dflt)
static
my_bool
xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=0, ulonglong max_size=ULLONG_MAX)
{
char dst_name[FN_REFLEN];
ds_file_t *dstfile = NULL;
@ -2356,20 +2405,35 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
return(FALSE);
}
bool was_dropped;
pthread_mutex_lock(&backup_mutex);
was_dropped = (ddl_tracker.drops.find(node->space->id) != ddl_tracker.drops.end());
pthread_mutex_unlock(&backup_mutex);
if (was_dropped) {
if (node->is_open()) {
mutex_enter(&fil_system.mutex);
node->close();
mutex_exit(&fil_system.mutex);
}
goto skip;
}
if (!changed_page_bitmap) {
read_filter = &rf_pass_through;
}
else {
read_filter = &rf_bitmap;
}
res = xb_fil_cur_open(&cursor, read_filter, node, thread_n);
res = xb_fil_cur_open(&cursor, read_filter, node, thread_n,max_size);
if (res == XB_FIL_CUR_SKIP) {
goto skip;
} else if (res == XB_FIL_CUR_ERROR) {
goto error;
}
strncpy(dst_name, cursor.rel_path, sizeof(dst_name));
strncpy(dst_name, (dest_name)?dest_name : cursor.rel_path, sizeof(dst_name));
/* Setup the page write filter */
if (xtrabackup_incremental) {
@ -2421,6 +2485,10 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
goto error;
}
pthread_mutex_lock(&backup_mutex);
ddl_tracker.tables_in_backup[node->space->id] = node_name;
pthread_mutex_unlock(&backup_mutex);
/* close */
msg_ts("[%02u] ...done\n", thread_n);
xb_fil_cur_close(&cursor);
@ -2583,7 +2651,7 @@ static bool xtrabackup_copy_logfile(bool last = false)
if (!start_lsn) {
msg("mariabackup: Error: xtrabackup_copy_logfile()"
" failed.\n");
return(true);
exit(EXIT_FAILURE);
}
} while (start_lsn == end_lsn);
@ -2592,12 +2660,30 @@ static bool xtrabackup_copy_logfile(bool last = false)
msg_ts(">> log scanned up to (" LSN_PF ")\n", start_lsn);
/* update global variable*/
pthread_mutex_lock(&backup_mutex);
log_copy_scanned_lsn = start_lsn;
pthread_cond_broadcast(&scanned_lsn_cond);
pthread_mutex_unlock(&backup_mutex);
debug_sync_point("xtrabackup_copy_logfile_pause");
return(false);
}
/**
Wait until redo log copying thread processes given lsn
*/
void backup_wait_for_lsn(lsn_t lsn) {
bool completed = false;
pthread_mutex_lock(&backup_mutex);
do {
pthread_cond_wait(&scanned_lsn_cond, &backup_mutex);
completed = log_copy_scanned_lsn >= lsn;
} while (!completed);
pthread_mutex_unlock(&backup_mutex);
}
extern lsn_t server_lsn_after_lock;
static os_thread_ret_t DECLARE_THREAD(log_copying_thread)(void*)
{
/*
@ -2654,6 +2740,42 @@ static os_thread_ret_t DECLARE_THREAD(io_watching_thread)(void*)
return(0);
}
#ifndef DBUG_OFF
/*
In debug mode, execute SQL statement that was passed via environment.
To use this facility, you need to
1. Add code DBUG_EXECUTE_MARIABACKUP_EVENT("my_event_name", key););
to the code. key is usually a table name
2. Set environment variable my_event_name_$key SQL statement you want to execute
when event occurs, in DBUG_EXECUTE_IF from above.
In mtr , you can set environment via 'let' statement (do not use $ as the first char
for the variable)
3. start mariabackup with --dbug=+d,debug_mariabackup_events
*/
static void dbug_mariabackup_event(const char *event,const char *key)
{
char envvar[FN_REFLEN];
if (key) {
snprintf(envvar, sizeof(envvar), "%s_%s", event, key);
char *slash = strchr(envvar, '/');
if (slash)
*slash = '_';
} else {
strncpy(envvar, event, sizeof(envvar));
}
char *sql = getenv(envvar);
if (sql) {
msg("dbug_mariabackup_event : executing '%s'\n", sql);
xb_mysql_query(mysql_connection, sql, false, true);
}
}
#define DBUG_MARIABACKUP_EVENT(A, B) DBUG_EXECUTE_IF("mariabackup_events", dbug_mariabackup_event(A,B););
#else
#define DBUG_MARIABACKUP_EVENT(A,B)
#endif
/**************************************************************************
Datafiles copying thread.*/
static
@ -2676,12 +2798,18 @@ DECLARE_THREAD(data_copy_thread_func)(
while ((node = datafiles_iter_next(ctxt->it)) != NULL) {
DBUG_MARIABACKUP_EVENT("before_copy", node->space->name);
/* copy the datafile */
if(xtrabackup_copy_datafile(node, num)) {
msg("[%02u] mariabackup: Error: "
"failed to copy datafile.\n", num);
exit(EXIT_FAILURE);
}
DBUG_MARIABACKUP_EVENT("after_copy", node->space->name);
}
pthread_mutex_lock(&ctxt->count_mutex);
@ -2853,6 +2981,7 @@ xb_load_single_table_tablespace(
Datafile *file = xb_new_datafile(name, is_remote);
if (file->open_read_only(true) != DB_SUCCESS) {
msg("Can't open datafile %s\n", name);
ut_free(name);
exit(EXIT_FAILURE);
}
@ -3170,7 +3299,7 @@ xb_load_tablespaces()
}
debug_sync_point("xtrabackup_load_tablespaces_pause");
DBUG_MARIABACKUP_EVENT("after_load_tablespaces", 0);
return(DB_SUCCESS);
}
@ -3765,6 +3894,8 @@ xtrabackup_backup_func()
uint count;
pthread_mutex_t count_mutex;
data_thread_ctxt_t *data_threads;
pthread_mutex_init(&backup_mutex, NULL);
pthread_cond_init(&scanned_lsn_cond, NULL);
#ifdef USE_POSIX_FADVISE
msg("mariabackup: uses posix_fadvise().\n");
@ -3778,7 +3909,7 @@ xtrabackup_backup_func()
return(false);
}
msg("mariabackup: cd to %s\n", mysql_real_data_home);
encryption_plugin_backup_init(mysql_connection);
msg("mariabackup: open files limit requested %u, set to %u\n",
(uint) xb_open_files_limit,
xb_set_max_open_files(xb_open_files_limit));
@ -3791,6 +3922,7 @@ xtrabackup_backup_func()
srv_read_only_mode = TRUE;
srv_operation = SRV_OPERATION_BACKUP;
log_file_op = backup_file_op;
metadata_to_lsn = 0;
if (xb_close_files)
@ -3804,6 +3936,7 @@ xtrabackup_backup_func()
fail:
metadata_to_lsn = log_copying_running;
stop_backup_threads();
log_file_op = NULL;
if (dst_log_file) {
ds_close(dst_log_file);
dst_log_file = NULL;
@ -4053,6 +4186,7 @@ fail_before_log_copying_thread_start:
goto fail_before_log_copying_thread_start;
log_copying_stop = os_event_create(0);
log_optimized_ddl_op = backup_optimized_ddl_op;
os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);
/* FLUSH CHANGED_PAGE_BITMAPS call */
@ -4084,6 +4218,11 @@ fail_before_log_copying_thread_start:
if (opt_lock_ddl_per_table) {
mdl_lock_all();
DBUG_EXECUTE_IF("check_mdl_lock_works",
dbug_alter_thread_done =
dbug_start_query_thread("ALTER TABLE test.t ADD COLUMN mdl_lock_column int",
"Waiting for table metadata lock", 1, ER_QUERY_INTERRUPTED););
}
it = datafiles_iter_new();
@ -4121,10 +4260,6 @@ fail_before_log_copying_thread_start:
pthread_mutex_destroy(&count_mutex);
free(data_threads);
datafiles_iter_free(it);
if (changed_page_bitmap) {
xb_page_bitmap_deinit(changed_page_bitmap);
}
}
bool ok = backup_start();
@ -4148,6 +4283,9 @@ fail_before_log_copying_thread_start:
goto fail;
}
if (changed_page_bitmap) {
xb_page_bitmap_deinit(changed_page_bitmap);
}
xtrabackup_destroy_datasinks();
msg("mariabackup: Redo log (from LSN " LSN_PF " to " LSN_PF
@ -4165,9 +4303,182 @@ fail_before_log_copying_thread_start:
}
innodb_shutdown();
log_file_op = NULL;
pthread_mutex_destroy(&backup_mutex);
pthread_cond_destroy(&scanned_lsn_cond);
return(true);
}
/**
This function handles DDL changes at the end of backup, under protection of
FTWRL. This ensures consistent backup in presence of DDL.
- New tables, that were created during backup, are now copied into backup.
Also, tablespaces with optimized (no redo loggin DDL) are re-copied into
backup. This tablespaces will get the extension ".new" in the backup
- Tables that were renamed during backup, are marked as renamed
For these, file <old_name>.ren will be created.
The content of the file is the new tablespace name.
- Tables that were deleted during backup, are marked as deleted
For these , an empty file <name>.del will be created
It is the responsibility of the prepare phase to deal with .new, .ren, and .del
files.
*/
void backup_fix_ddl(void)
{
std::set<std::string> new_tables;
std::set<std::string> dropped_tables;
std::map<std::string, std::string> renamed_tables;
for (space_id_to_name_t::iterator iter = ddl_tracker.tables_in_backup.begin();
iter != ddl_tracker.tables_in_backup.end();
iter++) {
const std::string name = iter->second;
ulint id = iter->first;
if (ddl_tracker.drops.find(id) != ddl_tracker.drops.end()) {
dropped_tables.insert(name);
continue;
}
bool has_optimized_ddl =
ddl_tracker.optimized_ddl.find(id) != ddl_tracker.optimized_ddl.end();
if (ddl_tracker.id_to_name.find(id) == ddl_tracker.id_to_name.end()) {
if (has_optimized_ddl) {
new_tables.insert(name);
}
continue;
}
/* tablespace was affected by DDL. */
const std::string new_name = ddl_tracker.id_to_name[id];
if (new_name != name) {
if (has_optimized_ddl) {
/* table was renamed, but we need a full copy
of it because of optimized DDL. We emulate a drop/create.*/
dropped_tables.insert(name);
new_tables.insert(new_name);
} else {
/* Renamed, and no optimized DDL*/
renamed_tables[name] = new_name;
}
} else if (has_optimized_ddl) {
/* Table was recreated, or optimized DDL ran.
In both cases we need a full copy in the backup.*/
new_tables.insert(name);
}
}
/* Find tables that were created during backup (and not removed).*/
for(space_id_to_name_t::iterator iter = ddl_tracker.id_to_name.begin();
iter != ddl_tracker.id_to_name.end();
iter++) {
ulint id = iter->first;
std::string name = iter->second;
if (ddl_tracker.tables_in_backup.find(id) != ddl_tracker.tables_in_backup.end()) {
/* already processed above */
continue;
}
if (ddl_tracker.drops.find(id) == ddl_tracker.drops.end()) {
dropped_tables.erase(name);
new_tables.insert(name);
}
}
// Mark tablespaces for rename
for (std::map<std::string, std::string>::iterator iter = renamed_tables.begin();
iter != renamed_tables.end(); ++iter) {
const std::string old_name = iter->first;
std::string new_name = iter->second;
backup_file_printf((old_name + ".ren").c_str(), "%s", new_name.c_str());
}
// Mark tablespaces for drop
for (std::set<std::string>::iterator iter = dropped_tables.begin();
iter != dropped_tables.end();
iter++) {
const std::string name(*iter);
backup_file_printf((name + ".del").c_str(), "%s", "");
}
// Load and copy new tables.
// Close all datanodes first, reload only new tables.
std::vector<fil_node_t *> all_nodes;
datafiles_iter_t *it = datafiles_iter_new();
if (!it)
return;
while (fil_node_t *node = datafiles_iter_next(it)) {
all_nodes.push_back(node);
}
for (size_t i = 0; i < all_nodes.size(); i++) {
fil_node_t *n = all_nodes[i];
if (n->space->id == 0)
continue;
if (n->is_open()) {
mutex_enter(&fil_system.mutex);
n->close();
mutex_exit(&fil_system.mutex);
}
fil_space_free(n->space->id, false);
}
for (std::set<std::string>::iterator iter = new_tables.begin();
iter != new_tables.end(); iter++) {
const char *space_name = iter->c_str();
if (check_if_skip_table(space_name))
continue;
std::string name(*iter);
bool is_remote = access((name + ".ibd").c_str(), R_OK) != 0;
const char *extension = is_remote ? ".isl" : ".ibd";
name.append(extension);
char buf[FN_REFLEN];
strncpy(buf, name.c_str(), sizeof(buf));
const char *dbname = buf;
char *p = strchr(buf, '/');
if (p == 0) {
msg("Unexpected tablespace %s filename %s\n", space_name, name.c_str());
ut_a(0);
}
ut_a(p);
*p = 0;
const char *tablename = p + 1;
xb_load_single_table_tablespace(dbname, tablename, is_remote);
}
it = datafiles_iter_new();
if (!it)
return;
while (fil_node_t *node = datafiles_iter_next(it)) {
fil_space_t * space = node->space;
if (!fil_is_user_tablespace_id(space->id))
continue;
std::string dest_name(node->space->name);
dest_name.append(".new");
#if 0
bool do_full_copy = ddl_tracker.optimized_ddl.find(n->space->id) != ddl_tracker.optimized_ddl.end();
if (do_full_copy) {
msg(
"Performing a full copy of the tablespace %s, because optimized (without redo logging) DDL operation"
"ran during backup. You can use set innodb_log_optimize_ddl=OFF to improve backup performance"
"in the future.\n",
n->space->name);
}
#endif
xtrabackup_copy_datafile(node, 0, dest_name.c_str()/*, do_full_copy ? ULONGLONG_MAX:UNIV_PAGE_SIZE */);
}
}
/* ================= prepare ================= */
/***********************************************************************
@ -4680,6 +4991,27 @@ error:
return FALSE;
}
std::string change_extension(std::string filename, std::string new_ext) {
DBUG_ASSERT(new_ext.size() == 3);
std::string new_name(filename);
new_name.resize(new_name.size() - new_ext.size());
new_name.append(new_ext);
return new_name;
}
static void rename_file(const char *from,const char *to) {
msg("Renaming %s to %s\n", from, to);
if (my_rename(from, to, MY_WME)) {
msg("Cannot rename %s to %s errno %d", from, to, errno);
exit(EXIT_FAILURE);
}
}
static void rename_file(const std::string& from, const std::string &to) {
rename_file(from.c_str(), to.c_str());
}
/************************************************************************
Callback to handle datadir entry. Function of this type will be called
for each entry which matches the mask by xb_process_datadir.
@ -4691,6 +5023,37 @@ typedef ibool (*handle_datadir_entry_func_t)(
const char* file_name, /*!<in: file name with suffix */
void* arg); /*!<in: caller-provided data */
/** Rename, and replace destination file, if exists */
static void rename_force(const char *from, const char *to) {
if (access(to, R_OK) == 0) {
msg("Removing %s\n", to);
if (my_delete(to, MYF(MY_WME))) {
msg("Can't remove %s, errno %d", to, errno);
exit(EXIT_FAILURE);
}
}
rename_file(from,to);
}
/* During prepare phase, rename ".new" files , that were created in backup_fix_ddl(),
to ".ibd".*/
static ibool prepare_handle_new_files(
const char* data_home_dir, /*!<in: path to datadir */
const char* db_name, /*!<in: database name */
const char* file_name, /*!<in: file name with suffix */
void *)
{
std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/' + file_name;
std::string dest_path = src_path;
size_t index = dest_path.find(".new");
DBUG_ASSERT(index != std::string::npos);
dest_path.replace(index, 4, ".ibd");
rename_force(src_path.c_str(),dest_path.c_str());
return TRUE;
}
/************************************************************************
Callback to handle datadir entry. Deletes entry if it has no matching
fil_space in fil_system directory.
@ -4896,6 +5259,103 @@ store_binlog_info(const char* filename, const char* name, ulonglong pos)
return(true);
}
/** Check if file exists*/
static bool file_exists(std::string name)
{
return access(name.c_str(), R_OK) == 0 ;
}
/** Read file content into STL string */
static std::string read_file_as_string(const std::string file) {
char content[FN_REFLEN];
FILE *f = fopen(file.c_str(), "r");
if (!f) {
msg("Can not open %s\n", file.c_str());
}
size_t len = fread(content, 1, FN_REFLEN, f);
fclose(f);
return std::string(content, len);
}
/** Delete file- Provide verbose diagnostics and exit, if operation fails. */
static void delete_file(const std::string& file, bool if_exists = false) {
if (if_exists && !file_exists(file))
return;
if (my_delete(file.c_str(), MYF(MY_WME))) {
msg("Can't remove %s, errno %d", file.c_str(), errno);
exit(EXIT_FAILURE);
}
}
/**
Rename tablespace during prepare.
Backup in its end phase may generate some .ren files, recording
tablespaces that should be renamed in --prepare.
*/
static void rename_table_in_prepare(const std::string &datadir, const std::string& from , const std::string& to,
const char *extension=0) {
if (!extension) {
static const char *extensions_nonincremental[] = { ".ibd", 0 };
static const char *extensions_incremental[] = { ".ibd.delta", ".ibd.meta", 0 };
const char **extensions = xtrabackup_incremental_dir ?
extensions_incremental : extensions_nonincremental;
for (size_t i = 0; extensions[i]; i++) {
rename_table_in_prepare(datadir, from, to, extensions[i]);
}
return;
}
std::string src = std::string(datadir) + "/" + from + extension;
std::string dest = std::string(datadir) + "/" + to + extension;
std::string ren2, tmp;
if (file_exists(dest)) {
ren2= std::string(datadir) + "/" + to + ".ren";
if (!file_exists(ren2)) {
msg("ERROR : File %s was not found, but expected during rename processing\n", ren2.c_str());
ut_a(0);
}
tmp = to + "#";
rename_table_in_prepare(datadir, to, tmp);
}
rename_file(src, dest);
if (ren2.size()) {
// Make sure the temp. renamed file is processed.
std::string to2 = read_file_as_string(ren2);
rename_table_in_prepare(datadir, tmp, to2);
delete_file(ren2);
}
}
static ibool prepare_handle_ren_files(const char *datadir, const char *db, const char *filename, void *) {
std::string ren_file = std::string(datadir) + "/" + db + "/" + filename;
if (!file_exists(ren_file))
return TRUE;
std::string to = read_file_as_string(ren_file);
std::string source_space_name = std::string(db) + "/" + filename;
source_space_name.resize(source_space_name.size() - 4); // remove extension
rename_table_in_prepare(datadir, source_space_name.c_str(), to.c_str());
delete_file(ren_file);
return TRUE;
}
/* Remove tablespaces during backup, based on */
static ibool prepare_handle_del_files(const char *datadir, const char *db, const char *filename, void *) {
std::string del_file = std::string(datadir) + "/" + db + "/" + filename;
std::string path(del_file);
path.resize(path.size() - 4); // remove extension;
if (xtrabackup_incremental) {
delete_file(path + ".ibd.delta", true);
delete_file(path + ".ibd.meta", true);
}
else {
delete_file(path + ".ibd", true);
}
delete_file(del_file);
return TRUE;
}
/** Implement --prepare
@return whether the operation succeeded */
static bool
@ -4913,6 +5373,21 @@ xtrabackup_prepare_func(char** argv)
}
msg("mariabackup: cd to %s\n", xtrabackup_real_target_dir);
fil_path_to_mysql_datadir = ".";
if (xtrabackup_incremental_dir) {
xb_process_datadir(xtrabackup_incremental_dir, ".new.meta", prepare_handle_new_files);
xb_process_datadir(xtrabackup_incremental_dir, ".new.delta", prepare_handle_new_files);
}
else {
xb_process_datadir(".", ".new", prepare_handle_new_files);
}
xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".",
".ren", prepare_handle_ren_files);
xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".",
".del", prepare_handle_del_files);
int argc; for (argc = 0; argv[argc]; argc++) {}
encryption_plugin_prepare_init(argc, argv);
@ -5203,7 +5678,6 @@ xb_init()
return(false);
}
encryption_plugin_backup_init(mysql_connection);
history_start_time = time(NULL);
}
@ -5261,7 +5735,7 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server)
srv_operation = SRV_OPERATION_RESTORE;
files_charset_info = &my_charset_utf8_general_ci;
check_if_backup_includes = backup_includes;
setup_error_messages();
sys_var_init();

View File

@ -105,11 +105,13 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case 'V':
print_version();
my_end(0);
exit(0);
break;
case 'I':
case '?':
usage();
my_end(0);
exit(0);
break;
}
@ -122,7 +124,10 @@ static int get_options(int *argc,char ***argv)
int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
{
my_end(0);
exit(ho_error);
}
if (!*argc && !print_all_codes)
{
@ -260,7 +265,10 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]);
if (get_options(&argc,&argv))
{
my_end(0);
exit(1);
}
my_handler_error_register();

View File

@ -79,6 +79,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'I':
case '?':
usage();
my_end(0);
exit(0);
}
return 0;
@ -91,7 +92,10 @@ static int get_options(int *argc,char ***argv)
int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
{
my_end(0);
exit(ho_error);
}
if (*argc == 0)
{
@ -113,10 +117,14 @@ int main(int argc, char **argv)
MY_INIT(argv[0]);
if (get_options(&argc,&argv))
{
my_end(0);
exit(1);
}
while (argc--)
{
my_bool do_more;
#ifndef WIN32
struct in_addr addr;
#endif
@ -125,13 +133,13 @@ int main(int argc, char **argv)
/* Not compatible with IPv6! Probably should use getnameinfo(). */
#ifdef WIN32
taddr = inet_addr(ip);
if(taddr != INADDR_NONE)
{
do_more= (taddr != INADDR_NONE);
#else
if (inet_aton(ip, &addr) != 0)
{
if ((do_more= (inet_aton(ip, &addr) != 0)))
taddr= addr.s_addr;
#endif
if (do_more)
{
if (taddr == htonl(INADDR_BROADCAST))
{
puts("Broadcast");
@ -205,5 +213,6 @@ int main(int argc, char **argv)
}
}
}
my_end(0);
exit(error);
}

View File

@ -20,9 +20,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
ADD_DEFINITIONS(${SSL_DEFINES})
#Remove -fno-implicit-templates
#(yassl sources cannot be compiled with it)
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp
src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp
src/yassl_imp.cpp src/yassl_int.cpp)

View File

@ -370,7 +370,7 @@ typedef int (*my_charset_conv_mb_wc)(CHARSET_INFO *, my_wc_t *,
typedef int (*my_charset_conv_wc_mb)(CHARSET_INFO *, my_wc_t,
uchar *, uchar *);
typedef size_t (*my_charset_conv_case)(CHARSET_INFO *,
char *, size_t, char *, size_t);
const char *, size_t, char *, size_t);
/*
A structure to return the statistics of a native string copying,
@ -725,9 +725,11 @@ size_t my_copy_fix_mb(CHARSET_INFO *cs,
/* Functions for 8bit */
extern size_t my_caseup_str_8bit(CHARSET_INFO *, char *);
extern size_t my_casedn_str_8bit(CHARSET_INFO *, char *);
extern size_t my_caseup_8bit(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_caseup_8bit(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_8bit(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_casedn_8bit(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
@ -821,17 +823,17 @@ int my_charlen_8bit(CHARSET_INFO *, const uchar *str, const uchar *end);
/* Functions for multibyte charsets */
extern size_t my_caseup_str_mb(CHARSET_INFO *, char *);
extern size_t my_casedn_str_mb(CHARSET_INFO *, char *);
extern size_t my_caseup_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_caseup_mb_varlen(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_mb_varlen(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_caseup_ujis(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_caseup_mb(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_mb(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_caseup_ujis(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_ujis(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_casedn_ujis(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);

View File

@ -1,7 +1,7 @@
#ifndef SQL_COMMON_INCLUDED
#define SQL_COMMON_INCLUDED
/* Copyright (c) 2003, 2012, Oracle and/or its affiliates.
Copyright (c) 2010, 2012, Monty Program Ab
/* Copyright (c) 2003, 2018, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -155,8 +155,7 @@ SET(LIBS
# (with corresponding target ${engine}_embedded)
SET(EMBEDDED_LIBS)
FOREACH(LIB ${LIBS})
GET_TARGET_PROPERTY(EMBEDDED_LOCATION ${LIB}_embedded LOCATION)
IF(EMBEDDED_LOCATION)
IF(TARGET ${LIB}_embedded)
LIST(APPEND EMBEDDED_LIBS ${LIB}_embedded)
ELSE()
LIST(APPEND EMBEDDED_LIBS ${LIB})

View File

@ -0,0 +1,15 @@
--echo #
--echo # MDEV-13118 Wrong results with LOWER and UPPER and subquery
--echo #
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
--sorted_result
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
--sorted_result
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;

View File

@ -112,6 +112,8 @@ sub check_socket_path_length {
return 0 if ($^O eq 'aix');
# See Debian bug #670722 - failing on kFreeBSD even after setting short path
return 0 if $^O eq 'gnukfreebsd' and length $path < 40;
# GNU/Hurd doesn't have hostpath(), but no limitation either
return 0 if $^O eq 'gnu';
require IO::Socket::UNIX;

View File

@ -114,4 +114,14 @@ EOF
--source include/kill_mysqld.inc
--exec $MYSQLD_BOOTSTRAP_CMD --ignore-db-dirs='some_dir' --ignore-db-dirs='some_dir' < $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql
#
# MDEV-13397 MariaDB upgrade fail when using default_time_zone
#
--write_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql
use test;
EOF
--exec $MYSQLD_BOOTSTRAP_CMD --default-time-zone=Europe/Moscow < $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql
--source include/start_mysqld.inc

View File

@ -3048,6 +3048,29 @@ DROP TABLE t1;
SELECT _binary 0x7E, _binary X'7E', _binary B'01111110';
_binary 0x7E _binary X'7E' _binary B'01111110'
~ ~ ~
SET NAMES utf8, character_set_connection=binary;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varbinary(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
abcdefghi-abcdefghi
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -24,6 +24,9 @@ SET NAMES binary;
--echo #
SELECT _binary 0x7E, _binary X'7E', _binary B'01111110';
SET NAMES utf8, character_set_connection=binary;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View File

@ -33844,6 +33844,29 @@ HEX(a) CHAR_LENGTH(a)
DROP TABLE t1;
SELECT _eucjpms 0x8EA0;
ERROR HY000: Invalid eucjpms character string: '8EA0'
SET NAMES eucjpms;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET eucjpms DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -537,6 +537,8 @@ DROP TABLE t1;
--error ER_INVALID_CHARACTER_STRING
SELECT _eucjpms 0x8EA0;
SET NAMES eucjpms;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests

View File

@ -25405,6 +25405,35 @@ A1A1A1A1A1A120202020202020202020202020202020202020
# End of 5.6 tests
#
#
# Start of 10.0 tests
#
SET NAMES utf8, character_set_connection=euckr;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET euckr DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
#
# Start of 10.2 tests
#
#

View File

@ -197,6 +197,16 @@ set collation_connection=euckr_bin;
--echo # End of 5.6 tests
--echo #
--echo #
--echo # Start of 10.0 tests
--echo #
SET NAMES utf8, character_set_connection=euckr;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #
--echo #
--echo # Start of 10.2 tests

View File

@ -5081,6 +5081,29 @@ E05C5B
E05B
DROP TABLE t1;
# Start of ctype_E05C.inc
SET NAMES utf8, character_set_connection=gbk;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET gbk DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
#

View File

@ -199,6 +199,9 @@ let $ctype_unescape_combinations=selected;
SET NAMES gbk;
--source include/ctype_E05C.inc
SET NAMES utf8, character_set_connection=gbk;
--source include/ctype_mdev13118.inc
--echo #
--echo # MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
--echo #

View File

@ -8022,6 +8022,29 @@ a
0
DROP VIEW v1;
DROP TABLE t1;
SET NAMES latin1;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -262,6 +262,9 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
SET NAMES latin1;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests

View File

@ -5690,6 +5690,29 @@ c2
YWJjZGVmZ2hp-YWJjZGVmZ2hp
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
SET NAMES utf8, character_set_connection=ucs2;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -992,6 +992,10 @@ DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
SET NAMES utf8, character_set_connection=ucs2;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View File

@ -26149,6 +26149,29 @@ HEX(a) CHAR_LENGTH(a)
DROP TABLE t1;
SELECT _ujis 0x8EA0;
ERROR HY000: Invalid ujis character string: '8EA0'
SET NAMES ujis;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET ujis DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -1368,6 +1368,10 @@ DROP TABLE t1;
SELECT _ujis 0x8EA0;
SET NAMES ujis;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View File

@ -2142,6 +2142,29 @@ EXECUTE stmt USING @arg00;
CONCAT(_utf16'a' COLLATE utf16_unicode_ci, ?)
aÿ
DEALLOCATE PREPARE stmt;
SET NAMES utf8, character_set_connection=utf16;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf16 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -870,6 +870,11 @@ SET @arg00=_binary 0x00FF;
EXECUTE stmt USING @arg00;
DEALLOCATE PREPARE stmt;
SET NAMES utf8, character_set_connection=utf16;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View File

@ -2326,6 +2326,35 @@ DFFFFFDFFFFF9CFFFF9DFFFF9EFFFF
# End of 5.6 tests
#
#
# Start of 10.0 tests
#
SET NAMES utf8, character_set_connection=utf16le;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf16le DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# Start of 10.0 tests
#
#
# Start of 10.1 tests
#
#

View File

@ -747,6 +747,19 @@ SET NAMES utf8, collation_connection=utf16le_bin;
--echo # End of 5.6 tests
--echo #
--echo #
--echo # Start of 10.0 tests
--echo #
SET NAMES utf8, character_set_connection=utf16le;
--source include/ctype_mdev13118.inc
--echo #
--echo # Start of 10.0 tests
--echo #
--echo #
--echo # Start of 10.1 tests
--echo #

View File

@ -2241,6 +2241,29 @@ EXECUTE stmt USING @arg00;
CONCAT(_utf32'a' COLLATE utf32_unicode_ci, ?)
aÿ
DEALLOCATE PREPARE stmt;
SET NAMEs utf8, character_set_connection=utf32;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf32 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -983,6 +983,14 @@ SET @arg00=_binary 0x00FF;
EXECUTE stmt USING @arg00;
DEALLOCATE PREPARE stmt;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET NAMEs utf8, character_set_connection=utf32;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View File

@ -10286,6 +10286,29 @@ SELECT * FROM v1;
c
ß
DROP VIEW v1;
SET NAMES utf8;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -1890,6 +1890,13 @@ SELECT * FROM v1;
DROP VIEW v1;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET NAMES utf8;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View File

@ -3478,6 +3478,29 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET NAMES default;
SET NAMES utf8mb4;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View File

@ -1959,6 +1959,14 @@ DROP TABLE t1;
SET NAMES default;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET NAMES utf8mb4;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View File

@ -1053,6 +1053,7 @@ INSERT INTO t2 VALUES (NULL),(NULL);
CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
@ -1082,6 +1083,38 @@ i
drop procedure pr;
drop view v1;
drop table t1;
set @@join_cache_level= @save_join_cache_level;
#
# MDEV-16307: Incorrect results when using BNLH join instead of BNL join with views
#
CREATE TABLE t1 (c1 text, c2 int);
INSERT INTO t1 VALUES ('a',1), ('c',3), ('g',7), ('d',4), ('c',3);
CREATE TABLE t2 (c1 text, c2 int);
INSERT INTO t2 VALUES ('b',2), ('c',3);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 5
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
c1 c2 c1 c2
c 3 c 3
c 3 c 3
set @save_join_cache_level= @@join_cache_level;
set @@join_cache_level=4;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY <derived2> hash_ALL NULL #hash#$hj 3 test.t2.c1 5 Using where; Using join buffer (flat, BNLH join)
2 DERIVED t1 ALL NULL NULL NULL NULL 5
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
c1 c2 c1 c2
c 3 c 3
c 3 c 3
drop table t1,t2;
drop view v1;
set @@join_cache_level= @save_join_cache_level;
# end of 5.5
#
# Start of 10.1 tests

View File

@ -913,6 +913,7 @@ CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
@ -935,7 +936,27 @@ call pr(2);
drop procedure pr;
drop view v1;
drop table t1;
set @@join_cache_level= @save_join_cache_level;
--echo #
--echo # MDEV-16307: Incorrect results when using BNLH join instead of BNL join with views
--echo #
CREATE TABLE t1 (c1 text, c2 int);
INSERT INTO t1 VALUES ('a',1), ('c',3), ('g',7), ('d',4), ('c',3);
CREATE TABLE t2 (c1 text, c2 int);
INSERT INTO t2 VALUES ('b',2), ('c',3);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
set @save_join_cache_level= @@join_cache_level;
set @@join_cache_level=4;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
drop table t1,t2;
drop view v1;
set @@join_cache_level= @save_join_cache_level;
--echo # end of 5.5
--echo #

View File

@ -15960,3 +15960,123 @@ f c
9 1
DROP VIEW v1;
DROP TABLE t1;
#
# MDEV-15087: error from inexpensive subquery before check
# for condition pushdown into derived
#
CREATE TABLE t1 (i1 int, v1 varchar(1));
INSERT INTO t1 VALUES (7,'x');
CREATE TABLE t2 (i1 int);
INSERT INTO t2 VALUES (8);
CREATE TABLE t3 (i1 int ,v1 varchar(1), v2 varchar(1));
INSERT INTO t3 VALUES (4, 'v','v'),(62,'v','k'),(7, 'n', NULL);
SELECT 1
FROM (t1 AS a1
JOIN (((SELECT DISTINCT t3.*
FROM t3) AS a2
JOIN t1 ON (t1.v1 = a2.v2))) ON (t1.v1 = a2.v1))
WHERE (SELECT BIT_COUNT(t2.i1)
FROM (t2 JOIN t3)) IS NULL;
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1, t2, t3;
#
# MDEV-16614 signal 7 after calling stored procedure, that uses regexp
#
CREATE PROCEDURE p1(m1 varchar(5), m2 varchar(5))
BEGIN
SELECT a FROM
(SELECT "aa" a) t
JOIN (SELECT "aa" b) t1 on t.a=t1.b
WHERE t.a regexp m1 and t1.b regexp m2
GROUP BY a;
END$$
CALL p1('a','a');
a
aa
DROP PROCEDURE p1;
CREATE PROCEDURE p1(m1 varchar(5))
BEGIN
SELECT a FROM (SELECT "aa" a) t WHERE t.a regexp m1;
END$$
CALL p1('a');
a
aa
DROP PROCEDURE p1;
SELECT a FROM (SELECT "aa" a) t WHERE REGEXP_INSTR(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
a
aa
CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
BEGIN
RETURN 1;
END;$$
CREATE OR REPLACE PROCEDURE p1(m1 varchar(5))
BEGIN
SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, m1);
END$$
CALL p1('a');
a
aa
DROP PROCEDURE p1;
DROP FUNCTION f1;
CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
BEGIN
RETURN 1;
END;$$
SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
a
aa
DROP FUNCTION f1;
#
# MDEV-16801: splittable materialized derived/views with
# one grouping field from table without keys
#
CREATE TABLE t1 (a int, b int, INDEX idx_a(a), INDEX idx_b(b)) ENGINE=MYISAM;
CREATE TABLE t2 (c int) ENGINE=MYISAM;
CREATE TABLE t3 (d int) ENGINE=MYISAM;
INSERT INTO t1 VALUES
(77,7), (11,1), (33,3), (44,4), (8,88),
(78,7), (98,9), (38,3), (28,2), (79,7),
(58,5), (42,4), (71,7), (27,2), (91,9);
INSERT INTO t1 SELECT a+100, b+10 FROM t1;
INSERT INTO t2 VALUES
(100), (700), (200), (100), (200);
INSERT INTO t3 VALUES
(3), (4), (1), (8), (3);
ANALYZE tables t1,t2,t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
SELECT *
FROM t3,
(SELECT t1.b, t2.c
FROM t1, t2
GROUP BY t1.b,t2.c) dt
WHERE t3.d = dt.b;
d b c
3 3 700
3 3 200
3 3 100
4 4 700
4 4 200
4 4 100
1 1 700
1 1 200
1 1 100
3 3 700
3 3 200
3 3 100
EXPLAIN EXTENDED SELECT *
FROM t3,
(SELECT t1.b, t2.c
FROM t1, t2
GROUP BY t1.b,t2.c) dt
WHERE t3.d = dt.b;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 5 100.00 Using where
1 PRIMARY <derived2> ref key0 key0 5 test.t3.d 2 100.00
2 LATERAL DERIVED t1 ref idx_b idx_b 5 test.t3.d 2 100.00 Using index; Using temporary; Using filesort
2 LATERAL DERIVED t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 /* select#1 */ select `test`.`t3`.`d` AS `d`,`dt`.`b` AS `b`,`dt`.`c` AS `c` from `test`.`t3` join (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`b` = `test`.`t3`.`d` group by `test`.`t1`.`b`,`test`.`t2`.`c`) `dt` where `dt`.`b` = `test`.`t3`.`d`
DROP TABLE t1,t2,t3;

View File

@ -2906,3 +2906,116 @@ SELECT * FROM ( SELECT STRAIGHT_JOIN f, COUNT(*) as c FROM v1 GROUP BY f ) AS s;
DROP VIEW v1;
DROP TABLE t1;
--echo #
--echo # MDEV-15087: error from inexpensive subquery before check
--echo # for condition pushdown into derived
--echo #
CREATE TABLE t1 (i1 int, v1 varchar(1));
INSERT INTO t1 VALUES (7,'x');
CREATE TABLE t2 (i1 int);
INSERT INTO t2 VALUES (8);
CREATE TABLE t3 (i1 int ,v1 varchar(1), v2 varchar(1));
INSERT INTO t3 VALUES (4, 'v','v'),(62,'v','k'),(7, 'n', NULL);
--error ER_SUBQUERY_NO_1_ROW
SELECT 1
FROM (t1 AS a1
JOIN (((SELECT DISTINCT t3.*
FROM t3) AS a2
JOIN t1 ON (t1.v1 = a2.v2))) ON (t1.v1 = a2.v1))
WHERE (SELECT BIT_COUNT(t2.i1)
FROM (t2 JOIN t3)) IS NULL;
DROP TABLE t1, t2, t3;
--echo #
--echo # MDEV-16614 signal 7 after calling stored procedure, that uses regexp
--echo #
DELIMITER $$;
CREATE PROCEDURE p1(m1 varchar(5), m2 varchar(5))
BEGIN
SELECT a FROM
(SELECT "aa" a) t
JOIN (SELECT "aa" b) t1 on t.a=t1.b
WHERE t.a regexp m1 and t1.b regexp m2
GROUP BY a;
END$$
DELIMITER ;$$
CALL p1('a','a');
DROP PROCEDURE p1;
DELIMITER $$;
CREATE PROCEDURE p1(m1 varchar(5))
BEGIN
SELECT a FROM (SELECT "aa" a) t WHERE t.a regexp m1;
END$$
DELIMITER ;$$
CALL p1('a');
DROP PROCEDURE p1;
SELECT a FROM (SELECT "aa" a) t WHERE REGEXP_INSTR(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
DELIMITER $$;
CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
BEGIN
RETURN 1;
END;$$
CREATE OR REPLACE PROCEDURE p1(m1 varchar(5))
BEGIN
SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, m1);
END$$
DELIMITER ;$$
CALL p1('a');
DROP PROCEDURE p1;
DROP FUNCTION f1;
DELIMITER $$;
CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
BEGIN
RETURN 1;
END;$$
DELIMITER ;$$
SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
DROP FUNCTION f1;
--echo #
--echo # MDEV-16801: splittable materialized derived/views with
--echo # one grouping field from table without keys
--echo #
CREATE TABLE t1 (a int, b int, INDEX idx_a(a), INDEX idx_b(b)) ENGINE=MYISAM;
CREATE TABLE t2 (c int) ENGINE=MYISAM;
CREATE TABLE t3 (d int) ENGINE=MYISAM;
INSERT INTO t1 VALUES
(77,7), (11,1), (33,3), (44,4), (8,88),
(78,7), (98,9), (38,3), (28,2), (79,7),
(58,5), (42,4), (71,7), (27,2), (91,9);
INSERT INTO t1 SELECT a+100, b+10 FROM t1;
INSERT INTO t2 VALUES
(100), (700), (200), (100), (200);
INSERT INTO t3 VALUES
(3), (4), (1), (8), (3);
ANALYZE tables t1,t2,t3;
let $q=
SELECT *
FROM t3,
(SELECT t1.b, t2.c
FROM t1, t2
GROUP BY t1.b,t2.c) dt
WHERE t3.d = dt.b;
eval $q;
eval EXPLAIN EXTENDED $q;
DROP TABLE t1,t2,t3;

View File

@ -761,6 +761,36 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
# MDEV-16054 simple json functions flatline cpu on garbage input.
#
select json_array(1,uuid(),compress(5.140264e+307));
json_array(1,uuid(),compress(5.140264e+307))
NULL
#
# MDEV-16869 String functions don't respect character set of JSON_VALUE.
#
create table t1(json_col TEXT) DEFAULT CHARSET=latin1;
insert into t1 values (_latin1 X'7B226B657931223A2253EC227D');
select JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC' from t1;
JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC'
1
select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' from t1;
REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC'
1
drop table t1;
#
# MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
#
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
JSON_SET('{}', '$.a', _utf8 0xC3B6)
{"a": "<22>"}
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6)
{"a": "<22>", "b": "<22>"}
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6')
{"a": "<22>", "x": 1, "b": "<22>"}
#
# End of 10.2 tests
#
#

View File

@ -422,6 +422,30 @@ CREATE TABLE t1 AS SELECT
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # MDEV-16054 simple json functions flatline cpu on garbage input.
--echo #
select json_array(1,uuid(),compress(5.140264e+307));
--echo #
--echo # MDEV-16869 String functions don't respect character set of JSON_VALUE.
--echo #
create table t1(json_col TEXT) DEFAULT CHARSET=latin1;
insert into t1 values (_latin1 X'7B226B657931223A2253EC227D');
select JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC' from t1;
select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' from t1;
drop table t1;
--echo #
--echo # MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
--echo #
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
--echo #
--echo # End of 10.2 tests
--echo #

View File

@ -3554,6 +3554,38 @@ DROP FUNCTION fn_sleep_before_now;
DROP TRIGGER trg_insert_t_ts;
DROP TABLE t_ts, t_trig;
#
# MDEV-16878 Functions ADDTIME and SUBTIME get wrongly removed from WHERE by the equal expression optimizer
#
CREATE TABLE t1 (a TIME);
INSERT INTO t1 VALUES ('00:00:10'),('00:00:20');
SELECT a, SUBTIME(a,TIME'00:00:01'), ADDTIME(a,TIME'00:00:01') FROM t1;
a SUBTIME(a,TIME'00:00:01') ADDTIME(a,TIME'00:00:01')
00:00:10 00:00:09 00:00:11
00:00:20 00:00:19 00:00:21
SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09';
a
00:00:10
SELECT * FROM t1 WHERE ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
a
SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
a
EXPLAIN EXTENDED SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where subtime(`test`.`t1`.`a`,TIME'00:00:01') = TIME'00:00:09' and addtime(`test`.`t1`.`a`,TIME'00:00:01') <= TIME'00:00:09'
DROP TABLE t1;
#
# MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
#
SELECT
LAST_DAY(TIME'00:00:00') AS c1,
CAST(CAST(LAST_DAY(TIME'00:00:00') AS DATE) AS TIME) AS c2,
CAST(LAST_DAY(TIME'00:00:00') AS TIME) AS c3;
c1 c2 c3
2018-08-31 00:00:00 00:00:00
# End of 10.3 tests
#
# MDEV-14032 SEC_TO_TIME executes side effect two times
#
SET @a=10000000;

View File

@ -2140,6 +2140,31 @@ DROP TABLE t_ts, t_trig;
###################
--echo #
--echo # MDEV-16878 Functions ADDTIME and SUBTIME get wrongly removed from WHERE by the equal expression optimizer
--echo #
CREATE TABLE t1 (a TIME);
INSERT INTO t1 VALUES ('00:00:10'),('00:00:20');
SELECT a, SUBTIME(a,TIME'00:00:01'), ADDTIME(a,TIME'00:00:01') FROM t1;
SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09';
SELECT * FROM t1 WHERE ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
EXPLAIN EXTENDED SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
DROP TABLE t1;
--echo #
--echo # MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
--echo #
SELECT
LAST_DAY(TIME'00:00:00') AS c1,
CAST(CAST(LAST_DAY(TIME'00:00:00') AS DATE) AS TIME) AS c2,
CAST(LAST_DAY(TIME'00:00:00') AS TIME) AS c3;
--echo # End of 10.3 tests
--echo #
--echo # MDEV-14032 SEC_TO_TIME executes side effect two times
--echo #

View File

@ -1759,6 +1759,7 @@ drop user mysqltest@localhost;
disconnect user1;
drop database mysqltest;
use test;
call mtr.add_suppression("Can't open and lock privilege tables");
FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
FLUSH PRIVILEGES;
@ -1852,8 +1853,6 @@ BEGIN
SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END ;||
Warnings:
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
connection default;
SHOW GRANTS FOR 'user1'@'localhost';
Grants for user1@localhost
@ -1864,6 +1863,7 @@ SHOW GRANTS FOR 'user2';
Grants for user2@%
GRANT USAGE ON *.* TO 'user2'@'%'
GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%'
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db1`.`proc2` TO 'user2'@'%'
disconnect con1;
disconnect con2;
DROP PROCEDURE db1.proc1;

View File

@ -1598,6 +1598,9 @@ use test;
#
# Bug#16470 crash on grant if old grant tables
#
call mtr.add_suppression("Can't open and lock privilege tables");
--echo FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
FLUSH PRIVILEGES;

View File

@ -369,3 +369,8 @@ t1 1 invisible 1 c A NULL NULL NULL YES BTREE
t1 1 invisible_2 1 invisible A NULL NULL NULL YES BTREE
drop table t1;
set @old_debug= @@debug_dbug;
CREATE TABLE t1 (i INT );
SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
CREATE TABLE t2 LIKE t1;
SET debug_dbug= DEFAULT;
DROP TABLE t1, t2;

View File

@ -270,3 +270,9 @@ explain select * from t1 where invisible =9;
show indexes in t1;
drop table t1;
set @old_debug= @@debug_dbug;
## MDEV 15127
CREATE TABLE t1 (i INT );
SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
CREATE TABLE t2 LIKE t1;
SET debug_dbug= DEFAULT;
DROP TABLE t1, t2;

View File

@ -1506,6 +1506,46 @@ DROP VIEW v2;
DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
#
# MDEV-16512
# Server crashes in find_field_in_table_ref on 2nd execution of SP referring to
# non-existing field
#
CREATE TABLE t (i INT);
CREATE PROCEDURE p() SELECT t1.f FROM t AS t1 JOIN t AS t2 USING (f);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
FLUSH TABLES;
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP TABLE t;
CREATE TABLE t (f INT);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP TABLE t;
CREATE TABLE t (i INT);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP PROCEDURE p;
DROP TABLE t;
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT, c INT);
CREATE TABLE t4 (a INT, c INT);
CREATE TABLE t5 (a INT, c INT);
CREATE PROCEDURE p1() SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
LEFT JOIN t5 USING (a)) USING (a);
CALL p1;
ERROR 23000: Column 'c' in field list is ambiguous
CALL p1;
ERROR 23000: Column 'c' in field list is ambiguous
DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
#
# End of MariaDB 5.5 tests
#
#
# Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
#
CREATE TABLE t1 (a int);

View File

@ -1160,6 +1160,59 @@ DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
--echo #
--echo # MDEV-16512
--echo # Server crashes in find_field_in_table_ref on 2nd execution of SP referring to
--echo # non-existing field
--echo #
CREATE TABLE t (i INT);
CREATE PROCEDURE p() SELECT t1.f FROM t AS t1 JOIN t AS t2 USING (f);
--error ER_BAD_FIELD_ERROR
CALL p;
--error ER_BAD_FIELD_ERROR
CALL p;
FLUSH TABLES;
--error ER_BAD_FIELD_ERROR
CALL p;
DROP TABLE t;
#
# Fix the table definition to match the using
#
CREATE TABLE t (f INT);
#
# The following shouldn't fail as the table is now matching the using
#
--error ER_BAD_FIELD_ERROR
CALL p;
DROP TABLE t;
CREATE TABLE t (i INT);
--error ER_BAD_FIELD_ERROR
CALL p;
DROP PROCEDURE p;
DROP TABLE t;
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT, c INT);
CREATE TABLE t4 (a INT, c INT);
CREATE TABLE t5 (a INT, c INT);
CREATE PROCEDURE p1() SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
LEFT JOIN t5 USING (a)) USING (a);
--error ER_NON_UNIQ_ERROR
CALL p1;
--error ER_NON_UNIQ_ERROR
CALL p1;
DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
--echo #
--echo # End of MariaDB 5.5 tests
--echo #
--echo #
--echo # Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
--echo #

View File

@ -5925,6 +5925,39 @@ SET join_buffer_space_limit= default;
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t4,t5,t2;
#
# MDEV-16603: BNLH for query with materialized semi-join
#
set join_cache_level=4;
CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (7,'x');
CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
INSERT INTO t2 VALUES
(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
(228,'x'),(3,'y'),(1,'z'),(9,'z');
CREATE TABLE temp
SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
f1 f2
7 x
7 x
7 x
7 x
7 x
7 x
7 x
EXPLAIN EXTENDED SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1 100.00
1 PRIMARY temp hash_ALL NULL #hash#$hj 9 test.t1.i1,test.t1.v1 7 100.00 Using where; Using join buffer (flat, BNLH join)
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
2 MATERIALIZED t2 hash_index v1 #hash#v1:v1 4:9 test.t1.v1 10 10.00 Using index; Using join buffer (flat, BNLH join)
Warnings:
Note 1003 select `test`.`temp`.`f1` AS `f1`,`test`.`temp`.`f2` AS `f2` from `test`.`temp` semi join (`test`.`t2` join `test`.`t1`) where `test`.`temp`.`f1` = `test`.`t1`.`i1` and `test`.`t2`.`v1` = `test`.`t1`.`v1` and `test`.`temp`.`f2` = `test`.`t1`.`v1`
DROP TABLE t1,t2,temp;
SET join_cache_level = default;
#
# MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins.
#
set join_cache_level=default;

View File

@ -3869,6 +3869,37 @@ set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t4,t5,t2;
--echo #
--echo # MDEV-16603: BNLH for query with materialized semi-join
--echo #
--source include/have_innodb.inc
set join_cache_level=4;
CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (7,'x');
CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
INSERT INTO t2 VALUES
(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
(228,'x'),(3,'y'),(1,'z'),(9,'z');
CREATE TABLE temp
SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
let $q =
SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
eval $q;
eval EXPLAIN EXTENDED $q;
DROP TABLE t1,t2,temp;
SET join_cache_level = default;
--echo #
--echo # MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins.
--echo #
@ -3958,5 +3989,4 @@ drop table t1, t2;
set join_buffer_size = default;
# The following command must be the last one the file
# this must be the last command in the file
set @@optimizer_switch=@save_optimizer_switch;

View File

@ -2460,5 +2460,55 @@ id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
#
# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
# converted to INNER JOIN with first constant inner table
#
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
# end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch;

View File

@ -1992,6 +1992,54 @@ select * from t1 t
on t.id=r.id ;
drop table t1, t2;
--echo #
--echo # MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
--echo # converted to INNER JOIN with first constant inner table
--echo #
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
DROP TABLE t1,t2;
--echo # end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch;

View File

@ -2471,6 +2471,56 @@ id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
#
# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
# converted to INNER JOIN with first constant inner table
#
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
# end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch;
set join_cache_level=default;

View File

@ -144,3 +144,7 @@ select * from t2;
a
1
drop table tmp,t2;
create table t1 (a int) engine=memory;
rename table t1 to non_existent.t2;
ERROR 42000: Unknown database 'non_existent'
drop table t1;

View File

@ -141,3 +141,10 @@ select * from tmp;
select * from t2;
drop table tmp,t2;
#
# MDEV-11741 handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed or server crash in mi_reset or buffer overrun or unexpected ER_CANT_REMOVE_ALL_FIELDS
#
create table t1 (a int) engine=memory;
--error ER_BAD_DB_ERROR
rename table t1 to non_existent.t2;
drop table t1;

View File

@ -2,7 +2,13 @@
# MDEV-15477: SESSION_SYSVARS_TRACKER does not track last_gtid
#
SET gtid_seq_no=1000;
-- Tracker : SESSION_TRACK_SCHEMA
-- test
SET @@session.session_track_system_variables='last_gtid';
-- Tracker : SESSION_TRACK_SCHEMA
-- test
create table t1 (a int) engine=innodb;
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- last_gtid

View File

@ -228,8 +228,6 @@ FLUSH PRIVILEGES;
connect con1, localhost, mysqltest_1,,;
connection con1;
CREATE PROCEDURE p1(i INT) BEGIN END;
Warnings:
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
disconnect con1;
connection default;
DROP PROCEDURE p1;

View File

@ -516,4 +516,133 @@ use test;
drop database db1;
drop database db2;
drop table t1;
#
# MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
#
SET use_stat_tables = PREFERABLY;
SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' )
NULL
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
SELECT MAX(pk) FROM t1;
MAX(pk)
NULL
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;

View File

@ -305,4 +305,116 @@ drop database db1;
drop database db2;
drop table t1;
--echo #
--echo # MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
--echo #
SET use_stat_tables = PREFERABLY;
SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16757: manual addition of min/max statistics for BLOB
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
--sorted_result
SELECT * FROM mysql.column_stats;
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
--sorted_result
SELECT * FROM mysql.column_stats;
SELECT pk FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16757: manual addition of min/max statistics for BLOB
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
--sorted_result
SELECT * FROM mysql.column_stats;
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
--sorted_result
SELECT * FROM mysql.column_stats;
SELECT pk FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
SELECT MAX(pk) FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;

View File

@ -543,6 +543,135 @@ use test;
drop database db1;
drop database db2;
drop table t1;
#
# MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
#
SET use_stat_tables = PREFERABLY;
SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' )
NULL
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
SELECT MAX(pk) FROM t1;
MAX(pk)
NULL
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;

View File

@ -7237,6 +7237,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
#
# MDEV-16820: impossible where with inexpensive subquery
#
create table t1 (a int) engine=myisam;
insert into t1 values (3), (1), (7);
create table t2 (b int, index idx(b));
insert into t2 values (2), (5), (3), (2);
explain select * from t1 where (select max(b) from t2) = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -6098,6 +6098,21 @@ and t1.a in (select `test`.`t3`.`c` from `test`.`t3`);
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
--echo #
--echo # MDEV-16820: impossible where with inexpensive subquery
--echo #
create table t1 (a int) engine=myisam;
insert into t1 values (3), (1), (7);
create table t2 (b int, index idx(b));
insert into t2 values (2), (5), (3), (2);
explain select * from t1 where (select max(b) from t2) = 10;
explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
drop table t1,t2;
--echo End of 5.5 tests
--echo # End of 10.0 tests

View File

@ -2391,6 +2391,99 @@ ec70316637232000158bbfc8bcbe5d60
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
#
# MDEV-16751: Server crashes in st_join_table::cleanup or
# TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
#
set @save_join_cache_level= @@join_cache_level;
set join_cache_level=4;
CREATE TABLE t1 ( id int NOT NULL);
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
explain
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join)
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
1
1
1
1
set @@join_cache_level= @save_join_cache_level;
alter table t1 add key(id);
explain
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
1
1
1
1
drop table t1,t2;
#
# MDEV-15454: Nested SELECT IN returns wrong results
#
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
CREATE TABLE t2 ( a int, b int );
INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
INSERT INTO t3 (c, b) VALUES (27, 96);
CREATE PROCEDURE prepare_data()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 1000 DO
INSERT INTO t1 (a) VALUES (i);
INSERT INTO t2 (a,b) VALUES (i,56);
INSERT INTO t3 (c,b) VALUES (i,i);
SET i = i + 1;
END WHILE;
END$$
CALL prepare_data();
SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
a
7878
3465
1403
4189
8732
5
set @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch='materialization=off';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
SET optimizer_switch='materialization=on';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
1
1
1
1
drop table t1,t2;
drop view v1;
# End of 5.5 tests
#
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View File

@ -442,7 +442,7 @@ SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t3 const PRIMARY PRIMARY 4 const 1
2 DEPENDENT SUBQUERY t2 index NULL i2 11 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t2 index i2 i2 11 NULL 2 Using where; Using index
DROP TABLE t1,t2,t3;
#
# MDEV-7599: in-to-exists chosen after min/max optimization

View File

@ -7237,6 +7237,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
#
# MDEV-16820: impossible where with inexpensive subquery
#
create table t1 (a int) engine=myisam;
insert into t1 values (3), (1), (7);
create table t2 (b int, index idx(b));
insert into t2 values (2), (5), (3), (2);
explain select * from t1 where (select max(b) from t2) = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -7230,6 +7230,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
#
# MDEV-16820: impossible where with inexpensive subquery
#
create table t1 (a int) engine=myisam;
insert into t1 values (3), (1), (7);
create table t2 (b int, index idx(b));
insert into t2 values (2), (5), (3), (2);
explain select * from t1 where (select max(b) from t2) = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -7228,6 +7228,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
#
# MDEV-16820: impossible where with inexpensive subquery
#
create table t1 (a int) engine=myisam;
insert into t1 values (3), (1), (7);
create table t2 (b int, index idx(b));
insert into t2 values (2), (5), (3), (2);
explain select * from t1 where (select max(b) from t2) = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -7243,6 +7243,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
#
# MDEV-16820: impossible where with inexpensive subquery
#
create table t1 (a int) engine=myisam;
insert into t1 values (3), (1), (7);
create table t2 (b int, index idx(b));
insert into t2 values (2), (5), (3), (2);
explain select * from t1 where (select max(b) from t2) = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -7228,6 +7228,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
#
# MDEV-16820: impossible where with inexpensive subquery
#
create table t1 (a int) engine=myisam;
insert into t1 values (3), (1), (7);
create table t2 (b int, index idx(b));
insert into t2 values (2), (5), (3), (2);
explain select * from t1 where (select max(b) from t2) = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -1728,6 +1728,57 @@ id
13
drop table t1;
#
# MDEV-15982: Incorrect results when subquery is materialized
#
CREATE TABLE `t1` (`id` int(32) NOT NULL primary key);
INSERT INTO `t1` VALUES
(45), (46), (47), (48), (49), (50), (51), (52), (53), (54), (55), (56), (57), (58), (59), (60), (61), (62),
(63), (64), (65), (66), (67), (68), (69), (70), (71), (72), (73), (74), (75), (76), (77), (78), (79), (80),
(81), (82), (83), (84), (85), (86), (87), (88), (89), (90), (91), (92),(93),(94),(95),(96), (97), (98),
(99), (100), (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), (111), (112), (113),
(114), (115), (116), (117), (118), (119), (120), (121), (122), (123), (124), (125), (126), (127), (128),
(129), (130), (131), (132), (133), (134), (135), (136), (137), (138), (139), (140), (141), (142), (143), (144), (145), (146),
(147), (148), (149), (150), (151), (152), (153), (154), (155), (156), (157), (158), (159), (160), (161),
(162), (163), (164), (165), (166), (167), (168), (169), (170), (171), (172), (173),
(174), (175), (176), (177), (178), (179), (180), (181), (182), (183), (2), (3), (4), (5), (6), (19), (35),
(7), (20), (8), (36), (219), (22), (10), (23), (37), (11), (24);
CREATE TABLE `t2` (`type` int , `id` int(32) NOT NULL primary key);
INSERT INTO `t2` VALUES
(2,2),(2,3),(1,4),(2,5),(1,6),(1,19),(5,7),(1,20),(1,8),(1,21),(1,9),
(1,22),(2,10),(1,23),(2,11),(1,24),(1,12),(1,25),(2,13),(2,26),(2,14),
(2,27),(1,15),(1,28),(3,16),(1,29),(2,17),(1,30),(5,18),(2,1);
CREATE TABLE `t3` (`ref_id` int(32) unsigned ,`type` varchar(80),`id` int(32) NOT NULL );
INSERT INTO `t3` VALUES
(1,'incident',31),(2,'faux pas',32),
(5,'oopsies',33),(3,'deniable',34),
(11,'wasntme',35),(10,'wasntme',36),
(17,'faux pas',37),(13,'unlikely',38),
(13,'improbable',39),(14,'incident',40),
(26,'problem',41),(14,'problem',42),
(26,'incident',43),(27,'incident',44);
explain
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 30 Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using index
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 14
2 MATERIALIZED t1 eq_ref PRIMARY PRIMARY 4 test.t3.id 1 Using index
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
id
10
11
set optimizer_switch='materialization=off';
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
id
11
10
set optimizer_switch='materialization=on';
DROP TABLE t1,t2,t3;
#
# MDEV-15247: Crash when SET NAMES 'utf8' is set
#
CREATE TABLE t1 (

View File

@ -346,6 +346,55 @@ WHERE (
);
drop table t1;
--echo #
--echo # MDEV-15982: Incorrect results when subquery is materialized
--echo #
CREATE TABLE `t1` (`id` int(32) NOT NULL primary key);
INSERT INTO `t1` VALUES
(45), (46), (47), (48), (49), (50), (51), (52), (53), (54), (55), (56), (57), (58), (59), (60), (61), (62),
(63), (64), (65), (66), (67), (68), (69), (70), (71), (72), (73), (74), (75), (76), (77), (78), (79), (80),
(81), (82), (83), (84), (85), (86), (87), (88), (89), (90), (91), (92),(93),(94),(95),(96), (97), (98),
(99), (100), (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), (111), (112), (113),
(114), (115), (116), (117), (118), (119), (120), (121), (122), (123), (124), (125), (126), (127), (128),
(129), (130), (131), (132), (133), (134), (135), (136), (137), (138), (139), (140), (141), (142), (143), (144), (145), (146),
(147), (148), (149), (150), (151), (152), (153), (154), (155), (156), (157), (158), (159), (160), (161),
(162), (163), (164), (165), (166), (167), (168), (169), (170), (171), (172), (173),
(174), (175), (176), (177), (178), (179), (180), (181), (182), (183), (2), (3), (4), (5), (6), (19), (35),
(7), (20), (8), (36), (219), (22), (10), (23), (37), (11), (24);
CREATE TABLE `t2` (`type` int , `id` int(32) NOT NULL primary key);
INSERT INTO `t2` VALUES
(2,2),(2,3),(1,4),(2,5),(1,6),(1,19),(5,7),(1,20),(1,8),(1,21),(1,9),
(1,22),(2,10),(1,23),(2,11),(1,24),(1,12),(1,25),(2,13),(2,26),(2,14),
(2,27),(1,15),(1,28),(3,16),(1,29),(2,17),(1,30),(5,18),(2,1);
CREATE TABLE `t3` (`ref_id` int(32) unsigned ,`type` varchar(80),`id` int(32) NOT NULL );
INSERT INTO `t3` VALUES
(1,'incident',31),(2,'faux pas',32),
(5,'oopsies',33),(3,'deniable',34),
(11,'wasntme',35),(10,'wasntme',36),
(17,'faux pas',37),(13,'unlikely',38),
(13,'improbable',39),(14,'incident',40),
(26,'problem',41),(14,'problem',42),
(26,'incident',43),(27,'incident',44);
explain
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
set optimizer_switch='materialization=off';
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
set optimizer_switch='materialization=on';
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-15247: Crash when SET NAMES 'utf8' is set
--echo #

View File

@ -2431,6 +2431,99 @@ ec70316637232000158bbfc8bcbe5d60
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
#
# MDEV-16751: Server crashes in st_join_table::cleanup or
# TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
#
set @save_join_cache_level= @@join_cache_level;
set join_cache_level=4;
CREATE TABLE t1 ( id int NOT NULL);
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
explain
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join)
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
1
1
1
1
set @@join_cache_level= @save_join_cache_level;
alter table t1 add key(id);
explain
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
1
1
1
1
drop table t1,t2;
#
# MDEV-15454: Nested SELECT IN returns wrong results
#
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
CREATE TABLE t2 ( a int, b int );
INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
INSERT INTO t3 (c, b) VALUES (27, 96);
CREATE PROCEDURE prepare_data()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 1000 DO
INSERT INTO t1 (a) VALUES (i);
INSERT INTO t2 (a,b) VALUES (i,56);
INSERT INTO t3 (c,b) VALUES (i,i);
SET i = i + 1;
END WHILE;
END$$
CALL prepare_data();
SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
a
7878
3465
1403
4189
8732
5
set @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch='materialization=off';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
SET optimizer_switch='materialization=on';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
1
1
1
1
drop table t1,t2;
drop view v1;
# End of 5.5 tests
#
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View File

@ -2157,6 +2157,85 @@ eval $q;
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
--echo #
--echo # MDEV-16751: Server crashes in st_join_table::cleanup or
--echo # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
--echo #
set @save_join_cache_level= @@join_cache_level;
set join_cache_level=4;
CREATE TABLE t1 ( id int NOT NULL);
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
explain
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
set @@join_cache_level= @save_join_cache_level;
alter table t1 add key(id);
explain
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
drop table t1,t2;
--echo #
--echo # MDEV-15454: Nested SELECT IN returns wrong results
--echo #
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
CREATE TABLE t2 ( a int, b int );
INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
INSERT INTO t3 (c, b) VALUES (27, 96);
DELIMITER $$;
CREATE PROCEDURE prepare_data()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 1000 DO
INSERT INTO t1 (a) VALUES (i);
INSERT INTO t2 (a,b) VALUES (i,56);
INSERT INTO t3 (c,b) VALUES (i,i);
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;$$
CALL prepare_data();
SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
set @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch='materialization=off';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
SET optimizer_switch='materialization=on';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
drop table t1,t2;
drop view v1;
--echo # End of 5.5 tests
--echo #
--echo # MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View File

@ -2149,6 +2149,22 @@ DROP VIEW v1;
UNION
(SELECT 2, 2);
ERROR 42S02: Table 'test.v1' doesn't exist
#
# Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
# WRONG VALUES
#
SET NAMES utf8;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
a
1000003.0
1.0
SET NAMES latin1;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
a
1000003.0
1.0
End of 5.5 tests
#
# WL#1763 Avoid creating temporary table in UNION ALL

View File

@ -1480,6 +1480,21 @@ DROP VIEW v1;
UNION
(SELECT 2, 2);
--echo #
--echo # Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
--echo # WRONG VALUES
--echo #
let $old_charset= `SELECT @@character_set_client`;
SET NAMES utf8;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
eval SET NAMES $old_charset;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
--echo End of 5.5 tests
--echo #

View File

@ -0,0 +1,31 @@
# This file runs the query and checks
# whether the size of binlog is increased or not
# If size is changed it issue die command
# Parameters
# $sql_query = query to run
#Only last row of show binlog events matter
--let $tmp= 0
--let $counter= 1
while ($tmp != "No such row")
{
--let $initial_binlog_size= $tmp
--let $tmp= query_get_value(show binary logs, File_size, $counter)
--inc $counter
}
--eval $sql_query
--let $tmp= 0
--let $counter= 1
while ($tmp != "No such row")
{
--let $current_binlog_size= $tmp
--let $tmp= query_get_value(show binary logs, File_size, $counter)
--inc $counter
}
if ($initial_binlog_size != $current_binlog_size)
{
die "Binlog size changed";
}

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