diff options
author | Sergei Golubchik <sergii@pisem.net> | 2015-01-21 12:03:02 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2015-01-21 12:03:02 +0100 |
commit | d9c01e4b4ac6a7e2bdbcaf71819fa3d4f5269840 (patch) | |
tree | 4f86f6ce4e298430e313ed70f2225b3f29485f51 | |
parent | d854a254b84595b3a8f3a4d8083a2b997d59912e (diff) | |
parent | 8bc712e481a18976853fa57a7be77aab6159d431 (diff) | |
download | mariadb-git-d9c01e4b4ac6a7e2bdbcaf71819fa3d4f5269840.tar.gz |
5.5 merge
159 files changed, 2564 insertions, 454 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index be9616ea515..7ca9c0b6bf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,12 @@ 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) ENDIF() MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") @@ -108,36 +110,15 @@ FOREACH(_base ENDFOREACH() - # Following autotools tradition, add preprocessor definitions # specified in environment variable CPPFLAGS IF(DEFINED ENV{CPPFLAGS}) ADD_DEFINITIONS($ENV{CPPFLAGS}) ENDIF() -# -# Control aspects of the development environment which are -# specific to MySQL maintainers and developers. -# -INCLUDE(maintainer) - -SET(MYSQL_MAINTAINER_MODE "OFF" CACHE STRING "MySQL maintainer-specific development environment. Options are: ON OFF AUTO.") +SET(MYSQL_MAINTAINER_MODE "AUTO" CACHE STRING "MySQL maintainer-specific development environment. Options are: ON OFF AUTO.") MARK_AS_ADVANCED(MYSQL_MAINTAINER_MODE) -# Whether the maintainer mode compiler options should be enabled. -IF(CMAKE_C_COMPILER_ID MATCHES "GNU") - SET_MYSQL_MAINTAINER_GNU_C_OPTIONS() -ENDIF() -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS() -ENDIF() -IF(CMAKE_C_COMPILER_ID MATCHES "Intel") - SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS() -ENDIF() -IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS() -ENDIF() - # Packaging IF (NOT CPACK_GENERATOR) IF(WIN32) @@ -185,7 +166,7 @@ OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED) OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF) - + include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) # We need some extra FAIL_REGEX patterns @@ -388,18 +369,7 @@ CHECK_PCRE() # We have to add MAINTAINER_C_WARNINGS first to ensure that the flags # given by the invoking user are honored # -IF(MYSQL_MAINTAINER_MODE MATCHES "ON") - SET(CMAKE_C_FLAGS "${MY_MAINTAINER_C_WARNINGS} ${CMAKE_C_FLAGS}") - SET(CMAKE_CXX_FLAGS "${MY_MAINTAINER_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}") -ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") - SET(CMAKE_C_FLAGS_DEBUG "${MY_MAINTAINER_C_WARNINGS} ${CMAKE_C_FLAGS_DEBUG}") - SET(CMAKE_CXX_FLAGS_DEBUG "${MY_MAINTAINER_CXX_WARNINGS} ${CMAKE_CXX_FLAGS_DEBUG}") -ENDIF() - -IF(CMAKE_CROSSCOMPILING) - SET(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Path to import_executables.cmake from a native build") - INCLUDE(${IMPORT_EXECUTABLES}) -ENDIF() +INCLUDE(maintainer) IF(WITH_UNIT_TESTS) ENABLE_TESTING() @@ -523,4 +493,3 @@ IF(NON_DISTRIBUTABLE_WARNING) MESSAGE(WARNING " You have linked MariaDB with GPLv3 libraries! You may not distribute the resulting binary. If you do, you will put yourself into a legal problem with Free Software Foundation.") ENDIF() - diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 319be9111aa..7c93e8d3ebd 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. + Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2009, 2014, 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 @@ -2435,6 +2435,7 @@ int main(int argc, char** argv) DBUG_PROCESS(argv[0]); my_init_time(); // for time functions + tzset(); // set tzname init_alloc_root(&s_mem_root, 16384, 0, MYF(0)); if (load_defaults("my", load_groups, &argc, &argv)) diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 7e5ce563b15..02492f2dbc9 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -202,15 +202,16 @@ IF(UNIX) ENDIF() ENDIF() - # OSX flags - IF(APPLE) - SET(COMMON_C_FLAGS "-g -fno-common -fno-strict-aliasing") - # XXX: why are we using -felide-constructors on OSX? - SET(COMMON_CXX_FLAGS "-g -fno-common -felide-constructors -fno-strict-aliasing") - SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}") - SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os ${COMMON_C_FLAGS}") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os ${COMMON_CXX_FLAGS}") + # Default Clang flags + IF(CMAKE_C_COMPILER_ID MATCHES "Clang") + SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing") + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}") + ENDIF() + IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}") ENDIF() # Solaris flags diff --git a/cmake/compile_flags.cmake b/cmake/compile_flags.cmake new file mode 100644 index 00000000000..5e872f981b0 --- /dev/null +++ b/cmake/compile_flags.cmake @@ -0,0 +1,44 @@ +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +## ADD_COMPILE_FLAGS(<source files> COMPILE_FLAGS <flags>) +MACRO(ADD_COMPILE_FLAGS) + SET(FILES "") + SET(FLAGS "") + SET(COMPILE_FLAGS) + FOREACH(ARG ${ARGV}) + IF(ARG STREQUAL "COMPILE_FLAGS") + SET(COMPILE_FLAGS "COMPILE_FLAGS") + ELSEIF(COMPILE_FLAGS) + LIST(APPEND FLAGS ${ARG}) + ELSE() + LIST(APPEND FILES ${ARG}) + ENDIF() + ENDFOREACH() + FOREACH(FILE ${FILES}) + FOREACH(FLAG ${FLAGS}) + GET_SOURCE_FILE_PROPERTY(PROP ${FILE} COMPILE_FLAGS) + IF(NOT PROP) + SET(PROP ${FLAG}) + ELSE() + SET(PROP "${PROP} ${FLAG}") + ENDIF() + SET_SOURCE_FILES_PROPERTIES( + ${FILE} PROPERTIES COMPILE_FLAGS "${PROP}" + ) + ENDFOREACH() + ENDFOREACH() +ENDMACRO() diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index f5642ff4a00..bd8d96154b2 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -188,6 +188,7 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7") ALTERNATIVE_NAME("client" "mysql") ALTERNATIVE_NAME("devel" "mariadb-devel") ALTERNATIVE_NAME("server" "mariadb-server") + ALTERNATIVE_NAME("server" "mysql-compat-server") ALTERNATIVE_NAME("shared" "mariadb-libs") ALTERNATIVE_NAME("shared" "mysql-libs") ALTERNATIVE_NAME("test" "mariadb-test") diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 874e05b8a43..872d61d9aac 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,51 +13,46 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -INCLUDE(CheckCCompilerFlag) - -# Setup GCC (GNU C compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS) - SET(MY_MAINTAINER_WARNINGS - "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -DFORCE_INIT_OF_VARS") - - CHECK_C_COMPILER_FLAG("-Wno-missing-field-initializers" - HAVE_NO_MISSING_FIELD_INITIALIZERS) - - IF (HAVE_NO_MISSING_FIELD_INITIALIZERS) - SET(MY_MAINTAINER_WARNINGS - "${MY_MAINTAINER_WARNINGS} -Wno-missing-field-initializers") - ENDIF() - - CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement" - HAVE_DECLARATION_AFTER_STATEMENT) - IF(HAVE_DECLARATION_AFTER_STATEMENT) - SET(MY_MAINTAINER_DECLARATION_AFTER_STATEMENT - "-Wdeclaration-after-statement") - ENDIF() - SET(MY_MAINTAINER_C_WARNINGS - "${MY_MAINTAINER_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}" - CACHE INTERNAL "C warning options used in maintainer builds.") - # Do not make warnings in checks into errors. - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error") -ENDMACRO() - -# Setup G++ (GNU C++ compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS) - SET(MY_MAINTAINER_CXX_WARNINGS - "${MY_MAINTAINER_WARNINGS} -Wno-invalid-offsetof -Wno-unused-parameter -Woverloaded-virtual" - CACHE INTERNAL "C++ warning options used in maintainer builds.") -ENDMACRO() - -# Setup ICC (Intel C Compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS) - SET(MY_MAINTAINER_WARNINGS "-Wcheck") - SET(MY_MAINTAINER_C_WARNINGS "${MY_MAINTAINER_WARNINGS}" - CACHE INTERNAL "C warning options used in maintainer builds.") -ENDMACRO() - -# Setup ICPC (Intel C++ Compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS) - SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_WARNINGS}" - CACHE INTERNAL "C++ warning options used in maintainer builds.") -ENDMACRO() - +# Common warning flags for GCC, G++, Clang and Clang++ +SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security") +MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang +IF(HAVE_WVLA) + SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") +ENDIF() + +# Common warning flags for GCC and Clang +SET(MY_C_WARNING_FLAGS + "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement") + +# Common warning flags for G++ and Clang++ +SET(MY_CXX_WARNING_FLAGS + "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wno-unused-parameter") + +# Extra warning flags for Clang++ +IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(MY_CXX_WARNING_FLAGS + "${MY_CXX_WARNING_FLAGS} -Wno-null-conversion -Wno-unused-private-field") +ENDIF() + +# Turn on Werror (warning => error) when using maintainer mode. +IF(MYSQL_MAINTAINER_MODE MATCHES "ON") + SET(MY_C_WARNING_FLAGS "${MY_C_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror") + SET(MY_CXX_WARNING_FLAGS "${MY_CXX_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror") +ENDIF() + +# Set warning flags for GCC/Clang +IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + SET(MY_MAINTAINER_C_WARNINGS "${MY_C_WARNING_FLAGS}") +ENDIF() +# Set warning flags for G++/Clang++ +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(MY_MAINTAINER_CXX_WARNINGS "${MY_CXX_WARNING_FLAGS}") +ENDIF() + +IF(MYSQL_MAINTAINER_MODE MATCHES "ON") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}") +ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_MAINTAINER_C_WARNINGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_MAINTAINER_CXX_WARNINGS}") +ENDIF() diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake index 0d8bac106f0..4ac72070e8b 100644 --- a/cmake/os/Darwin.cmake +++ b/cmake/os/Darwin.cmake @@ -1,5 +1,4 @@ -# Copyright (c) 2010 Sun Microsystems, Inc. -# Use is subject to license terms. +# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -15,21 +14,3 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # This file includes OSX specific options and quirks, related to system checks - -# Workaround for CMake bug#9051 -# (CMake does not pass CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET when -# running TRY_COMPILE) - -IF(CMAKE_OSX_SYSROOT) - SET(ENV{CMAKE_OSX_SYSROOT} ${CMAKE_OSX_SYSROOT}) -ENDIF() -IF(CMAKE_OSX_SYSROOT) - SET(ENV{MACOSX_DEPLOYMENT_TARGET} ${OSX_DEPLOYMENT_TARGET}) -ENDIF() - -IF(CMAKE_OSX_DEPLOYMENT_TARGET) - # Workaround linker problems on OSX 10.4 - IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.5") - ADD_DEFINITIONS(-fno-common) - ENDIF() -ENDIF() diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 1453cc55053..c75f2e45bf6 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -90,7 +90,7 @@ SET(HAVE_GETRLIMIT CACHE INTERNAL "") SET(HAVE_GETRUSAGE CACHE INTERNAL "") SET(HAVE_GETTIMEOFDAY CACHE INTERNAL "") SET(HAVE_GETWD CACHE INTERNAL "") -SET(HAVE_GMTIME_R CACHE INTERNAL "") +SET(HAVE_GMTIME_R 1 CACHE INTERNAL "") SET(HAVE_GRP_H CACHE INTERNAL "") SET(HAVE_IA64INTRIN_H CACHE INTERNAL "") SET(HAVE_IEEEFP_H CACHE INTERNAL "") @@ -111,7 +111,7 @@ SET(HAVE_LANGINFO_H CACHE INTERNAL "") SET(HAVE_LDIV 1 CACHE INTERNAL "") SET(HAVE_LIMITS_H 1 CACHE INTERNAL "") SET(HAVE_LOCALE_H 1 CACHE INTERNAL "") -SET(HAVE_LOCALTIME_R CACHE INTERNAL "") +SET(HAVE_LOCALTIME_R 1 CACHE INTERNAL "") SET(HAVE_LOG2 CACHE INTERNAL "") SET(HAVE_LONGJMP 1 CACHE INTERNAL "") SET(HAVE_LRAND48 CACHE INTERNAL "") diff --git a/configure.cmake b/configure.cmake index d16a82a2309..215b0dc32b4 100644 --- a/configure.cmake +++ b/configure.cmake @@ -52,16 +52,6 @@ IF(NOT SYSTEM_TYPE) ENDIF() ENDIF() - -# Always enable -Wall for gnu C/C++ -IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_FLAGS MATCHES ".*-Wall.*") - SET(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter") -ENDIF() -IF(CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_C_FLAGS MATCHES ".*-Wall.*") - SET(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS} -Wall") -ENDIF() - - IF(CMAKE_COMPILER_IS_GNUCXX) # MySQL "canonical" GCC flags. At least -fno-rtti flag affects # ABI and cannot be simply removed. diff --git a/extra/replace.c b/extra/replace.c index c4105e45973..56cf02f2002 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2000, 2014, Oracle and/or its affiliates This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1021,7 +1021,7 @@ FILE *in,*out; updated=retain=0; reset_buffer(); - while ((error=fill_buffer_retaining(fileno(in),retain)) > 0) + while ((error=fill_buffer_retaining(my_fileno(in),retain)) > 0) { end_of_line=buffer ; buffer[bufbytes]=0; /* Sentinel */ diff --git a/extra/yassl/README b/extra/yassl/README index b18e2baeea8..30c7af4a702 100644 --- a/extra/yassl/README +++ b/extra/yassl/README @@ -12,6 +12,15 @@ before calling SSL_new(); *** end Note *** +yaSSL Release notes, version 2.3.5 (9/29/2014) + + This release of yaSSL fixes an RSA Padding check vulnerability reported by + Intel Security Advanced Threat Research team + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0 and note in 1.5.8. + + yaSSL Release notes, version 2.3.4 (8/15/2014) This release of yaSSL adds checking to the input_buffer class itself. diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 835a46eaea8..f819d76adc7 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -34,7 +34,7 @@ #include "rsa.h" -#define YASSL_VERSION "2.3.4" +#define YASSL_VERSION "2.3.5" #if defined(__cplusplus) diff --git a/extra/yassl/taocrypt/src/rsa.cpp b/extra/yassl/taocrypt/src/rsa.cpp index 69c59402e48..79a8a8f1c4f 100644 --- a/extra/yassl/taocrypt/src/rsa.cpp +++ b/extra/yassl/taocrypt/src/rsa.cpp @@ -177,7 +177,7 @@ word32 RSA_BlockType1::UnPad(const byte* pkcsBlock, word32 pkcsBlockLen, // skip past the padding until we find the separator unsigned i=1; - while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body + while (i<pkcsBlockLen && pkcsBlock[i++] == 0xFF) { // null body } if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0)) return 0; diff --git a/include/my_check_opt.h b/include/my_check_opt.h index a95cb79b3ac..ccf003decab 100644 --- a/include/my_check_opt.h +++ b/include/my_check_opt.h @@ -64,9 +64,11 @@ extern "C" { #define T_ZEROFILL_KEEP_LSN (1ULL << 33) /** If repair should not bump create_rename_lsn */ #define T_NO_CREATE_RENAME_LSN (1ULL << 34) -#define T_CREATE_UNIQUE_BY_SORT (1ULL << 35) -#define T_SUPPRESS_ERR_HANDLING (1ULL << 36) -#define T_FORCE_SORT_MEMORY (1ULL << 37) +/** If repair shouldn't do any locks */ +#define T_NO_LOCKS (1ULL << 35) +#define T_CREATE_UNIQUE_BY_SORT (1ULL << 36) +#define T_SUPPRESS_ERR_HANDLING (1ULL << 37) +#define T_FORCE_SORT_MEMORY (1ULL << 38) #define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL) diff --git a/include/my_pthread.h b/include/my_pthread.h index 36664775545..7770c28f45f 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. +/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2009, 2014, 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 @@ -104,8 +104,18 @@ int pthread_attr_init(pthread_attr_t *connect_att); int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack); int pthread_attr_destroy(pthread_attr_t *connect_att); int my_pthread_once(my_pthread_once_t *once_control,void (*init_routine)(void)); -struct tm *localtime_r(const time_t *timep,struct tm *tmp); -struct tm *gmtime_r(const time_t *timep,struct tm *tmp); + +static inline struct tm *localtime_r(const time_t *timep, struct tm *tmp) +{ + localtime_s(tmp, timep); + return tmp; +} + +static inline struct tm *gmtime_r(const time_t *clock, struct tm *res) +{ + gmtime_s(res, clock); + return res; +} void pthread_exit(void *a); int pthread_join(pthread_t thread, void **value_ptr); diff --git a/include/mysql.h b/include/mysql.h index 025bd397a65..63e86937063 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -75,6 +75,7 @@ typedef int my_socket; #include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */ +extern unsigned int mariadb_deinitialize_ssl; extern unsigned int mysql_port; extern char *mysql_unix_port; diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 6b60389acc3..dd794e856e1 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -172,6 +172,7 @@ extern LIST *list_reverse(LIST *root); extern void list_free(LIST *root,unsigned int free_data); extern unsigned int list_length(LIST *); extern int list_walk(LIST *,list_walk_action action,unsigned char * argument); +extern unsigned int mariadb_deinitialize_ssl; extern unsigned int mysql_port; extern char *mysql_unix_port; typedef struct st_mysql_field { diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index d432d499d47..bb85b47f863 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -257,7 +257,8 @@ mariadb_dyncol_unpack_free mariadb_dyncol_column_cmp_named mariadb_dyncol_column_count mariadb_dyncol_prepare_decimal - +# +mariadb_deinitialize_ssl # Added in MariaDB-10.0 to stay compatible with MySQL-5.6, yuck! mysql_options4 ) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 554c3fc0ab6..a0bfe4e0d4f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -205,7 +205,8 @@ void STDCALL mysql_server_end() mysql_client_plugin_deinit(); finish_client_errs(); - vio_end(); + if (mariadb_deinitialize_ssl) + vio_end(); #ifdef EMBEDDED_LIBRARY end_embedded_server(); #endif diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 9024ae9321e..a5fef8ecdd0 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -2,6 +2,9 @@ * Copyright (c) 2000 * SWsoft company * + * Modifications copyright (c) 2001, 2013. Oracle and/or its affiliates. + * All rights reserved. + * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * diff --git a/mysql-test/lib/My/SafeProcess/Base.pm b/mysql-test/lib/My/SafeProcess/Base.pm index 0e8c191c440..1ac0120a735 100644 --- a/mysql-test/lib/My/SafeProcess/Base.pm +++ b/mysql-test/lib/My/SafeProcess/Base.pm @@ -180,6 +180,7 @@ sub create_process { } $SIG{INT}= 'DEFAULT'; + $SIG{HUP}= 'DEFAULT'; # Make this process it's own process group to be able to kill # it and any childs(that hasn't changed group themself) diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index f19ca622278..d6110f5f8c8 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -141,6 +141,7 @@ extern "C" void handle_signal(int sig) // Ignore further signals signal(SIGTERM, SIG_IGN); signal(SIGINT, SIG_IGN); + signal(SIGHUP, SIG_IGN); // Continune execution, allow the child to be started and // finally terminated by monitor loop @@ -164,6 +165,7 @@ int main(int argc, char* const argv[] ) /* Install signal handlers */ sigaction(SIGTERM, &sa,NULL); sigaction(SIGINT, &sa,NULL); + sigaction(SIGHUP, &sa, NULL); sigaction(SIGCHLD, &sa,NULL); sigaction(SIGABRT, &sa_abort,NULL); @@ -231,6 +233,7 @@ int main(int argc, char* const argv[] ) // Use default signal handlers in child signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); + signal(SIGHUP, SIG_DFL); signal(SIGCHLD, SIG_DFL); // Make this process it's own process group to be able to kill diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 701dd30528b..ae037c2485e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -109,6 +109,7 @@ require "lib/mtr_gprof.pl"; require "lib/mtr_misc.pl"; $SIG{INT}= sub { mtr_error("Got ^C signal"); }; +$SIG{HUP}= sub { mtr_error("Hangup detected on controlling terminal"); }; our $mysql_version_id; my $mysql_version_extra; @@ -258,6 +259,7 @@ our $opt_ddd; our $opt_client_ddd; my $opt_boot_ddd; our $opt_manual_gdb; +our $opt_manual_lldb; our $opt_manual_dbx; our $opt_manual_ddd; our $opt_manual_debug; @@ -919,6 +921,7 @@ sub run_worker ($) { my ($server_port, $thread_num)= @_; $SIG{INT}= sub { exit(1); }; + $SIG{HUP}= sub { exit(1); }; # Connect to server my $server = new IO::Socket::INET @@ -1168,6 +1171,7 @@ sub command_line_setup { 'gdb' => \$opt_gdb, 'client-gdb' => \$opt_client_gdb, 'manual-gdb' => \$opt_manual_gdb, + 'manual-lldb' => \$opt_manual_lldb, 'boot-gdb' => \$opt_boot_gdb, 'manual-debug' => \$opt_manual_debug, 'ddd' => \$opt_ddd, @@ -1498,6 +1502,7 @@ sub command_line_setup { { $default_vardir= "$glob_mysql_test_dir/var"; } + $default_vardir = realpath $default_vardir unless IS_WINDOWS; if ( ! $opt_vardir ) { @@ -1604,8 +1609,9 @@ sub command_line_setup { $opt_debugger= undef; } - if ( $opt_gdb || $opt_ddd || $opt_manual_gdb || $opt_manual_ddd || - $opt_manual_debug || $opt_debugger || $opt_dbx || $opt_manual_dbx) + if ( $opt_gdb || $opt_ddd || $opt_manual_gdb || $opt_manual_lldb || + $opt_manual_ddd || $opt_manual_debug || $opt_debugger || $opt_dbx || + $opt_manual_dbx) { mtr_error("You need to use the client debug options for the", "embedded server. Ex: --client-gdb"); @@ -1632,9 +1638,9 @@ sub command_line_setup { # -------------------------------------------------------------------------- # Check debug related options # -------------------------------------------------------------------------- - if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd || - $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug || - $opt_dbx || $opt_client_dbx || $opt_manual_dbx || + if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd || + $opt_manual_gdb || $opt_manual_lldb || $opt_manual_ddd || + $opt_manual_debug || $opt_dbx || $opt_client_dbx || $opt_manual_dbx || $opt_debugger || $opt_client_debugger ) { if ( using_extern() ) @@ -2492,6 +2498,15 @@ sub environment_setup { $ENV{'MYSQL_TZINFO_TO_SQL'}= native_path($exe_mysql_tzinfo_to_sql); # ---------------------------------------------------- + # replace + # ---------------------------------------------------- + my $exe_replace= mtr_exe_exists(vs_config_dirs('extra', 'replace'), + "$basedir/extra/replace", + "$bindir/extra$opt_vs_config/replace", + "$path_client_bindir/replace"); + $ENV{'REPLACE'}= native_path($exe_replace); + + # ---------------------------------------------------- # innochecksum # ---------------------------------------------------- my $exe_innochecksum= @@ -5462,6 +5477,10 @@ sub mysqld_start ($$) { { gdb_arguments(\$args, \$exe, $mysqld->name()); } + elsif ( $opt_manual_lldb ) + { + lldb_arguments(\$args, \$exe, $mysqld->name()); + } elsif ( $opt_ddd || $opt_manual_ddd ) { ddd_arguments(\$args, \$exe, $mysqld->name()); @@ -6008,7 +6027,6 @@ sub start_mysqltest ($) { return $proc; } - # # Modify the exe and args so that program is run in gdb in xterm # @@ -6059,6 +6077,32 @@ sub gdb_arguments { $$exe= "xterm"; } +# +# Modify the exe and args so that program is run in lldb +# +sub lldb_arguments { + my $args= shift; + my $exe= shift; + my $type= shift; + my $input= shift; + + my $lldb_init_file= "$opt_vardir/tmp/lldbinit.$type"; + unlink($lldb_init_file); + + # Put $args into a single string + my $str= join(" ", @$$args); + $input = $input ? "< $input" : ""; + + # write init file for mysqld or client + mtr_tofile($lldb_init_file, "set args $str $input\n"); + + print "\nTo start lldb for $type, type in another window:\n"; + print "cd $glob_mysql_test_dir && lldb -s $lldb_init_file $$exe\n"; + + # Indicate the exe should not be started + $$exe= undef; + return; +} # # Modify the exe and args so that program is run in ddd @@ -6493,6 +6537,8 @@ Options for debugging the product test(s) manual-dbx Let user manually start mysqld in dbx, before running test(s) + manual-lldb Let user manually start mysqld in lldb, before running + test(s) max-save-core Limit the number of core files saved (to avoid filling up disks for heavily crashing server). Defaults to $opt_max_save_core, set to 0 for no limit. Set diff --git a/mysql-test/r/frm_bad_row_type-7333.result b/mysql-test/r/frm_bad_row_type-7333.result new file mode 100644 index 00000000000..4df3b70fc9f --- /dev/null +++ b/mysql-test/r/frm_bad_row_type-7333.result @@ -0,0 +1,14 @@ +call mtr.add_suppression("bad_row_type.frm: invalid value 11 for the field row_format"); +select * from bad_row_type; +category_id category_name +show create table bad_row_type; +Table Create Table +bad_row_type CREATE TABLE `bad_row_type` ( + `category_id` int(11) NOT NULL AUTO_INCREMENT, + `category_name` varchar(255) DEFAULT NULL, + PRIMARY KEY (`category_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 /* `compression`='tokudb_zlib' */ +show table status like 'bad_row_type'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +bad_row_type MyISAM 10 Dynamic 0 0 0 281474976710655 1024 0 1 x x NULL utf8_general_ci NULL `compression`='tokudb_zlib' +drop table bad_row_type; diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index bf07595bc3a..950d2e72666 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2677,3 +2677,27 @@ Warning 1292 Truncated incorrect time value: '9336:00:00' Warning 1292 Truncated incorrect time value: '2952:00:00' Warning 1292 Truncated incorrect time value: '2952:00:00' DROP TABLE t1; +# +# MDEV-7221 from_days fails after null value +# +CREATE TABLE t1 ( +id INT(11) NOT NULL PRIMARY KEY, +date1 DATE NULL DEFAULT NULL +); +INSERT INTO t1 VALUES (12, '2011-05-12'); +INSERT INTO t1 VALUES (13, NULL); +INSERT INTO t1 VALUES (14, '2009-10-23'); +INSERT INTO t1 VALUES (15, '2014-10-30'); +INSERT INTO t1 VALUES (16, NULL); +INSERT INTO t1 VALUES (17, NULL); +INSERT INTO t1 VALUES (18, '2010-10-13'); +SELECT a.id,a.date1,FROM_DAYS(TO_DAYS(a.date1)-10) as date2, DATE_ADD(a.date1,INTERVAL -10 DAY),TO_DAYS(a.date1)-10 FROM t1 a ORDER BY a.id; +id date1 date2 DATE_ADD(a.date1,INTERVAL -10 DAY) TO_DAYS(a.date1)-10 +12 2011-05-12 2011-05-02 2011-05-02 734624 +13 NULL NULL NULL NULL +14 2009-10-23 2009-10-13 2009-10-13 734058 +15 2014-10-30 2014-10-20 2014-10-20 735891 +16 NULL NULL NULL NULL +17 NULL NULL NULL NULL +18 2010-10-13 2010-10-03 2010-10-03 734413 +DROP TABLE t1; diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 0858198694b..9a259b3c4c6 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2494,6 +2494,20 @@ WHERE t1a.c1 = c2 GROUP BY i2; i2 DROP TABLE t1,t2; # +# MDEV-6855 +# MIN(*) with subqueries with IS NOT NULL in WHERE clause crashed. +# +CREATE TABLE t1 (i INT, c VARCHAR(3), KEY(c,i)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,'foo'),(0,'bar'); +CREATE TABLE t2 (j INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0),(8),(1),(8),(9); +SELECT MAX(i), c FROM t1 +WHERE c != 'qux' AND ( SELECT SUM(j) FROM t1, t2 ) IS NOT NULL GROUP BY c; +MAX(i) c +0 bar +7 foo +drop table t1,t2; +# # Bug #58782 # Missing rows with SELECT .. WHERE .. IN subquery # with full GROUP BY and no aggr diff --git a/mysql-test/r/insert_update_autoinc-7150.result b/mysql-test/r/insert_update_autoinc-7150.result new file mode 100644 index 00000000000..96773479310 --- /dev/null +++ b/mysql-test/r/insert_update_autoinc-7150.result @@ -0,0 +1,9 @@ +create table t1 (a int(10) auto_increment primary key, b int(11)); +insert t1 values (null,1); +insert t1 values (null,2), (1,-1), (null,3) on duplicate key update b=values(b); +select * from t1; +a b +1 -1 +2 2 +3 3 +drop table t1; diff --git a/mysql-test/r/kill-2.result b/mysql-test/r/kill-2.result new file mode 100644 index 00000000000..c2bcc979441 --- /dev/null +++ b/mysql-test/r/kill-2.result @@ -0,0 +1,10 @@ +# +# MDEV-6896 kill user command cause MariaDB crash! +# +create user foo@'127.0.0.1'; +select user from information_schema.processlist; +user +foo +root +kill user foo@'127.0.0.1'; +drop user foo@'127.0.0.1'; diff --git a/mysql-test/r/mdev6830.result b/mysql-test/r/mdev6830.result new file mode 100644 index 00000000000..0570659e860 --- /dev/null +++ b/mysql-test/r/mdev6830.result @@ -0,0 +1,49 @@ +drop table if exists t1,t2,t3; +drop view if exists v2,v3; +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM; +CREATE TABLE t2 ( +f1 DATE, +f2 VARCHAR(1024), +f3 VARCHAR(10), +f4 DATE, +f5 VARCHAR(10), +f6 VARCHAR(10), +f7 VARCHAR(10), +f8 DATETIME, +f9 INT, +f10 VARCHAR(1024), +f11 VARCHAR(1024), +f12 INT, +f13 VARCHAR(1024) +) ENGINE=MyISAM; +CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2; +CREATE TABLE t3 ( +f1 VARCHAR(1024), +f2 VARCHAR(1024), +f3 DATETIME, +f4 VARCHAR(10), +f5 INT, +f6 VARCHAR(10), +f7 VARCHAR(1024), +f8 VARCHAR(10), +f9 INT, +f10 DATE, +f11 INT, +f12 VARCHAR(1024), +f13 VARCHAR(10), +f14 DATE, +f15 DATETIME +) ENGINE=MyISAM; +CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t3 VALUES +('FOO','foo','2000-08-04 00:00:00','one',1,'1','FOO','foo',1,'2004-05-09',1,'one','one','2001-12-07','2001-10-17 08:25:04'), +('BAR','bar','2001-01-01 04:52:37','two',2,'2','BAR','bar',2,'2008-01-01',2,'two','two','2006-06-19','2002-01-01 08:22:49'); +CREATE TABLE t4 (f1 VARCHAR(10), f2 INT) ENGINE=MyISAM; +SELECT * FROM t1; +pk +SELECT non_existing FROM v2; +ERROR 42S22: Unknown column 'non_existing' in 'field list' +SELECT * FROM t1, v3, t4 WHERE v3.f1 = t4.f1 AND t4.f2 = 6 AND t1.pk = v3.f5; +pk f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f1 f2 +drop table t1,t2,t3,t4; +drop view v2,v3; diff --git a/mysql-test/r/processlist.result b/mysql-test/r/processlist.result index 0182245c278..eb3af67c5bf 100644 --- a/mysql-test/r/processlist.result +++ b/mysql-test/r/processlist.result @@ -7,9 +7,8 @@ SELECT ID, TIME,TIME_MS FROM INFORMATION_SCHEMA.PROCESSLIST WHERE CONCAT(":", ID SET DEBUG_SYNC = 'now SIGNAL fill_schema_proceed'; ID TIME TIME_MS TID 0 0.000 -SET DEBUG_SYNC = 'dispatch_command_end SIGNAL query_done EXECUTE 2'; -SET DEBUG_SYNC= 'now WAIT_FOR query_done'; -SET DEBUG_SYNC= 'now SIGNAL nosignal'; +set debug_sync='reset'; +SET debug_dbug="+d,sleep_inject_query_done_debug_sync"; select sleep(5); sleep(5) 0 diff --git a/mysql-test/r/sp-innodb.result b/mysql-test/r/sp-innodb.result new file mode 100644 index 00000000000..da02957d3c9 --- /dev/null +++ b/mysql-test/r/sp-innodb.result @@ -0,0 +1,32 @@ +drop table if exists t1,t2; +drop procedure if exists p1; +# +#MDEV-6985: MariaDB crashes on stored procedure call +# +CREATE TABLE `t1` ( +`ID` int(11) NOT NULL, +PRIMARY KEY (`ID`) +) ENGINE=InnoDB; +CREATE TABLE `t2` ( +`ID` int(11) NOT NULL, +`DATE` datetime DEFAULT NULL, +PRIMARY KEY (`ID`) +) ENGINE=InnoDB; +CREATE PROCEDURE `p1`() +BEGIN +DECLARE _mySelect CURSOR FOR +SELECT DISTINCT t1.ID +FROM t1 +LEFT JOIN t2 AS t2 ON +t2.ID = t1.ID +AND t2.DATE = ( +SELECT MAX(T3.DATE) FROM t2 AS T3 WHERE T3.ID = t2.ID AND T3.DATE<=NOW() +) +WHERE t1.ID = 1; +OPEN _mySelect; +CLOSE _mySelect; +END ;; +CALL p1(); +CALL p1(); +drop procedure p1; +drop table t1,t2; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index ff155e5fe15..23d1d76ca26 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -5394,6 +5394,8 @@ SELECT `f1`(1); DROP FUNCTION f1; DROP VIEW v1; DROP TABLE t1, t2; +create view v1 as select 1; +drop view v1; # ----------------------------------------------------------------- # -- End of 5.5 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index d0cdd858d4a..05e4600f4b7 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -60,3 +60,8 @@ SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'socket'; VARIABLE_NAME SOCKET +# +# Bug#16581605: REPLACE.EXE UTILITY IS BROKEN IN 5.5 +# +xyz +def diff --git a/mysql-test/std_data/bad_row_type.MYD b/mysql-test/std_data/bad_row_type.MYD new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/mysql-test/std_data/bad_row_type.MYD diff --git a/mysql-test/std_data/bad_row_type.MYI b/mysql-test/std_data/bad_row_type.MYI Binary files differnew file mode 100644 index 00000000000..731a83ed078 --- /dev/null +++ b/mysql-test/std_data/bad_row_type.MYI diff --git a/mysql-test/std_data/bad_row_type.frm b/mysql-test/std_data/bad_row_type.frm Binary files differnew file mode 100644 index 00000000000..d993c98d73e --- /dev/null +++ b/mysql-test/std_data/bad_row_type.frm diff --git a/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result b/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result index 48b6dfa61d9..0819d4e778f 100644 --- a/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result +++ b/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result @@ -1,6 +1,5 @@ set @save_binlog_format= @@global.binlog_format; set @save_binlog_dirct= @@global.binlog_direct_non_transactional_updates; -set @save_sql_log_bin= @@global.sql_log_bin; create table t1 (a int) engine= myisam; create table t2 (a int) engine= innodb; SELECT @@session.binlog_format; @@ -129,7 +128,7 @@ commit; begin; insert into t2 values (5); # Test that the global variable 'binlog_format' and -# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are +# 'binlog_direct_non_transactional_updates' are # writable inside a transaction. # Current session values are ROW, FALSE, TRUE respectively. SELECT @@global.binlog_format; @@ -137,20 +136,15 @@ SELECT @@global.binlog_format; ROW set @@global.binlog_format= statement; set @@global.binlog_direct_non_transactional_updates= TRUE; -set @@global.sql_log_bin= FALSE; SELECT @@global.binlog_format; @@global.binlog_format STATEMENT SELECT @@global.binlog_direct_non_transactional_updates; @@global.binlog_direct_non_transactional_updates 1 -SELECT @@global.sql_log_bin; -@@global.sql_log_bin -0 commit; set @@global.binlog_format= @save_binlog_format; set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct; -set @@global.sql_log_bin= @save_sql_log_bin; create table t3(a int, b int) engine= innodb; create table t4(a int) engine= innodb; create table t5(a int) engine= innodb; diff --git a/mysql-test/suite/binlog/t/binlog_grant.test b/mysql-test/suite/binlog/t/binlog_grant.test index f0367b3aa79..0c9d9a45ec9 100644 --- a/mysql-test/suite/binlog/t/binlog_grant.test +++ b/mysql-test/suite/binlog/t/binlog_grant.test @@ -15,7 +15,7 @@ show grants for mysqltest_1@localhost; connect (plain,localhost,mysqltest_1,,test); connect (root,localhost,root,,test); -# Testing setting both session and global SQL_LOG_BIN variable both as +# Testing setting session SQL_LOG_BIN variable both as # root and as plain user. --echo **** Variable SQL_LOG_BIN **** diff --git a/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test b/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test index 06c5e78bd0e..a93cd44fa17 100644 --- a/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test +++ b/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test @@ -10,7 +10,6 @@ source include/have_binlog_format_row.inc; set @save_binlog_format= @@global.binlog_format; set @save_binlog_dirct= @@global.binlog_direct_non_transactional_updates; -set @save_sql_log_bin= @@global.sql_log_bin; create table t1 (a int) engine= myisam; create table t2 (a int) engine= innodb; @@ -117,21 +116,18 @@ commit; begin; insert into t2 values (5); --echo # Test that the global variable 'binlog_format' and ---echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are +--echo # 'binlog_direct_non_transactional_updates' are --echo # writable inside a transaction. --echo # Current session values are ROW, FALSE, TRUE respectively. SELECT @@global.binlog_format; set @@global.binlog_format= statement; set @@global.binlog_direct_non_transactional_updates= TRUE; - set @@global.sql_log_bin= FALSE; SELECT @@global.binlog_format; SELECT @@global.binlog_direct_non_transactional_updates; - SELECT @@global.sql_log_bin; commit; set @@global.binlog_format= @save_binlog_format; set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct; -set @@global.sql_log_bin= @save_sql_log_bin; create table t3(a int, b int) engine= innodb; create table t4(a int) engine= innodb; diff --git a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result index 8ec10a86b37..353303825e5 100644 --- a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result +++ b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result @@ -78,4 +78,5 @@ z 31 32 drop table corrupt_bit_test_Ä; +DROP DATABASE pad; SET GLOBAL innodb_change_buffering_debug = 0; diff --git a/mysql-test/suite/innodb/r/insert_debug.result b/mysql-test/suite/innodb/r/insert_debug.result new file mode 100644 index 00000000000..0d176afa116 --- /dev/null +++ b/mysql-test/suite/innodb/r/insert_debug.result @@ -0,0 +1,11 @@ +# +# Bug#19904003 INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=1 +# CAUSES INFINITE PAGE SPLIT +# +SET GLOBAL innodb_change_buffering_debug=1; +SET GLOBAL innodb_limit_optimistic_insert_debug=1; +CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB +PARTITION BY HASH (c1) PARTITIONS 15; +DROP TABLE t1; +SET GLOBAL innodb_change_buffering_debug=0; +SET GLOBAL innodb_limit_optimistic_insert_debug=0; diff --git a/mysql-test/suite/innodb/r/multi_repair-7404.result b/mysql-test/suite/innodb/r/multi_repair-7404.result new file mode 100644 index 00000000000..b3db5755b87 --- /dev/null +++ b/mysql-test/suite/innodb/r/multi_repair-7404.result @@ -0,0 +1,21 @@ +create table `t1`(`a` int) engine=innodb partition by key (`a`); +create table `t2`(`b` int) engine=innodb; +create table `t3`(`c` int) engine=innodb; +insert t1 values (1); +insert t2 values (2); +insert t3 values (3); +repair table `t1`,`t2`,`t3`; +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair status OK +select * from t1; +a +1 +select * from t2; +b +2 +select * from t3; +c +3 +drop table t1, t2, t3; diff --git a/mysql-test/suite/innodb/r/sp_temp_table.result b/mysql-test/suite/innodb/r/sp_temp_table.result new file mode 100644 index 00000000000..49a2a4aa831 --- /dev/null +++ b/mysql-test/suite/innodb/r/sp_temp_table.result @@ -0,0 +1,253 @@ +# +# Bug #19306524 FAILING ASSERTION WITH TEMP TABLE FOR A PROCEDURE +# CALLED FROM A FUNCTION +# +call mtr.add_suppression("MySQL is trying to drop table"); +CREATE PROCEDURE cachedata( +IN obj_id BIGINT UNSIGNED, +IN start DATETIME, +IN end DATETIME +) +cachedata:BEGIN +DECLARE cache_count BIGINT; +SET @timestamp := NOW(); +CREATE TEMPORARY TABLE IF NOT EXISTS cachedata ( +timestamp DATETIME, +object_id BIGINT UNSIGNED NOT NULL, +start DATETIME, +end DATETIME, +seqno BIGINT AUTO_INCREMENT, +value FLOAT, +PRIMARY KEY (seqno), +INDEX (timestamp), +INDEX (object_id, start, end) +) ENGINE=INNODB; +DELETE FROM cachedata WHERE +timestamp < DATE_SUB(@timestamp, INTERVAL 15 SECOND); +SELECT count(*) INTO cache_count FROM cachedata WHERE +object_id = obj_id +AND start = start +AND end = end; +IF cache_count > 0 THEN LEAVE cachedata; +END IF; +INSERT INTO cachedata (timestamp, object_id, start, end, value) VALUES +(@timestamp, obj_id, start, end, 1234), +(@timestamp, obj_id, start, end, 4567), +(@timestamp, obj_id, start, end, 8901), +(@timestamp, obj_id, start, end, 1234), +(@timestamp, obj_id, start, end, 4567), +(@timestamp, obj_id, start, end, 8901), +(@timestamp, obj_id, start, end, 1234), +(@timestamp, obj_id, start, end, 4567), +(@timestamp, obj_id, start, end, 8901), +(@timestamp, obj_id, start, end, 1234), +(@timestamp, obj_id, start, end, 4567), +(@timestamp, obj_id, start, end, 8901), +(@timestamp, obj_id, start, end, 2345), +(@timestamp, obj_id, start, end, 1234), +(@timestamp, obj_id, start, end, 4567), +(@timestamp, obj_id, start, end, 8901), +(@timestamp, obj_id, start, end, 2345), +(@timestamp, obj_id, start, end, 1234), +(@timestamp, obj_id, start, end, 4567), +(@timestamp, obj_id, start, end, 8901), +(@timestamp, obj_id, start, end, 2345); +END$$ +CREATE FUNCTION get_cache( +obj_id BIGINT UNSIGNED, +start DATETIME, +end DATETIME +) +RETURNS FLOAT +READS SQL DATA +BEGIN +DECLARE result FLOAT; +CALL cachedata(obj_id, start, end); +SELECT SUM(value) INTO result FROM cachedata WHERE +object_id = obj_id +AND start = start +AND end = end; +RETURN result; +END$$ +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +SELECT get_cache(1, '2014-01-01', '2014-02-01'); +get_cache(1, '2014-01-01', '2014-02-01') +95247 +select sleep(1); +sleep(1) +0 +DROP FUNCTION get_cache; +DROP PROCEDURE cachedata; diff --git a/mysql-test/suite/innodb/r/strict_mode.result b/mysql-test/suite/innodb/r/strict_mode.result new file mode 100644 index 00000000000..6d11847cb19 --- /dev/null +++ b/mysql-test/suite/innodb/r/strict_mode.result @@ -0,0 +1,240 @@ +# +# Bug #17852083 PRINT A WARNING WHEN DDL HAS AN ERROR IN +# INNODB_STRICT_MODE = 1 +# +set innodb_strict_mode = 0; +create table t1 (id int auto_increment primary key, +v varchar(32), +col1 text, +col2 text, +col3 text, +col4 text, +col5 text, +col6 text, +col7 text, +col8 text, +col9 text, +col10 text, +col11 text, +col12 text, +col13 text, +col14 text, +col15 text, +col16 text, +col17 text, +col18 text, +col19 text, +col20 text, +col21 text, +col22 text, +col23 text, +col24 text, +col25 text, +col26 text, +col27 text, +col28 text, +col29 text, +col30 text, +col31 text, +col32 text, +col33 text, +col34 text, +col35 text, +col36 text, +col37 text, +col38 text, +col39 text, +col40 text, +col41 text, +col42 text, +col43 text, +col44 text, +col45 text , +col46 text, +col47 text, +col48 text, +col49 text, +col50 text, +col51 text, +col52 text, +col53 text, +col54 text, +col55 text, +col56 text, +col57 text, +col58 text, +col59 text, +col60 text, +col61 text, +col62 text, +col63 text, +col64 text, +col65 text, +col66 text, +col67 text, +col68 text , +col69 text, +col70 text, +col71 text, +col72 text, +col73 text, +col74 text, +col75 text, +col76 text, +col77 text, +col78 text, +col79 text, +col80 text, +col81 text, +col82 text, +col83 text, +col84 text, +col85 text, +col86 text, +col87 text, +col88 text, +col89 text, +col90 text, +col91 text, +col92 text, +col93 text, +col94 text, +col95 text, +col96 text, +col97 text, +col98 text, +col99 text, +col100 text, +col101 text, +col102 text, +col103 text, +col104 text, +col105 text, +col106 text, +col107 text, +col108 text, +col109 text, +col110 text, +col111 text, +col112 text, +col113 text, +col114 text, +col115 text, +col116 text, +col117 text, +col118 text, +col119 text, +col120 text, +col121 text, +col122 text, +col123 text, +col124 text, +col125 text, +col126 text , +col127 text, +col128 text, +col129 text, +col130 text, +col131 text, +col132 text, +col133 text, +col134 text, +col135 text, +col136 text, +col137 text, +col138 text, +col139 text, +col140 text, +col141 text, +col142 text, +col143 text, +col144 text, +col145 text, +col146 text, +col147 text , +col148 text, +col149 text, +col150 text, +col151 text, +col152 text, +col153 text, +col154 text, +col155 text, +col156 text, +col157 text, +col158 text, +col159 text, +col160 text, +col161 text, +col162 text, +col163 text, +col164 text, +col165 text, +col166 text, +col167 text, +col168 text, +col169 text, +col170 text, +col171 text, +col172 text , +col173 text, +col174 text, +col175 text, +col176 text, +col177 text, +col178 text, +col179 text, +col180 text, +col181 text, +col182 text, +col183 text, +col184 text, +col185 text, +col186 text, +col187 text, +col188 text, +col189 text, +col190 text, +col191 text, +col192 text, +col193 text, +col194 text, +col195 text, +col196 text, +col197 text, +col198 text, +col199 text, +col200 text, +col201 text, +col202 text, +col203 text, +col204 text, +col205 text, +col206 text, +col207 text, +col208 text, +col209 text, +col210 text, +col211 text, +col212 text, +col213 text, +col214 text, +col215 text, +col216 text, +col217 text, +col218 text, +col219 text, +col220 text, +col221 text, +col222 text, +col223 text, +col224 text, +col225 text, +col226 text, +col227 text, +col228 text +) ENGINE=InnoDB; +set innodb_strict_mode = 1; +alter table t1 engine=InnoDB; +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test index 1774bb7f796..8cbe4938cab 100644 --- a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test +++ b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test @@ -14,6 +14,8 @@ if (`select plugin_auth_version < "5.6.17" from information_schema.plugins where --source include/not_embedded.inc # DBUG_SUICIDE() hangs under valgrind --source include/not_valgrind.inc +# No windows, need perl +--source include/not_windows.inc # The flag innodb_change_buffering_debug is only available in debug builds. # It instructs InnoDB to try to evict pages from the buffer pool when diff --git a/mysql-test/suite/innodb/t/innodb_bug12400341.test b/mysql-test/suite/innodb/t/innodb_bug12400341.test index a60a5104c3f..165e19b7cbc 100644 --- a/mysql-test/suite/innodb/t/innodb_bug12400341.test +++ b/mysql-test/suite/innodb/t/innodb_bug12400341.test @@ -10,6 +10,8 @@ if (`select count(*)=0 from information_schema.global_variables where variable_n # Don't test under valgrind, undo slots of the previous test might exist still # and cause unstable result. --source include/not_valgrind.inc +# undo slots of the previous test might exist still +--source include/not_windows.inc # Previous undo slots cause unnecessary failures --source include/not_windows.inc diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test index c57e52b65cc..12c560934ef 100644 --- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test +++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test @@ -4,6 +4,11 @@ -- source include/have_innodb.inc -- source include/have_innodb_16k.inc +if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier +} + # Issues with innodb_change_buffering_debug on Windows, so the test scenario # cannot be created on windows --source include/not_windows.inc @@ -18,14 +23,20 @@ call mtr.add_suppression("Flagged corruption of idx.*in CHECK TABLE"); # It instructs InnoDB to try to evict pages from the buffer pool when # change buffering is possible, so that the change buffer will be used # whenever possible. --- error 0,ER_UNKNOWN_SYSTEM_VARIABLE SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; --- error 0,ER_UNKNOWN_SYSTEM_VARIABLE SET GLOBAL innodb_change_buffering_debug = 1; # Turn off Unique Check to create corrupted index with dup key SET UNIQUE_CHECKS=0; +CREATE DATABASE pad; +let $i=345; +while ($i) +{ + --eval CREATE TABLE pad.t$i (a INT PRIMARY KEY) ENGINE=InnoDB; + dec $i; +} + -- enable_query_log set names utf8; @@ -121,6 +132,6 @@ select z from corrupt_bit_test_Ä limit 10; # Drop table drop table corrupt_bit_test_Ä; +DROP DATABASE pad; --- error 0, ER_UNKNOWN_SYSTEM_VARIABLE SET GLOBAL innodb_change_buffering_debug = 0; diff --git a/mysql-test/suite/innodb/t/insert_debug.test b/mysql-test/suite/innodb/t/insert_debug.test new file mode 100644 index 00000000000..36ceba2ee8b --- /dev/null +++ b/mysql-test/suite/innodb/t/insert_debug.test @@ -0,0 +1,17 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_partition.inc + +--echo # +--echo # Bug#19904003 INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=1 +--echo # CAUSES INFINITE PAGE SPLIT +--echo # + +SET GLOBAL innodb_change_buffering_debug=1; +SET GLOBAL innodb_limit_optimistic_insert_debug=1; +CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB +PARTITION BY HASH (c1) PARTITIONS 15; +DROP TABLE t1; + +SET GLOBAL innodb_change_buffering_debug=0; +SET GLOBAL innodb_limit_optimistic_insert_debug=0; diff --git a/mysql-test/suite/innodb/t/multi_repair-7404.test b/mysql-test/suite/innodb/t/multi_repair-7404.test new file mode 100644 index 00000000000..0775cd8b200 --- /dev/null +++ b/mysql-test/suite/innodb/t/multi_repair-7404.test @@ -0,0 +1,18 @@ +# +# MDEV-7404 REPAIR multiple tables crash in MDL_ticket::has_stronger_or_equal_type +# + +--source include/have_partition.inc +--source include/have_innodb.inc +create table `t1`(`a` int) engine=innodb partition by key (`a`); +create table `t2`(`b` int) engine=innodb; +create table `t3`(`c` int) engine=innodb; +insert t1 values (1); +insert t2 values (2); +insert t3 values (3); +repair table `t1`,`t2`,`t3`; +select * from t1; +select * from t2; +select * from t3; +drop table t1, t2, t3; + diff --git a/mysql-test/suite/innodb/t/sp_temp_table.test b/mysql-test/suite/innodb/t/sp_temp_table.test new file mode 100644 index 00000000000..b2883f551b9 --- /dev/null +++ b/mysql-test/suite/innodb/t/sp_temp_table.test @@ -0,0 +1,103 @@ +--source include/have_innodb.inc +--source include/big_test.inc + +--echo # +--echo # Bug #19306524 FAILING ASSERTION WITH TEMP TABLE FOR A PROCEDURE +--echo # CALLED FROM A FUNCTION +--echo # + +call mtr.add_suppression("MySQL is trying to drop table"); + +DELIMITER $$; +CREATE PROCEDURE cachedata( + IN obj_id BIGINT UNSIGNED, + IN start DATETIME, + IN end DATETIME +) + +cachedata:BEGIN + DECLARE cache_count BIGINT; + + SET @timestamp := NOW(); + + CREATE TEMPORARY TABLE IF NOT EXISTS cachedata ( + timestamp DATETIME, + object_id BIGINT UNSIGNED NOT NULL, + start DATETIME, + end DATETIME, + seqno BIGINT AUTO_INCREMENT, + value FLOAT, + PRIMARY KEY (seqno), + INDEX (timestamp), + INDEX (object_id, start, end) + ) ENGINE=INNODB; + + DELETE FROM cachedata WHERE + timestamp < DATE_SUB(@timestamp, INTERVAL 15 SECOND); + + SELECT count(*) INTO cache_count FROM cachedata WHERE + object_id = obj_id + AND start = start + AND end = end; + + IF cache_count > 0 THEN LEAVE cachedata; + END IF; + + INSERT INTO cachedata (timestamp, object_id, start, end, value) VALUES + (@timestamp, obj_id, start, end, 1234), + (@timestamp, obj_id, start, end, 4567), + (@timestamp, obj_id, start, end, 8901), + (@timestamp, obj_id, start, end, 1234), + (@timestamp, obj_id, start, end, 4567), + (@timestamp, obj_id, start, end, 8901), + (@timestamp, obj_id, start, end, 1234), + (@timestamp, obj_id, start, end, 4567), + (@timestamp, obj_id, start, end, 8901), + (@timestamp, obj_id, start, end, 1234), + (@timestamp, obj_id, start, end, 4567), + (@timestamp, obj_id, start, end, 8901), + (@timestamp, obj_id, start, end, 2345), + (@timestamp, obj_id, start, end, 1234), + (@timestamp, obj_id, start, end, 4567), + (@timestamp, obj_id, start, end, 8901), + (@timestamp, obj_id, start, end, 2345), + (@timestamp, obj_id, start, end, 1234), + (@timestamp, obj_id, start, end, 4567), + (@timestamp, obj_id, start, end, 8901), + (@timestamp, obj_id, start, end, 2345); + +END$$ + + +CREATE FUNCTION get_cache( + obj_id BIGINT UNSIGNED, + start DATETIME, + end DATETIME +) + RETURNS FLOAT + READS SQL DATA +BEGIN + DECLARE result FLOAT; + + CALL cachedata(obj_id, start, end); + + SELECT SUM(value) INTO result FROM cachedata WHERE + object_id = obj_id + AND start = start + AND end = end; + + RETURN result; +END$$ + +DELIMITER ;$$ + +let $i = 30; +while ($i) +{ + SELECT get_cache(1, '2014-01-01', '2014-02-01'); + select sleep(1); + dec $i; +} + +DROP FUNCTION get_cache; +DROP PROCEDURE cachedata; diff --git a/mysql-test/suite/innodb/t/strict_mode.test b/mysql-test/suite/innodb/t/strict_mode.test new file mode 100644 index 00000000000..9b115091f84 --- /dev/null +++ b/mysql-test/suite/innodb/t/strict_mode.test @@ -0,0 +1,251 @@ +--source include/have_innodb.inc + +if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`) +{ + --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier +} + +--echo # +--echo # Bug #17852083 PRINT A WARNING WHEN DDL HAS AN ERROR IN +--echo # INNODB_STRICT_MODE = 1 +--echo # + +set innodb_strict_mode = 0; + +create table t1 (id int auto_increment primary key, +v varchar(32), +col1 text, +col2 text, +col3 text, +col4 text, +col5 text, +col6 text, +col7 text, +col8 text, +col9 text, +col10 text, +col11 text, +col12 text, +col13 text, +col14 text, +col15 text, +col16 text, +col17 text, +col18 text, +col19 text, +col20 text, +col21 text, +col22 text, +col23 text, +col24 text, +col25 text, +col26 text, +col27 text, +col28 text, +col29 text, +col30 text, +col31 text, +col32 text, +col33 text, +col34 text, +col35 text, +col36 text, +col37 text, +col38 text, +col39 text, +col40 text, +col41 text, +col42 text, +col43 text, +col44 text, +col45 text , +col46 text, +col47 text, +col48 text, +col49 text, +col50 text, +col51 text, +col52 text, +col53 text, +col54 text, +col55 text, +col56 text, +col57 text, +col58 text, +col59 text, +col60 text, +col61 text, +col62 text, +col63 text, +col64 text, +col65 text, +col66 text, +col67 text, +col68 text , +col69 text, +col70 text, +col71 text, +col72 text, +col73 text, +col74 text, +col75 text, +col76 text, +col77 text, +col78 text, +col79 text, +col80 text, +col81 text, +col82 text, +col83 text, +col84 text, +col85 text, +col86 text, +col87 text, +col88 text, +col89 text, +col90 text, +col91 text, +col92 text, +col93 text, +col94 text, +col95 text, +col96 text, +col97 text, +col98 text, +col99 text, +col100 text, +col101 text, +col102 text, +col103 text, +col104 text, +col105 text, +col106 text, +col107 text, +col108 text, +col109 text, +col110 text, +col111 text, +col112 text, +col113 text, +col114 text, +col115 text, +col116 text, +col117 text, +col118 text, +col119 text, +col120 text, +col121 text, +col122 text, +col123 text, +col124 text, +col125 text, +col126 text , +col127 text, +col128 text, +col129 text, +col130 text, +col131 text, +col132 text, +col133 text, +col134 text, +col135 text, +col136 text, +col137 text, +col138 text, +col139 text, +col140 text, +col141 text, +col142 text, +col143 text, +col144 text, +col145 text, +col146 text, +col147 text , +col148 text, +col149 text, +col150 text, +col151 text, +col152 text, +col153 text, +col154 text, +col155 text, +col156 text, +col157 text, +col158 text, +col159 text, +col160 text, +col161 text, +col162 text, +col163 text, +col164 text, +col165 text, +col166 text, +col167 text, +col168 text, +col169 text, +col170 text, +col171 text, +col172 text , +col173 text, +col174 text, +col175 text, +col176 text, +col177 text, +col178 text, +col179 text, +col180 text, +col181 text, +col182 text, +col183 text, +col184 text, +col185 text, +col186 text, +col187 text, +col188 text, +col189 text, +col190 text, +col191 text, +col192 text, +col193 text, +col194 text, +col195 text, +col196 text, +col197 text, +col198 text, +col199 text, +col200 text, +col201 text, +col202 text, +col203 text, +col204 text, +col205 text, +col206 text, +col207 text, +col208 text, +col209 text, +col210 text, +col211 text, +col212 text, +col213 text, +col214 text, +col215 text, +col216 text, +col217 text, +col218 text, +col219 text, +col220 text, +col221 text, +col222 text, +col223 text, +col224 text, +col225 text, +col226 text, +col227 text, +col228 text +) ENGINE=InnoDB; + +set innodb_strict_mode = 1; +--error ER_TOO_BIG_ROWSIZE +alter table t1 engine=InnoDB; + +drop table t1; diff --git a/mysql-test/suite/maria/insert_select-7314.result b/mysql-test/suite/maria/insert_select-7314.result new file mode 100644 index 00000000000..2f25cc5855c --- /dev/null +++ b/mysql-test/suite/maria/insert_select-7314.result @@ -0,0 +1,17 @@ +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +# +# MDEV-7314 +# Concurrent "INSERT INTO table SELECT MAX(id)+1 FROM table" are +# hitting deadlocks on Aria tables using ROW_FORMAT=PAGE +# +create table t1 (pk int primary key) engine=Aria; +insert into t1 values (1); +insert into t1 select sleep(2)+1 from t1; +insert into t1 select 2 from t1; +select * from t1; +pk +1 +2 +drop table t1; diff --git a/mysql-test/suite/maria/insert_select-7314.test b/mysql-test/suite/maria/insert_select-7314.test new file mode 100644 index 00000000000..f5869edd4ce --- /dev/null +++ b/mysql-test/suite/maria/insert_select-7314.test @@ -0,0 +1,27 @@ +-- source include/have_maria.inc +--source include/have_binlog_format_statement.inc + +drop table if exists t1; + +--echo # +--echo # MDEV-7314 +--echo # Concurrent "INSERT INTO table SELECT MAX(id)+1 FROM table" are +--echo # hitting deadlocks on Aria tables using ROW_FORMAT=PAGE +--echo # + +create table t1 (pk int primary key) engine=Aria; +insert into t1 values (1); + +send insert into t1 select sleep(2)+1 from t1; + +--connect (con1,localhost,root,,) + +--error 0,1062 +insert into t1 select 2 from t1; + +--connection default +--error 0,1062 +--reap + +select * from t1; +drop table t1; diff --git a/mysql-test/suite/maria/insert_select.result b/mysql-test/suite/maria/insert_select.result index 2f25cc5855c..878914ddabf 100644 --- a/mysql-test/suite/maria/insert_select.result +++ b/mysql-test/suite/maria/insert_select.result @@ -1,17 +1,6 @@ -drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' -# -# MDEV-7314 -# Concurrent "INSERT INTO table SELECT MAX(id)+1 FROM table" are -# hitting deadlocks on Aria tables using ROW_FORMAT=PAGE -# create table t1 (pk int primary key) engine=Aria; insert into t1 values (1); insert into t1 select sleep(2)+1 from t1; insert into t1 select 2 from t1; -select * from t1; -pk -1 -2 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' drop table t1; diff --git a/mysql-test/suite/maria/insert_select.test b/mysql-test/suite/maria/insert_select.test index f5869edd4ce..a86edc7d857 100644 --- a/mysql-test/suite/maria/insert_select.test +++ b/mysql-test/suite/maria/insert_select.test @@ -1,14 +1,10 @@ --- source include/have_maria.inc +# +# MDEV-4010 +# Deadlock on concurrent INSERT .. SELECT into an Aria table with statement +# binary logging +# --source include/have_binlog_format_statement.inc -drop table if exists t1; - ---echo # ---echo # MDEV-7314 ---echo # Concurrent "INSERT INTO table SELECT MAX(id)+1 FROM table" are ---echo # hitting deadlocks on Aria tables using ROW_FORMAT=PAGE ---echo # - create table t1 (pk int primary key) engine=Aria; insert into t1 values (1); @@ -16,12 +12,10 @@ send insert into t1 select sleep(2)+1 from t1; --connect (con1,localhost,root,,) ---error 0,1062 insert into t1 select 2 from t1; --connection default ---error 0,1062 +--error 1062 --reap - -select * from t1; +--disconnect con1 drop table t1; diff --git a/mysql-test/suite/rpl/r/myisam_external_lock.result b/mysql-test/suite/rpl/r/myisam_external_lock.result new file mode 100644 index 00000000000..ef24f8b4e3c --- /dev/null +++ b/mysql-test/suite/rpl/r/myisam_external_lock.result @@ -0,0 +1,12 @@ +include/master-slave.inc +[connection master] +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE `t1` (`col1` int(11) NOT NULL,`col2` int(11) NOT NULL, +PRIMARY KEY (`col1`,`col2`), +KEY `col2` (`col2`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `t1` VALUES (2775,974),(2775,975),(2775,976),(2778,977),(2778,978),(2782,979),(2790,986),(2790,1139),(2792,840),(2792,984),(2792,989),(2793,982),(2793,992),(2793,993),(2793,994),(2795,323),(2795,332),(2797,980),(2797,997),(2797,998),(2798,1103),(2798,1104),(2799,841),(2799,985),(2799,988),(2833,983),(2833,990),(2833,991),(2834,981),(2834,995),(2834,996),(2835,316),(2835,317),(3007,854),(3007,856),(3008,855),(3008,857),(3009,823),(3009,824),(3014,1),(3015,1),(3016,2),(3017,2),(3018,3),(3019,3),(3024,842),(3024,843),(3024,844),(3025,845),(3025,846),(3025,847),(3040,31),(3041,32),(3042,52),(3042,55),(3043,53),(3043,54),(3044,278),(3044,279),(3044,280),(3044,281),(3044,282),(3044,283),(3044,284),(3044,285),(3045,1),(3046,1),(3049,220),(3050,221),(3050,222),(3051,2),(3052,2),(3053,223),(3054,224),(3055,225),(3056,226),(3057,227),(3058,228),(3059,229),(3060,327),(3066,236),(3067,237),(3068,238),(3069,239),(3070,240),(3080,241),(3081,242),(3082,247),(3083,248),(3084,249),(3085,250),(3086,251),(3087,252),(3088,253),(3089,254),(3090,255),(3091,256),(3092,257),(3093,258),(3094,259),(3096,263),(3097,264),(3100,273),(3100,302),(3101,266),(3102,267),(3103,268),(3104,269),(3105,270),(3111,275),(3112,238),(3113,272),(3115,286),(3116,318),(3116,319),(3117,290),(3117,292),(3118,238),(3119,291),(3119,293),(3120,304),(3121,305),(3122,306),(3123,307),(3124,308),(3125,309),(3126,310),(3127,311),(3128,312),(3128,336),(3129,313),(3129,350),(3130,314),(3131,315),(3131,351),(3132,325),(3132,328),(3134,502),(3138,334),(3139,338),(3139,339),(3140,340),(3140,341),(3141,344),(3141,345),(3142,346),(3142,347),(3149,351),(3149,354),(3150,351),(3150,356),(3152,358),(3152,359),(3153,361),(3153,370),(3154,363),(3154,369),(3156,350),(3156,371),(3159,376),(3160,377),(3160,379),(3160,384),(3161,378),(3161,380),(3161,383),(3162,388),(3162,389),(3162,390),(3169,392),(3169,393),(3169,394),(3170,395),(3170,396),(3170,397),(3171,398),(3171,399),(3171,400),(3172,401),(3172,402),(3172,403),(3173,404),(3173,405),(3173,406),(3178,351),(3178,421),(3190,411),(3190,412),(3191,413),(3191,414),(3192,415),(3192,416),(3193,417),(3193,418),(3194,419),(3194,420),(3195,353),(3195,424),(3196,425),(3196,426),(3197,427),(3197,428),(3198,429),(3198,430),(3199,431),(3199,432),(3200,433),(3200,434),(3201,435),(3201,436),(3202,437),(3202,438),(3203,439),(3203,440),(3204,441),(3204,442),(3205,443),(3205,444),(3206,445),(3206,446),(3207,447),(3207,448),(3208,449),(3208,450),(3209,451),(3209,452),(3210,453),(3210,454),(3211,455),(3211,456),(3212,457),(3212,458),(3213,459),(3213,460),(3214,461),(3214,462),(3215,463),(3215,464),(3218,466),(3218,467),(3218,468),(3219,469),(3219,470),(3219,471),(3220,474),(3220,475),(3220,476),(3221,477),(3221,478),(3221,479),(3222,480),(3222,481),(3223,482),(3223,483),(3224,484),(3224,485),(3225,486),(3225,487),(3227,503),(3227,505),(3228,506),(3228,507),(3230,508),(3230,509),(3231,510),(3231,511),(3232,512),(3232,513),(3233,514),(3233,515),(3234,516),(3234,517),(3235,518),(3235,519),(3237,521),(3237,522),(3239,524),(3239,525),(3240,526),(3240,527),(3241,528),(3241,529),(3242,530),(3242,531),(3243,532),(3243,533),(3244,534),(3244,535),(3245,536),(3245,537),(3246,538),(3246,539),(3252,540),(3252,541),(3254,543),(3254,544),(3254,545),(3255,547),(3255,548),(3255,571),(3256,550),(3256,551),(3256,572),(3257,553),(3257,554),(3257,573),(3258,556),(3258,557),(3258,574),(3259,559),(3259,560),(3259,575),(3260,561),(3260,562),(3260,563),(3261,565),(3261,576),(3262,566),(3262,567),(3263,568),(3263,569),(3263,570),(3264,577),(3264,578),(3265,579),(3265,580),(3266,581),(3266,582),(3266,591),(3267,583),(3267,584),(3267,592),(3268,585),(3268,586),(3268,593),(3269,587),(3269,588),(3269,594),(3270,589),(3270,590),(3271,595),(3271,596),(3271,597),(3272,598),(3272,599),(3273,600),(3273,601),(3273,602),(3274,603),(3274,604),(3274,605),(3275,606),(3275,607),(3275,608),(3276,609),(3276,610),(3276,611),(3277,612),(3277,613),(3277,614),(3278,615),(3278,616),(3279,617),(3279,618),(3279,619),(3279,628),(3279,629),(3280,620),(3280,621),(3280,622),(3281,623),(3281,624),(3281,625),(3282,626),(3282,825),(3283,630),(3283,631),(3284,632),(3284,633),(3284,634),(3285,635),(3285,940),(3286,638),(3286,639),(3286,640),(3287,641),(3287,642),(3287,643),(3288,644),(3288,645),(3288,646),(3289,647),(3289,648),(3289,649),(3290,650),(3290,651),(3290,652),(3291,653),(3291,654),(3291,655),(3292,656),(3292,657),(3292,658),(3293,659),(3293,660),(3293,661),(3294,662),(3294,663),(3294,664),(3295,665),(3295,666),(3295,667),(3296,668),(3296,669),(3296,670),(3297,671),(3297,672),(3297,673),(3298,674),(3298,675),(3298,676),(3299,677),(3299,678),(3299,679),(3300,680),(3300,681),(3300,682),(3301,683),(3301,684),(3301,685),(3302,686),(3302,687),(3302,688),(3303,689),(3303,690),(3303,691),(3304,692),(3304,693),(3304,694),(3305,695),(3305,696),(3305,697),(3306,698),(3306,699),(3306,700),(3307,701),(3307,702),(3307,703),(3308,704),(3308,705),(3308,706),(3309,707),(3309,708),(3310,709),(3310,710),(3311,711),(3311,712),(3311,713),(3312,714),(3312,715),(3312,716),(3313,717),(3313,1167),(3314,720),(3314,721),(3314,722),(3315,723),(3315,724),(3315,725),(3316,726),(3316,727),(3316,728),(3317,729),(3317,730),(3317,731),(3318,732),(3318,733),(3318,734),(3319,735),(3319,736),(3319,737),(3320,738),(3320,739),(3320,740),(3321,741),(3321,742),(3322,743),(3322,744),(3323,745),(3323,746),(3323,747),(3324,748),(3324,749),(3324,750),(3325,751),(3325,752),(3325,753),(3326,754),(3326,755),(3327,756),(3327,757),(3328,758),(3328,789),(3329,761),(3329,790),(3330,762),(3330,763),(3331,768),(3331,785),(3331,786),(3332,769),(3332,783),(3332,784),(3335,766),(3336,767),(3343,770),(3343,771),(3344,772),(3344,773),(3345,774),(3345,775),(3347,776),(3347,777),(3347,987),(3348,778),(3348,779),(3349,780),(3372,781),(3372,782),(3373,787),(3373,788),(3376,791),(3376,792),(3377,793),(3377,794),(3378,799),(3378,800),(3379,801),(3379,802),(3380,795),(3380,796),(3381,797),(3381,798),(3383,805),(3384,806),(3384,807),(3385,808),(3385,809),(3386,810),(3386,811),(3387,812),(3387,814),(3388,815),(3388,816),(3391,817),(3391,818),(3391,819),(3392,820),(3392,821),(3392,822),(3393,826),(3393,827),(3394,828),(3394,829),(3395,830),(3395,831),(3396,834),(3396,835),(3397,832),(3397,833),(3398,836),(3398,837),(3399,838),(3399,839),(3410,850),(3410,851),(3411,852),(3411,853),(3412,848),(3412,849),(3419,860),(3419,951),(3420,859),(3420,861),(3422,862),(3422,863),(3423,864),(3423,865),(3424,866),(3424,867),(3424,872),(3424,873),(3425,868),(3425,869),(3425,874),(3425,875),(3426,878),(3426,879),(3427,876),(3427,877),(3428,880),(3432,884),(3432,885),(3432,886),(3434,887),(3434,888),(3434,889),(3441,894),(3441,895),(3442,896),(3442,897),(3444,904),(3445,905),(3449,906),(3449,907),(3450,908),(3450,909),(3453,910),(3458,915),(3458,916),(3459,917),(3459,918),(3463,919),(3463,920),(3485,929),(3486,930),(3487,931),(3488,932),(3489,933),(3493,2),(3494,2),(3501,934),(3502,936),(3503,938),(3504,939),(3505,941),(3506,942),(3507,943),(3508,944),(3509,945),(3510,946),(3511,947),(3512,948),(3514,949),(3514,950),(3515,953),(3516,954),(3517,955),(3518,956),(3519,957),(3520,958),(3521,959),(3527,960),(3527,965),(3528,961),(3528,962),(3529,963),(3529,964),(3530,966),(3530,967),(3531,968),(3531,969),(3535,970),(3535,971),(3536,972),(3536,973),(3540,999),(3540,1000),(3541,1001),(8888,9999); +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/myisam_external_lock-slave.opt b/mysql-test/suite/rpl/t/myisam_external_lock-slave.opt new file mode 100644 index 00000000000..db53e17d4b3 --- /dev/null +++ b/mysql-test/suite/rpl/t/myisam_external_lock-slave.opt @@ -0,0 +1,2 @@ +--log-slave-updates=0 +--skip_external_locking=0 diff --git a/mysql-test/suite/rpl/t/myisam_external_lock.test b/mysql-test/suite/rpl/t/myisam_external_lock.test new file mode 100644 index 00000000000..14824fd8321 --- /dev/null +++ b/mysql-test/suite/rpl/t/myisam_external_lock.test @@ -0,0 +1,24 @@ +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +# +# MDEV-6871 Multi-value insert on MyISAM table that makes slaves crash +# This only happens if external_lock is enabled +# + +drop table if exists t1; +CREATE TABLE `t1` (`col1` int(11) NOT NULL,`col2` int(11) NOT NULL, + PRIMARY KEY (`col1`,`col2`), + KEY `col2` (`col2`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `t1` VALUES (2775,974),(2775,975),(2775,976),(2778,977),(2778,978),(2782,979),(2790,986),(2790,1139),(2792,840),(2792,984),(2792,989),(2793,982),(2793,992),(2793,993),(2793,994),(2795,323),(2795,332),(2797,980),(2797,997),(2797,998),(2798,1103),(2798,1104),(2799,841),(2799,985),(2799,988),(2833,983),(2833,990),(2833,991),(2834,981),(2834,995),(2834,996),(2835,316),(2835,317),(3007,854),(3007,856),(3008,855),(3008,857),(3009,823),(3009,824),(3014,1),(3015,1),(3016,2),(3017,2),(3018,3),(3019,3),(3024,842),(3024,843),(3024,844),(3025,845),(3025,846),(3025,847),(3040,31),(3041,32),(3042,52),(3042,55),(3043,53),(3043,54),(3044,278),(3044,279),(3044,280),(3044,281),(3044,282),(3044,283),(3044,284),(3044,285),(3045,1),(3046,1),(3049,220),(3050,221),(3050,222),(3051,2),(3052,2),(3053,223),(3054,224),(3055,225),(3056,226),(3057,227),(3058,228),(3059,229),(3060,327),(3066,236),(3067,237),(3068,238),(3069,239),(3070,240),(3080,241),(3081,242),(3082,247),(3083,248),(3084,249),(3085,250),(3086,251),(3087,252),(3088,253),(3089,254),(3090,255),(3091,256),(3092,257),(3093,258),(3094,259),(3096,263),(3097,264),(3100,273),(3100,302),(3101,266),(3102,267),(3103,268),(3104,269),(3105,270),(3111,275),(3112,238),(3113,272),(3115,286),(3116,318),(3116,319),(3117,290),(3117,292),(3118,238),(3119,291),(3119,293),(3120,304),(3121,305),(3122,306),(3123,307),(3124,308),(3125,309),(3126,310),(3127,311),(3128,312),(3128,336),(3129,313),(3129,350),(3130,314),(3131,315),(3131,351),(3132,325),(3132,328),(3134,502),(3138,334),(3139,338),(3139,339),(3140,340),(3140,341),(3141,344),(3141,345),(3142,346),(3142,347),(3149,351),(3149,354),(3150,351),(3150,356),(3152,358),(3152,359),(3153,361),(3153,370),(3154,363),(3154,369),(3156,350),(3156,371),(3159,376),(3160,377),(3160,379),(3160,384),(3161,378),(3161,380),(3161,383),(3162,388),(3162,389),(3162,390),(3169,392),(3169,393),(3169,394),(3170,395),(3170,396),(3170,397),(3171,398),(3171,399),(3171,400),(3172,401),(3172,402),(3172,403),(3173,404),(3173,405),(3173,406),(3178,351),(3178,421),(3190,411),(3190,412),(3191,413),(3191,414),(3192,415),(3192,416),(3193,417),(3193,418),(3194,419),(3194,420),(3195,353),(3195,424),(3196,425),(3196,426),(3197,427),(3197,428),(3198,429),(3198,430),(3199,431),(3199,432),(3200,433),(3200,434),(3201,435),(3201,436),(3202,437),(3202,438),(3203,439),(3203,440),(3204,441),(3204,442),(3205,443),(3205,444),(3206,445),(3206,446),(3207,447),(3207,448),(3208,449),(3208,450),(3209,451),(3209,452),(3210,453),(3210,454),(3211,455),(3211,456),(3212,457),(3212,458),(3213,459),(3213,460),(3214,461),(3214,462),(3215,463),(3215,464),(3218,466),(3218,467),(3218,468),(3219,469),(3219,470),(3219,471),(3220,474),(3220,475),(3220,476),(3221,477),(3221,478),(3221,479),(3222,480),(3222,481),(3223,482),(3223,483),(3224,484),(3224,485),(3225,486),(3225,487),(3227,503),(3227,505),(3228,506),(3228,507),(3230,508),(3230,509),(3231,510),(3231,511),(3232,512),(3232,513),(3233,514),(3233,515),(3234,516),(3234,517),(3235,518),(3235,519),(3237,521),(3237,522),(3239,524),(3239,525),(3240,526),(3240,527),(3241,528),(3241,529),(3242,530),(3242,531),(3243,532),(3243,533),(3244,534),(3244,535),(3245,536),(3245,537),(3246,538),(3246,539),(3252,540),(3252,541),(3254,543),(3254,544),(3254,545),(3255,547),(3255,548),(3255,571),(3256,550),(3256,551),(3256,572),(3257,553),(3257,554),(3257,573),(3258,556),(3258,557),(3258,574),(3259,559),(3259,560),(3259,575),(3260,561),(3260,562),(3260,563),(3261,565),(3261,576),(3262,566),(3262,567),(3263,568),(3263,569),(3263,570),(3264,577),(3264,578),(3265,579),(3265,580),(3266,581),(3266,582),(3266,591),(3267,583),(3267,584),(3267,592),(3268,585),(3268,586),(3268,593),(3269,587),(3269,588),(3269,594),(3270,589),(3270,590),(3271,595),(3271,596),(3271,597),(3272,598),(3272,599),(3273,600),(3273,601),(3273,602),(3274,603),(3274,604),(3274,605),(3275,606),(3275,607),(3275,608),(3276,609),(3276,610),(3276,611),(3277,612),(3277,613),(3277,614),(3278,615),(3278,616),(3279,617),(3279,618),(3279,619),(3279,628),(3279,629),(3280,620),(3280,621),(3280,622),(3281,623),(3281,624),(3281,625),(3282,626),(3282,825),(3283,630),(3283,631),(3284,632),(3284,633),(3284,634),(3285,635),(3285,940),(3286,638),(3286,639),(3286,640),(3287,641),(3287,642),(3287,643),(3288,644),(3288,645),(3288,646),(3289,647),(3289,648),(3289,649),(3290,650),(3290,651),(3290,652),(3291,653),(3291,654),(3291,655),(3292,656),(3292,657),(3292,658),(3293,659),(3293,660),(3293,661),(3294,662),(3294,663),(3294,664),(3295,665),(3295,666),(3295,667),(3296,668),(3296,669),(3296,670),(3297,671),(3297,672),(3297,673),(3298,674),(3298,675),(3298,676),(3299,677),(3299,678),(3299,679),(3300,680),(3300,681),(3300,682),(3301,683),(3301,684),(3301,685),(3302,686),(3302,687),(3302,688),(3303,689),(3303,690),(3303,691),(3304,692),(3304,693),(3304,694),(3305,695),(3305,696),(3305,697),(3306,698),(3306,699),(3306,700),(3307,701),(3307,702),(3307,703),(3308,704),(3308,705),(3308,706),(3309,707),(3309,708),(3310,709),(3310,710),(3311,711),(3311,712),(3311,713),(3312,714),(3312,715),(3312,716),(3313,717),(3313,1167),(3314,720),(3314,721),(3314,722),(3315,723),(3315,724),(3315,725),(3316,726),(3316,727),(3316,728),(3317,729),(3317,730),(3317,731),(3318,732),(3318,733),(3318,734),(3319,735),(3319,736),(3319,737),(3320,738),(3320,739),(3320,740),(3321,741),(3321,742),(3322,743),(3322,744),(3323,745),(3323,746),(3323,747),(3324,748),(3324,749),(3324,750),(3325,751),(3325,752),(3325,753),(3326,754),(3326,755),(3327,756),(3327,757),(3328,758),(3328,789),(3329,761),(3329,790),(3330,762),(3330,763),(3331,768),(3331,785),(3331,786),(3332,769),(3332,783),(3332,784),(3335,766),(3336,767),(3343,770),(3343,771),(3344,772),(3344,773),(3345,774),(3345,775),(3347,776),(3347,777),(3347,987),(3348,778),(3348,779),(3349,780),(3372,781),(3372,782),(3373,787),(3373,788),(3376,791),(3376,792),(3377,793),(3377,794),(3378,799),(3378,800),(3379,801),(3379,802),(3380,795),(3380,796),(3381,797),(3381,798),(3383,805),(3384,806),(3384,807),(3385,808),(3385,809),(3386,810),(3386,811),(3387,812),(3387,814),(3388,815),(3388,816),(3391,817),(3391,818),(3391,819),(3392,820),(3392,821),(3392,822),(3393,826),(3393,827),(3394,828),(3394,829),(3395,830),(3395,831),(3396,834),(3396,835),(3397,832),(3397,833),(3398,836),(3398,837),(3399,838),(3399,839),(3410,850),(3410,851),(3411,852),(3411,853),(3412,848),(3412,849),(3419,860),(3419,951),(3420,859),(3420,861),(3422,862),(3422,863),(3423,864),(3423,865),(3424,866),(3424,867),(3424,872),(3424,873),(3425,868),(3425,869),(3425,874),(3425,875),(3426,878),(3426,879),(3427,876),(3427,877),(3428,880),(3432,884),(3432,885),(3432,886),(3434,887),(3434,888),(3434,889),(3441,894),(3441,895),(3442,896),(3442,897),(3444,904),(3445,905),(3449,906),(3449,907),(3450,908),(3450,909),(3453,910),(3458,915),(3458,916),(3459,917),(3459,918),(3463,919),(3463,920),(3485,929),(3486,930),(3487,931),(3488,932),(3489,933),(3493,2),(3494,2),(3501,934),(3502,936),(3503,938),(3504,939),(3505,941),(3506,942),(3507,943),(3508,944),(3509,945),(3510,946),(3511,947),(3512,948),(3514,949),(3514,950),(3515,953),(3516,954),(3517,955),(3518,956),(3519,957),(3520,958),(3521,959),(3527,960),(3527,965),(3528,961),(3528,962),(3529,963),(3529,964),(3530,966),(3530,967),(3531,968),(3531,969),(3535,970),(3535,971),(3536,972),(3536,973),(3540,999),(3540,1000),(3541,1001),(8888,9999); + +drop table t1; + +save_master_pos; +connection slave; +sync_with_master; + +connection master; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result index 5e8fe4e02f7..909c434340c 100644 --- a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result +++ b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result @@ -57,11 +57,16 @@ ERROR 42000: Variable 'sql_log_bin' can't be set to the value of '¹' SET @@session.sql_log_bin = NO; ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'NO' '#-------------------FN_DYNVARS_156_05----------------------------#' +SELECT @@global.sql_log_bin; +@@global.sql_log_bin +1 SET @@global.sql_log_bin = 0; +ERROR HY000: Variable 'sql_log_bin' is a SESSION variable SELECT @@global.sql_log_bin; @@global.sql_log_bin -0 +1 SET @@global.sql_log_bin = 1; +ERROR HY000: Variable 'sql_log_bin' is a SESSION variable '#----------------------FN_DYNVARS_156_06------------------------#' SELECT count(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sql_log_bin'; count(VARIABLE_VALUE) diff --git a/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result b/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result index f1638520f72..7f882255567 100644 --- a/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result +++ b/mysql-test/suite/sys_vars/r/stored_program_cache_basic.result @@ -23,7 +23,7 @@ Warnings: Warning 1292 Truncated incorrect stored_program_cache value: '-1' SELECT @@global.stored_program_cache; @@global.stored_program_cache -256 +0 SET @@global.stored_program_cache =100000000000; Warnings: Warning 1292 Truncated incorrect stored_program_cache value: '100000000000' @@ -31,11 +31,9 @@ SELECT @@global.stored_program_cache; @@global.stored_program_cache 524288 SET @@global.stored_program_cache = 0; -Warnings: -Warning 1292 Truncated incorrect stored_program_cache value: '0' SELECT @@global.stored_program_cache; @@global.stored_program_cache -256 +0 SET @@global.stored_program_cache = 10000.01; ERROR 42000: Incorrect argument type to variable 'stored_program_cache' SET @@global.stored_program_cache = ON; diff --git a/mysql-test/suite/sys_vars/r/stored_program_cache_func.result b/mysql-test/suite/sys_vars/r/stored_program_cache_func.result new file mode 100644 index 00000000000..11151847d6b --- /dev/null +++ b/mysql-test/suite/sys_vars/r/stored_program_cache_func.result @@ -0,0 +1,52 @@ +create procedure p1() select 1; +flush status; +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 0 +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 1 +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 1 +set global stored_program_cache=0; +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 2 +call p1; +1 +1 +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 3 +drop procedure p1; +set global stored_program_cache=default; +create procedure pr(i int) begin +create table t1 (a int, b int); +if (i = 1) then alter table t1 drop a; +else alter table t1 drop b; +end if; +select * from t1; +drop table t1; +end | +call pr(1); +b +call pr(2); +ERROR 42S22: Unknown column 'test.t1.b' in 'field list' +drop table t1; +set global stored_program_cache=0; +call pr(1); +b +call pr(2); +a +drop procedure pr; +set global stored_program_cache=default; diff --git a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test index 153a0be0b8f..5f5e3920862 100644 --- a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test +++ b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test @@ -109,11 +109,15 @@ SET @@session.sql_log_bin = NO; --echo '#-------------------FN_DYNVARS_156_05----------------------------#' ########################################################################### -# Test if accessing global sql_log_bin gives error # +# Test if setting global sql_log_bin gives error, # +# and there is no error on reading it. # ########################################################################### +SELECT @@global.sql_log_bin; +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@global.sql_log_bin = 0; SELECT @@global.sql_log_bin; +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@global.sql_log_bin = 1; --echo '#----------------------FN_DYNVARS_156_06------------------------#' diff --git a/mysql-test/suite/sys_vars/t/stored_program_cache_func.test b/mysql-test/suite/sys_vars/t/stored_program_cache_func.test new file mode 100644 index 00000000000..f85fc8eb1bf --- /dev/null +++ b/mysql-test/suite/sys_vars/t/stored_program_cache_func.test @@ -0,0 +1,43 @@ +create procedure p1() select 1; + +flush status; +show status like 'handler_read_key'; +call p1; +show status like 'handler_read_key'; +call p1; +show status like 'handler_read_key'; + +set global stored_program_cache=0; + +call p1; +show status like 'handler_read_key'; +call p1; +show status like 'handler_read_key'; + +drop procedure p1; +set global stored_program_cache=default; + +# Test for missing SP automatic reparsing. +# when MDEV-5816 is implemented, it should be removed. + +--delimiter | +create procedure pr(i int) begin + create table t1 (a int, b int); + if (i = 1) then alter table t1 drop a; + else alter table t1 drop b; + end if; + select * from t1; + drop table t1; +end | +--delimiter ; +call pr(1); +--error ER_BAD_FIELD_ERROR +call pr(2); +drop table t1; + +set global stored_program_cache=0; +call pr(1); +call pr(2); +drop procedure pr; +set global stored_program_cache=default; + diff --git a/mysql-test/t/frm_bad_row_type-7333.test b/mysql-test/t/frm_bad_row_type-7333.test new file mode 100644 index 00000000000..5100a85cb22 --- /dev/null +++ b/mysql-test/t/frm_bad_row_type-7333.test @@ -0,0 +1,14 @@ +# +# MDEV-7333 "'show table status like 'table_name'" on tokudb table lead to MariaDB crash +# +let $datadir= `select @@datadir`; +call mtr.add_suppression("bad_row_type.frm: invalid value 11 for the field row_format"); +copy_file std_data/bad_row_type.MYD $datadir/test/bad_row_type.MYD; +copy_file std_data/bad_row_type.MYI $datadir/test/bad_row_type.MYI; +copy_file std_data/bad_row_type.frm $datadir/test/bad_row_type.frm; + +select * from bad_row_type; +show create table bad_row_type; +replace_column 12 x 13 x; +show table status like 'bad_row_type'; +drop table bad_row_type; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index a3f488a8d1e..2b189765bbc 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1631,3 +1631,21 @@ CREATE TABLE t1 ( d DATE, t TIME ); INSERT INTO t1 VALUES ('2008-12-05','22:34:09'),('2005-03-27','14:26:02'); SELECT EXTRACT(DAY_MINUTE FROM GREATEST(t,d)), GREATEST(t,d) FROM t1; DROP TABLE t1; + + +--echo # +--echo # MDEV-7221 from_days fails after null value +--echo # +CREATE TABLE t1 ( + id INT(11) NOT NULL PRIMARY KEY, + date1 DATE NULL DEFAULT NULL +); +INSERT INTO t1 VALUES (12, '2011-05-12'); +INSERT INTO t1 VALUES (13, NULL); +INSERT INTO t1 VALUES (14, '2009-10-23'); +INSERT INTO t1 VALUES (15, '2014-10-30'); +INSERT INTO t1 VALUES (16, NULL); +INSERT INTO t1 VALUES (17, NULL); +INSERT INTO t1 VALUES (18, '2010-10-13'); +SELECT a.id,a.date1,FROM_DAYS(TO_DAYS(a.date1)-10) as date2, DATE_ADD(a.date1,INTERVAL -10 DAY),TO_DAYS(a.date1)-10 FROM t1 a ORDER BY a.id; +DROP TABLE t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 35bd447e9ea..4b1cb82d0f9 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1664,6 +1664,21 @@ WHERE t1a.c1 = c2 GROUP BY i2; DROP TABLE t1,t2; +--echo # +--echo # MDEV-6855 +--echo # MIN(*) with subqueries with IS NOT NULL in WHERE clause crashed. +--echo # + +CREATE TABLE t1 (i INT, c VARCHAR(3), KEY(c,i)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,'foo'),(0,'bar'); + +CREATE TABLE t2 (j INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0),(8),(1),(8),(9); + +SELECT MAX(i), c FROM t1 +WHERE c != 'qux' AND ( SELECT SUM(j) FROM t1, t2 ) IS NOT NULL GROUP BY c; +drop table t1,t2; + # # End of MariaDB 5.5 tests # diff --git a/mysql-test/t/insert_update_autoinc-7150.test b/mysql-test/t/insert_update_autoinc-7150.test new file mode 100644 index 00000000000..1229898b4aa --- /dev/null +++ b/mysql-test/t/insert_update_autoinc-7150.test @@ -0,0 +1,8 @@ +# +# MDEV-7150 Wrong auto increment values on INSERT .. ON DUPLICATE KEY UPDATE when the inserted columns include NULL in an auto-increment column +# +create table t1 (a int(10) auto_increment primary key, b int(11)); +insert t1 values (null,1); +insert t1 values (null,2), (1,-1), (null,3) on duplicate key update b=values(b); +select * from t1; +drop table t1; diff --git a/mysql-test/t/kill-2-master.opt b/mysql-test/t/kill-2-master.opt new file mode 100644 index 00000000000..ab6ca1731f5 --- /dev/null +++ b/mysql-test/t/kill-2-master.opt @@ -0,0 +1 @@ +--skip-name-resolve diff --git a/mysql-test/t/kill-2.test b/mysql-test/t/kill-2.test new file mode 100644 index 00000000000..0c1177722b4 --- /dev/null +++ b/mysql-test/t/kill-2.test @@ -0,0 +1,29 @@ +# +# Test KILL and KILL QUERY statements. +# +# Killing a connection in an embedded server does not work like in a normal +# server, if it is waiting for a new statement. In an embedded server, the +# connection does not read() from a socket, but returns control to the +# application. 'mysqltest' does not handle the kill request. +# + +-- source include/not_embedded.inc +-- source include/not_threadpool.inc + +--echo # +--echo # MDEV-6896 kill user command cause MariaDB crash! +--echo # + +create user foo@'127.0.0.1'; + +--connect (con1,127.0.0.1,foo,,) + +--connection default +select user from information_schema.processlist; +kill user foo@'127.0.0.1'; + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where user = "foo"; +--source include/wait_condition.inc +drop user foo@'127.0.0.1'; diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test index f00080d917b..ef79cc2c0f4 100644 --- a/mysql-test/t/lock_sync.test +++ b/mysql-test/t/lock_sync.test @@ -1186,7 +1186,6 @@ DROP TABLE t1; disconnect con1; disconnect con2; - # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/mdev6830-master.opt b/mysql-test/t/mdev6830-master.opt new file mode 100644 index 00000000000..2a8c27d4731 --- /dev/null +++ b/mysql-test/t/mdev6830-master.opt @@ -0,0 +1 @@ +--debug diff --git a/mysql-test/t/mdev6830.test b/mysql-test/t/mdev6830.test new file mode 100644 index 00000000000..24565d04fed --- /dev/null +++ b/mysql-test/t/mdev6830.test @@ -0,0 +1,63 @@ + +--source include/have_debug.inc + +--disable_warnings +drop table if exists t1,t2,t3; +drop view if exists v2,v3; +--enable_warnings +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM; + +CREATE TABLE t2 ( + f1 DATE, + f2 VARCHAR(1024), + f3 VARCHAR(10), + f4 DATE, + f5 VARCHAR(10), + f6 VARCHAR(10), + f7 VARCHAR(10), + f8 DATETIME, + f9 INT, + f10 VARCHAR(1024), + f11 VARCHAR(1024), + f12 INT, + f13 VARCHAR(1024) +) ENGINE=MyISAM; + +CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2; + +CREATE TABLE t3 ( + f1 VARCHAR(1024), + f2 VARCHAR(1024), + f3 DATETIME, + f4 VARCHAR(10), + f5 INT, + f6 VARCHAR(10), + f7 VARCHAR(1024), + f8 VARCHAR(10), + f9 INT, + f10 DATE, + f11 INT, + f12 VARCHAR(1024), + f13 VARCHAR(10), + f14 DATE, + f15 DATETIME +) ENGINE=MyISAM; + +CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3; + +INSERT INTO t3 VALUES + ('FOO','foo','2000-08-04 00:00:00','one',1,'1','FOO','foo',1,'2004-05-09',1,'one','one','2001-12-07','2001-10-17 08:25:04'), + ('BAR','bar','2001-01-01 04:52:37','two',2,'2','BAR','bar',2,'2008-01-01',2,'two','two','2006-06-19','2002-01-01 08:22:49'); + +CREATE TABLE t4 (f1 VARCHAR(10), f2 INT) ENGINE=MyISAM; + +SELECT * FROM t1; + +--error ER_BAD_FIELD_ERROR +SELECT non_existing FROM v2; + +SELECT * FROM t1, v3, t4 WHERE v3.f1 = t4.f1 AND t4.f2 = 6 AND t1.pk = v3.f5; + +drop table t1,t2,t3,t4; +drop view v2,v3; + diff --git a/mysql-test/t/processlist.test b/mysql-test/t/processlist.test index 9c555c0f9fb..a8f8a4ed64c 100644 --- a/mysql-test/t/processlist.test +++ b/mysql-test/t/processlist.test @@ -2,6 +2,7 @@ # MDEV-4578 information_schema.processlist reports incorrect value for Time (2147483647) # +source include/have_debug.inc; source include/have_debug_sync.inc; let $tid= `SELECT CONNECTION_ID()`; @@ -21,6 +22,7 @@ SET DEBUG_SYNC = 'now SIGNAL fill_schema_proceed'; connection con1; --replace_result $tid TID reap; +set debug_sync='reset'; connection default; # @@ -28,15 +30,13 @@ connection default; # connection con1; -# Trigger a signal once the thread has gone from "Query" to "Sleep" command -# state. Note we need to execute this twice: Once at the end of SET DEBUG_SYNC, -# and once for the intended time, at the end of SELECT SLEEP(). -SET DEBUG_SYNC = 'dispatch_command_end SIGNAL query_done EXECUTE 2'; -connection default; -# Wait for and clear the first signal set during SET DEBUG_SYNC. -SET DEBUG_SYNC= 'now WAIT_FOR query_done'; -SET DEBUG_SYNC= 'now SIGNAL nosignal'; -connection con1; +# This DBUG insertion triggers a DEBUG_SYNC signal "query_done" once +# the below SELECT SLEEP(5) has gone from "Query" to "Sleep" command +# state. (We cannot just set the DEBUG_SYNC directly here, because +# then it can trigger at the end of the SET DEBUG_SYNC statement (or +# at the end of the Prepare step of the SELECT, if --ps-protocol), +# thus occuring too early). +SET debug_dbug="+d,sleep_inject_query_done_debug_sync"; select sleep(5); #run a query that will take some time connection default; diff --git a/mysql-test/t/sp-innodb.test b/mysql-test/t/sp-innodb.test new file mode 100644 index 00000000000..228ab42544d --- /dev/null +++ b/mysql-test/t/sp-innodb.test @@ -0,0 +1,45 @@ + +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t1,t2; +drop procedure if exists p1; +--enable_warnings + +--echo # +--echo #MDEV-6985: MariaDB crashes on stored procedure call +--echo # +CREATE TABLE `t1` ( + `ID` int(11) NOT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB; + +CREATE TABLE `t2` ( + `ID` int(11) NOT NULL, + `DATE` datetime DEFAULT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB; + +--delimiter ;; + +CREATE PROCEDURE `p1`() +BEGIN + DECLARE _mySelect CURSOR FOR + SELECT DISTINCT t1.ID + FROM t1 + LEFT JOIN t2 AS t2 ON + t2.ID = t1.ID + AND t2.DATE = ( + SELECT MAX(T3.DATE) FROM t2 AS T3 WHERE T3.ID = t2.ID AND T3.DATE<=NOW() + ) + WHERE t1.ID = 1; + OPEN _mySelect; + CLOSE _mySelect; +END ;; +--delimiter ; + +CALL p1(); +CALL p1(); + +drop procedure p1; +drop table t1,t2; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index eb905b5c4df..ae78d5504cf 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -5335,6 +5335,16 @@ DROP FUNCTION f1; DROP VIEW v1; DROP TABLE t1, t2; + +create view v1 as select 1; + +--let $MYSQLD_DATADIR= `select @@datadir` +--let SEARCH_FILE= $MYSQLD_DATADIR/test/v1.frm +--let SEARCH_PATTERN=mariadb-version +--source include/search_pattern_in_file.inc + +drop view v1; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. --echo # ----------------------------------------------------------------- diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index b7d31948d23..617daba6b8e 100644 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test @@ -98,3 +98,19 @@ deallocate prepare abc; SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'socket'; + +--echo # +--echo # Bug#16581605: REPLACE.EXE UTILITY IS BROKEN IN 5.5 +--echo # + +# Creating a temporary text file. +--write_file $MYSQL_TMP_DIR/bug16581605.txt +abc +def +EOF + +#REPLACE.EXE UTILITY will work fine after the fix. +--exec $REPLACE abc xyz < $MYSQL_TMP_DIR/bug16581605.txt + +#Cleanup +remove_file $MYSQL_TMP_DIR/bug16581605.txt; diff --git a/mysys/my_context.c b/mysys/my_context.c index 4d9f1a1a12f..60c0014b3b9 100644 --- a/mysys/my_context.c +++ b/mysys/my_context.c @@ -727,33 +727,36 @@ my_context_continue(struct my_context *c) #ifdef MY_CONTEXT_DISABLE int -my_context_continue(struct my_context *c) +my_context_continue(struct my_context *c __attribute__((unused))) { return -1; } int -my_context_spawn(struct my_context *c, void (*f)(void *), void *d) +my_context_spawn(struct my_context *c __attribute__((unused)), + void (*f)(void *) __attribute__((unused)), + void *d __attribute__((unused))) { return -1; } int -my_context_yield(struct my_context *c) +my_context_yield(struct my_context *c __attribute__((unused))) { return -1; } int -my_context_init(struct my_context *c, size_t stack_size) +my_context_init(struct my_context *c __attribute__((unused)), + size_t stack_size __attribute__((unused))) { return -1; /* Out of memory */ } void -my_context_destroy(struct my_context *c) +my_context_destroy(struct my_context *c __attribute__((unused))) { } diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 6674a5d394d..c761064dd96 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 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 @@ -328,26 +328,4 @@ int pthread_attr_destroy(pthread_attr_t *connect_att) return 0; } -/**************************************************************************** -** Fix localtime_r() to be a bit safer -****************************************************************************/ - -struct tm *localtime_r(const time_t *timep,struct tm *tmp) -{ - if (*timep == (time_t) -1) /* This will crash win32 */ - { - bzero(tmp,sizeof(*tmp)); - } - else - { - struct tm *res=localtime(timep); - if (!res) /* Wrong date */ - { - bzero(tmp,sizeof(*tmp)); /* Keep things safe */ - return 0; - } - *tmp= *res; - } - return tmp; -} #endif /* __WIN__ */ diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 20af094f711..1782aecd4df 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -325,7 +325,7 @@ static void check_locks(THR_LOCK *lock, const char *where, found_errors++; fprintf(stderr, "Warning at '%s': Write lock %d waiting while no exclusive read locks\n",where,(int) lock->write_wait.data->type); - DBUG_PRINT("warning", ("Warning at '%s': Write lock %d waiting while no exclusive read locks\n",where,(int) lock->write_wait.data->type)); + DBUG_PRINT("warning", ("Warning at '%s': Write lock %d waiting while no exclusive read locks",where,(int) lock->write_wait.data->type)); } } } @@ -345,7 +345,7 @@ static void check_locks(THR_LOCK *lock, const char *where, fprintf(stderr, "Warning at '%s': Found TL_WRITE_CONCURRENT_INSERT lock mixed with other write lock: %d\n", where, data->type); - DBUG_PRINT("warning", ("Warning at '%s': Found TL_WRITE_CONCURRENT_INSERT lock mixed with other write lock: %d\n", + DBUG_PRINT("warning", ("Warning at '%s': Found TL_WRITE_CONCURRENT_INSERT lock mixed with other write lock: %d", where, data->type)); break; } @@ -361,7 +361,7 @@ static void check_locks(THR_LOCK *lock, const char *where, fprintf(stderr, "Warning at '%s': Found WRITE_ALLOW_WRITE lock waiting for WRITE_ALLOW_WRITE lock\n", where); - DBUG_PRINT("warning", ("Warning at '%s': Found WRITE_ALLOW_WRITE lock waiting for WRITE_ALLOW_WRITE lock\n", + DBUG_PRINT("warning", ("Warning at '%s': Found WRITE_ALLOW_WRITE lock waiting for WRITE_ALLOW_WRITE lock", where)); } @@ -384,7 +384,7 @@ static void check_locks(THR_LOCK *lock, const char *where, "Warning at '%s' for lock: %d: Found lock of type %d that is write and read locked. Read_no_write_count: %d\n", where, (int) type, lock->write.data->type, lock->read_no_write_count); - DBUG_PRINT("warning",("At '%s' for lock %d: Found lock of type %d that is write and read locked\n", + DBUG_PRINT("warning",("At '%s' for lock %d: Found lock of type %d that is write and read locked", where, (int) type, lock->write.data->type)); } @@ -800,7 +800,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) The idea is to allow us to get a lock at once if we already have a write lock or if there is no pending write locks and if all write locks are of the same type and are either - TL_WRITE_ALLOW_WRITE or TL_WRITE_CONCURRENT_INSERT + TL_WRITE_ALLOW_WRITE or TL_WRITE_CONCURRENT_INSERT and + there is no TL_READ_NO_INSERT lock. Note that, since lock requests for the same table are sorted in such way that requests with higher thr_lock_type value come first @@ -817,7 +818,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) situation. **) The exceptions are situations when: - when old lock type is TL_WRITE_DELAYED - But these should never happen within MySQL. + But these should never happen within MariaDB. Therefore it is OK to allow acquiring write lock on the table if this thread already holds some write lock on it. @@ -836,7 +837,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout) lock->allow_multiple_concurrent_insert && !lock->read_no_write_count)) && ! lock->write_wait.data && - lock->write.data->type == lock_type) || + lock->write.data->type == lock_type && + ! lock->read_no_write_count) || has_old_lock(lock->write.data, data->owner)) { DBUG_PRINT("info", ("write_wait.data: 0x%lx old_type: %d", diff --git a/packaging/rpm-oel/mysql-systemd-start b/packaging/rpm-oel/mysql-systemd-start index 9cb2a25c990..8670f889574 100644 --- a/packaging/rpm-oel/mysql-systemd-start +++ b/packaging/rpm-oel/mysql-systemd-start @@ -8,10 +8,19 @@ # post mode : ping server until answer is received # +get_option () { + local section=$1 + local option=$2 + local default=$3 + ret=$(/usr/bin/my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-) + [ -z $ret ] && ret=$default + echo $ret +} + install_db () { # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode) - datadir=$(/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p') - + datadir=$(get_option mysqld datadir "/var/lib/mysql") + # Restore log, dir, perms and SELinux contexts [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 log=/var/log/mysqld.log @@ -35,9 +44,16 @@ pinger () { # Wait for ping to answer to signal startup completed, # might take a while in case of e.g. crash recovery # MySQL systemd service will timeout script if no answer + datadir=$(get_option mysqld datadir "/var/lib/mysql") + socket=$(get_option mysqld socket "$datadir/mysql.sock") + case $socket in + /*) adminsocket="$socket" ;; + *) adminsocket="$datadir/$socket" ;; + esac + while /bin/true ; do sleep 1 - mysqladmin ping >/dev/null 2>&1 && break + mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping >/dev/null 2>&1 && break done exit 0 } diff --git a/packaging/rpm-oel/mysql.init b/packaging/rpm-oel/mysql.init index d6f8f023850..79c8a8daa7d 100644 --- a/packaging/rpm-oel/mysql.init +++ b/packaging/rpm-oel/mysql.init @@ -50,11 +50,15 @@ errlogfile="$result" get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid" mypidfile="$result" +case $socketfile in + /*) adminsocket="$socketfile" ;; + *) adminsocket="$datadir/$socketfile" ;; +esac start(){ [ -x $exec ] || exit 5 # check to see if it's already running - RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` + RESPONSE=$(/usr/bin/mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping 2>&1) if [ $? = 0 ]; then # already running, do nothing action $"Starting $prog: " /bin/true @@ -107,7 +111,7 @@ start(){ ret=0 TIMEOUT="$STARTTIMEOUT" while [ $TIMEOUT -gt 0 ]; do - RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` && break + RESPONSE=$(/usr/bin/mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping 2>&1) && break echo "$RESPONSE" | grep -q "Access denied for user" && break if ! /bin/kill -0 $safe_pid 2>/dev/null; then echo "MySQL Daemon failed to start." diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index e1c774a4830..eadd6ae5af0 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -90,17 +90,10 @@ IF(MALLOC_LIB) ENDIF() IF(CMAKE_GENERATOR MATCHES "Makefiles") - # Strip maintainer mode options if necessary - STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}") - STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") FOREACH(ARCH ${CMAKE_OSX_ARCHITECTURES}) SET(CFLAGS "${CFLAGS} -arch ${ARCH}") SET(CXXFLAGS "${CXXFLAGS} -arch ${ARCH}") ENDFOREACH() -ELSE() - # Strip maintainer mode options if necessary - STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") ENDIF() IF(UNIX) diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index f23011a5ae6..48f0b09b566 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -264,13 +264,13 @@ sub addall { foreach $host (@hosts) { # user privileges: SELECT if (($todo == 2) || ($todo == 3)) { - $sth = $dbh->do("GRANT SELECT ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr; + $sth = $dbh->do("GRANT SELECT ON $db.* TO \'$user\'@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr; } elsif ($todo == 4) { # user privileges: SELECT,INSERT,UPDATE,DELETE - $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr; + $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE ON $db.* TO \'$user\'@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr; } elsif ($todo == 5) { # user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES - $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr; + $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO \'$user\'@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr; } elsif ($todo == 6) { # all privileges $sth = $dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr; diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 7c43558523b..0293631fb56 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -579,6 +579,7 @@ then then # User explicitly asked for syslog, so warn that it isn't used log_error "Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect." + want_syslog=0 fi # Log to err_log file diff --git a/sql-bench/test-table-elimination.sh b/sql-bench/test-table-elimination.sh index 5b494688bec..7772cab42b0 100755 --- a/sql-bench/test-table-elimination.sh +++ b/sql-bench/test-table-elimination.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Test of table elimination feature use Cwd; diff --git a/sql-common/client.c b/sql-common/client.c index 89f6a8434a5..20ccd73596c 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -113,7 +113,7 @@ my_bool net_flush(NET *net); #define native_password_plugin_name "mysql_native_password" #define old_password_plugin_name "mysql_old_password" - +uint mariadb_deinitialize_ssl= 1; uint mysql_port=0; char *mysql_unix_port= 0; const char *unknown_sqlstate= "HY000"; diff --git a/sql-common/client_plugin.c b/sql-common/client_plugin.c index 063fc5c6dc6..133d008f99b 100644 --- a/sql-common/client_plugin.c +++ b/sql-common/client_plugin.c @@ -28,11 +28,6 @@ There is no reference counting and no unloading either. */ -#if _MSC_VER -/* Silence warnings about variable 'unused' being used. */ -#define FORCE_INIT_OF_VARS 1 -#endif - #include <my_global.h> #include "mysql.h" #include <my_sys.h> diff --git a/sql/handler.cc b/sql/handler.cc index 75481e9e9b5..518ca7b860d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -83,9 +83,7 @@ static const LEX_STRING sys_table_aliases[]= }; const char *ha_row_type[] = { - "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", - "PAGE", - "?","?","?" + "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", "PAGE" }; const char *tx_isolation_names[] = diff --git a/sql/handler.h b/sql/handler.h index 5bba570f8ec..4222270e9c4 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -452,8 +452,10 @@ enum legacy_db_type enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED, - ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, - ROW_TYPE_PAGE }; + ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE }; + +/* not part of the enum, so that it shouldn't be in switch(row_type) */ +#define ROW_TYPE_MAX ((uint)ROW_TYPE_PAGE + 1) /* Specifies data storage format for individual columns */ enum column_format_type { @@ -1389,6 +1391,9 @@ static inline sys_var *find_hton_sysvar(handlerton *hton, st_mysql_sys_var *var) #define HTON_NO_BINLOG_ROW_OPT (1 << 9) #define HTON_SUPPORTS_EXTENDED_KEYS (1 <<10) //supports extended keys +// MySQL compatibility. Unused. +#define HTON_SUPPORTS_FOREIGN_KEYS (1 << 0) //Foreign key constraint supported. + class Ha_trx_info; struct THD_TRANS @@ -1570,7 +1575,7 @@ class partition_info; struct st_partition_iter; -enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES }; +enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES, HA_CHOICE_MAX }; enum enum_stats_auto_recalc { HA_STATS_AUTO_RECALC_DEFAULT= 0, HA_STATS_AUTO_RECALC_ON, diff --git a/sql/item.cc b/sql/item.cc index 1dd4fc2909f..132cfa2846a 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -885,20 +885,20 @@ Item_ident::Item_ident(THD *thd, Item_ident *item) void Item_ident::cleanup() { DBUG_ENTER("Item_ident::cleanup"); -#ifdef CANT_BE_USED_AS_MEMORY_IS_FREED - db_name ? db_name : "(null)", - orig_db_name ? orig_db_name : "(null)", - table_name ? table_name : "(null)", - orig_table_name ? orig_table_name : "(null)", - field_name ? field_name : "(null)", - orig_field_name ? orig_field_name : "(null)")); -#endif + bool was_fixed= fixed; Item::cleanup(); db_name= orig_db_name; table_name= orig_table_name; field_name= orig_field_name; /* Store if this Item was depended */ - can_be_depended= MY_TEST(depended_from); + if (was_fixed) + { + /* + We can trust that depended_from set correctly only if this item + was fixed + */ + can_be_depended= MY_TEST(depended_from); + } DBUG_VOID_RETURN; } diff --git a/sql/item.h b/sql/item.h index f337db92ef3..13e80639657 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4458,7 +4458,7 @@ private: /** @todo Implement the is_null() method for this class. Currently calling is_null() - on any Item_cache object resolves to Item::is_null(), which reutns FALSE + on any Item_cache object resolves to Item::is_null(), which returns FALSE for any value. */ diff --git a/sql/item_func.cc b/sql/item_func.cc index de05ee358a2..92ddd5feada 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4620,6 +4620,11 @@ longlong Item_func_sleep::val_int() mysql_cond_destroy(&cond); + DBUG_EXECUTE_IF("sleep_inject_query_done_debug_sync", { + debug_sync_set_action + (thd, STRING_WITH_LEN("dispatch_command_end SIGNAL query_done")); + };); + return MY_TEST(!error); // Return 1 killed } diff --git a/sql/item_func.h b/sql/item_func.h index e40f2d771c6..ce1f2fdd676 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1,7 +1,7 @@ #ifndef ITEM_FUNC_INCLUDED #define ITEM_FUNC_INCLUDED -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. +/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2009, 2014, 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 @@ -287,7 +287,8 @@ public: inline longlong check_integer_overflow(longlong value, bool val_unsigned) { if ((unsigned_flag && !val_unsigned && value < 0) || - (!unsigned_flag && val_unsigned && (ulonglong) value > LONGLONG_MAX)) + (!unsigned_flag && val_unsigned && + (ulonglong) value > (ulonglong) LONGLONG_MAX)) return raise_integer_overflow(); return value; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 389d9d5380c..fb55b7660cb 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1564,10 +1564,9 @@ String *Item_temporal_hybrid_func::val_str_ascii(String *str) bool Item_func_from_days::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { longlong value=args[0]->val_int(); - if (args[0]->null_value) - return (null_value= 1); - if ((fuzzy_date & TIME_NO_ZERO_DATE) && value == 0) - return (null_value= 1); + if ((null_value= (args[0]->null_value || + ((fuzzy_date & TIME_NO_ZERO_DATE) && value == 0)))) + return true; bzero(ltime, sizeof(MYSQL_TIME)); if (get_date_from_daynr((long) value, <ime->year, <ime->month, <ime->day)) diff --git a/sql/log_event.cc b/sql/log_event.cc index d568b91a1e2..dd272ac52cd 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1669,7 +1669,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, ev = new Execute_load_log_event(buf, event_len, description_event); break; case START_EVENT_V3: /* this is sent only by MySQL <=4.x */ - ev = new Start_log_event_v3(buf, description_event); + ev = new Start_log_event_v3(buf, event_len, description_event); break; case STOP_EVENT: ev = new Stop_log_event(buf, description_event); @@ -4662,11 +4662,16 @@ void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info) Start_log_event_v3::Start_log_event_v3() */ -Start_log_event_v3::Start_log_event_v3(const char* buf, +Start_log_event_v3::Start_log_event_v3(const char* buf, uint event_len, const Format_description_log_event *description_event) - :Log_event(buf, description_event) + :Log_event(buf, description_event), binlog_version(BINLOG_VERSION) { + if (event_len < LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET) + { + server_version[0]= 0; + return; + } buf+= LOG_EVENT_MINIMAL_HEADER_LEN; binlog_version= uint2korr(buf+ST_BINLOG_VER_OFFSET); memcpy(server_version, buf+ST_SERVER_VER_OFFSET, @@ -4971,9 +4976,12 @@ Format_description_log_event(const char* buf, const Format_description_log_event* description_event) - :Start_log_event_v3(buf, description_event), event_type_permutation(0) + :Start_log_event_v3(buf, event_len, description_event), + common_header_len(0), post_header_len(NULL), event_type_permutation(0) { DBUG_ENTER("Format_description_log_event::Format_description_log_event(char*,...)"); + if (!Start_log_event_v3::is_valid()) + DBUG_VOID_RETURN; /* sanity check */ buf+= LOG_EVENT_MINIMAL_HEADER_LEN; if ((common_header_len=buf[ST_COMMON_HEADER_LEN_OFFSET]) < OLD_HEADER_LEN) DBUG_VOID_RETURN; /* sanity check */ diff --git a/sql/log_event.h b/sql/log_event.h index c0370014c7d..6a3e6f174bb 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -2515,7 +2515,7 @@ public: void print(FILE* file, PRINT_EVENT_INFO* print_event_info); #endif - Start_log_event_v3(const char* buf, + Start_log_event_v3(const char* buf, uint event_len, const Format_description_log_event* description_event); ~Start_log_event_v3() {} Log_event_type get_type_code() { return START_EVENT_V3;} @@ -2524,7 +2524,7 @@ public: #ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif - bool is_valid() const { return 1; } + bool is_valid() const { return server_version[0] != 0; } int get_data_size() { return START_V3_HEADER_LEN; //no variable-sized part diff --git a/sql/opt_range.cc b/sql/opt_range.cc index a5c27fa66e2..3597ade2cba 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -13167,12 +13167,13 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) SYNOPSIS check_group_min_max_predicates() - cond [in] the expression tree being analyzed - min_max_arg [in] the field referenced by the MIN/MAX function(s) - image_type [in] - has_min_max_arg [out] true if the subtree being analyzed references min_max_arg - has_other_arg [out] true if the subtree being analyzed references a column - other min_max_arg + cond [in] the expression tree being analyzed + min_max_arg [in] the field referenced by the MIN/MAX function(s) + image_type [in] + has_min_max_arg [out] true if the subtree being analyzed references + min_max_arg + has_other_arg [out] true if the subtree being analyzed references a + column other min_max_arg DESCRIPTION The function walks recursively over the cond tree representing a WHERE @@ -13216,7 +13217,7 @@ check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item, (2) the subtree passes the test, but it is an OR and it references both the min/max argument and other columns. */ - if (!check_group_min_max_predicates(and_or_arg, min_max_arg_item, //1 + if (!check_group_min_max_predicates(and_or_arg, min_max_arg_item, //1 image_type, &has_min_max, &has_other) || (func_type == Item_func::COND_OR_FUNC && has_min_max && has_other))//2 @@ -13232,7 +13233,7 @@ check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item, a subquery in the WHERE clause. */ - if (cond_type == Item::SUBSELECT_ITEM) + if (unlikely(cond_type == Item::SUBSELECT_ITEM)) { Item_subselect *subs_cond= (Item_subselect*) cond; if (subs_cond->is_correlated) @@ -13249,7 +13250,14 @@ check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item, } DBUG_RETURN(TRUE); } - + /* + Subquery with IS [NOT] NULL + TODO: Look into the cache_item and optimize it like we do for + subselect's above + */ + if (unlikely(cond_type == Item::CACHE_ITEM)) + DBUG_RETURN(cond->const_item()); + /* Condition of the form 'field' is equivalent to 'field <> 0' and thus satisfies the SA3 condition. @@ -13266,7 +13274,9 @@ check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item, /* We presume that at this point there are no other Items than functions. */ DBUG_ASSERT(cond_type == Item::FUNC_ITEM); - + if (unlikely(cond_type != Item::FUNC_ITEM)) /* Safety */ + DBUG_RETURN(FALSE); + /* Test if cond references only group-by or non-group fields. */ Item_func *pred= (Item_func*) cond; Item_func::Functype pred_type= pred->functype(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0ecc6418cb2..11f2d6b3dbc 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1758,7 +1758,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) table->file->adjust_next_insert_id_after_explicit_value(table->next_number_field->val_int()); } - else + else if (prev_insert_id_for_cur_row) { table->file->restore_auto_increment(prev_insert_id_for_cur_row); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 88dc862df3e..96e7bbc822e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5982,6 +5982,115 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors) #endif } + +/** + Checks foreign key's parent table access. + + @param thd [in] Thread handler + @param create_info [in] Create information (like MAX_ROWS, ENGINE or + temporary table flag) + @param alter_info [in] Initial list of columns and indexes for the + table to be created + + @retval + false ok. + @retval + true error or access denied. Error is sent to client in this case. +*/ +bool check_fk_parent_table_access(THD *thd, + HA_CREATE_INFO *create_info, + Alter_info *alter_info) +{ + Key *key; + List_iterator<Key> key_iterator(alter_info->key_list); + + while ((key= key_iterator++)) + { + if (key->type == Key::FOREIGN_KEY) + { + TABLE_LIST parent_table; + bool is_qualified_table_name; + Foreign_key *fk_key= (Foreign_key *)key; + LEX_STRING db_name; + LEX_STRING table_name= { fk_key->ref_table.str, + fk_key->ref_table.length }; + const ulong privileges= (SELECT_ACL | INSERT_ACL | UPDATE_ACL | + DELETE_ACL | REFERENCES_ACL); + + // Check if tablename is valid or not. + DBUG_ASSERT(table_name.str != NULL); + if (check_table_name(table_name.str, table_name.length, false)) + { + my_error(ER_WRONG_TABLE_NAME, MYF(0), table_name.str); + return true; + } + + if (fk_key->ref_db.str) + { + is_qualified_table_name= true; + db_name.str= (char *) thd->memdup(fk_key->ref_db.str, + fk_key->ref_db.length+1); + db_name.length= fk_key->ref_db.length; + + // Check if database name is valid or not. + if (fk_key->ref_db.str && check_db_name(&db_name)) + { + my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str); + return true; + } + } + else if (thd->lex->copy_db_to(&db_name.str, &db_name.length)) + return true; + else + is_qualified_table_name= false; + + // if lower_case_table_names is set then convert tablename to lower case. + if (lower_case_table_names) + { + table_name.str= (char *) thd->memdup(fk_key->ref_table.str, + fk_key->ref_table.length+1); + table_name.length= my_casedn_str(files_charset_info, table_name.str); + } + + parent_table.init_one_table(db_name.str, db_name.length, + table_name.str, table_name.length, + table_name.str, TL_IGNORE); + + /* + Check if user has any of the "privileges" at table level on + "parent_table". + Having privilege on any of the parent_table column is not + enough so checking whether user has any of the "privileges" + at table level only here. + */ + if (check_some_access(thd, privileges, &parent_table) || + parent_table.grant.want_privilege) + { + if (is_qualified_table_name) + { + const size_t qualified_table_name_len= NAME_LEN + 1 + NAME_LEN + 1; + char *qualified_table_name= (char *) thd->alloc(qualified_table_name_len); + + my_snprintf(qualified_table_name, qualified_table_name_len, "%s.%s", + db_name.str, table_name.str); + table_name.str= qualified_table_name; + } + + my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), + "REFERENCES", + thd->security_ctx->priv_user, + thd->security_ctx->host_or_ip, + table_name.str); + + return true; + } + } + } + + return false; +} + + /**************************************************************************** Check stack size; Send error if there isn't enough stack to continue ****************************************************************************/ @@ -7391,7 +7500,7 @@ static uint kill_threads_for_user(THD *thd, LEX_USER *user, host.str[0] == '%' means that host name was not given. See sql_yacc.yy */ if (((user->host.str[0] == '%' && !user->host.str[1]) || - !strcmp(tmp->security_ctx->host, user->host.str)) && + !strcmp(tmp->security_ctx->host_or_ip, user->host.str)) && !strcmp(tmp->security_ctx->user, user->user.str)) { if (!(thd->security_ctx->master_access & SUPER_ACL) && @@ -8047,7 +8156,9 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, if (check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE)) goto err; } - error= FALSE; + + if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info)) + goto err; /* For CREATE TABLE we should not open the table even if it exists. @@ -8055,6 +8166,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, */ lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB; + error= FALSE; + err: DBUG_RETURN(error); } diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 926a4d800ad..40ae5427133 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -46,6 +46,9 @@ bool delete_precheck(THD *thd, TABLE_LIST *tables); bool insert_precheck(THD *thd, TABLE_LIST *tables); bool create_table_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *create_table); +bool check_fk_parent_table_access(THD *thd, + HA_CREATE_INFO *create_info, + Alter_info *alter_info); bool parse_sql(THD *thd, Parser_state *parser_state, Object_creation_ctx *creation_ctx, bool do_pfs_digest=false); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 3741712160e..4227641859d 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3961,7 +3961,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, we copy string values to a plugin's memroot. */ if (mysqld_server_started && - ((o->flags & (PLUGIN_VAR_STR | PLUGIN_VAR_NOCMDOPT | + ((o->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_MEMALLOC)) == PLUGIN_VAR_STR)) { sysvar_str_t* str= (sysvar_str_t *)o; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3912a039b9c..ed56191c32b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9991,7 +9991,7 @@ bool generate_derived_keys_for_table(KEYUSE *keyuse, uint count, uint keys) else { /* Mark keyuses for this key to be excluded */ - for (KEYUSE *curr=save_first_keyuse; curr < first_keyuse; curr++) + for (KEYUSE *curr=save_first_keyuse; curr < keyuse; curr++) { curr->key= MAX_KEY; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8a2f38831dc..48aac779215 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -8376,9 +8376,21 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, } /* - If this is an ALTER TABLE and no explicit row type specified reuse - the table's row type. - Note : this is the same as if the row type was specified explicitly. + If foreign key is added then check permission to access parent table. + + In function "check_fk_parent_table_access", create_info->db_type is used + to identify whether engine supports FK constraint or not. Since + create_info->db_type is set here, check to parent table access is delayed + till this point for the alter operation. + */ + if ((alter_info->flags & Alter_info::ADD_FOREIGN_KEY) && + check_fk_parent_table_access(thd, create_info, alter_info)) + DBUG_RETURN(true); + + /* + If this is an ALTER TABLE and no explicit row type specified reuse + the table's row type. + Note: this is the same as if the row type was specified explicitly. */ if (create_info->row_type == ROW_TYPE_NOT_USED) { @@ -9521,12 +9533,12 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, /* - Recreates tables by calling mysql_alter_table(). + Recreates one table by calling mysql_alter_table(). SYNOPSIS mysql_recreate_table() thd Thread handler - tables Tables to recreate + table_list Table to recreate table_copy Recreate the table by using ALTER TABLE COPY algorithm @@ -9538,13 +9550,15 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) { HA_CREATE_INFO create_info; Alter_info alter_info; - DBUG_ENTER("mysql_recreate_table"); - DBUG_ASSERT(!table_list->next_global); + TABLE_LIST *next_table= table_list->next_global; + DBUG_ENTER("mysql_recreate_table"); /* Set lock type which is appropriate for ALTER TABLE. */ table_list->lock_type= TL_READ_NO_INSERT; /* Same applies to MDL request. */ table_list->mdl_request.set_type(MDL_SHARED_NO_WRITE); + /* hide following tables from open_tables() */ + table_list->next_global= NULL; bzero((char*) &create_info, sizeof(create_info)); create_info.row_type=ROW_TYPE_NOT_USED; @@ -9556,9 +9570,11 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) if (table_copy) alter_info.requested_algorithm= Alter_info::ALTER_TABLE_ALGORITHM_COPY; - DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info, + bool res= mysql_alter_table(thd, NullS, NullS, &create_info, table_list, &alter_info, 0, - (ORDER *) 0, 0)); + (ORDER *) 0, 0); + table_list->next_global= next_table; + DBUG_RETURN(res); } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 6a81301a6d9..20a16e3eae1 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -685,7 +685,7 @@ err: /* number of required parameters for making view */ -static const int required_view_parameters= 14; +static const int required_view_parameters= 15; /* table of VIEW .frm field descriptors @@ -736,6 +736,9 @@ static File_option view_parameters[]= {{(char*) STRING_WITH_LEN("view_body_utf8")}, my_offsetof(TABLE_LIST, view_body_utf8), FILE_OPTIONS_ESTRING}, + {{ C_STRING_WITH_LEN("mariadb-version")}, + my_offsetof(TABLE_LIST, mariadb_version), + FILE_OPTIONS_ULONGLONG}, {{NullS, 0}, 0, FILE_OPTIONS_STRING} }; @@ -836,6 +839,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, version 2 - empty definer_host means a role */ view->file_version= 2; + view->mariadb_version= MYSQL_VERSION_ID; view->calc_md5(md5); if (!(view->md5.str= (char*) thd->memdup(md5, 32))) { diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index a0cc344d43f..f1942d08591 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3435,13 +3435,13 @@ static Sys_var_bit Sys_log_off( static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd, enum_var_type type) { - if (type == OPT_SESSION) - { - if (thd->variables.sql_log_bin) - thd->variables.option_bits |= OPTION_BIN_LOG; - else - thd->variables.option_bits &= ~OPTION_BIN_LOG; - } + DBUG_ASSERT(type == OPT_SESSION); + + if (thd->variables.sql_log_bin) + thd->variables.option_bits |= OPTION_BIN_LOG; + else + thd->variables.option_bits &= ~OPTION_BIN_LOG; + return FALSE; } @@ -3463,7 +3463,10 @@ static bool check_sql_log_bin(sys_var *self, THD *thd, set_var *var) return TRUE; if (var->type == OPT_GLOBAL) - return FALSE; + { + my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), self->name.str, "SESSION"); + return TRUE; + } if (error_if_in_trans_or_substatement(thd, ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN, @@ -3474,9 +3477,9 @@ static bool check_sql_log_bin(sys_var *self, THD *thd, set_var *var) } static Sys_var_mybool Sys_log_binlog( - "sql_log_bin", "sql_log_bin", - SESSION_VAR(sql_log_bin), NO_CMD_LINE, - DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_log_bin), + "sql_log_bin", "Controls whether logging to the binary log is done", + SESSION_VAR(sql_log_bin), NO_CMD_LINE, DEFAULT(TRUE), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_log_bin), ON_UPDATE(fix_sql_log_bin_after_update)); static Sys_var_bit Sys_sql_warnings( @@ -4483,7 +4486,7 @@ static Sys_var_ulong Sys_sp_cache_size( "The soft upper limit for number of cached stored routines for " "one connection.", GLOBAL_VAR(stored_program_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(256, 512 * 1024), DEFAULT(256), BLOCK_SIZE(1)); + VALID_RANGE(0, 512 * 1024), DEFAULT(256), BLOCK_SIZE(1)); export const char *plugin_maturity_names[]= { "unknown", "experimental", "alpha", "beta", "gamma", "stable", 0 }; diff --git a/sql/table.cc b/sql/table.cc index f23823bdf4f..321c2a96b4f 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -828,6 +828,24 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end, } +/** ensures that the enum value (read from frm) is within limits + + if not - issues a warning and resets the value to 0 + (that is, 0 is assumed to be a default value) +*/ + +static uint enum_value_with_check(THD *thd, TABLE_SHARE *share, + const char *name, uint value, uint limit) +{ + if (value < limit) + return value; + + sql_print_warning("%s.frm: invalid value %d for the field %s", + share->normalized_path.str, value, name); + return 0; +} + + /** Check if a collation has changed number @@ -837,8 +855,7 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end, @retval new collation number (same as current collation number of no change) */ -static uint -upgrade_collation(ulong mysql_version, uint cs_number) +static uint upgrade_collation(ulong mysql_version, uint cs_number) { if (mysql_version >= 50300 && mysql_version <= 50399) { @@ -862,8 +879,6 @@ upgrade_collation(ulong mysql_version, uint cs_number) } - - /** Read data from a binary .frm file image into a TABLE_SHARE @@ -1047,9 +1062,12 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, share->incompatible_version|= HA_CREATE_USED_CHARSET; share->avg_row_length= uint4korr(frm_image+34); - share->transactional= (ha_choice) (frm_image[39] & 3); - share->page_checksum= (ha_choice) ((frm_image[39] >> 2) & 3); - share->row_type= (enum row_type) frm_image[40]; + share->transactional= (ha_choice) + enum_value_with_check(thd, share, "transactional", frm_image[39] & 3, HA_CHOICE_MAX); + share->page_checksum= (ha_choice) + enum_value_with_check(thd, share, "page_checksum", (frm_image[39] >> 2) & 3, HA_CHOICE_MAX); + share->row_type= (enum row_type) + enum_value_with_check(thd, share, "row_format", frm_image[40], ROW_TYPE_MAX); if (cs_new && !(share->table_charset= get_charset(cs_new, MYF(MY_WME)))) goto err; diff --git a/sql/table.h b/sql/table.h index 58b78af6836..b978484158b 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1898,6 +1898,7 @@ struct TABLE_LIST LEX_STRING timestamp; /* GMT time stamp of last operation */ st_lex_user definer; /* definer of view */ ulonglong file_version; /* version of file's field set */ + ulonglong mariadb_version; /* version of server on creation */ ulonglong updatable_view; /* VIEW can be updated */ /** @brief The declared algorithm, if this is a view. diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index e80ce15165b..14ab6ec7599 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1569,6 +1569,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) MARIA_SHARE *share= file->s; ha_rows rows= file->state->records; TRN *old_trn= file->trn; + my_bool locking= 0; DBUG_ENTER("ha_maria::repair"); /* @@ -1605,12 +1606,18 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) share->state.dupp_key= MI_MAX_KEY; strmov(fixed_name, share->open_file_name.str); - // Don't lock tables if we have used LOCK TABLE - if (!thd->locked_tables_mode && - maria_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK)) + /* + Don't lock tables if we have used LOCK TABLE or if we come from + enable_index() + */ + if (!thd->locked_tables_mode && ! (param->testflag & T_NO_LOCKS)) { - _ma_check_print_error(param, ER(ER_CANT_LOCK), my_errno); - DBUG_RETURN(HA_ADMIN_FAILED); + locking= 1; + if (maria_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK)) + { + _ma_check_print_error(param, ER(ER_CANT_LOCK), my_errno); + DBUG_RETURN(HA_ADMIN_FAILED); + } } if (!do_optimize || @@ -1746,7 +1753,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) mysql_mutex_unlock(&share->intern_lock); thd_proc_info(thd, old_proc_info); thd_progress_end(thd); // Mark done - if (!thd->locked_tables_mode) + if (locking) maria_lock_database(file, F_UNLCK); /* Reset trn, that may have been set by repair */ @@ -1980,8 +1987,16 @@ int ha_maria::enable_indexes(uint mode) param.op_name= "recreating_index"; param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK | T_CREATE_MISSING_KEYS | T_SAFE_REPAIR); + /* + Don't lock and unlock table if it's locked. + Normally table should be locked. This test is mostly for safety. + */ + if (likely(file->lock_type != F_UNLCK)) + param.testflag|= T_NO_LOCKS; + if (file->create_unique_index_by_sort) param.testflag|= T_CREATE_UNIQUE_BY_SORT; + if (bulk_insert_single_undo == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR) { bulk_insert_single_undo= BULK_INSERT_SINGLE_UNDO_AND_REPAIR; @@ -2225,7 +2240,7 @@ bool ha_maria::check_and_repair(THD *thd) { /* Remove error about crashed table */ thd->get_stmt_da()->clear_warning_info(thd->query_id); - push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_NOTE, + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_CRASHED_ON_USAGE, "Zerofilling moved table %s", table->s->path.str); sql_print_information("Zerofilling moved table: '%s'", diff --git a/storage/myisam/ftbench/ft-test-run.sh b/storage/myisam/ftbench/ft-test-run.sh index 17b13d73d47..08e03474dac 100755 --- a/storage/myisam/ftbench/ft-test-run.sh +++ b/storage/myisam/ftbench/ft-test-run.sh @@ -2,7 +2,7 @@ # Copyright (c) 2003, 2005, 2006 MySQL AB # Use is subject to license terms - +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; version 2 diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index f21845bae63..2fe519da794 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1084,6 +1084,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) char fixed_name[FN_REFLEN]; MYISAM_SHARE* share = file->s; ha_rows rows= file->state->records; + my_bool locking= 0; DBUG_ENTER("ha_myisam::repair"); param.db_name= table->s->db.str; @@ -1098,12 +1099,18 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) // Release latches since this can take a long time ha_release_temporary_latches(thd); - // Don't lock tables if we have used LOCK TABLE - if (! thd->locked_tables_mode && - mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK)) + /* + Don't lock tables if we have used LOCK TABLE or if we come from + enable_index() + */ + if (!thd->locked_tables_mode && ! (param.testflag & T_NO_LOCKS)) { - mi_check_print_error(¶m,ER(ER_CANT_LOCK),my_errno); - DBUG_RETURN(HA_ADMIN_FAILED); + locking= 1; + if (mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK)) + { + mi_check_print_error(¶m,ER(ER_CANT_LOCK),my_errno); + DBUG_RETURN(HA_ADMIN_FAILED); + } } if (!do_optimize || @@ -1226,7 +1233,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize) update_state_info(¶m, file, 0); } thd_proc_info(thd, old_proc_info); - if (! thd->locked_tables_mode) + if (locking) mi_lock_database(file,F_UNLCK); DBUG_RETURN(error ? HA_ADMIN_FAILED : !optimize_done ? HA_ADMIN_ALREADY_DONE : HA_ADMIN_OK); @@ -1458,8 +1465,16 @@ int ha_myisam::enable_indexes(uint mode) param.op_name= "recreating_index"; param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK | T_CREATE_MISSING_KEYS); + /* + Don't lock and unlock table if it's locked. + Normally table should be locked. This test is mostly for safety. + */ + if (likely(file->lock_type != F_UNLCK)) + param.testflag|= T_NO_LOCKS; + if (file->create_unique_index_by_sort) param.testflag|= T_CREATE_UNIQUE_BY_SORT; + param.myf_rw&= ~MY_WAIT_IF_FULL; param.sort_buffer_length= THDVAR(thd, sort_buffer_size); param.stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method); @@ -1539,7 +1554,7 @@ int ha_myisam::indexes_are_disabled(void) void ha_myisam::start_bulk_insert(ha_rows rows, uint flags) { DBUG_ENTER("ha_myisam::start_bulk_insert"); - THD *thd= current_thd; + THD *thd= table->in_use; ulong size= MY_MIN(thd->variables.read_buff_size, (ulong) (table->s->avg_row_length*rows)); DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu", @@ -1613,7 +1628,7 @@ int ha_myisam::end_bulk_insert() */ if (((err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) && - current_thd->killed) + table->in_use->killed) { delete_all_rows(); /* not crashed, despite being killed during repair */ diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index e66c3b7c639..3c41257bef7 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -17,6 +17,13 @@ IF(NOT LIBJEMALLOC) MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported") ENDIF() +IF (HAVE_WVLA) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-vla") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla") +ENDIF() + ############################################ SET(TOKUDB_VERSION "tokudb-7.5.3") SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump\nusr/share/doc/mariadb-server-10.0/README-TOKUDB\nusr/share/doc/mariadb-server-10.0/README.md" PARENT_SCOPE) @@ -65,18 +72,34 @@ include(CheckCXXCompilerFlag) macro(set_cflags_if_supported) foreach(flag ${ARGN}) - check_c_compiler_flag(${flag} HAVE_C_${flag}) - if (HAVE_C_${flag}) + string(REGEX REPLACE "-" "_" temp_flag ${flag}) + check_c_compiler_flag(${flag} HAVE_C_${temp_flag}) + if (HAVE_C_${temp_flag}) set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}") endif () - check_cxx_compiler_flag(${flag} HAVE_CXX_${flag}) - if (HAVE_CXX_${flag}) + check_cxx_compiler_flag(${flag} HAVE_CXX_${temp_flag}) + if (HAVE_CXX_${temp_flag}) set(CMAKE_CXX_FLAGS "${flag} ${CMAKE_CXX_FLAGS}") endif () endforeach(flag) endmacro(set_cflags_if_supported) +macro(append_cflags_if_supported) + foreach(flag ${ARGN}) + string(REGEX REPLACE "-" "_" temp_flag ${flag}) + check_c_compiler_flag(${flag} HAVE_C_${temp_flag}) + if (HAVE_C_${temp_flag}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif () + check_cxx_compiler_flag(${flag} HAVE_CXX_${temp_flag}) + if (HAVE_CXX_${temp_flag}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") + endif () + endforeach(flag) +endmacro(append_cflags_if_supported) + set_cflags_if_supported(-Wno-missing-field-initializers) +append_cflags_if_supported(-Wno-vla) ADD_SUBDIRECTORY(ft-index) diff --git a/storage/tokudb/README.md b/storage/tokudb/README.md index dc7362a5124..2ab2e21a5a1 100644 --- a/storage/tokudb/README.md +++ b/storage/tokudb/README.md @@ -1,11 +1,10 @@ TokuDB ====== -TokuDB is a high-performance, write optimized, transactional storage engine for MySQL and -MariaDB. For more details, see our [product page][products]. +TokuDB is a high-performance, write optimized, transactional storage engine for MySQL, MariaDB, and Percona Server. +For more details, see our [product page][products]. -This repository contains the MySQL plugin that uses the [TokuFT][tokuft] -core. +This repository contains the MySQL plugin that uses the [TokuFT][tokuft] core. There are also patches to the MySQL and MariaDB kernels, available in our forks of [mysql][mysql] and [mariadb][mariadb]. @@ -15,23 +14,30 @@ forks of [mysql][mysql] and [mariadb][mariadb]. [mysql]: http://github.com/Tokutek/mysql [mariadb]: http://github.com/Tokutek/mariadb - -Building +Download -------- +* [MySQL 5.5 + TokuDB](http://www.tokutek.com/tokudb-for-mysql/download-community/) +* [MariaDB 5.5 + TokuDB](http://www.tokutek.com/tokudb-for-mysql/download-community/) +* [MariaDB 10.0 + TokuDB](https://downloads.mariadb.org/) +* [Percona Server 5.6 + TokuDB](http://www.percona.com/downloads/) + +Build +----- + The `scripts/` directory contains a script that can be used to build a working MySQL or MariaDB with Tokutek patches, and with the TokuDB storage engine, called `make.mysql.bash`. This script will download copies of the needed source code from github and build everything. -To build MySQL 5.5.39 with TokuDB 7.5.2: +To build MySQL 5.5.40 with TokuDB 7.5.3: ```sh -scripts/make.mysql.bash --mysqlbuild=mysql-5.5.39-tokudb-7.5.2-linux-x86_64 +scripts/make.mysql.bash --mysqlbuild=mysql-5.5.40-tokudb-7.5.3-linux-x86_64 ``` -To build MariaDB 5.5.39 with TokuDB 7.5.2: +To build MariaDB 5.5.40 with TokuDB 7.5.3: ```sh -scripts/make.mysql.bash --mysqlbuild=mariadb-5.5.39-tokudb-7.5.2-linux-x86_64 +scripts/make.mysql.bash --mysqlbuild=mariadb-5.5.40-tokudb-7.5.3-linux-x86_64 ``` Before you start, make sure you have a C++11-compatible compiler (GCC >= @@ -54,10 +60,10 @@ scripts/make.mysql.debug.env.bash ``` -Contributing ------------- +Contribute +---------- -Please report bugs in TokuDB here on github. +Please report TokuDB bugs at https://tokutek.atlassian.net/browse/DB. We have two publicly accessible mailing lists: @@ -66,7 +72,7 @@ We have two publicly accessible mailing lists: - tokudb-dev@googlegroups.com is for discussion of the development of TokuDB. -We are also available on IRC on freenode.net, in the #tokutek channel. +We are on IRC on freenode.net, in the #tokutek channel. License @@ -74,7 +80,7 @@ License TokuDB is available under the GPL version 2. See [COPYING][copying] -The TokuKV component of TokuDB is available under the GPL version 2, with +The TokuFT component of TokuDB is available under the GPL version 2, with slight modifications. See [README-TOKUDB][license]. [copying]: http://github.com/Tokutek/tokudb-engine/blob/master/COPYING diff --git a/storage/tokudb/doc2/sysbench.update.ma10.tokudb754.loglog.png b/storage/tokudb/doc2/sysbench.update.ma10.tokudb754.loglog.png Binary files differnew file mode 100644 index 00000000000..99b15ff642f --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.ma10.tokudb754.loglog.png diff --git a/storage/tokudb/doc2/sysbench.update.ma10.tokudb754.png b/storage/tokudb/doc2/sysbench.update.ma10.tokudb754.png Binary files differnew file mode 100644 index 00000000000..7297013b51f --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.ma10.tokudb754.png diff --git a/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.binlog.png b/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.binlog.png Binary files differnew file mode 100644 index 00000000000..510f1811e5a --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.binlog.png diff --git a/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.loglog.png b/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.loglog.png Binary files differnew file mode 100644 index 00000000000..81fecd37684 --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.loglog.png diff --git a/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.png b/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.png Binary files differnew file mode 100644 index 00000000000..e5ed5f90b63 --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.ma55.tokudb753.png diff --git a/storage/tokudb/doc2/sysbench.update.my55.tokudb753.loglog.png b/storage/tokudb/doc2/sysbench.update.my55.tokudb753.loglog.png Binary files differnew file mode 100644 index 00000000000..1fe55b07b19 --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.my55.tokudb753.loglog.png diff --git a/storage/tokudb/doc2/sysbench.update.ps56.tokudb754.loglog.png b/storage/tokudb/doc2/sysbench.update.ps56.tokudb754.loglog.png Binary files differnew file mode 100644 index 00000000000..52985276249 --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.ps56.tokudb754.loglog.png diff --git a/storage/tokudb/doc2/sysbench.update.ps56.tokudb754.png b/storage/tokudb/doc2/sysbench.update.ps56.tokudb754.png Binary files differnew file mode 100644 index 00000000000..39b1c591730 --- /dev/null +++ b/storage/tokudb/doc2/sysbench.update.ps56.tokudb754.png diff --git a/storage/tokudb/ft-index/buildheader/make_tdb.cc b/storage/tokudb/ft-index/buildheader/make_tdb.cc index 9890b8ed34b..88f8882df78 100644 --- a/storage/tokudb/ft-index/buildheader/make_tdb.cc +++ b/storage/tokudb/ft-index/buildheader/make_tdb.cc @@ -585,6 +585,7 @@ static void print_db_txn_struct (void) { "uint64_t (*id64) (DB_TXN*)", "void (*set_client_id)(DB_TXN *, uint64_t client_id)", "uint64_t (*get_client_id)(DB_TXN *)", + "bool (*is_prepared)(DB_TXN *)", NULL}; sort_and_dump_fields("db_txn", false, extra); } diff --git a/storage/tokudb/ft-index/ft/ft-internal.h b/storage/tokudb/ft-index/ft/ft-internal.h index 3cd39705571..88fc5dca686 100644 --- a/storage/tokudb/ft-index/ft/ft-internal.h +++ b/storage/tokudb/ft-index/ft/ft-internal.h @@ -616,6 +616,7 @@ typedef enum { FT_PRO_RIGHTMOST_LEAF_SHORTCUT_SUCCESS, FT_PRO_RIGHTMOST_LEAF_SHORTCUT_FAIL_POS, FT_PRO_RIGHTMOST_LEAF_SHORTCUT_FAIL_REACTIVE, + FT_CURSOR_SKIP_DELETED_LEAF_ENTRY, // how many deleted leaf entries were skipped by a cursor FT_STATUS_NUM_ROWS } ft_status_entry; diff --git a/storage/tokudb/ft-index/ft/ft-ops.cc b/storage/tokudb/ft-index/ft/ft-ops.cc index 481d80fdbe4..34c9c46f1c6 100644 --- a/storage/tokudb/ft-index/ft/ft-ops.cc +++ b/storage/tokudb/ft-index/ft/ft-ops.cc @@ -377,6 +377,8 @@ status_init(void) STATUS_INIT(FT_PRO_RIGHTMOST_LEAF_SHORTCUT_FAIL_POS, nullptr, PARCOUNT, "promotion: tried the rightmost leaf shorcut but failed (out-of-bounds)", TOKU_ENGINE_STATUS); STATUS_INIT(FT_PRO_RIGHTMOST_LEAF_SHORTCUT_FAIL_REACTIVE,nullptr, PARCOUNT, "promotion: tried the rightmost leaf shorcut but failed (child reactive)", TOKU_ENGINE_STATUS); + STATUS_INIT(FT_CURSOR_SKIP_DELETED_LEAF_ENTRY, CURSOR_SKIP_DELETED_LEAF_ENTRY, PARCOUNT, "cursor skipped deleted leaf entries", TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS); + ft_status.initialized = true; } static void status_destroy(void) { @@ -3378,13 +3380,13 @@ ok: ; if (le_val_is_del(le, ftcursor->is_snapshot_read, ftcursor->ttxn)) { // Provisionally deleted stuff is gone. // So we need to scan in the direction to see if we can find something. - // Every 100 deleted leaf entries check if the leaf's key is within the search bounds. - for (uint n_deleted = 1; ; n_deleted++) { + // Every 64 deleted leaf entries check if the leaf's key is within the search bounds. + for (uint64_t n_deleted = 1; ; n_deleted++) { switch (search->direction) { case FT_SEARCH_LEFT: idx++; - if (idx >= bn->data_buffer.num_klpairs() || - ((n_deleted % 64) == 0 && !search_continue(search, key, keylen))) { + if (idx >= bn->data_buffer.num_klpairs() || ((n_deleted % 64) == 0 && !search_continue(search, key, keylen))) { + STATUS_INC(FT_CURSOR_SKIP_DELETED_LEAF_ENTRY, n_deleted); if (ftcursor->interrupt_cb && ftcursor->interrupt_cb(ftcursor->interrupt_cb_extra)) { return TOKUDB_INTERRUPTED; } @@ -3393,6 +3395,7 @@ ok: ; break; case FT_SEARCH_RIGHT: if (idx == 0) { + STATUS_INC(FT_CURSOR_SKIP_DELETED_LEAF_ENTRY, n_deleted); if (ftcursor->interrupt_cb && ftcursor->interrupt_cb(ftcursor->interrupt_cb_extra)) { return TOKUDB_INTERRUPTED; } @@ -3406,6 +3409,7 @@ ok: ; r = bn->data_buffer.fetch_klpair(idx, &le, &keylen, &key); assert_zero(r); // we just validated the index if (!le_val_is_del(le, ftcursor->is_snapshot_read, ftcursor->ttxn)) { + STATUS_INC(FT_CURSOR_SKIP_DELETED_LEAF_ENTRY, n_deleted); goto got_a_good_value; } } diff --git a/storage/tokudb/ft-index/locktree/lock_request.cc b/storage/tokudb/ft-index/locktree/lock_request.cc index 97fa780bb04..18f6051afdf 100644 --- a/storage/tokudb/ft-index/locktree/lock_request.cc +++ b/storage/tokudb/ft-index/locktree/lock_request.cc @@ -113,12 +113,19 @@ void lock_request::create(void) { m_complete_r = 0; m_state = state::UNINITIALIZED; + m_info = nullptr; toku_cond_init(&m_wait_cond, nullptr); + + m_start_test_callback = nullptr; + m_retry_test_callback = nullptr; } // destroy a lock request. void lock_request::destroy(void) { + invariant(m_state != state::PENDING); + invariant(m_state != state::DESTROYED); + m_state = state::DESTROYED; toku_destroy_dbt(&m_left_key_copy); toku_destroy_dbt(&m_right_key_copy); toku_cond_destroy(&m_wait_cond); @@ -135,7 +142,7 @@ void lock_request::set(locktree *lt, TXNID txnid, const DBT *left_key, const DBT toku_destroy_dbt(&m_right_key_copy); m_type = lock_type; m_state = state::INITIALIZED; - m_info = lt->get_lock_request_info(); + m_info = lt ? lt->get_lock_request_info() : nullptr; m_big_txn = big_txn; } @@ -223,15 +230,18 @@ int lock_request::start(void) { insert_into_lock_requests(); if (deadlock_exists(conflicts)) { remove_from_lock_requests(); - complete(DB_LOCK_DEADLOCK); + r = DB_LOCK_DEADLOCK; } toku_mutex_unlock(&m_info->mutex); - } else { + if (m_start_test_callback) m_start_test_callback(); // test callback + } + + if (r != DB_LOCK_NOTGRANTED) { complete(r); } conflicts.destroy(); - return m_state == state::COMPLETE ? m_complete_r : r; + return r; } // sleep on the lock request until it becomes resolved or the wait time has elapsed. @@ -292,8 +302,8 @@ int lock_request::wait(uint64_t wait_time_ms, uint64_t killed_time_ms, int (*kil // complete this lock request with the given return value void lock_request::complete(int complete_r) { - m_state = state::COMPLETE; m_complete_r = complete_r; + m_state = state::COMPLETE; } const DBT *lock_request::get_left_key(void) const { @@ -331,6 +341,7 @@ int lock_request::retry(void) { if (r == 0) { remove_from_lock_requests(); complete(r); + if (m_retry_test_callback) m_retry_test_callback(); // test callback toku_cond_broadcast(&m_wait_cond); } @@ -416,7 +427,8 @@ void lock_request::remove_from_lock_requests(void) { uint32_t idx; lock_request *request; int r = m_info->pending_lock_requests.find_zero<TXNID, find_by_txnid>(m_txnid, &request, &idx); - invariant_zero(r && request == this); + invariant_zero(r); + invariant(request == this); r = m_info->pending_lock_requests.delete_at(idx); invariant_zero(r); } @@ -432,4 +444,12 @@ int lock_request::find_by_txnid(lock_request * const &request, const TXNID &txni } } +void lock_request::set_start_test_callback(void (*f)(void)) { + m_start_test_callback = f; +} + +void lock_request::set_retry_test_callback(void (*f)(void)) { + m_retry_test_callback = f; +} + } /* namespace toku */ diff --git a/storage/tokudb/ft-index/locktree/lock_request.h b/storage/tokudb/ft-index/locktree/lock_request.h index d1a4c2822e0..c504961fcc0 100644 --- a/storage/tokudb/ft-index/locktree/lock_request.h +++ b/storage/tokudb/ft-index/locktree/lock_request.h @@ -164,6 +164,8 @@ public: // The rest remain pending. static void retry_all_lock_requests(locktree *lt); + void set_start_test_callback(void (*f)(void)); + void set_retry_test_callback(void (*f)(void)); private: enum state { @@ -171,6 +173,7 @@ private: INITIALIZED, PENDING, COMPLETE, + DESTROYED, }; // The keys for a lock request are stored "unowned" in m_left_key @@ -236,6 +239,9 @@ private: static int find_by_txnid(lock_request * const &request, const TXNID &txnid); + void (*m_start_test_callback)(void); + void (*m_retry_test_callback)(void); + friend class lock_request_unit_test; }; ENSURE_POD(lock_request); diff --git a/storage/tokudb/ft-index/locktree/locktree.cc b/storage/tokudb/ft-index/locktree/locktree.cc index 27e528db8e8..fc2470e98bd 100644 --- a/storage/tokudb/ft-index/locktree/locktree.cc +++ b/storage/tokudb/ft-index/locktree/locktree.cc @@ -152,6 +152,7 @@ void locktree::create(locktree_manager *mgr, DICTIONARY_ID dict_id, const compar void locktree::destroy(void) { invariant(m_reference_count == 0); + invariant(m_lock_request_info.pending_lock_requests.size() == 0); m_cmp.destroy(); m_rangetree->destroy(); toku_free(m_rangetree); diff --git a/storage/tokudb/ft-index/locktree/tests/lock_request_start_retry_race.cc b/storage/tokudb/ft-index/locktree/tests/lock_request_start_retry_race.cc new file mode 100644 index 00000000000..86ef2dd9cc5 --- /dev/null +++ b/storage/tokudb/ft-index/locktree/tests/lock_request_start_retry_race.cc @@ -0,0 +1,193 @@ +/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: +#ident "$Id$" +/* +COPYING CONDITIONS NOTICE: + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation, and provided that the + following conditions are met: + + * Redistributions of source code must retain this COPYING + CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the + DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the + PATENT MARKING NOTICE (below), and the PATENT RIGHTS + GRANT (below). + + * Redistributions in binary form must reproduce this COPYING + CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the + DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the + PATENT MARKING NOTICE (below), and the PATENT RIGHTS + GRANT (below) in the documentation and/or other materials + provided with the distribution. + + 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. + +COPYRIGHT NOTICE: + + TokuFT, Tokutek Fractal Tree Indexing Library. + Copyright (C) 2007-2013 Tokutek, Inc. + +DISCLAIMER: + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + +UNIVERSITY PATENT NOTICE: + + The technology is licensed by the Massachusetts Institute of + Technology, Rutgers State University of New Jersey, and the Research + Foundation of State University of New York at Stony Brook under + United States of America Serial No. 11/760379 and to the patents + and/or patent applications resulting from it. + +PATENT MARKING NOTICE: + + This software is covered by US Patent No. 8,185,551. + This software is covered by US Patent No. 8,489,638. + +PATENT RIGHTS GRANT: + + "THIS IMPLEMENTATION" means the copyrightable works distributed by + Tokutek as part of the Fractal Tree project. + + "PATENT CLAIMS" means the claims of patents that are owned or + licensable by Tokutek, both currently or in the future; and that in + the absence of this license would be infringed by THIS + IMPLEMENTATION or by using or running THIS IMPLEMENTATION. + + "PATENT CHALLENGE" shall mean a challenge to the validity, + patentability, enforceability and/or non-infringement of any of the + PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS. + + Tokutek hereby grants to you, for the term and geographical scope of + the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free, + irrevocable (except as stated in this section) patent license to + make, have made, use, offer to sell, sell, import, transfer, and + otherwise run, modify, and propagate the contents of THIS + IMPLEMENTATION, where such license applies only to the PATENT + CLAIMS. This grant does not include claims that would be infringed + only as a consequence of further modifications of THIS + IMPLEMENTATION. If you or your agent or licensee institute or order + or agree to the institution of patent litigation against any entity + (including a cross-claim or counterclaim in a lawsuit) alleging that + THIS IMPLEMENTATION constitutes direct or contributory patent + infringement, or inducement of patent infringement, then any rights + granted to you under this License shall terminate as of the date + such litigation is filed. If you or your agent or exclusive + licensee institute or order or agree to the institution of a PATENT + CHALLENGE, then Tokutek may terminate any rights granted to you + under this License. +*/ + +#ident "Copyright (c) 2014 Tokutek Inc. All rights reserved." +#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." + +#include <iostream> +#include "test.h" +#include "locktree.h" +#include "lock_request.h" + +// Test FT-633, the data race on the lock request between ::start and ::retry +// This test is non-deterministic. It uses sleeps at 2 critical places to +// expose the data race on the lock requests state. + +namespace toku { + +struct locker_arg { + locktree *_lt; + TXNID _id; + const DBT *_key; + + locker_arg(locktree *lt, TXNID id, const DBT *key) : _lt(lt), _id(id), _key(key) { + } +}; + +static void locker_callback(void) { + usleep(10000); +} + +static void run_locker(locktree *lt, TXNID txnid, const DBT *key) { + int i; + for (i = 0; i < 1000; i++) { + + lock_request request; + request.create(); + + request.set(lt, txnid, key, key, lock_request::type::WRITE, false); + + // set the test callbacks + request.set_start_test_callback(locker_callback); + request.set_retry_test_callback(locker_callback); + + // try to acquire the lock + int r = request.start(); + if (r == DB_LOCK_NOTGRANTED) { + // wait for the lock to be granted + r = request.wait(10 * 1000); + } + + if (r == 0) { + // release the lock + range_buffer buffer; + buffer.create(); + buffer.append(key, key); + lt->release_locks(txnid, &buffer); + buffer.destroy(); + + // retry pending lock requests + lock_request::retry_all_lock_requests(lt); + } + + request.destroy(); + memset(&request, 0xab, sizeof request); + + toku_pthread_yield(); + if ((i % 10) == 0) + std::cout << toku_pthread_self() << " " << i << std::endl; + } +} + +static void *locker(void *v_arg) { + locker_arg *arg = static_cast<locker_arg *>(v_arg); + run_locker(arg->_lt, arg->_id, arg->_key); + return arg; +} + +} /* namespace toku */ + +int main(void) { + int r; + + toku::locktree lt; + DICTIONARY_ID dict_id = { 1 }; + lt.create(nullptr, dict_id, toku::dbt_comparator); + + const DBT *one = toku::get_dbt(1); + + const int n_workers = 2; + toku_pthread_t ids[n_workers]; + for (int i = 0; i < n_workers; i++) { + toku::locker_arg *arg = new toku::locker_arg(<, i, one); + r = toku_pthread_create(&ids[i], nullptr, toku::locker, arg); + assert_zero(r); + } + for (int i = 0; i < n_workers; i++) { + void *ret; + r = toku_pthread_join(ids[i], &ret); + assert_zero(r); + toku::locker_arg *arg = static_cast<toku::locker_arg *>(ret); + delete arg; + } + + lt.release_reference(); + lt.destroy(); + return 0; +} + diff --git a/storage/tokudb/ft-index/src/ydb_row_lock.cc b/storage/tokudb/ft-index/src/ydb_row_lock.cc index 5ca853d92d9..4dd527220ec 100644 --- a/storage/tokudb/ft-index/src/ydb_row_lock.cc +++ b/storage/tokudb/ft-index/src/ydb_row_lock.cc @@ -307,6 +307,7 @@ void toku_db_grab_write_lock (DB *db, DBT *key, TOKUTXN tokutxn) { int r = request.start(); invariant_zero(r); db_txn_note_row_lock(db, txn_anc, key, key); + request.destroy(); } void toku_db_release_lt_key_ranges(DB_TXN *txn, txn_lt_key_ranges *ranges) { diff --git a/storage/tokudb/ft-index/src/ydb_txn.cc b/storage/tokudb/ft-index/src/ydb_txn.cc index dd428c4d502..ce06e78b23f 100644 --- a/storage/tokudb/ft-index/src/ydb_txn.cc +++ b/storage/tokudb/ft-index/src/ydb_txn.cc @@ -422,6 +422,11 @@ static int toku_txn_discard(DB_TXN *txn, uint32_t flags) { return 0; } +static bool toku_txn_is_prepared(DB_TXN *txn) { + TOKUTXN ttxn = db_txn_struct_i(txn)->tokutxn; + return toku_txn_get_state(ttxn) == TOKUTXN_PREPARING; +} + static inline void txn_func_init(DB_TXN *txn) { #define STXN(name) txn->name = locked_txn_ ## name STXN(abort); @@ -438,6 +443,7 @@ static inline void txn_func_init(DB_TXN *txn) { SUTXN(discard); #undef SUTXN txn->id64 = toku_txn_id64; + txn->is_prepared = toku_txn_is_prepared; } // diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 28c5a77ce74..f68b50b9fdc 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -1742,7 +1742,7 @@ int ha_tokudb::initialize_share(const char* name, int mode) { // initialize cardinality info from the status dictionary share->n_rec_per_key = tokudb::compute_total_key_parts(table_share); - share->rec_per_key = (uint64_t *) tokudb_my_realloc(share->rec_per_key, share->n_rec_per_key * sizeof (uint64_t), MYF(MY_FAE)); + share->rec_per_key = (uint64_t *) tokudb_my_realloc(share->rec_per_key, share->n_rec_per_key * sizeof (uint64_t), MYF(MY_FAE + MY_ALLOW_ZERO_PTR)); error = tokudb::get_card_from_status(share->status_block, txn, share->n_rec_per_key, share->rec_per_key); if (error) { for (uint i = 0; i < share->n_rec_per_key; i++) @@ -5992,6 +5992,9 @@ int ha_tokudb::extra(enum ha_extra_function operation) { case HA_EXTRA_NO_IGNORE_NO_KEY: using_ignore_no_key = false; break; + case HA_EXTRA_NOT_USED: + case HA_EXTRA_PREPARE_FOR_RENAME: + break; // must do nothing and return 0 default: break; } @@ -6237,7 +6240,11 @@ int ha_tokudb::start_stmt(THD * thd, thr_lock_type lock_type) { int error = 0; tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, tokudb_hton); - DBUG_ASSERT(trx); + if (!trx) { + error = create_tokudb_trx_data_instance(&trx); + if (error) { goto cleanup; } + thd_set_ha_data(thd, tokudb_hton, trx); + } /* note that trx->stmt may have been already initialized as start_stmt() diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index 10be517f7ea..bbc84e050b8 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -834,7 +834,7 @@ static inline bool key_is_clustering(const KEY *key) { #else static inline bool key_is_clustering(const KEY *key) { - return key->option_struct && key->option_struct->clustering; + return key->flags & HA_CLUSTERING; } #endif diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc index 1a03dc815a1..cae50446fa0 100644 --- a/storage/tokudb/ha_tokudb_alter_56.cc +++ b/storage/tokudb/ha_tokudb_alter_56.cc @@ -765,7 +765,9 @@ bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_i #else THD::killed_state saved_killed_state = thd->killed; thd->killed = THD::NOT_KILLED; - for (volatile uint i = 0; wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED); i++) { + // MySQL does not handle HA_EXTRA_NOT_USED so we use HA_EXTRA_PREPARE_FOR_RENAME since it is passed through + // the partition storage engine and is treated as a NOP by tokudb + for (volatile uint i = 0; wait_while_table_is_used(thd, table, HA_EXTRA_PREPARE_FOR_RENAME); i++) { if (thd->killed != THD::NOT_KILLED) thd->killed = THD::NOT_KILLED; sleep(1); diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc index 37742227de2..99f9cc56037 100644 --- a/storage/tokudb/hatoku_hton.cc +++ b/storage/tokudb/hatoku_hton.cc @@ -415,10 +415,10 @@ static int tokudb_init_func(void *p) { tokudb_hton->commit = tokudb_commit; tokudb_hton->rollback = tokudb_rollback; #if TOKU_INCLUDE_XA - tokudb_hton->prepare=tokudb_xa_prepare; - tokudb_hton->recover=tokudb_xa_recover; - tokudb_hton->commit_by_xid=tokudb_commit_by_xid; - tokudb_hton->rollback_by_xid=tokudb_rollback_by_xid; + tokudb_hton->prepare = tokudb_xa_prepare; + tokudb_hton->recover = tokudb_xa_recover; + tokudb_hton->commit_by_xid = tokudb_commit_by_xid; + tokudb_hton->rollback_by_xid = tokudb_rollback_by_xid; #endif tokudb_hton->table_options= tokudb_table_options; @@ -775,16 +775,35 @@ static void tokudb_cleanup_handlers(tokudb_trx_data *trx, DB_TXN *txn) { } } +#if MYSQL_VERSION_ID >= 50600 +extern "C" enum durability_properties thd_get_durability_property(const MYSQL_THD thd); +#endif + +// Determine if an fsync is used when a transaction is committed. +static bool tokudb_fsync_on_commit(THD *thd, tokudb_trx_data *trx, DB_TXN *txn) { +#if MYSQL_VERSION_ID >= 50600 + // Check the client durability property which is set during 2PC + if (thd_get_durability_property(thd) == HA_IGNORE_DURABILITY) + return false; +#endif +#if defined(MARIADB_BASE_VERSION) + // Check is the txn is prepared and the binlog is open + if (txn->is_prepared(txn) && mysql_bin_log.is_open()) + return false; +#endif + return THDVAR(thd, commit_sync) != 0; +} + static int tokudb_commit(handlerton * hton, THD * thd, bool all) { TOKUDB_DBUG_ENTER(""); DBUG_PRINT("trans", ("ending transaction %s", all ? "all" : "stmt")); - uint32_t syncflag = THDVAR(thd, commit_sync) ? 0 : DB_TXN_NOSYNC; tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton); DB_TXN **txn = all ? &trx->all : &trx->stmt; DB_TXN *this_txn = *txn; if (this_txn) { + uint32_t syncflag = tokudb_fsync_on_commit(thd, trx, this_txn) ? 0 : DB_TXN_NOSYNC; if (tokudb_debug & TOKUDB_DEBUG_TXN) { - TOKUDB_TRACE("commit trx %u txn %p", all, this_txn); + TOKUDB_TRACE("commit trx %u txn %p syncflag %u", all, this_txn, syncflag); } // test hook to induce a crash on a debug build DBUG_EXECUTE_IF("tokudb_crash_commit_before", DBUG_SUICIDE();); @@ -838,7 +857,7 @@ static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { TOKUDB_DBUG_ENTER(""); int r = 0; - /* if support_xa is disable, just return */ + // if tokudb_support_xa is disable, just return if (!THDVAR(thd, support_xa)) { TOKUDB_DBUG_RETURN(r); } @@ -1598,12 +1617,12 @@ static ST_FIELD_INFO tokudb_fractal_tree_info_field_info[] = { static int tokudb_report_fractal_tree_info_for_db(const DBT *dname, const DBT *iname, TABLE *table, THD *thd) { int error; - DB *db; uint64_t bt_num_blocks_allocated; uint64_t bt_num_blocks_in_use; uint64_t bt_size_allocated; uint64_t bt_size_in_use; + DB *db = NULL; error = db_create(&db, db_env, 0); if (error) { goto exit; @@ -1615,12 +1634,6 @@ static int tokudb_report_fractal_tree_info_for_db(const DBT *dname, const DBT *i error = db->get_fractal_tree_info64(db, &bt_num_blocks_allocated, &bt_num_blocks_in_use, &bt_size_allocated, &bt_size_in_use); - { - int close_error = db->close(db, 0); - if (!error) { - error = close_error; - } - } if (error) { goto exit; } @@ -1652,6 +1665,11 @@ static int tokudb_report_fractal_tree_info_for_db(const DBT *dname, const DBT *i error = schema_table_store_record(thd, table); exit: + if (db) { + int close_error = db->close(db, 0); + if (error == 0) + error = close_error; + } return error; } diff --git a/storage/tokudb/mysql-test/tokudb/r/change_column_varchar.result b/storage/tokudb/mysql-test/tokudb/r/change_column_varchar.result index 7f3d4265662..5018e2db278 100644 --- a/storage/tokudb/mysql-test/tokudb/r/change_column_varchar.result +++ b/storage/tokudb/mysql-test/tokudb/r/change_column_varchar.result @@ -6,6 +6,7 @@ Table Create Table t CREATE TABLE `t` ( `a` varchar(1) DEFAULT NULL ) ENGINE=TokuDB DEFAULT CHARSET=latin1 `compression`='tokudb_zlib' +INSERT INTO t VALUES (null); ALTER TABLE t CHANGE COLUMN a a VARCHAR(2); ALTER TABLE t CHANGE COLUMN a a VARCHAR(2); ALTER TABLE t CHANGE COLUMN a a VARCHAR(3); diff --git a/storage/tokudb/mysql-test/tokudb/r/information-schema-global-status.result b/storage/tokudb/mysql-test/tokudb/r/information-schema-global-status.result index 369c14fe4fe..7d0e83260e1 100644 --- a/storage/tokudb/mysql-test/tokudb/r/information-schema-global-status.result +++ b/storage/tokudb/mysql-test/tokudb/r/information-schema-global-status.result @@ -65,6 +65,7 @@ TOKUDB_CHECKPOINT_LONG_BEGIN_COUNT TOKUDB_CHECKPOINT_LONG_BEGIN_TIME TOKUDB_CHECKPOINT_PERIOD TOKUDB_CHECKPOINT_TAKEN +TOKUDB_CURSOR_SKIP_DELETED_LEAF_ENTRY TOKUDB_DB_CLOSES TOKUDB_DB_OPENS TOKUDB_DB_OPEN_CURRENT diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_create_select.test b/storage/tokudb/mysql-test/tokudb/t/bf_create_select.test index 20455da874f..8c457b75f27 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_create_select.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_create_select.test @@ -65,8 +65,8 @@ while ($i < $maxq) { let $time_elapsed_off = `select unix_timestamp() - $s`; -# Check that the time with bulk fetch off is at least twice that whith bulk fetch on -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# Check that the time with bulk fetch off is greater that with bulk fetch on +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo index $verdict $time_elapsed_on $time_elapsed_off; } if (!$verdict) { echo index $time_elapsed_on $time_elapsed_off; } @@ -94,8 +94,8 @@ while ($i < $maxq) { let $time_elapsed_off = `select unix_timestamp() - $s`; -# Check that the time with bulk fetch off is at least twice that whith bulk fetch on -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# Check that the time with bulk fetch off is greater that with bulk fetch on +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_on $time_elapsed_off; } if (!$verdict) { echo range $time_elapsed_on $time_elapsed_off; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_create_select_hash_part.test b/storage/tokudb/mysql-test/tokudb/t/bf_create_select_hash_part.test index 4df0a138be8..34995b4ba2f 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_create_select_hash_part.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_create_select_hash_part.test @@ -65,8 +65,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 1.5 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 1.5 * $time_elapsed_on`; +# check that bulk fetch on is greater than bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; } @@ -93,8 +93,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 1.5 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 1.5 * $time_elapsed_on`; +# check that bulk fetch on is greater than bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_create_select_range_part.test b/storage/tokudb/mysql-test/tokudb/t/bf_create_select_range_part.test index b66b2c42808..a53249893f4 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_create_select_range_part.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_create_select_range_part.test @@ -72,8 +72,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 2 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# check that bulk fetch on is greater than bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; } @@ -100,8 +100,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 2 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# check that bulk fetch on is greater than bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_create_temp_select.test b/storage/tokudb/mysql-test/tokudb/t/bf_create_temp_select.test index 52cb886a410..4f8211a51d9 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_create_temp_select.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_create_temp_select.test @@ -65,8 +65,8 @@ while ($i < $maxq) { let $time_elapsed_off = `select unix_timestamp() - $s`; -# Check that the time with bulk fetch off is at least twice that whith bulk fetch on -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# Check that the time with bulk fetch off is greater that with bulk fetch on +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo index $verdict $time_elapsed_on $time_elapsed_off; } if (!$verdict) { echo index $time_elapsed_on $time_elapsed_off; } @@ -94,8 +94,8 @@ while ($i < $maxq) { let $time_elapsed_off = `select unix_timestamp() - $s`; -# Check that the time with bulk fetch off is at least twice that whith bulk fetch on -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# Check that the time with bulk fetch off is greater than with bulk fetch on +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_on $time_elapsed_off; } if (!$verdict) { echo range $time_elapsed_on $time_elapsed_off; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_delete.test b/storage/tokudb/mysql-test/tokudb/t/bf_delete.test index f98e87f1ec1..a55d78784cc 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_delete.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_delete.test @@ -1,5 +1,4 @@ -# Verify that index scans for delete statements use bulk fetch and are -# at least twice as fast +# Verify that index scans for delete statements use bulk fetch are faster than when not using bulk fetch source include/have_tokudb.inc; source include/big_test.inc; @@ -62,8 +61,8 @@ while ($i < $maxq) { } let $time_elapsed_bf_off = `select unix_timestamp() - $s`; -# verify that a delete scan with bulk fetch ON is at least 2 times faster than with bulk fetch OFF -let $verdict = `select $time_elapsed_bf_on > 0 && $time_elapsed_bf_off >= 2 * $time_elapsed_bf_on`; +# verify that a delete scan with bulk fetch ON is greater than with bulk fetch OFF +let $verdict = `select $time_elapsed_bf_on > 0 && $time_elapsed_bf_off > $time_elapsed_bf_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_bf_on $time_elapsed_bf_off; } if (!$verdict) { echo range $time_elapsed_bf_on $time_elapsed_bf_off; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_insert_select.test b/storage/tokudb/mysql-test/tokudb/t/bf_insert_select.test index 5fcb8fa58b5..8d96c26bc29 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_insert_select.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_insert_select.test @@ -66,8 +66,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 2 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# check that the time with bulk fetch on is greater than with bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; } @@ -92,7 +92,7 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_insert_select_dup_key.test b/storage/tokudb/mysql-test/tokudb/t/bf_insert_select_dup_key.test index 51c6d66d706..1b015b2c272 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_insert_select_dup_key.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_insert_select_dup_key.test @@ -70,8 +70,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 2 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# check that bulk fetch on is greater than with bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; } @@ -96,8 +96,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 2 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# check that bulk fetch on is greater than bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_replace_select.test b/storage/tokudb/mysql-test/tokudb/t/bf_replace_select.test index 1ca754454eb..72cda349f80 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_replace_select.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_replace_select.test @@ -66,8 +66,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -# check that bulk fetch on is at least 2 times faster than bulk fetch off -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# check that the time with bulk fetch on is greater than with bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; } @@ -92,7 +92,8 @@ while ($i < $maxq) { } let $time_elapsed_off = `select unix_timestamp() - $s`; -let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`; +# check that the time with bulk fetch on is greater than with bulk fetch off +let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off > $time_elapsed_on`; echo $verdict; if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; } if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_select_hash_part.test b/storage/tokudb/mysql-test/tokudb/t/bf_select_hash_part.test index 2271a2086be..46986278743 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_select_hash_part.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_select_hash_part.test @@ -65,8 +65,8 @@ let $time_bf_off = `select unix_timestamp() - $s`; if ($debug) { echo index scans took $time_bf_off.; } -# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on -let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`; +# check that the scan time with bulk fetch off is greater than with bulk fetch on +let $verdict = `select $time_bf_on > 0 && $time_bf_off > $time_bf_on`; echo $verdict; if ($debug) { echo index $verdict $time_bf_on $time_bf_off; } if (!$verdict) { echo index $time_bf_on $time_bf_off; } @@ -93,8 +93,8 @@ let $time_bf_off = `select unix_timestamp() - $s`; if ($debug) { echo range scans took $time_bf_off.; } -# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on -let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`; +# check that the scan time with bulk fetch off is greater than with bulk fetch on +let $verdict = `select $time_bf_on > 0 && $time_bf_off > $time_bf_on`; echo $verdict; if ($debug) { echo range $verdict $time_bf_on $time_bf_off; } if (!$verdict) { echo range $time_bf_on $time_bf_off; } diff --git a/storage/tokudb/mysql-test/tokudb/t/bf_select_range_part.test b/storage/tokudb/mysql-test/tokudb/t/bf_select_range_part.test index 9dcb044d4d4..7e608777798 100644 --- a/storage/tokudb/mysql-test/tokudb/t/bf_select_range_part.test +++ b/storage/tokudb/mysql-test/tokudb/t/bf_select_range_part.test @@ -70,8 +70,8 @@ while ($i < $maxq) { } let $time_bf_off = `select unix_timestamp() - $s`; -# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on -let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`; +# check that the scan time with bulk fetch off is greater than with bulk fetch on +let $verdict = `select $time_bf_on > 0 && $time_bf_off > $time_bf_on`; echo $verdict; if ($debug) { echo index $verdict $time_bf_on $time_bf_off; } if (!$verdict) { echo index scan $time_bf_on $time_bf_off; } @@ -94,8 +94,8 @@ while ($i < $maxq) { } let $time_bf_off = `select unix_timestamp() - $s`; -# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on -let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`; +# check that the scan time with bulk fetch off is greater than with bulk fetch on +let $verdict = `select $time_bf_on > 0 && $time_bf_off > $time_bf_on`; echo $verdict; if ($debug) { echo range $verdict $time_bf_on $time_bf_off; } if (!$verdict) { echo range $time_bf_on $time_bf_off; } diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_varchar.test b/storage/tokudb/mysql-test/tokudb/t/change_column_varchar.test index f2b4e3cbf78..6543952ad29 100644 --- a/storage/tokudb/mysql-test/tokudb/t/change_column_varchar.test +++ b/storage/tokudb/mysql-test/tokudb/t/change_column_varchar.test @@ -9,6 +9,7 @@ SET SESSION TOKUDB_DISABLE_SLOW_ALTER=ON; CREATE TABLE t (a VARCHAR(1)) ENGINE=TokuDB; SHOW CREATE TABLE t; +INSERT INTO t VALUES (null); # 1->1 let $i=1 diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db762.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db762.result new file mode 100644 index 00000000000..159957dba3e --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db762.result @@ -0,0 +1,7 @@ +drop table if exists t1,t2; +create table t1 (x int) engine=innodb; +lock table t1 read; +create temporary table t2 (x int) engine=tokudb; +insert into t2 values (1); +unlock tables; +drop table t1, t2; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db766.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db766.result new file mode 100644 index 00000000000..e109b0a7f15 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db766.result @@ -0,0 +1,7 @@ +set default_storage_engine=TokuDB; +drop table if exists t1; +CREATE TABLE t1(c1 INT,c2 CHAR)PARTITION BY KEY(c1) PARTITIONS 5; +insert INTO t1 values(1,1),(2,1),(2,2),(2,3); +ALTER TABLE t1 ADD UNIQUE INDEX i1(c1); +ERROR 23000: Can't write; duplicate key in table 't1' +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db768.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db768.result new file mode 100644 index 00000000000..f302114b45c --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db768.result @@ -0,0 +1,10 @@ +set default_storage_engine='tokudb'; +drop table if exists t; +create table t (id int primary key); +set autocommit=OFF; +lock tables t write; +optimize table t; +Table Op Msg_type Msg_text +test.t optimize status OK +unlock tables; +drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db771.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db771.result new file mode 100644 index 00000000000..3fc012a732f --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db771.result @@ -0,0 +1,11 @@ +set default_storage_engine=tokudb; +drop table if exists t1; +CREATE TABLE t1 (a int key, b varchar(32), c varchar(32)); +REPLACE t1 SET a = 4; +ALTER TABLE t1 CHANGE COLUMN c c VARCHAR(500); +update t1 set b='hi'; +update t1 set c='there'; +select * from t1; +a b c +4 hi there +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/5585-master.opt b/storage/tokudb/mysql-test/tokudb_bugs/t/5585-master.opt new file mode 100644 index 00000000000..017432e797d --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/5585-master.opt @@ -0,0 +1 @@ +--tokudb-cache-size=1000000000 --innodb-buffer-pool-size=1000000000 diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db762.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db762.test new file mode 100644 index 00000000000..4428e9df8ec --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db762.test @@ -0,0 +1,13 @@ +# test for DB-762 and DB-767 +source include/have_tokudb.inc; +source include/have_innodb.inc; +disable_warnings; +drop table if exists t1,t2; +enable_warnings; +create table t1 (x int) engine=innodb; +lock table t1 read; +create temporary table t2 (x int) engine=tokudb; +insert into t2 values (1); +unlock tables; +drop table t1, t2; + diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db766.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db766.test new file mode 100644 index 00000000000..3aad3404296 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db766.test @@ -0,0 +1,12 @@ +# reproducer for DB-766 +source include/have_tokudb.inc; +source include/have_partition.inc; +set default_storage_engine=TokuDB; +disable_warnings; +drop table if exists t1; +enable_warnings; +CREATE TABLE t1(c1 INT,c2 CHAR)PARTITION BY KEY(c1) PARTITIONS 5; +insert INTO t1 values(1,1),(2,1),(2,2),(2,3); +--error ER_DUP_KEY +ALTER TABLE t1 ADD UNIQUE INDEX i1(c1); +drop table t1; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db768.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db768.test new file mode 100644 index 00000000000..be2155f5c18 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db768.test @@ -0,0 +1,12 @@ +# test case for DB-768 +source include/have_tokudb.inc; +set default_storage_engine='tokudb'; +disable_warnings; +drop table if exists t; +enable_warnings; +create table t (id int primary key); +set autocommit=OFF; +lock tables t write; +optimize table t; +unlock tables; +drop table t; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/db771.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db771.test new file mode 100644 index 00000000000..039ad7471c1 --- /dev/null +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/db771.test @@ -0,0 +1,13 @@ +# test case for DB-771 +source include/have_tokudb.inc; +set default_storage_engine=tokudb; +disable_warnings; +drop table if exists t1; +enable_warnings; +CREATE TABLE t1 (a int key, b varchar(32), c varchar(32)); +REPLACE t1 SET a = 4; +ALTER TABLE t1 CHANGE COLUMN c c VARCHAR(500); +update t1 set b='hi'; +update t1 set c='there'; +select * from t1; +drop table t1; diff --git a/storage/tokudb/tokudb_update_fun.cc b/storage/tokudb/tokudb_update_fun.cc index 3ab7510121a..9754dc989a2 100644 --- a/storage/tokudb/tokudb_update_fun.cc +++ b/storage/tokudb/tokudb_update_fun.cc @@ -851,7 +851,7 @@ static int tokudb_expand_variable_offsets( DBT new_val; memset(&new_val, 0, sizeof new_val); if (old_val != NULL) { - assert(offset_start + number_of_offsets < old_val->size); + assert(offset_start + number_of_offsets <= old_val->size); // compute the new val from the old val uchar *old_val_ptr = (uchar *)old_val->data; diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index ee95e65780b..e45573a6d77 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -499,12 +499,14 @@ mkdir debug # Attempt to remove any optimisation flags from the debug build CFLAGS=`echo " ${CFLAGS} " | \ sed -e 's/ -O[0-9]* / /' \ + -e 's/-Wp,-D_FORTIFY_SOURCE=2/ /' \ -e 's/ -unroll2 / /' \ -e 's/ -ip / /' \ -e 's/^ //' \ -e 's/ $//'` CXXFLAGS=`echo " ${CXXFLAGS} " | \ sed -e 's/ -O[0-9]* / /' \ + -e 's/-Wp,-D_FORTIFY_SOURCE=2/ /' \ -e 's/ -unroll2 / /' \ -e 's/ -ip / /' \ -e 's/^ //' \ @@ -1250,12 +1252,12 @@ echo "=====" >> $STATUS_HISTORY * Mon Jun 11 2012 Joerg Bruehe <joerg.bruehe@oracle.com> - Make sure newly added "SPECIFIC-ULN/" directory does not disturb packaging. - + * Wed Sep 28 2011 Joerg Bruehe <joerg.bruehe@oracle.com> - Fix duplicate mentioning of "mysql_plugin" and its manual page, it is better to keep alphabetic order in the files list (merging!). - + * Wed Sep 14 2011 Joerg Bruehe <joerg.bruehe@oracle.com> - Let the RPM capabilities ("obsoletes" etc) ensure that an upgrade may replace @@ -1288,7 +1290,7 @@ echo "=====" >> $STATUS_HISTORY * Fri Aug 19 2011 Joerg Bruehe <joerg.bruehe@oracle.com> - Null-upmerge the fix of bug#37165: This spec file is not affected. -- Replace "/var/lib/mysql" by the spec file variable "%{mysqldatadir}". +- Replace "/var/lib/mysql" by the spec file variable "%%{mysqldatadir}". * Fri Aug 12 2011 Daniel Fischer <daniel.fischer@oracle.com> @@ -1309,13 +1311,13 @@ echo "=====" >> $STATUS_HISTORY not in an RPM upgrade. This affects both the "mkdir" and the call of "mysql_install_db". -* Thu Feb 09 2011 Joerg Bruehe <joerg.bruehe@oracle.com> +* Wed Feb 09 2011 Joerg Bruehe <joerg.bruehe@oracle.com> - Fix bug#56581: If an installation deviates from the default file locations ("datadir" and "pid-file"), the mechanism to detect a running server (on upgrade) should still work, and use these locations. The problem was that the fix for bug#27072 did not check for local settings. - + * Mon Jan 31 2011 Joerg Bruehe <joerg.bruehe@oracle.com> - Install the new "manifest" files: "INFO_SRC" and "INFO_BIN". @@ -1430,7 +1432,7 @@ echo "=====" >> $STATUS_HISTORY - Fix some problems with the directives around "tcmalloc" (experimental), remove erroneous traces of the InnoDB plugin (that is 5.1 only). -* Fri Oct 06 2009 Magnus Blaudd <mvensson@mysql.com> +* Tue Oct 06 2009 Magnus Blaudd <mvensson@mysql.com> - Removed mysql_fix_privilege_tables @@ -1548,7 +1550,7 @@ echo "=====" >> $STATUS_HISTORY * Thu Nov 30 2006 Joerg Bruehe <joerg@mysql.com> -- Call "make install" using "benchdir_root=%{_datadir}", +- Call "make install" using "benchdir_root=%%{_datadir}", because that is affecting the regression test suite as well. * Thu Nov 16 2006 Joerg Bruehe <joerg@mysql.com> @@ -1627,7 +1629,7 @@ echo "=====" >> $STATUS_HISTORY - Set $LDFLAGS from $MYSQL_BUILD_LDFLAGS -* Wed Mar 07 2006 Kent Boortz <kent@mysql.com> +* Tue Mar 07 2006 Kent Boortz <kent@mysql.com> - Changed product name from "Community Edition" to "Community Server" @@ -1665,7 +1667,7 @@ echo "=====" >> $STATUS_HISTORY - Added zlib to the list of (static) libraries installed - Added check against libtool wierdness (WRT: sql/mysqld || sql/.libs/mysqld) - Compile MySQL with bundled zlib -- Fixed %packager name to "MySQL Production Engineering Team" +- Fixed %%packager name to "MySQL Production Engineering Team" * Mon Dec 05 2005 Joerg Bruehe <joerg@mysql.com> @@ -1815,7 +1817,7 @@ echo "=====" >> $STATUS_HISTORY - ISAM and merge storage engines were purged. As well as appropriate tools and manpages (isamchk and isamlog) -* Thu Dec 31 2004 Lenz Grimmer <lenz@mysql.com> +* Fri Dec 31 2004 Lenz Grimmer <lenz@mysql.com> - enabled the "Archive" storage engine for the max binary - enabled the "CSV" storage engine for the max binary @@ -1875,7 +1877,7 @@ echo "=====" >> $STATUS_HISTORY - marked /etc/logrotate.d/mysql as a config file (BUG 2156) -* Fri Dec 13 2003 Lenz Grimmer <lenz@mysql.com> +* Sat Dec 13 2003 Lenz Grimmer <lenz@mysql.com> - fixed file permissions (BUG 1672) @@ -2017,7 +2019,7 @@ echo "=====" >> $STATUS_HISTORY - Added separate libmysql_r directory; now both a threaded and non-threaded library is shipped. -* Wed Sep 28 1999 David Axmark <davida@mysql.com> +* Tue Sep 28 1999 David Axmark <davida@mysql.com> - Added the support-files/my-example.cnf to the docs directory. diff --git a/tests/fork_big.pl b/tests/fork_big.pl index b866b899f8d..6e78e779d11 100755 --- a/tests/fork_big.pl +++ b/tests/fork_big.pl @@ -2,7 +2,7 @@ # Copyright (c) 2001, 2006 MySQL AB # Use is subject to license terms - +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index e92cf869e52..0f1d65be8f9 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -2,7 +2,7 @@ # Copyright (c) 2002, 2003, 2005, 2006 MySQL AB # Use is subject to license terms - +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. |