diff options
548 files changed, 7633 insertions, 11382 deletions
diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index be5e1c348fa..7d0379c08a0 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-trunk-runtime" +tree_name = "mysql-5.5-bugfixing" diff --git a/.bzrignore b/.bzrignore index f5f678ca360..a17b1dec6cb 100644 --- a/.bzrignore +++ b/.bzrignore @@ -3101,3 +3101,4 @@ libmysqld/merge_archives_mysqlserver.cmake libmysqld/mysqlserver_depends.c libmysqld/examples/mysql_embedded sql/.empty +mysys/thr_lock diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am index c5732d43fbf..56c86e7a80c 100644 --- a/BUILD/Makefile.am +++ b/BUILD/Makefile.am @@ -52,7 +52,6 @@ EXTRA_DIST = FINISH.sh \ compile-pentium-icc-yassl \ compile-pentium-max \ compile-pentium-myodbc \ - compile-pentium-mysqlfs-debug \ compile-pentium-pgcc \ compile-pentium-valgrind-max \ compile-pentium64 \ diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index b5f1c7b200e..a23a801e7e0 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -14,8 +14,7 @@ Usage: $0 [-h|-n] [configure-options] -h, --help Show this help message. -n, --just-print Don't actually run any commands; just print them. -c, --just-configure Stop after running configure. - --with-debug=full Build with full debug. - --warning-mode=[old|pedantic] + --warning-mode=[old|pedantic|maintainer] Influences the debug flags. Old is default. --prefix=path Build with prefix 'path'. @@ -30,8 +29,6 @@ parse_options() case "$1" in --prefix=*) prefix=`get_key_value "$1"`;; - --with-debug=full) - full_debug="=full";; --warning-mode=*) warning_mode=`get_key_value "$1"`;; -c | --just-configure) @@ -60,8 +57,8 @@ fi prefix="/usr/local/mysql" just_print= just_configure= -full_debug= warning_mode= +maintainer_mode= parse_options "$@" @@ -88,7 +85,21 @@ AM_MAKEFLAGS="-j 6" # Ex --with-ssl=/usr SSL_LIBRARY=--with-ssl -if [ "x$warning_mode" != "xpedantic" ]; then +if [ "x$warning_mode" = "xpedantic" ]; then + warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE" + c_warnings="$warnings" + cxx_warnings="$warnings -std=c++98" +# NOTE: warning mode should not influence optimize/debug mode. +# Please feel free to add a separate option if you don't feel it's an overkill. + debug_extra_cflags="-O0" +# Reset CPU flags (-mtune), they don't work in -pedantic mode + check_cpu_cflags="" +elif [ "x$warning_mode" = "xmaintainer" ]; then + c_warnings="-Wall -Wextra" + cxx_warnings="$c_warnings -Wno-unused-parameter" + maintainer_mode="--enable-mysql-maintainer-mode" + debug_extra_cflags="-g3" +else # Both C and C++ warnings warnings="-Wall -Wextra -Wunused -Wwrite-strings" @@ -101,17 +112,7 @@ if [ "x$warning_mode" != "xpedantic" ]; then cxx_warnings="$warnings -Wno-unused-parameter" # cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo" cxx_warnings="$cxx_warnings -Wctor-dtor-privacy -Wnon-virtual-dtor" -# Added unless --with-debug=full debug_extra_cflags="-O0 -g3 -gdwarf-2" -else - warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE" - c_warnings="$warnings" - cxx_warnings="$warnings -std=c++98" -# NOTE: warning mode should not influence optimize/debug mode. -# Please feel free to add a separate option if you don't feel it's an overkill. - debug_extra_cflags="-O0" -# Reset CPU flags (-mtune), they don't work in -pedantic mode - check_cpu_cflags="" fi # Set flags for various build configurations. @@ -135,11 +136,8 @@ base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti" # Be as fast as we can be without losing our ability to backtrace. fast_cflags="-O3 -fno-omit-frame-pointer" -debug_configs="--with-debug$full_debug" -if [ -z "$full_debug" ] -then - debug_cflags="$debug_cflags $debug_extra_cflags" -fi +debug_configs="--with-debug" +debug_cflags="$debug_cflags $debug_extra_cflags" # # Configuration options. @@ -147,7 +145,7 @@ fi base_configs="--prefix=$prefix --enable-assembler " base_configs="$base_configs --with-extra-charsets=complex " base_configs="$base_configs --enable-thread-safe-client " -base_configs="$base_configs --with-big-tables" +base_configs="$base_configs --with-big-tables $maintainer_mode" if test -d "$path/../cmd-line-utils/readline" then diff --git a/BUILD/autorun.sh b/BUILD/autorun.sh index 9fdd0486360..f4508ab12b6 100755 --- a/BUILD/autorun.sh +++ b/BUILD/autorun.sh @@ -21,24 +21,18 @@ done IFS="$save_ifs" rm -rf configure - -# Ensure that cmake and perl are available. Required for cmake based builds. -cmake -P cmake/check_minimal_version.cmake >/dev/null 2>&1 || HAVE_CMAKE=no -perl --version >/dev/null 2>&1 || HAVE_CMAKE=no - -# Whether to use the autotools configuration script or cmake. -if test "$HAVE_CMAKE" = "no" -then - aclocal || die "Can't execute aclocal" - autoheader || die "Can't execute autoheader" - # --force means overwrite ltmain.sh script if it already exists - $LIBTOOLIZE --automake --force --copy || die "Can't execute libtoolize" - # --add-missing instructs automake to install missing auxiliary files - # and --force to overwrite them if they already exist - automake --add-missing --force --copy || die "Can't execute automake" - autoconf || die "Can't execute autoconf" -else - path=`dirname $0` - cp $path/cmake_configure.sh $path/../configure - chmod +x $path/../configure -fi +aclocal || die "Can't execute aclocal" +autoheader || die "Can't execute autoheader" +# --force means overwrite ltmain.sh script if it already exists +$LIBTOOLIZE --automake --force --copy || die "Can't execute libtoolize" + +# --add-missing instructs automake to install missing auxiliary files +# and --force to overwrite them if they already exist +automake --add-missing --force --copy || die "Can't execute automake" +autoconf || die "Can't execute autoconf" +# Do not use autotools generated configure directly. Instead, use a script +# that will either call CMake or original configure shell script at build +# time (CMake is preferred if installed). +mv configure configure.am +cp BUILD/cmake_configure.sh configure +chmod a+x configure diff --git a/BUILD/build_mccge.sh b/BUILD/build_mccge.sh index aae017aa54d..cb70a8cef67 100755 --- a/BUILD/build_mccge.sh +++ b/BUILD/build_mccge.sh @@ -148,7 +148,6 @@ Usage: $0 [options] --extended-help Show extended help message --without-debug Build non-debug version --with-debug Build debug version - --with-debug=full Build with full debug. --configure-only Stop after running configure. --use-autotools Start by running autoconf, automake,.. tools --no-autotools Start from configure @@ -262,10 +261,6 @@ extended_usage() This flag prevents the use of GPL libraries which cannot be used under a commercial license, such as the readline library. - --with-debug[=full] - This option will ensure that the version is built with debug - information enabled; the optimisation level is decreased to -O. - --developer This option changes a number of things to make the version built more appropriate to the debugging and testing needs of developers. @@ -658,11 +653,6 @@ parse_options() --datadir=*) datadir=`get_key_value "$1"` ;; - --with-debug=full) - full_debug="=full" - with_debug_flag="yes" - fast_flag="no" - ;; --without-debug) with_debug_flag="no" if test "x$fast_flag" != "xyes" ; then @@ -1044,10 +1034,7 @@ set_warning_flags() # C++ warnings cxx_warnings="$warnings -Woverloaded-virtual -Wsign-promo -Wreorder" cxx_warnings="$warnings -Wctor-dtor-privacy -Wnon-virtual-dtor" -# Added unless --with-debug=full - if test "x$full_debug" = "x" ; then - compiler_flags="$compiler_flags -Wuninitialized" - fi + compiler_flags="$compiler_flags -Wuninitialized" elif test "x$warning_mode" = "xpedantic" ; then warnings="-W -Wall -ansi -pedantic -Wno-long-long -D_POSIX_SOURCE" c_warnings="$warnings" @@ -1113,7 +1100,7 @@ set_base_configs() base_configs="$base_configs --localstatedir=$datadir" fi if test "x$with_debug_flag" = "xyes" ; then - base_configs="$base_configs --with-debug$full_debug" + base_configs="$base_configs --with-debug" fi base_configs="$base_configs --enable-local-infile" base_configs="$base_configs --enable-thread-safe-client" @@ -1546,7 +1533,6 @@ gpl="yes" version_text= developer_flag="no" just_configure= -full_debug= warning_mode= with_flags= error_inject_flag= diff --git a/BUILD/check-cpu b/BUILD/check-cpu index f9f5d423f4f..585043de67c 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -7,6 +7,79 @@ # check_cpu_args : Arguments for GCC compiler settings # +check_compiler_cpu_flags () { + # different compiler versions have different option names + # for CPU specific command line options + if test -z "$CC" ; then + cc="gcc"; + else + cc=$CC + fi + + # check if compiler is gcc and dump its version + cc_verno=`$cc -dumpversion 2>/dev/null` + if test "x$?" = "x0" ; then + set -- `echo $cc_verno | tr '.' ' '` + cc_ver="GCC" + cc_major=$1 + cc_minor=$2 + cc_patch=$3 + cc_comp=`expr $cc_major '*' 100 '+' $cc_minor` + fi + + case "$cc_ver--$cc_verno" in + *GCC*) + # different gcc backends (and versions) have different CPU flags + case `gcc -dumpmachine` in + i?86-* | x86_64-*) + if test "$cc_comp" -lt 304 ; then + check_cpu_cflags="-mcpu=${cpu_arg}" + elif test "$cc_comp" -ge 402 ; then + check_cpu_cflags="-mtune=native" + else + check_cpu_cflags="-mtune=${cpu_arg}" + fi + ;; + ppc-*) + check_cpu_cflags="-mcpu=${cpu_arg} -mtune=${cpu_arg}" + ;; + *) + check_cpu_cflags="" + return + ;; + esac + ;; + 2.95.*) + # GCC 2.95 doesn't expose its name in --version output + check_cpu_cflags="-m${cpu_arg}" + ;; + *) + check_cpu_cflags="" + return + ;; + esac + + # now we check whether the compiler really understands the cpu type + touch __test.c + + while [ "$cpu_arg" ] ; do + printf "testing $cpu_arg ... " >&2 + + # compile check + eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null + if test "x$?" = "x0" ; then + echo ok >&2 + break; + fi + + echo failed >&2 + check_cpu_cflags="" + break; + done + rm __test.* + return 0 +} + check_cpu () { CPUINFO=/proc/cpuinfo if test -n "$TEST_CPUINFO" ; then @@ -179,83 +252,14 @@ check_cpu () { return fi - # different compiler versions have different option names - # for CPU specific command line options - if test -z "$CC" ; then - cc="gcc"; - else - cc=$CC + if test "x$compiler" = "x" ; then + check_compiler_cpu_flags fi if test "x$core2" = "xyes" ; then cpu_arg="core2" fi - if test "x$compiler" != "x" ; then - return 0 - fi - - # check if compiler is gcc and dump its version - cc_verno=`$cc -dumpversion 2>/dev/null` - if test "x$?" = "x0" ; then - set -- `echo $cc_verno | tr '.' ' '` - cc_ver="GCC" - cc_major=$1 - cc_minor=$2 - cc_patch=$3 - cc_comp=`expr $cc_major '*' 100 '+' $cc_minor` - fi - - case "$cc_ver--$cc_verno" in - *GCC*) - # different gcc backends (and versions) have different CPU flags - case `gcc -dumpmachine` in - i?86-* | x86_64-*) - if test "$cc_comp" -lt 304 ; then - check_cpu_cflags="-mcpu=${cpu_arg}" - elif test "$cc_comp" -ge 402 ; then - check_cpu_cflags="-mtune=native" - else - check_cpu_cflags="-mtune=${cpu_arg}" - fi - ;; - ppc-*) - check_cpu_cflags="-mcpu=${cpu_arg} -mtune=${cpu_arg}" - ;; - *) - check_cpu_cflags="" - return - ;; - esac - ;; - 2.95.*) - # GCC 2.95 doesn't expose its name in --version output - check_cpu_cflags="-m${cpu_arg}" - ;; - *) - check_cpu_cflags="" - return - ;; - esac - - # now we check whether the compiler really understands the cpu type - touch __test.c - - while [ "$cpu_arg" ] ; do - printf "testing $cpu_arg ... " >&2 - - # compile check - eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null - if test "x$?" = "x0" ; then - echo ok >&2 - break; - fi - - echo failed >&2 - check_cpu_cflags="" - break; - done - rm __test.* return 0 } diff --git a/BUILD/compile-ndb-autotest b/BUILD/compile-ndb-autotest index be28cc28346..6f86eeb7464 100755 --- a/BUILD/compile-ndb-autotest +++ b/BUILD/compile-ndb-autotest @@ -4,16 +4,6 @@ path=`dirname $0` . "$path/SETUP.sh" extra_configs="$max_configs --with-ndb-test --with-ndb-ccflags='-DERROR_INSERT'" -if [ "$full_debug" ] -then - extra_flags="$debug_cflags" - c_warnings="$c_warnings $debug_extra_warnings" - cxx_warnings="$cxx_warnings $debug_extra_warnings" - extra_configs="$debug_configs $extra_configs" -else - extra_flags="$fast_cflags" -fi - -extra_flags="$extra_flags $max_cflags -g" +extra_flags="$fast_cflags $max_cflags -g" . "$path/FINISH.sh" diff --git a/BUILD/compile-pentium-debug b/BUILD/compile-pentium-debug index 3f4027c5dd6..37381cc47df 100755 --- a/BUILD/compile-pentium-debug +++ b/BUILD/compile-pentium-debug @@ -1,7 +1,6 @@ #! /bin/sh path=`dirname $0` -set -- "$@" --with-debug=full . "$path/SETUP.sh" extra_flags="$pentium_cflags $debug_cflags" diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max index 941a63a209f..5c56ceb37ba 100755 --- a/BUILD/compile-pentium-debug-max +++ b/BUILD/compile-pentium-debug-max @@ -1,7 +1,6 @@ #! /bin/sh path=`dirname $0` -set -- "$@" --with-debug=full . "$path/SETUP.sh" extra_flags="$pentium_cflags $debug_cflags" diff --git a/BUILD/compile-pentium-debug-max-no-ndb b/BUILD/compile-pentium-debug-max-no-ndb index 3f7a7904050..f1e14b73ecd 100755 --- a/BUILD/compile-pentium-debug-max-no-ndb +++ b/BUILD/compile-pentium-debug-max-no-ndb @@ -1,7 +1,6 @@ #! /bin/sh path=`dirname $0` -set -- "$@" --with-debug=full . "$path/SETUP.sh" extra_flags="$pentium_cflags $debug_cflags" diff --git a/BUILD/compile-pentium-debug-openssl b/BUILD/compile-pentium-debug-openssl index 2e24dbfd2f1..7026e0fde05 100755 --- a/BUILD/compile-pentium-debug-openssl +++ b/BUILD/compile-pentium-debug-openssl @@ -6,6 +6,6 @@ path=`dirname $0` extra_flags="$pentium_cflags $debug_cflags" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-debug=full --with-ssl=/usr" +extra_configs="$extra_configs --with-debug --with-ssl=/usr" . "$path/FINISH.sh" diff --git a/BUILD/compile-pentium-debug-yassl b/BUILD/compile-pentium-debug-yassl index 61ad2937c4a..3f9a36ce5a1 100755 --- a/BUILD/compile-pentium-debug-yassl +++ b/BUILD/compile-pentium-debug-yassl @@ -6,6 +6,6 @@ path=`dirname $0` extra_flags="$pentium_cflags $debug_cflags" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-debug=full --with-ssl" +extra_configs="$extra_configs --with-debug --with-ssl" . "$path/FINISH.sh" diff --git a/BUILD/compile-pentium-mysqlfs-debug b/BUILD/compile-pentium-mysqlfs-debug deleted file mode 100755 index c871200604e..00000000000 --- a/BUILD/compile-pentium-mysqlfs-debug +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh - -path=`dirname $0` -. "$path/SETUP.sh" - -extra_flags="$pentium_cflags $debug_cflags" -extra_configs="$pentium_configs $debug_configs $static_link" - -extra_configs="$extra_configs --with-debug=full --with-mysqlfs --without-server --without-pstack" - -. "$path/FINISH.sh" diff --git a/BUILD/compile-pentium64-debug b/BUILD/compile-pentium64-debug index 06ee672789c..7d11ee9df76 100755 --- a/BUILD/compile-pentium64-debug +++ b/BUILD/compile-pentium64-debug @@ -1,7 +1,6 @@ #! /bin/sh path=`dirname $0` -set -- "$@" --with-debug=full . "$path/SETUP.sh" extra_flags="$pentium64_cflags $debug_cflags" diff --git a/BUILD/compile-pentium64-debug-max b/BUILD/compile-pentium64-debug-max index b8b271688be..322b232a20c 100755 --- a/BUILD/compile-pentium64-debug-max +++ b/BUILD/compile-pentium64-debug-max @@ -1,7 +1,6 @@ #! /bin/sh path=`dirname $0` -set -- "$@" --with-debug=full . "$path/SETUP.sh" extra_flags="$pentium64_cflags $debug_cflags" diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ff2507dcc3..3ba9e1cf7f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,6 @@ ENDIF() SET(CUSTOM_C_FLAGS $ENV{CFLAGS}) OPTION(WITH_DEBUG "Use dbug/safemutex" OFF) -OPTION(WITH_DEBUG_FULL "Use dbug and safemutex. Slow." OFF) # Distinguish between community and non-community builds, with the # default being a community build. This does not impact the feature @@ -46,7 +45,8 @@ OPTION(COMMUNITY_BUILD "Set to true if this is a community build" ON) SET(MANUFACTURER_DOCSTRING "Set the entity that appears as the manufacturer of packages that support a manufacturer field.") IF(NOT DEFINED MANUFACTURER) - SET(MANUFACTURER "Built from Source" CACHE BOOL ${MANUFACTURER_DOCSTRING}) + SET(MANUFACTURER "Built from Source" CACHE STRING ${MANUFACTURER_DOCSTRING}) + MARK_AS_ADVANCED(MANUFACTURER) ENDIF() # We choose to provide WITH_DEBUG as alias to standard CMAKE_BUILD_TYPE=Debug @@ -59,7 +59,7 @@ SET(BUILDTYPE_DOCSTRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel") -IF(WITH_DEBUG OR WITH_DEBUG_FULL) +IF(WITH_DEBUG) SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE) SET(OLD_WITH_DEBUG 1 CACHE INTERNAL "" FORCE) ELSEIF(NOT HAVE_CMAKE_BUILD_TYPE OR OLD_WITH_DEBUG) @@ -148,6 +148,9 @@ OPTION(ENABLED_PROFILING "Enable profiling" ON) OPTION(CYBOZU "" OFF) OPTION(BACKUP_TEST "" OFF) OPTION(WITHOUT_SERVER OFF) +IF(UNIX) + OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF) +ENDIF() OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED) @@ -158,16 +161,9 @@ IF(ENABLE_DEBUG_SYNC) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC") ENDIF() -OPTION(WITH_ERROR_INJECT - "Enable error injection in MySQL Server (debug builds only)" OFF) -IF(WITH_ERROR_INJECT) - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DERROR_INJECT_SUPPORT") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DERROR_INJECT_SUPPORT") -ENDIF() - -OPTION(ENABLE_LOCAL_INFILE +OPTION(ENABLED_LOCAL_INFILE "If we should should enable LOAD DATA LOCAL by default" ${IF_WIN}) -MARK_AS_ADVANCED(ENABLE_LOCAL_INFILE) +MARK_AS_ADVANCED(ENABLED_LOCAL_INFILE) OPTION(WITH_FAST_MUTEXES "Compile with fast mutexes" OFF) MARK_AS_ADVANCED(WITH_FAST_MUTEXES) @@ -198,15 +194,10 @@ ENDIF() # Add safemutex for debug configurations, except on Windows # (safemutex has never worked on Windows) -IF(WITH_DEBUG OR WITH_DEBUG_FULL AND NOT WIN32) +IF(WITH_DEBUG AND NOT WIN32) FOREACH(LANG C CXX) - IF(WITH_DEBUG_FULL) - SET(CMAKE_${LANG}_FLAGS_DEBUG - "${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFE_MUTEX") - ELSE() - SET(CMAKE_${LANG}_FLAGS_DEBUG - "${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFE_MUTEX") - ENDIF() + SET(CMAKE_${LANG}_FLAGS_DEBUG + "${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFE_MUTEX") ENDFOREACH() ENDIF() diff --git a/Makefile.am b/Makefile.am index 297e923905e..7ab9a9aa061 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ @libmysqld_dirs@ \ mysql-test support-files sql-bench \ win \ + packaging \ cmake DIST_SUBDIRS = . include Docs zlib \ cmd-line-utils sql-common scripts \ @@ -40,6 +41,7 @@ DIST_SUBDIRS = . include Docs zlib \ mysql-test support-files sql-bench \ win \ cmake \ + packaging \ BUILD DISTCLEANFILES = ac_available_languages_fragment @@ -63,7 +65,7 @@ dist-hook: test ! -f $(top_srcdir)/configure.am || \ $(INSTALL_DATA) $(top_srcdir)/configure.am $(distdir) -all-local: @ABI_CHECK@ +all-local: @ABI_CHECK@ tags: support-files/build-tags @@ -312,7 +314,7 @@ abi_check_all: abi_check do_abi_check: set -ex; \ for file in $(abi_headers); do \ - @CC@ -E -nostdinc -dI \ + @CC@ -E -nostdinc -dI -DMYSQL_ABI_CHECK \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/mysql \ -I$(top_srcdir)/sql \ diff --git a/client/Makefile.am b/client/Makefile.am index 04f0ac39b0e..393573a061e 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -62,7 +62,6 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc \ $(top_srcdir)/mysys/my_new.cc \ $(top_srcdir)/mysys/my_bit.c \ $(top_srcdir)/mysys/my_bitmap.c \ - $(top_srcdir)/mysys/my_vle.c \ $(top_srcdir)/mysys/base64.c mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) diff --git a/client/mysql.cc b/client/mysql.cc index abf01d8127d..01a786c13af 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -627,10 +627,6 @@ static COMMANDS commands[] = { { "QUARTER", 0, 0, 0, ""}, { "QUERY", 0, 0, 0, ""}, { "QUICK", 0, 0, 0, ""}, - { "RAID0", 0, 0, 0, ""}, - { "RAID_CHUNKS", 0, 0, 0, ""}, - { "RAID_CHUNKSIZE", 0, 0, 0, ""}, - { "RAID_TYPE", 0, 0, 0, ""}, { "READ", 0, 0, 0, ""}, { "READS", 0, 0, 0, ""}, { "REAL", 0, 0, 0, ""}, @@ -3656,7 +3652,7 @@ xmlencode_print(const char *src, uint length) tee_fputs("NULL", PAGER); else { - for (const char *p = src; length; *p++, length--) + for (const char *p = src; length; p++, length--) { const char *t; if ((t = array_value(xmlmeta, *p))) @@ -4744,7 +4740,7 @@ static const char* construct_prompt() struct tm *t = localtime(&lclock); /* parse thru the settings for the prompt */ - for (char *c = current_prompt; *c ; *c++) + for (char *c = current_prompt; *c ; c++) { if (*c != PROMPT_CHAR) processed_prompt.append(*c); diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 20436200c7e..eeab3611913 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -596,7 +596,10 @@ static int upgrade_already_done(void) my_fclose(in, MYF(0)); - return (strncmp(buf, MYSQL_SERVER_VERSION, + if (!res) + return 0; /* Could not read from file => not sure */ + + return (strncmp(res, MYSQL_SERVER_VERSION, sizeof(MYSQL_SERVER_VERSION)-1)==0); } diff --git a/client/mysqltest.cc b/client/mysqltest.cc index c8ec6c981ef..20f0f6d3164 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5954,8 +5954,8 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"result-format-version", OPT_RESULT_FORMAT_VERSION, "Version of the result file format to use", - (uchar**) &opt_result_format_version, - (uchar**) &opt_result_format_version, 0, + &opt_result_format_version, + &opt_result_format_version, 0, GET_INT, REQUIRED_ARG, 1, 1, 2, 0, 0, 0}, {"server-arg", 'A', "Send option value to embedded server as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -5998,8 +5998,7 @@ static struct my_option my_long_options[] = GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"connect_timeout", OPT_CONNECT_TIMEOUT, "Number of seconds before connection timeout.", - (uchar**) &opt_connect_timeout, - (uchar**) &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG, + &opt_connect_timeout, &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG, 120, 0, 3600 * 12, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -8513,7 +8512,7 @@ void free_replace_column() typedef struct st_pointer_array { /* when using array-strings */ TYPELIB typelib; /* Pointer to strings */ uchar *str; /* Strings is here */ - int7 *flag; /* Flag about each var. */ + uint8 *flag; /* Flag about each var. */ uint array_allocs,max_count,length,max_length; } POINTER_ARRAY; @@ -9644,7 +9643,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) } pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+ sizeof(*pa->flag)); - pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); + pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count); pa->length=0; pa->max_length=PS_MALLOC-MALLOC_OVERHEAD; pa->array_allocs=1; @@ -9680,7 +9679,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) pa->typelib.type_names=new_array; old_count=pa->max_count; pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag)); - pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); + pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count); memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count), old_count*sizeof(*pa->flag)); } diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake index 0d5bf21f540..7911b7848a8 100644 --- a/cmake/abi_check.cmake +++ b/cmake/abi_check.cmake @@ -38,7 +38,7 @@ IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_NAME MATCHES "Linux") -DCOMPILER=${COMPILER} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} - "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}" + "-DDMYSQL_ABI_CHECK -DABI_HEADERS=${API_PREPROCESSOR_HEADER}" -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake VERBATIM ) @@ -48,7 +48,7 @@ IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_NAME MATCHES "Linux") -DCMAKE_C_COMPILER=${COMPILER} -DCMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} - "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}" + "-DMYSQL_ABI_CHECK -DABI_HEADERS=${API_PREPROCESSOR_HEADER}" -P ${CMAKE_SOURCE_DIR}/cmake/scripts/do_abi_check.cmake VERBATIM ) diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 97de0965f6b..9d010ef7f2a 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -15,6 +15,18 @@ # This file includes build settings used for MySQL release +INCLUDE(CheckIncludeFiles) +INCLUDE(CheckLibraryExists) +INCLUDE(CheckTypeSize) + +# XXX package_name.cmake uses this too, move it somewhere global +CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP) +IF(SIZEOF_VOIDP EQUAL 4) + SET(32BIT 1) +ENDIF() +IF(SIZEOF_VOIDP EQUAL 8) + SET(64BIT 1) +ENDIF() SET(FEATURE_SET "community" CACHE STRING " Selection of features. Options are @@ -76,15 +88,14 @@ IF(FEATURE_SET) SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "") ELSE() SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "") - ENDIF() + ENDIF() ENDFOREACH() ENDIF() -OPTION(ENABLE_LOCAL_INFILE "" ON) +OPTION(ENABLED_LOCAL_INFILE "" ON) SET(WITH_SSL bundled CACHE STRING "") SET(WITH_ZLIB bundled CACHE STRING "") - IF(NOT COMPILATION_COMMENT) SET(COMPILATION_COMMENT "MySQL Community Server (GPL)") ENDIF() @@ -103,46 +114,75 @@ IF(UNIX) ENDIF() OPTION(WITH_PIC "" ON) # Why? -ENDIF() + # Ensure aio is available on Linux (required by InnoDB) + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H) + CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO) + IF(NOT HAVE_LIBAIO_H OR NOT HAVE_LIBAIO) + MESSAGE(FATAL_ERROR "aio is required on Linux") + ENDIF() + ENDIF() + +ENDIF() # Compiler options IF(UNIX) + # Default GCC flags + IF(CMAKE_COMPILER_IS_GNUCC) + SET(COMMON_C_FLAGS "-g -static-libgcc -fno-omit-frame-pointer") + SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}") + ENDIF() IF(CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3 -static-libgcc -fno-omit-frame-pointer") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3 -static-libgcc -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti") + SET(COMMON_CXX_FLAGS "-g -static-libgcc -fno-omit-frame-pointer") + SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}") ENDIF() - # HPUX flags IF(CMAKE_SYSTEM_NAME MATCHES "HP-UX") IF(CMAKE_C_COMPILER_ID MATCHES "HP") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64") - SET(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} +DD64 +DSitanium2 -mt -AC99") - SET(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} +DD64 +DSitanium2 -mt -Aa") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} +O2") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} +O2") + SET(COMMON_C_FLAGS "+DSitanium2 -mt -AC99") + SET(COMMON_CXX_FLAGS "+DSitanium2 -mt -Aa") + SET(CMAKE_C_FLAGS_DEBUG "+O0 -g ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "+O0 -g ${COMMON_CXX_FLAGS}") + # We have seen compiler bugs with optimisation and -g, so disabled for now + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_CXX_FLAGS}") ENDIF() ENDIF() - SET(WITH_SSL) + SET(WITH_SSL no) ENDIF() # Linux flags IF(CMAKE_SYSTEM_NAME MATCHES "Linux") IF(CMAKE_C_COMPILER_ID MATCHES "Intel") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-static-intel -static-libgcc -g -O3 -unroll2 -ip -mp -restrict -no-ftz -no-prefetch") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-static-intel -static-libgcc -g -O3 -unroll2 -ip -mp -restrict -no-ftz -no-prefetch") + SET(COMMON_C_FLAGS "-static-intel -static-libgcc -g -mp -restrict") + SET(COMMON_CXX_FLAGS "-static-intel -static-libgcc -g -mp -restrict -fno-exceptions -fno-rtti") + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64") + SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -no-ftz -no-prefetch") + SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -no-ftz -no-prefetch") + ENDIF() + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_CXX_FLAGS}") SET(WITH_SSL no) ENDIF() ENDIF() # OSX flags IF(APPLE) - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -Os -fno-common") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -Os -felide-constructors -fno-common") + SET(COMMON_C_FLAGS "-g -fno-common") + # XXX: why are we using -felide-constructors on OSX? + SET(COMMON_CXX_FLAGS "-g -fno-common -felide-constructors") + 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}") ENDIF() # Solaris flags @@ -153,37 +193,48 @@ IF(UNIX) ENDIF() IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386") - IF(CMAKE_SIZEOF_VOID_P EQUAL 4) - # Solaris x86 - SET(CMAKE_C_FLAGS_RELWITHDEBINFO - "-g -xO2 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO - "-g0 -xO2 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic") - ELSE() - # Solaris x64 - SET(CMAKE_C_FLAGS_RELWITHDEBINFO - "-g -xO3 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO - "-g0 -xO3 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic") - ENDIF() - ELSE() - IF(CMAKE_SIZEOF_VOID_P EQUAL 4) - # Solaris sparc 32 bit - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -xO3 -Xa -xstrconst -mt -xarch=sparc") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g0 -xO3 -noex -mt -xarch=sparc") - ELSE() - # Solaris sparc 64 bit - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -xO3 -Xa -xstrconst -mt") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g0 -xO3 -noex -mt") - ENDIF() - ENDIF() + SET(COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic") + SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic") + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + IF(32BIT) + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS}") + ELSEIF(64BIT) + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}") + ENDIF() + ELSE() + # Assume !x86 is SPARC + SET(COMMON_C_FLAGS "-g -Xa -xstrconst -mt") + SET(COMMON_CXX_FLAGS "-g0 -noex -mt") + IF(32BIT) + SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -xarch=sparc") + SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -xarch=sparc") + ENDIF() + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}") + ENDIF() ENDIF() ENDIF() + IF(CMAKE_C_FLAGS_DEBUG) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" + CACHE STRING "Debug C compile flags") + ENDIF() + IF(CMAKE_CXX_FLAGS_DEBUG) + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" + CACHE STRING "Debug C++ compile flags") + ENDIF() + IF(CMAKE_C_FLAGS_RELWITHDEBINFO) + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}" + CACHE STRING "RelWithDebInfo C compile flags") + ENDIF() IF(CMAKE_CXX_FLAGS_RELWITHDEBINFO) SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" - CACHE STRING "Compile flags") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}" - CACHE STRING "Compile flags") + CACHE STRING "RelWithDebInfo C++ compile flags") ENDIF() + ENDIF() diff --git a/cmake/configure.pl b/cmake/configure.pl index 5be47ce5a31..1dc8080810c 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -179,11 +179,6 @@ foreach my $option (@ARGV) $cmakeargs = $cmakeargs." -DMYSQL_DATADIR=".substr($option,14); next; } - if ($option =~ /with-debug=full/) - { - $cmakeargs = $cmakeargs." -DWITH_DEBUG_FULL=1"; - next; - } if ($option =~ /mysql-maintainer-mode/) { $cmakeargs = $cmakeargs." -DMYSQL_MAINTAINER_MODE=" . diff --git a/cmake/os/AIX.cmake b/cmake/os/AIX.cmake index b1b2cebdd14..c08cbbdc0cf 100644 --- a/cmake/os/AIX.cmake +++ b/cmake/os/AIX.cmake @@ -28,6 +28,6 @@ INCLUDE(CheckCXXCompilerFlag) # The following is required to export all symbols # (also with leading underscore) STRING(REPLACE "-bexpall" "-bexpfull" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS - ${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") + "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") STRING(REPLACE "-bexpall" "-bexpfull" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS - "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}")
\ No newline at end of file + "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}") diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index e07e3f54aa8..732f5d74181 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -262,7 +262,6 @@ SET(HAVE_SYS_DIR_H CACHE INTERNAL "") SET(HAVE_SYS_ERRLIST CACHE INTERNAL "") SET(HAVE_SYS_FILE_H CACHE INTERNAL "") SET(HAVE_SYS_FPU_H CACHE INTERNAL "") -SET(HAVE_SYS_IOCTL CACHE INTERNAL "") SET(HAVE_SYS_IOCTL_H CACHE INTERNAL "") SET(HAVE_SYS_IPC_H CACHE INTERNAL "") SET(HAVE_SYS_MALLOC_H CACHE INTERNAL "") @@ -340,4 +339,16 @@ SET(C_HAS_inline CACHE INTERNAL "") SET(C_HAS___inline 1 CACHE INTERNAL "") SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "") SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "") +SET(HAVE_CXXABI_H CACHE INTERNAL "") +SET(HAVE_NDIR_H CACHE INTERNAL "") +SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") +SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") +SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "") +SET(HAVE_TERMBITS_H CACHE INTERNAL "") +SET(HAVE_VIS_H CACHE INTERNAL "") +SET(HAVE_WCHAR_H 1 CACHE INTERNAL "") +SET(HAVE_WCTYPE_H 1 CACHE INTERNAL "") +SET(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP CACHE INTERNAL "") +SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "") +SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "") ENDIF() diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 94edfb8741a..138901dfa8a 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -57,11 +57,17 @@ MACRO(MYSQL_ADD_PLUGIN) SET(WITHOUT_NDBCLUSTER 1) ENDIF() + IF(ARG_DEFAULT) + IF(NOT DEFINED WITH_${plugin} AND + NOT DEFINED WITH_${plugin}_STORAGE_ENGINE) + SET(WITH_${plugin} 1) + ENDIF() + ENDIF() + IF(WITH_${plugin}_STORAGE_ENGINE OR WITH_{$plugin} OR WITH_ALL OR WITH_MAX - OR ARG_DEFAULT AND NOT WITHOUT_${plugin}_STORAGE_ENGINE AND NOT WITHOUT_${plugin} AND NOT ARG_MODULE_ONLY) @@ -88,6 +94,7 @@ MACRO(MYSQL_ADD_PLUGIN) IF(NOT ARG_DEPENDENCIES) SET(ARG_DEPENDENCIES) ENDIF() + SET(BUILD_PLUGIN 1) # Build either static library or module IF (WITH_${plugin} AND NOT ARG_MODULE_ONLY) ADD_LIBRARY(${target} STATIC ${SOURCES}) @@ -148,9 +155,6 @@ MACRO(MYSQL_ADD_PLUGIN) DTRACE_INSTRUMENT(${target}) SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "" COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN") - IF(ARG_LINK_LIBRARIES) - TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) - ENDIF() TARGET_LINK_LIBRARIES (${target} mysqlservices) # Plugin uses symbols defined in mysqld executable. @@ -165,17 +169,30 @@ MACRO(MYSQL_ADD_PLUGIN) ENDIF() ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES}) - IF(NOT ARG_MODULE_ONLY) + IF(NOT ARG_MODULE_ONLY) # set cached variable, e.g with checkbox in GUI SET(${with_var} OFF CACHE BOOL "Link ${plugin} statically to the server" FORCE) - ENDIF() + ENDIF() SET_TARGET_PROPERTIES(${target} PROPERTIES OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}") # Install dynamic library MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT Server) INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug) + ELSE() + IF(WITHOUT_${plugin}) + # Update cache variable + STRING(REPLACE "WITH_" "WITHOUT_" without_var ${with_var}) + SET(${without_var} ON CACHE BOOL "Don't build ${plugin}" + FORCE) + ENDIF() + SET(BUILD_PLUGIN 0) ENDIF() + + IF(BUILD_PLUGIN AND ARG_LINK_LIBRARIES) + TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) + ENDIF() + ENDMACRO() diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index d1f48888092..c5aa2de2721 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -29,14 +29,14 @@ MACRO (MYSQL_USE_BUNDLED_SSL) CHANGE_SSL_SETTINGS("bundled") #Remove -fno-implicit-templates #(yassl sources cannot be compiled with it) - SET(SAVE_CXX_FLAGS ${CXX_FLAGS}) + SET(SAVE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) IF(CMAKE_CXX_FLAGS) STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) ENDIF() ADD_SUBDIRECTORY(extra/yassl) ADD_SUBDIRECTORY(extra/yassl/taocrypt) - SET(CXX_FLAGS ${SAVE_CXX_FLAGS}) + SET(CMAKE_CXX_FLAGS ${SAVE_CXX_FLAGS}) GET_TARGET_PROPERTY(src yassl SOURCES) FOREACH(file ${src}) SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/${file}) diff --git a/config.h.cmake b/config.h.cmake index 2d877ed853f..c484edb65a5 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -22,11 +22,14 @@ #cmakedefine HAVE_ALLOCA_H 1 #cmakedefine HAVE_AIO_H 1 #cmakedefine HAVE_ARPA_INET_H 1 +#cmakedefine HAVE_ASM_MSR_H 1 +#cmakedefine HAVE_ASM_TERMBITS_H 1 #cmakedefine HAVE_BSEARCH 1 #cmakedefine HAVE_CRYPT_H 1 #cmakedefine HAVE_CURSES_H 1 #cmakedefine HAVE_CXXABI_H 1 #cmakedefine HAVE_NCURSES_H 1 +#cmakedefine HAVE_NDIR_H 1 #cmakedefine HAVE_DIRENT_H 1 #cmakedefine HAVE_DLFCN_H 1 #cmakedefine HAVE_EXECINFO_H 1 @@ -70,6 +73,7 @@ #cmakedefine HAVE_SYS_IPC_H 1 #cmakedefine HAVE_SYS_MALLOC_H 1 #cmakedefine HAVE_SYS_MMAN_H 1 +#cmakedefine HAVE_SYS_NDIR_H 1 #cmakedefine HAVE_SYS_PTE_H 1 #cmakedefine HAVE_SYS_PTEM_H 1 #cmakedefine HAVE_SYS_PRCTL_H 1 @@ -87,6 +91,7 @@ #cmakedefine HAVE_SYS_UN_H 1 #cmakedefine HAVE_SYS_VADVISE_H 1 #cmakedefine HAVE_TERM_H 1 +#cmakedefine HAVE_TERMBITS_H 1 #cmakedefine HAVE_TERMIOS_H 1 #cmakedefine HAVE_TERMIO_H 1 #cmakedefine HAVE_TERMCAP_H 1 @@ -129,9 +134,11 @@ #cmakedefine HAVE_BMOVE 1 #cmakedefine HAVE_BZERO 1 #cmakedefine HAVE_INDEX 1 +#cmakedefine HAVE_CHOWN 1 #cmakedefine HAVE_CLOCK_GETTIME 1 #cmakedefine HAVE_CRYPT 1 #cmakedefine HAVE_CUSERID 1 +#cmakedefine HAVE_CXX_NEW 1 #cmakedefine HAVE_DIRECTIO 1 #cmakedefine HAVE_DLERROR 1 #cmakedefine HAVE_DLOPEN 1 @@ -146,6 +153,7 @@ #cmakedefine HAVE_FPSETMASK 1 #cmakedefine HAVE_FSEEKO 1 #cmakedefine HAVE_FSYNC 1 +#cmakedefine HAVE_FTIME 1 #cmakedefine HAVE_GETADDRINFO 1 #cmakedefine HAVE_GETCWD 1 #cmakedefine HAVE_GETHOSTBYADDR_R 1 @@ -175,6 +183,8 @@ #cmakedefine HAVE_LOG2 1 #cmakedefine HAVE_LONGJMP 1 #cmakedefine HAVE_LSTAT 1 +#cmakedefine HAVE_MEMALIGN 1 +/* #cmakedefine HAVE_MLOCK 1 see Bug#54662 */ #cmakedefine HAVE_NPTL 1 #cmakedefine HAVE_NL_LANGINFO 1 #cmakedefine HAVE_MADVISE 1 @@ -195,6 +205,8 @@ #cmakedefine HAVE_PREAD 1 #cmakedefine HAVE_PAUSE_INSTRUCTION 1 #cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1 +#cmakedefine HAVE_RDTSCLL 1 +#cmakedefine HAVE_READ_REAL_TIME 1 #cmakedefine HAVE_PTHREAD_ATTR_CREATE 1 #cmakedefine HAVE_PTHREAD_ATTR_GETSTACKSIZE 1 #cmakedefine HAVE_PTHREAD_ATTR_SETPRIO 1 @@ -296,7 +308,7 @@ #define USE_MB 1 #define USE_MB_IDENT 1 - +#cmakedefine HAVE_VALGRIND /* Types we may use */ #ifdef __APPLE__ @@ -321,13 +333,13 @@ #endif #cmakedefine SIZEOF_CHAR @SIZEOF_CHAR@ -#cmakedefine HAVE_CHAR 1 -#cmakedefine HAVE_LONG 1 -#cmakedefine HAVE_CHARP 1 +#define HAVE_CHAR 1 +#define HAVE_LONG 1 +#define HAVE_CHARP 1 #cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@ -#cmakedefine HAVE_SHORT 1 +#define HAVE_SHORT 1 #cmakedefine SIZEOF_INT @SIZEOF_INT@ -#cmakedefine HAVE_INT 1 +#define HAVE_INT 1 #cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@ #cmakedefine HAVE_LONG_LONG 1 #cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@ diff --git a/config/ac-macros/character_sets.m4 b/config/ac-macros/character_sets.m4 index 81967d383ec..c49e4f89316 100644 --- a/config/ac-macros/character_sets.m4 +++ b/config/ac-macros/character_sets.m4 @@ -5,9 +5,6 @@ dnl you must also create strings/ctype-$charset_name.c AC_DIVERT_PUSH(0) -# Any changes to the available character sets must also go into -# include/config-win.h - define(CHARSETS_AVAILABLE0,binary) define(CHARSETS_AVAILABLE1,armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257) define(CHARSETS_AVAILABLE2,cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8) diff --git a/config/ac-macros/ha_ndbcluster.m4 b/config/ac-macros/ha_ndbcluster.m4 index 3718b64f688..533dba09feb 100644 --- a/config/ac-macros/ha_ndbcluster.m4 +++ b/config/ac-macros/ha_ndbcluster.m4 @@ -206,7 +206,7 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [ NDB_DEFS="-DNDB_DEBUG_FULL -DVM_TRACE -DERROR_INSERT -DARRAY_GUARD" else # no extra ndb debug but still do asserts if debug version - if test "$with_debug" = "yes" -o "$with_debug" = "full" + if test "$with_debug" = "yes" then NDB_DEFS="" else diff --git a/configure.cmake b/configure.cmake index ab3d706ee01..c2e1dc4647b 100644 --- a/configure.cmake +++ b/configure.cmake @@ -202,6 +202,7 @@ CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H) CHECK_INCLUDE_FILES (locale.h HAVE_LOCALE_H) CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H) CHECK_INCLUDE_FILES (memory.h HAVE_MEMORY_H) +CHECK_INCLUDE_FILES (ndir.h HAVE_NDIR_H) CHECK_INCLUDE_FILES (netinet/in.h HAVE_NETINET_IN_H) CHECK_INCLUDE_FILES (paths.h HAVE_PATHS_H) CHECK_INCLUDE_FILES (port.h HAVE_PORT_H) @@ -210,7 +211,8 @@ CHECK_INCLUDE_FILES (pwd.h HAVE_PWD_H) CHECK_INCLUDE_FILES (sched.h HAVE_SCHED_H) CHECK_INCLUDE_FILES (select.h HAVE_SELECT_H) CHECK_INCLUDE_FILES (semaphore.h HAVE_SEMAPHORE_H) -CHECK_INCLUDE_FILES (sys/dir.h HAVE_SYS_DIR_H) +CHECK_INCLUDE_FILES ("sys/types.h;sys/dir.h" HAVE_SYS_DIR_H) +CHECK_INCLUDE_FILES (sys/ndir.h HAVE_SYS_NDIR_H) CHECK_INCLUDE_FILES (sys/pte.h HAVE_SYS_PTE_H) CHECK_INCLUDE_FILES (stddef.h HAVE_STDDEF_H) CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H) @@ -236,6 +238,8 @@ CHECK_INCLUDE_FILES (sys/stream.h HAVE_SYS_STREAM_H) CHECK_INCLUDE_FILES (sys/termcap.h HAVE_SYS_TERMCAP_H) CHECK_INCLUDE_FILES ("time.h;sys/timeb.h" HAVE_SYS_TIMEB_H) CHECK_INCLUDE_FILES ("curses.h;term.h" HAVE_TERM_H) +CHECK_INCLUDE_FILES (asm/termbits.h HAVE_ASM_TERMBITS_H) +CHECK_INCLUDE_FILES (termbits.h HAVE_TERMBITS_H) CHECK_INCLUDE_FILES (termios.h HAVE_TERMIOS_H) CHECK_INCLUDE_FILES (termio.h HAVE_TERMIO_H) CHECK_INCLUDE_FILES (termcap.h HAVE_TERMCAP_H) @@ -249,11 +253,14 @@ CHECK_INCLUDE_FILES (sys/param.h HAVE_SYS_PARAM_H) CHECK_INCLUDE_FILES (sys/vadvise.h HAVE_SYS_VADVISE_H) CHECK_INCLUDE_FILES (fnmatch.h HAVE_FNMATCH_H) CHECK_INCLUDE_FILES (stdarg.h HAVE_STDARG_H) -CHECK_INCLUDE_FILES("stdlib.h;sys/un.h" HAVE_SYS_UN_H) +CHECK_INCLUDE_FILES ("stdlib.h;sys/un.h" HAVE_SYS_UN_H) +CHECK_INCLUDE_FILES (vis.h HAVE_VIS_H) +CHECK_INCLUDE_FILES (wchar.h HAVE_WCHAR_H) +CHECK_INCLUDE_FILES (wctype.h HAVE_WCTYPE_H) IF(HAVE_SYS_STREAM_H) # Needs sys/stream.h on Solaris - CHECK_INCLUDE_FILES (sys/stream.h sys/ptem.h HAVE_SYS_PTEM_H) + CHECK_INCLUDE_FILES ("sys/stream.h;sys/ptem.h" HAVE_SYS_PTEM_H) ELSE() CHECK_INCLUDE_FILES (sys/ptem.h HAVE_SYS_PTEM_H) ENDIF() @@ -494,14 +501,18 @@ IF(HAVE_STDINT_H) SET(CMAKE_EXTRA_INCLUDE_FILES stdint.h) ENDIF(HAVE_STDINT_H) +SET(HAVE_VOIDP 1) +SET(HAVE_CHARP 1) +SET(HAVE_LONG 1) +SET(HAVE_SIZE_T 1) + IF(NOT APPLE) - # Prevent some checks on OSX, they return ambigious results - # on universal 32/64 bit binariess - MY_CHECK_TYPE_SIZE("void *" VOIDP) - MY_CHECK_TYPE_SIZE("char *" CHARP) - MY_CHECK_TYPE_SIZE(long LONG) - MY_CHECK_TYPE_SIZE(size_t SIZE_T) +MY_CHECK_TYPE_SIZE("void *" VOIDP) +MY_CHECK_TYPE_SIZE("char *" CHARP) +MY_CHECK_TYPE_SIZE(long LONG) +MY_CHECK_TYPE_SIZE(size_t SIZE_T) ENDIF() + MY_CHECK_TYPE_SIZE(char CHAR) MY_CHECK_TYPE_SIZE(short SHORT) MY_CHECK_TYPE_SIZE(int INT) @@ -749,7 +760,6 @@ IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC) ENDIF() CHECK_SYMBOL_EXISTS(tcgetattr "termios.h" HAVE_TCGETATTR 1) -CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL 1) # # Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7) @@ -795,7 +805,7 @@ ENDIF(NOT HAVE_POSIX_SIGNALS) # Assume regular sprintf SET(SPRINTFS_RETURNS_INT 1) -IF(CMAKE_COMPILER_IS_GNUXX AND HAVE_CXXABI_H) +IF(CMAKE_COMPILER_IS_GNUCXX AND HAVE_CXXABI_H) CHECK_CXX_SOURCE_COMPILES(" #include <cxxabi.h> int main(int argc, char **argv) @@ -984,6 +994,14 @@ configuration. By default gcc built-in sync functions are used, if available and 'smp' configuration otherwise.") MARK_AS_ADVANCED(WITH_ATOMIC_LOCKS MY_ATOMIC_MODE_RWLOCK MY_ATOMIC_MODE_DUMMY) +IF(WITH_VALGRIND) + CHECK_INCLUDE_FILES("valgrind/memcheck.h;valgrind/valgrind.h" + HAVE_VALGRIND_HEADERS) + IF(HAVE_VALGRIND_HEADERS) + SET(HAVE_VALGRIND 1) + ENDIF() +ENDIF() + #-------------------------------------------------------------------- # Check for IPv6 support #-------------------------------------------------------------------- @@ -1038,4 +1056,3 @@ SET(CMAKE_EXTRA_INCLUDE_FILES) CHECK_STRUCT_HAS_MEMBER("struct dirent" d_ino "dirent.h" STRUCT_DIRENT_HAS_D_INO) CHECK_STRUCT_HAS_MEMBER("struct dirent" d_namlen "dirent.h" STRUCT_DIRENT_HAS_D_NAMLEN) SET(SPRINTF_RETURNS_INT 1) - diff --git a/configure.in b/configure.in index a2f0c432681..238cfc50a68 100644 --- a/configure.in +++ b/configure.in @@ -463,16 +463,7 @@ if test "$GCC" != "yes" || expr "$CC" : ".*icc.*" then ABI_CHECK="" else - # Workaround GCC >= 4.5 - See Bug#52514 - case `$CC -dumpversion` in - [[4-9]].[[5-9]]*) - AC_MSG_WARN([ABI check disabled (GCC >= 4.5)]) - ABI_CHECK="" - ;; - *) - ABI_CHECK="abi_check" - ;; - esac + ABI_CHECK="abi_check" fi AC_SUBST(ABI_CHECK) @@ -681,9 +672,8 @@ AC_ARG_ENABLE(assembler, AC_MSG_CHECKING(if we should use assembler functions) # For now we only support assembler on i386 and sparc systems AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386" && $AS strings/strings-x86.s -o checkassembler >/dev/null 2>&1 && test -f checkassembler && (rm -f checkassembler; exit 0;)) -AM_CONDITIONAL(ASSEMBLER_sparc32, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc") AM_CONDITIONAL(ASSEMBLER_sparc64, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparcv9") -AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc32_TRUE" = "") +AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "") if test "$ASSEMBLER_TRUE" = "" then @@ -1210,7 +1200,6 @@ case $SYSTEM_TYPE in # Fixes for HPUX 11.0 compiler if test "$ac_cv_prog_gcc" = "no" then - CFLAGS="$CFLAGS -DHAVE_BROKEN_INLINE" # set working flags first in line, letting override it (i. e. for debug): CXXFLAGS="+O2 $CXXFLAGS" MAX_C_OPTIMIZE="" @@ -1743,22 +1732,14 @@ then fi AC_ARG_WITH(debug, - [ --with-debug Add debug code - --with-debug=full Add debug code (adds memory checker, very slow)], + [AS_HELP_STRING([--with-debug], [Add debug code @<:@default=no@:>@])], [with_debug=$withval], [with_debug=no]) if test "$with_debug" = "yes" then - # Medium debug. AC_DEFINE([DBUG_ON], [1], [Use libdbug]) CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS" CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS" -elif test "$with_debug" = "full" -then - # Full debug. Very slow in some cases - AC_DEFINE([DBUG_ON], [1], [Use libdbug]) - CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX $CXXFLAGS" else # Optimized version. No debug AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug]) @@ -1794,21 +1775,6 @@ else AC_MSG_RESULT([no]) fi -# If we should allow error injection tests -AC_ARG_WITH(error-inject, - AC_HELP_STRING([--with-error-inject],[Enable error injection in MySQL Server]), - [ with_error_inject=$withval ], - [ with_error_inject=no ]) - -if test $with_debug != "no" -then - if test "$with_error_inject" = "yes" - then - AC_DEFINE([ERROR_INJECT_SUPPORT], [1], - [Enable error injection in MySQL Server]) - fi -fi - AC_ARG_WITH([fast-mutexes], AC_HELP_STRING([--with-fast-mutexes], [Compile with fast mutexes (default is disabled)]), @@ -1997,6 +1963,9 @@ fi dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE +AS_IF([test "x$ac_cv_c_inline" = "xno"], + [AC_MSG_WARN([The C compiler does not support inline. Beware that unused + functions might not be eliminated the object files.])]) AC_TYPE_OFF_T AC_STRUCT_ST_RDEV AC_HEADER_TIME @@ -3044,7 +3013,8 @@ fi AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl unittest/Makefile unittest/mytap/Makefile unittest/mytap/t/Makefile dnl - unittest/mysys/Makefile unittest/examples/Makefile dnl + unittest/mysys/Makefile unittest/strings/Makefile dnl + unittest/examples/Makefile dnl strings/Makefile regex/Makefile storage/Makefile dnl man/Makefile BUILD/Makefile vio/Makefile dnl libmysql/Makefile libmysql_r/Makefile client/Makefile dnl @@ -3057,7 +3027,7 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl libmysqld/Makefile libmysqld/examples/Makefile dnl mysql-test/Makefile mysql-test/lib/My/SafeProcess/Makefile dnl sql-bench/Makefile include/mysql_version.h plugin/Makefile win/Makefile dnl - cmake/Makefile + cmake/Makefile packaging/Makefile ) AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h) diff --git a/extra/comp_err.c b/extra/comp_err.c index 3c56770650f..4c40e70f5b7 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -857,7 +857,6 @@ static struct message *parse_message_string(struct message *new_message, static struct errors *parse_error_string(char *str, int er_count) { struct errors *new_error; - char *start; DBUG_ENTER("parse_error_string"); DBUG_PRINT("enter", ("str: %s", str)); @@ -868,7 +867,6 @@ static struct errors *parse_error_string(char *str, int er_count) DBUG_RETURN(0); /* OOM: Fatal error */ /* getting the error name */ - start= str; str= skip_delimiters(str); if (!(new_error->er_name= get_word(&str))) diff --git a/extra/replace.c b/extra/replace.c index bbe70ba586e..2ce374726eb 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -39,7 +39,6 @@ fill_buffer_retaining() is taken from gnu-grep and modified. */ -#define DONT_USE_RAID #include <my_global.h> #include <m_ctype.h> #include <my_sys.h> @@ -52,7 +51,7 @@ typedef struct st_pointer_array { /* when using array-strings */ TYPELIB typelib; /* Pointer to strings */ uchar *str; /* Strings is here */ - int7 *flag; /* Flag about each var. */ + uint8 *flag; /* Flag about each var. */ uint array_allocs,max_count,length,max_length; } POINTER_ARRAY; @@ -267,7 +266,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) } pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+ sizeof(*pa->flag)); - pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); + pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count); pa->length=0; pa->max_length=PS_MALLOC-MALLOC_OVERHEAD; pa->array_allocs=1; @@ -304,7 +303,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) pa->typelib.type_names=new_array; old_count=pa->max_count; pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag)); - pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); + pa->flag= (uint8*) (pa->typelib.type_names+pa->max_count); memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count), old_count*sizeof(*pa->flag)); } diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 432a207f424..6ea818c601b 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -17,7 +17,6 @@ versions into symbolic names. By Sasha Pachev <sasha@mysql.com> */ -#define DONT_USE_RAID #include <my_global.h> #include <m_ctype.h> #include <my_sys.h> diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt index 82d7e5b7581..ea991fee8dc 100644 --- a/extra/yassl/CMakeLists.txt +++ b/extra/yassl/CMakeLists.txt @@ -29,6 +29,11 @@ ENDIF() SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp src/yassl_imp.cpp src/yassl_int.cpp) + +IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION) + SET(YASSL_SOURCES ${YASSL_SOURCES} src/template_instnt.cpp) +ENDIF() + ADD_CONVENIENCE_LIBRARY(yassl ${YASSL_SOURCES}) RESTRICT_SYMBOL_EXPORTS(yassl) diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index f079df8c7ce..86799f961ae 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -884,21 +884,19 @@ void Alert::Process(input_buffer& input, SSL& ssl) else hmac(ssl, verify, data, aSz, alert, true); - // read mac and fill + // read mac and skip fill int digestSz = ssl.getCrypto().get_digest().get_digestSize(); opaque mac[SHA_LEN]; input.read(mac, digestSz); if (ssl.getSecurity().get_parms().cipher_type_ == block) { int ivExtra = 0; - opaque fill; if (ssl.isTLSv1_1()) ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra - aSz - digestSz; - for (int i = 0; i < padSz; i++) - fill = input[AUTO]; + input.set_current(input.get_current() + padSz); } // verify @@ -981,17 +979,17 @@ output_buffer& operator<<(output_buffer& output, const Data& data) void Data::Process(input_buffer& input, SSL& ssl) { int msgSz = ssl.getSecurity().get_parms().encrypt_size_; - int pad = 0, padByte = 0; + int pad = 0, padSz = 0; int ivExtra = 0; if (ssl.getSecurity().get_parms().cipher_type_ == block) { if (ssl.isTLSv1_1()) // IV ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1); - padByte = 1; + padSz = 1; } int digestSz = ssl.getCrypto().get_digest().get_digestSize(); - int dataSz = msgSz - ivExtra - digestSz - pad - padByte; + int dataSz = msgSz - ivExtra - digestSz - pad - padSz; opaque verify[SHA_LEN]; const byte* rawData = input.get_buffer() + input.get_current(); @@ -1020,14 +1018,10 @@ void Data::Process(input_buffer& input, SSL& ssl) hmac(ssl, verify, rawData, dataSz, application_data, true); } - // read mac and fill + // read mac and skip fill opaque mac[SHA_LEN]; - opaque fill; input.read(mac, digestSz); - for (int i = 0; i < pad; i++) - fill = input[AUTO]; - if (padByte) - fill = input[AUTO]; + input.set_current(input.get_current() + pad + padSz); // verify if (dataSz) { @@ -2073,11 +2067,9 @@ void Finished::Process(input_buffer& input, SSL& ssl) if (ssl.isTLSv1_1()) ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); - opaque fill; int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra - HANDSHAKE_HEADER - finishedSz - digestSz; - for (int i = 0; i < padSz; i++) - fill = input[AUTO]; + input.set_current(input.get_current() + padSz); // verify mac if (memcmp(mac, verifyMAC, digestSz)) { diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt index 2c43756b6f4..1781ea6f2fa 100644 --- a/extra/yassl/taocrypt/CMakeLists.txt +++ b/extra/yassl/taocrypt/CMakeLists.txt @@ -26,6 +26,11 @@ SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp) + +IF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION) + SET(TAOCRYPT_SOURCES ${TAOCRYPT_SOURCES} src/template_instnt.cpp) +ENDIF() + ADD_CONVENIENCE_LIBRARY(taocrypt ${TAOCRYPT_SOURCES}) RESTRICT_SYMBOL_EXPORTS(taocrypt) diff --git a/include/Makefile.am b/include/Makefile.am index ad023083829..e30588de065 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -33,16 +33,16 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \ $(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h -noinst_HEADERS = config-win.h lf.h my_bit.h \ +noinst_HEADERS = lf.h my_bit.h \ heap.h my_bitmap.h my_uctype.h password.h \ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h sha2.h \ - my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \ + my_aes.h my_tree.h hash.h thr_alarm.h \ thr_lock.h t_ctype.h violite.h my_md5.h base64.h \ my_handler.h my_time.h service_versions.h \ my_rdtsc.h mysql/psi/psi_abi_v1.h mysql/psi/psi_abi_v2.h \ - my_vle.h my_user.h my_atomic.h atomic/nolock.h \ + my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \ atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \ atomic/solaris.h mysql/innodb_priv.h my_compiler.h diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h index 100ff80cacd..d03d28f572e 100644 --- a/include/atomic/gcc_builtins.h +++ b/include/atomic/gcc_builtins.h @@ -22,8 +22,9 @@ v= __sync_lock_test_and_set(a, v); #define make_atomic_cas_body(S) \ int ## S sav; \ - sav= __sync_val_compare_and_swap(a, *cmp, set); \ - if (!(ret= (sav == *cmp))) *cmp= sav; + int ## S cmp_val= *cmp; \ + sav= __sync_val_compare_and_swap(a, cmp_val, set);\ + if (!(ret= (sav == cmp_val))) *cmp= sav #ifdef MY_ATOMIC_MODE_DUMMY #define make_atomic_load_body(S) ret= *a diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h index 5a0c41d9078..4c871473b60 100644 --- a/include/atomic/nolock.h +++ b/include/atomic/nolock.h @@ -29,21 +29,22 @@ We choose implementation as follows: ------------------------------------ On Windows using Visual C++ the native implementation should be - preferrable. When using gcc we prefer the native x86 implementation, - we prefer the Solaris implementation before the gcc because of - stability preference, we choose gcc implementation if nothing else - works on gcc. If neither Visual C++ or gcc we still choose the - Solaris implementation on Solaris (mainly for SunStudio compiles. + preferrable. When using gcc we prefer the Solaris implementation + before the gcc because of stability preference, we choose gcc + builtins if available, otherwise we choose the somewhat broken + native x86 implementation. If neither Visual C++ or gcc we still + choose the Solaris implementation on Solaris (mainly for SunStudio + compilers). */ # if defined(_MSV_VER) # include "generic-msvc.h" # elif __GNUC__ -# if defined(__i386__) || defined(__x86_64__) -# include "x86-gcc.h" -# elif defined(HAVE_SOLARIS_ATOMIC) +# if defined(HAVE_SOLARIS_ATOMIC) # include "solaris.h" # elif defined(HAVE_GCC_ATOMIC_BUILTINS) # include "gcc_builtins.h" +# elif defined(__i386__) || defined(__x86_64__) +# include "x86-gcc.h" # endif # elif defined(HAVE_SOLARIS_ATOMIC) # include "solaris.h" diff --git a/include/atomic/solaris.h b/include/atomic/solaris.h index fc9f369c707..5643f878cd2 100644 --- a/include/atomic/solaris.h +++ b/include/atomic/solaris.h @@ -20,11 +20,17 @@ #define MY_ATOMIC_MODE "solaris-atomic" +#if defined(__GNUC__) +#define atomic_typeof(T,V) __typeof__(V) +#else +#define atomic_typeof(T,V) T +#endif + #define uintptr_t void * #define atomic_or_ptr_nv(X,Y) (void *)atomic_or_ulong_nv((volatile ulong_t *)X, Y) #define make_atomic_cas_body(S) \ - uint ## S ## _t sav; \ + atomic_typeof(uint ## S ## _t, *cmp) sav; \ sav = atomic_cas_ ## S( \ (volatile uint ## S ## _t *)a, \ (uint ## S ## _t)*cmp, \ diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 61b94a48568..8baa84e110e 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -53,18 +53,29 @@ #endif #define make_atomic_add_body32 \ - asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a)) + asm volatile (LOCK_prefix "; xadd %0, %1;" \ + : "+r" (v), "=m" (*a) \ + : "m" (*a) \ + : "memory") #define make_atomic_cas_body32 \ + __typeof__(*cmp) sav; \ asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \ - : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set)) + : "=m" (*a), "=a" (sav), "=q" (ret) \ + : "r" (set), "m" (*a), "a" (*cmp) \ + : "memory"); \ + if (!ret) \ + *cmp= sav #ifdef __x86_64__ #define make_atomic_add_body64 make_atomic_add_body32 #define make_atomic_cas_body64 make_atomic_cas_body32 -#define make_atomic_fas_body(S) \ - asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a)) +#define make_atomic_fas_body(S) \ + asm volatile ("xchg %0, %1;" \ + : "+r" (v), "=m" (*a) \ + : "m" (*a) \ + : "memory") /* Actually 32-bit reads/writes are always atomic on x86 @@ -73,9 +84,14 @@ #define make_atomic_load_body(S) \ ret=0; \ asm volatile (LOCK_prefix "; cmpxchg %2, %0" \ - : "+m" (*a), "+a" (ret): "r" (ret)) + : "=m" (*a), "=a" (ret) \ + : "r" (ret), "m" (*a) \ + : "memory") #define make_atomic_store_body(S) \ - asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v)) + asm volatile ("; xchg %0, %1;" \ + : "=m" (*a), "+r" (v) \ + : "m" (*a) \ + : "memory") #else /* @@ -104,12 +120,13 @@ platforms the much simpler make_atomic_cas_body32 will work fine. */ -#define make_atomic_cas_body64 \ - int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32); \ - asm volatile ("push %%ebx; movl %3, %%ebx;" \ - LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx"\ - : "+m" (*a), "+A" (*cmp), "=c" (ret) \ - :"m" (ebx), "c" (ecx)) +#define make_atomic_cas_body64 \ + int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32); \ + asm volatile ("push %%ebx; movl %3, %%ebx;" \ + LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx" \ + : "=m" (*a), "+A" (*cmp), "=c" (ret) \ + : "m" (ebx), "c" (ecx), "m" (*a) \ + : "memory", "esp") #endif /* diff --git a/include/config-win.h b/include/config-win.h deleted file mode 100644 index 9e8bb19c12d..00000000000 --- a/include/config-win.h +++ /dev/null @@ -1,441 +0,0 @@ -#ifndef CONFIG_WIN_INCLUDED -#define CONFIG_WIN_INCLUDED - -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Defines for Win32 to make it compatible for MySQL */ - -#define BIG_TABLES - -/* - Minimal version of Windows we should be able to run on. - Currently Windows XP. -*/ -#define _WIN32_WINNT 0x0501 - - -#if defined(_MSC_VER) && _MSC_VER >= 1400 -/* Avoid endless warnings about sprintf() etc. being unsafe. */ -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif - -#include <sys/locking.h> -#include <winsock2.h> -#include <Ws2tcpip.h> -#include <fcntl.h> -#include <io.h> -#include <malloc.h> -#include <sys/stat.h> -#include <process.h> /* getpid()*/ - - -#define HAVE_SMEM 1 - -#if defined(_WIN64) || defined(WIN64) -#define SYSTEM_TYPE "Win64" -#elif defined(_WIN32) || defined(WIN32) -#define SYSTEM_TYPE "Win32" -#else -#define SYSTEM_TYPE "Windows" -#endif - -#if defined(_M_IA64) -#define MACHINE_TYPE "ia64" -#elif defined(_M_IX86) -#define MACHINE_TYPE "ia32" -#elif defined(_M_ALPHA) -#define MACHINE_TYPE "axp" -#else -#define MACHINE_TYPE "unknown" /* Define to machine type name */ -#endif - -#if !(defined(_WIN64) || defined(WIN64)) -#ifndef _WIN32 -#define _WIN32 /* Compatible with old source */ -#endif -#ifndef __WIN32__ -#define __WIN32__ -#endif -#endif /* _WIN64 */ -#ifndef __WIN__ -#define __WIN__ /* To make it easier in VC++ */ -#endif - -#ifndef MAX_INDEXES -#define MAX_INDEXES 64 -#endif - -/* File and lock constants */ -#ifdef __BORLANDC__ -#define F_RDLCK LK_NBLCK /* read lock */ -#define F_WRLCK LK_NBRLCK /* write lock */ -#define F_UNLCK LK_UNLCK /* remove lock(s) */ -#else -#define F_RDLCK _LK_NBLCK /* read lock */ -#define F_WRLCK _LK_NBRLCK /* write lock */ -#define F_UNLCK _LK_UNLCK /* remove lock(s) */ -#endif - -#define F_EXCLUSIVE 1 /* We have only exclusive locking */ -#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */ -#define F_OK 0 /* parameter to access() */ -#define W_OK 2 - -#define S_IROTH S_IREAD /* for my_lib */ - -/* Winsock2 constant (Vista SDK and later)*/ -#define IPPROTO_IPV6 41 -#ifndef IPV6_V6ONLY -#define IPV6_V6ONLY 27 -#endif - -#ifdef __BORLANDC__ -#define FILE_BINARY O_BINARY /* my_fopen in binary mode */ -#define O_TEMPORARY 0 -#define O_SHORT_LIVED 0 -#define SH_DENYNO _SH_DENYNO -#else -#define O_BINARY _O_BINARY /* compability with older style names */ -#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */ -#define O_TEMPORARY _O_TEMPORARY -#define O_SHORT_LIVED _O_SHORT_LIVED -#define SH_DENYNO _SH_DENYNO -#endif -#define NO_OPEN_3 /* For my_create() */ - -#define SIGQUIT SIGTERM /* No SIGQUIT */ - -#undef _REENTRANT /* Crashes something for win32 */ -#undef SAFE_MUTEX /* Can't be used on windows */ - -#if defined(_MSC_VER) && _MSC_VER >= 1310 -#define LL(A) A##ll -#define ULL(A) A##ull -#else -#define LL(A) ((__int64) A) -#define ULL(A) ((unsigned __int64) A) -#endif - -#define LONGLONG_MIN LL(0x8000000000000000) -#define LONGLONG_MAX LL(0x7FFFFFFFFFFFFFFF) -#define ULONGLONG_MAX ULL(0xFFFFFFFFFFFFFFFF) - -/* Type information */ - -#if !defined(HAVE_UINT) -#undef HAVE_UINT -#define HAVE_UINT -typedef unsigned short ushort; -typedef unsigned int uint; -#endif /* !defined(HAVE_UINT) */ - -typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ -typedef __int64 longlong; -#ifndef HAVE_SIGSET_T -typedef int sigset_t; -#endif -#define longlong_defined -/* - off_t should not be __int64 because of conflicts in header files; - Use my_off_t or os_off_t instead -*/ -#ifndef HAVE_OFF_T -typedef long off_t; -#endif -typedef __int64 os_off_t; -#ifdef _WIN64 -typedef UINT_PTR rf_SetTimer; -#else -typedef uint rf_SetTimer; -#endif - -#ifndef HAVE_SIZE_T -#ifndef _SIZE_T_DEFINED -typedef SIZE_T size_t; -#define _SIZE_T_DEFINED -#endif -#endif - -#ifndef HAVE_SSIZE_T -#ifndef _SSIZE_T_DEFINED -typedef SSIZE_T ssize_t; -#define _SSIZE_T_DEFINED -#endif -#endif - -#define Socket_defined -#define my_socket SOCKET -#define SIGPIPE SIGINT -#define RETQSORTTYPE void -#define QSORT_TYPE_IS_VOID -#define RETSIGTYPE void -#define SOCKET_SIZE_TYPE int -#define my_socket_defined -#define byte_defined -#define STDCALL __stdcall /* Used by libmysql.dll */ -#define isnan(X) _isnan(X) -#define finite(X) _finite(X) - -#ifndef MYSQL_CLIENT_NO_THREADS -#define THREAD -#endif -#define VOID_SIGHANDLER -#define SIZEOF_CHAR 1 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_OFF_T 8 -#ifdef _WIN64 -#define SIZEOF_CHARP 8 -#else -#define SIZEOF_CHARP 4 -#endif -#define HAVE_BROKEN_NETINET_INCLUDES -#ifdef _WIN32 -#define HAVE_NAMED_PIPE /* We can only create pipes on NT */ -#endif - -/* ERROR is defined in wingdi.h */ -#undef ERROR - -/* We need to close files to break connections on shutdown */ -#ifndef SIGNAL_WITH_VIO_CLOSE -#define SIGNAL_WITH_VIO_CLOSE -#endif - -/* All windows servers should support .sym files */ -#undef USE_SYMDIR -#define USE_SYMDIR - -/* If LOAD DATA LOCAL INFILE should be enabled by default */ -#define ENABLED_LOCAL_INFILE 1 - -/* If query profiling should be enabled by default */ -#define ENABLED_PROFILING 1 - -/* Convert some simple functions to Posix */ - -#define my_sigset(A,B) signal((A),(B)) -#define finite(A) _finite(A) -#define sleep(A) Sleep((A)*1000) -#define popen(A,B) _popen((A),(B)) -#define pclose(A) _pclose(A) - -#ifndef __BORLANDC__ -#define access(A,B) _access(A,B) -#endif - -#if !defined(__cplusplus) -#define inline __inline -#endif /* __cplusplus */ - -#ifdef _WIN64 -#define ulonglong2double(A) ((double) (ulonglong) (A)) -#define my_off_t2double(A) ((double) (my_off_t) (A)) - -#else -inline double ulonglong2double(ulonglong value) -{ - longlong nr=(longlong) value; - if (nr >= 0) - return (double) nr; - return (18446744073709551616.0 + (double) nr); -} -#define my_off_t2double(A) ulonglong2double(A) -#endif /* _WIN64 */ - -inline ulonglong double2ulonglong(double d) -{ - double t= d - (double) 0x8000000000000000ULL; - - if (t >= 0) - return ((ulonglong) t) + 0x8000000000000000ULL; - return (ulonglong) d; -} - -#if SIZEOF_OFF_T > 4 -#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C)) -#define tell(A) _telli64(A) -#endif - -#define STACK_DIRECTION -1 - -/* Difference between GetSystemTimeAsFileTime() and now() */ -#define OFFSET_TO_EPOCH ULL(116444736000000000) - -#define HAVE_PERROR -#define HAVE_VFPRINT -#define HAVE_RENAME /* Have rename() as function */ -#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */ -#define HAVE_LONG_JMP /* Have long jump function */ -#define HAVE_LOCKING /* have locking() call */ -#define HAVE_ERRNO_AS_DEFINE /* errno is a define */ -#define HAVE_STDLIB /* everything is include in this file */ -#define HAVE_MEMCPY -#define HAVE_MEMMOVE -#define HAVE_GETCWD -#define HAVE_TELL -#define HAVE_TZNAME -#define HAVE_PUTENV -#define HAVE_SELECT -#define HAVE_SETLOCALE -#define HAVE_SOCKET /* Giangi */ -#define HAVE_FLOAT_H -#define HAVE_LIMITS_H -#define HAVE_STDDEF_H -#define NO_FCNTL_NONBLOCK /* No FCNTL */ -#define HAVE_ALLOCA -#define HAVE_STRPBRK -#define HAVE_STRSTR -#define HAVE_COMPRESS -#define HAVE_CREATESEMAPHORE -#define HAVE_ISNAN -#define HAVE_FINITE -#define HAVE_QUERY_CACHE -#define SPRINTF_RETURNS_INT -#define HAVE_SETFILEPOINTER -#define HAVE_VIO_READ_BUFF -#if defined(_MSC_VER) && _MSC_VER >= 1400 -/* strnlen() appeared in Studio 2005 */ -#define HAVE_STRNLEN -#endif -#define HAVE_WINSOCK2 - -#define strcasecmp stricmp -#define strncasecmp strnicmp - -#define HAVE_SNPRINTF 1 -#define snprintf _snprintf - -#define HAVE_SETENV 1 -#define setenv(VAR,VAL,X) _putenv_s(VAR,VAL) - -#ifdef _MSC_VER -#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */ -#define HAVE_ANSI_INCLUDE -#define HAVE_SYS_UTIME_H -#define HAVE_STRTOUL -#endif -#define my_reinterpret_cast(A) reinterpret_cast <A> -#define my_const_cast(A) const_cast<A> - - -/* MYSQL OPTIONS */ - -#ifdef _CUSTOMCONFIG_ -#include <custom_conf.h> -#else -#ifndef CMAKE_CONFIGD -#define DEFAULT_MYSQL_HOME "c:\\mysql" -#define MYSQL_DATADIR "c:\\mysql\\data" -#define PACKAGE "mysql" -#define DEFAULT_BASEDIR "C:\\" -#define SHAREDIR "share" -#define DEFAULT_CHARSET_HOME "C:/mysql/" -#endif -#endif -#ifndef DEFAULT_HOME_ENV -#define DEFAULT_HOME_ENV MYSQL_HOME -#endif -#ifndef DEFAULT_GROUP_SUFFIX_ENV -#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX -#endif - -/* File name handling */ - -#define FN_LIBCHAR '\\' -#define FN_ROOTDIR "\\" -#define FN_DEVCHAR ':' -#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */ -#define FN_NO_CASE_SENSE /* Files are not case-sensitive */ -#define OS_FILE_LIMIT UINT_MAX /* No limit*/ - -#define DO_NOT_REMOVE_THREAD_WRAPPERS -#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V)) -#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V)) -/* The following is only used for statistics, so it should be good enough */ -#ifdef _WIN32 -#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C)) -#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C)) -#endif - -#define shared_memory_buffer_length 16000 -#define default_shared_memory_base_name "MYSQL" - -#define HAVE_SPATIAL 1 -#define HAVE_RTREE_KEYS 1 - -#define HAVE_OPENSSL 1 -#define HAVE_YASSL 1 - -#define ENABLED_PROFILING 1 - -/* - Our Windows binaries include all character sets which MySQL supports. - Any changes to the available character sets must also go into - config/ac-macros/character_sets.m4 -*/ - -#define MYSQL_DEFAULT_CHARSET_NAME "latin1" -#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" - -#define USE_MB 1 -#define USE_MB_IDENT 1 -#define USE_STRCOLL 1 - -#define HAVE_CHARSET_armscii8 -#define HAVE_CHARSET_ascii -#define HAVE_CHARSET_big5 1 -#define HAVE_CHARSET_cp1250 1 -#define HAVE_CHARSET_cp1251 -#define HAVE_CHARSET_cp1256 -#define HAVE_CHARSET_cp1257 -#define HAVE_CHARSET_cp850 -#define HAVE_CHARSET_cp852 -#define HAVE_CHARSET_cp866 -#define HAVE_CHARSET_cp932 1 -#define HAVE_CHARSET_dec8 -#define HAVE_CHARSET_eucjpms 1 -#define HAVE_CHARSET_euckr 1 -#define HAVE_CHARSET_gb2312 1 -#define HAVE_CHARSET_gbk 1 -#define HAVE_CHARSET_geostd8 -#define HAVE_CHARSET_greek -#define HAVE_CHARSET_hebrew -#define HAVE_CHARSET_hp8 -#define HAVE_CHARSET_keybcs2 -#define HAVE_CHARSET_koi8r -#define HAVE_CHARSET_koi8u -#define HAVE_CHARSET_latin1 1 -#define HAVE_CHARSET_latin2 1 -#define HAVE_CHARSET_latin5 -#define HAVE_CHARSET_latin7 -#define HAVE_CHARSET_macce -#define HAVE_CHARSET_macroman -#define HAVE_CHARSET_sjis 1 -#define HAVE_CHARSET_swe7 -#define HAVE_CHARSET_tis620 1 -#define HAVE_CHARSET_ucs2 1 -#define HAVE_CHARSET_ujis 1 -#define HAVE_CHARSET_utf8 1 -#define HAVE_CHARSET_utf8mb4 1 -#define HAVE_CHARSET_utf16 1 -#define HAVE_CHARSET_utf32 1 - -#define HAVE_UCA_COLLATIONS 1 -#define HAVE_BOOL 1 - -#endif /* CONFIG_WIN_INCLUDED */ diff --git a/include/lf.h b/include/lf.h index d1f592d1047..e9fb094493f 100644 --- a/include/lf.h +++ b/include/lf.h @@ -187,8 +187,6 @@ typedef struct st_lf_allocator { uchar * volatile top; uint element_size; uint32 volatile mallocs; - void (*constructor)(uchar *); /* called, when an object is malloc()'ed */ - void (*destructor)(uchar *); /* called, when an object is free()'d */ } LF_ALLOCATOR; void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset); @@ -222,8 +220,7 @@ C_MODE_START #define LF_HASH_UNIQUE 1 -/* lf_hash overhead per element (that is, sizeof(LF_SLIST) */ -extern const int LF_HASH_OVERHEAD; +/* lf_hash overhead per element is sizeof(LF_SLIST). */ typedef struct { LF_DYNARRAY array; /* hash itself */ diff --git a/include/m_string.h b/include/m_string.h index c2779c63941..2ec4eb64c8e 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -92,26 +92,12 @@ extern char _dig_vec_lower[]; #define strmake_overlapp(A,B,C) strmake(A,B,C) #endif -#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */ -#define memcpy_fixed(A,B,C) bmove((A),(B),(C)) -#else -#define memcpy_fixed(A,B,C) memcpy((A),(B),(C)) -#endif - -#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512) -#define bmove512(A,B,C) memcpy(A,B,C) -#endif - /* Prototypes for string functions */ #if !defined(bfill) && !defined(HAVE_BFILL) extern void bfill(uchar *dst,size_t len,pchar fill); #endif -#ifndef bmove512 -extern void bmove512(uchar *dst,const uchar *src,size_t len); -#endif - #if !defined(HAVE_BMOVE) && !defined(bmove) extern void bmove(uuchar *dst, const uchar *src,size_t len); #endif @@ -122,12 +108,7 @@ extern void bchange(uchar *dst,size_t old_len,const uchar *src, extern void strappend(char *s,size_t len,pchar fill); extern char *strend(const char *s); extern char *strcend(const char *, pchar); -extern char *strfield(char *src,int fields,int chars,int blanks, - int tabch); extern char *strfill(char * s,size_t len,pchar fill); -extern size_t strinstr(const char *str,const char *search); -extern size_t r_strinstr(const char *str, size_t from, const char *search); -extern char *strkey(char *dst,char *head,char *tail,char *flags); extern char *strmake(char *dst,const char *src,size_t length); #ifndef strmov @@ -136,35 +117,16 @@ extern char *strmov(char *dst,const char *src); extern char *strmov_overlapp(char *dst,const char *src); #endif extern char *strnmov(char *dst, const char *src, size_t n); -extern char *strsuff(const char *src, const char *suffix); extern char *strcont(const char *src, const char *set); -extern char *strxcat(char *dst, const char *src, ...); extern char *strxmov(char *dst, const char *src, ...); -extern char *strxcpy(char *dst, const char *src, ...); -extern char *strxncat(char *dst, size_t len, const char *src, ...); extern char *strxnmov(char *dst, size_t len, const char *src, ...); -extern char *strxncpy(char *dst, size_t len, const char *src, ...); /* Prototypes of normal stringfunctions (with may ours) */ - -#ifdef WANT_STRING_PROTOTYPES -extern char *strcat(char *, const char *); -extern char *strchr(const char *, pchar); -extern char *strrchr(const char *, pchar); -extern char *strcpy(char *, const char *); -extern int strcmp(const char *, const char *); -#ifndef __GNUC__ -extern size_t strlen(const char *); -#endif -#endif #ifndef HAVE_STRNLEN extern size_t strnlen(const char *s, size_t n); #endif #if !defined(__cplusplus) -#ifndef HAVE_STRPBRK -extern char *strpbrk(const char *, const char *); -#endif #ifndef HAVE_STRSTR extern char *strstr(const char *, const char *); #endif diff --git a/include/my_atomic.h b/include/my_atomic.h index 8ba3e201730..c2d514012d9 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -20,6 +20,7 @@ This header defines five atomic operations: my_atomic_add#(&var, what) + 'Fetch and Add' add 'what' to *var, and return the old value of *var my_atomic_fas#(&var, what) @@ -27,9 +28,10 @@ store 'what' in *var, and return the old value of *var my_atomic_cas#(&var, &old, new) - 'Compare And Swap' + An odd variation of 'Compare And Set/Swap' if *var is equal to *old, then store 'new' in *var, and return TRUE otherwise store *var in *old, and return FALSE + Usually, &old should not be accessed if the operation is successful. my_atomic_load#(&var) return *var @@ -153,10 +155,8 @@ make_transparent_unions(ptr) #define U_set set #endif /* __GCC__ transparent_union magic */ -#ifdef HAVE_INLINE - #define make_atomic_cas(S) \ -STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \ +static inline int my_atomic_cas ## S(Uv_ ## S U_a, \ Uv_ ## S U_cmp, U_ ## S U_set) \ { \ int8 ret; \ @@ -165,7 +165,7 @@ STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \ } #define make_atomic_add(S) \ -STATIC_INLINE int ## S my_atomic_add ## S( \ +static inline int ## S my_atomic_add ## S( \ Uv_ ## S U_a, U_ ## S U_v) \ { \ make_atomic_add_body(S); \ @@ -173,7 +173,7 @@ STATIC_INLINE int ## S my_atomic_add ## S( \ } #define make_atomic_fas(S) \ -STATIC_INLINE int ## S my_atomic_fas ## S( \ +static inline int ## S my_atomic_fas ## S( \ Uv_ ## S U_a, U_ ## S U_v) \ { \ make_atomic_fas_body(S); \ @@ -181,7 +181,7 @@ STATIC_INLINE int ## S my_atomic_fas ## S( \ } #define make_atomic_load(S) \ -STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \ +static inline int ## S my_atomic_load ## S(Uv_ ## S U_a) \ { \ int ## S ret; \ make_atomic_load_body(S); \ @@ -189,31 +189,12 @@ STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \ } #define make_atomic_store(S) \ -STATIC_INLINE void my_atomic_store ## S( \ +static inline void my_atomic_store ## S( \ Uv_ ## S U_a, U_ ## S U_v) \ { \ make_atomic_store_body(S); \ } -#else /* no inline functions */ - -#define make_atomic_add(S) \ -extern int ## S my_atomic_add ## S(Uv_ ## S U_a, U_ ## S U_v); - -#define make_atomic_fas(S) \ -extern int ## S my_atomic_fas ## S(Uv_ ## S U_a, U_ ## S U_v); - -#define make_atomic_cas(S) \ -extern int my_atomic_cas ## S(Uv_ ## S U_a, Uv_ ## S U_cmp, U_ ## S U_set); - -#define make_atomic_load(S) \ -extern int ## S my_atomic_load ## S(Uv_ ## S U_a); - -#define make_atomic_store(S) \ -extern void my_atomic_store ## S(Uv_ ## S U_a, U_ ## S U_v); - -#endif /* HAVE_INLINE */ - #ifdef MY_ATOMIC_HAS_8_16 make_atomic_cas(8) make_atomic_cas(16) diff --git a/include/my_attribute.h b/include/my_attribute.h index 8309d85f20a..d35b3013bdd 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -21,6 +21,12 @@ #ifndef _my_attribute_h #define _my_attribute_h +#if defined(__GNUC__) +# ifndef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +# endif +#endif + /* Disable __attribute__() on gcc < 2.7, g++ < 3.4, and non-gcc compilers. Some forms of __attribute__ are actually supported in earlier versions of diff --git a/include/my_bit.h b/include/my_bit.h index 5cbf4f8b83e..b396b84b0d8 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -6,7 +6,6 @@ */ C_MODE_START -#ifdef HAVE_INLINE extern const char _my_bits_nbits[256]; extern const uchar _my_bits_reverse_table[256]; @@ -16,14 +15,14 @@ extern const uchar _my_bits_reverse_table[256]; This can be used to divide a number with value by doing a shift instead */ -STATIC_INLINE uint my_bit_log2(ulong value) +static inline uint my_bit_log2(ulong value) { uint bit; for (bit=0 ; value > 1 ; value>>=1, bit++) ; return bit; } -STATIC_INLINE uint my_count_bits(ulonglong v) +static inline uint my_count_bits(ulonglong v) { #if SIZEOF_LONG_LONG > 4 /* The following code is a bit faster on 16 bit machines than if we would @@ -45,7 +44,7 @@ STATIC_INLINE uint my_count_bits(ulonglong v) #endif } -STATIC_INLINE uint my_count_bits_ushort(ushort v) +static inline uint my_count_bits_ushort(ushort v) { return _my_bits_nbits[v]; } @@ -70,7 +69,7 @@ STATIC_INLINE uint my_count_bits_ushort(ushort v) Comments shows how this works with 01100000000000000000000000001011 */ -STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v) +static inline uint32 my_round_up_to_next_power(uint32 v) { v--; /* 01100000000000000000000000001010 */ v|= v >> 1; /* 01110000000000000000000000001111 */ @@ -81,7 +80,7 @@ STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v) return v+1; /* 10000000000000000000000000000000 */ } -STATIC_INLINE uint32 my_clear_highest_bit(uint32 v) +static inline uint32 my_clear_highest_bit(uint32 v) { uint32 w=v >> 1; w|= w >> 1; @@ -92,7 +91,7 @@ STATIC_INLINE uint32 my_clear_highest_bit(uint32 v) return v & w; } -STATIC_INLINE uint32 my_reverse_bits(uint32 key) +static inline uint32 my_reverse_bits(uint32 key) { return (_my_bits_reverse_table[ key & 255] << 24) | @@ -101,14 +100,6 @@ STATIC_INLINE uint32 my_reverse_bits(uint32 key) _my_bits_reverse_table[(key>>24) ]; } -#else /* HAVE_INLINE */ -extern uint my_bit_log2(ulong value); -extern uint32 my_round_up_to_next_power(uint32 v); -uint32 my_clear_highest_bit(uint32 v); -uint32 my_reverse_bits(uint32 key); -extern uint my_count_bits(ulonglong v); -extern uint my_count_bits_ushort(ushort v); -#endif /* HAVE_INLINE */ C_MODE_END #endif /* MY_BIT_INCLUDED */ diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 0caf2da12d0..548eec14d6e 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -69,28 +69,6 @@ extern void bitmap_copy(MY_BITMAP *map, const MY_BITMAP *map2); extern uint bitmap_lock_set_next(MY_BITMAP *map); extern void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit); -#ifdef NOT_USED -extern uint bitmap_lock_bits_set(const MY_BITMAP *map); -extern my_bool bitmap_lock_is_set_all(const MY_BITMAP *map); -extern uint bitmap_lock_get_first(const MY_BITMAP *map); -extern uint bitmap_lock_get_first_set(const MY_BITMAP *map); -extern my_bool bitmap_lock_is_subset(const MY_BITMAP *map1, - const MY_BITMAP *map2); -extern my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size); -extern my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit); -extern my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map); -extern my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2); -extern void bitmap_lock_set_all(MY_BITMAP *map); -extern void bitmap_lock_clear_all(MY_BITMAP *map); -extern void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit); -extern void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit); -extern void bitmap_lock_set_prefix(MY_BITMAP *map, uint prefix_size); -extern void bitmap_lock_intersect(MY_BITMAP *map, const MY_BITMAP *map2); -extern void bitmap_lock_subtract(MY_BITMAP *map, const MY_BITMAP *map2); -extern void bitmap_lock_union(MY_BITMAP *map, const MY_BITMAP *map2); -extern void bitmap_lock_xor(MY_BITMAP *map, const MY_BITMAP *map2); -extern void bitmap_lock_invert(MY_BITMAP *map); -#endif /* Fast, not thread safe, bitmap functions */ #define bitmap_buffer_size(bits) (((bits)+31)/32)*4 #define no_bytes_in_map(map) (((map)->n_bits + 7)/8) diff --git a/include/my_global.h b/include/my_global.h index b0db017c565..1c615cc5ca2 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -86,24 +86,12 @@ #define IF_WIN(A,B) B #endif -#ifndef DBUG_OFF -#define IF_DBUG(A,B) A -#else -#define IF_DBUG(A,B) B -#endif - #ifdef HAVE_purify #define IF_PURIFY(A,B) A #else #define IF_PURIFY(A,B) B #endif -#ifdef DISABLE_GRANT_OPTIONS -#define IF_DISABLE_GRANT_OPTIONS(A,B) A -#else -#define IF_DISABLE_GRANT_OPTIONS(A,B) B -#endif - #ifndef EMBEDDED_LIBRARY #ifdef WITH_NDB_BINLOG #define HAVE_NDB_BINLOG 1 @@ -210,110 +198,6 @@ #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) - -/* - The macros below are useful in optimising places where it has been - discovered that cache misses stall the process and where a prefetch - of the cache line can improve matters. This is available in GCC 3.1.1 - and later versions. - PREFETCH_READ says that addr is going to be used for reading and that - it is to be kept in caches if possible for a while - PREFETCH_WRITE also says that the item to be cached is likely to be - updated. - The *LOCALITY scripts are also available for experimentation purposes - mostly and should only be used if they are verified to improve matters. - For more input see GCC manual (available in GCC 3.1.1 and later) -*/ - -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10) -#define PREFETCH_READ(addr) __builtin_prefetch(addr, 0, 3) -#define PREFETCH_WRITE(addr) \ - __builtin_prefetch(addr, 1, 3) -#define PREFETCH_READ_LOCALITY(addr, locality) \ - __builtin_prefetch(addr, 0, locality) -#define PREFETCH_WRITE_LOCALITY(addr, locality) \ - __builtin_prefetch(addr, 1, locality) -#else -#define PREFETCH_READ(addr) -#define PREFETCH_READ_LOCALITY(addr, locality) -#define PREFETCH_WRITE(addr) -#define PREFETCH_WRITE_LOCALITY(addr, locality) -#endif - -/* - The following macro is used to ensure that code often used in most - SQL statements and definitely for parts of the SQL processing are - kept in a code segment by itself. This has the advantage that the - risk of common code being overlapping in caches of the CPU is less. - This can be a cause of big performance problems. - Routines should be put in this category with care and when they are - put there one should also strive to make as much of the error handling - as possible (or uncommon code of the routine) to execute in a - separate method to avoid moving to much code to this code segment. - - It is very easy to use, simply add HOT_METHOD at the end of the - function declaration. - For more input see GCC manual (available in GCC 2.95 and later) -*/ - -#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR > 94) -#define HOT_METHOD \ - __attribute__ ((section ("hot_code_section"))) -#else -#define HOT_METHOD -#endif - -/* - The following macro is used to ensure that popular global variables - are located next to each other to avoid that they contend for the - same cache lines. - - It is very easy to use, simply add HOT_DATA at the end of the declaration - of the variable, the variable must be initialised because of the way - that linker works so a declaration using HOT_DATA should look like: - uint global_hot_data HOT_DATA = 0; - For more input see GCC manual (available in GCC 2.95 and later) -*/ - -#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR > 94) -#define HOT_DATA \ - __attribute__ ((section ("hot_data_section"))) -#else -#define HOT_DATA -#endif - -/* - now let's figure out if inline functions are supported - autoconf defines 'inline' to be empty, if not -*/ -#define inline_test_1(X) X ## 1 -#define inline_test_2(X) inline_test_1(X) -#if inline_test_2(inline) != 1 -#define HAVE_INLINE -#else -#warning No "inline" support in C, all "static inline" functions will be instantiated in every .o file!!! -#endif -#undef inline_test_2 -#undef inline_test_1 -/* helper macro for "instantiating" inline functions */ -#define STATIC_INLINE static inline - -/* - The following macros are used to control inlining a bit more than - usual. These macros are used to ensure that inlining always or - never occurs (independent of compilation mode). - For more input see GCC manual (available in GCC 3.1.1 and later) -*/ - -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR > 10) -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#define NEVER_INLINE __attribute__ ((noinline)) -#else -#define ALWAYS_INLINE -#define NEVER_INLINE -#endif - - /* Fix problem with S_ISLNK() on Linux */ #if defined(TARGET_OS_LINUX) || defined(__GLIBC__) #undef _GNU_SOURCE @@ -423,10 +307,6 @@ C_MODE_END #undef HAVE_PREAD #undef HAVE_PWRITE #endif -#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus) -#undef inline -#define inline -#endif #ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */ #undef HAVE_GETHOSTBYNAME_R @@ -441,18 +321,6 @@ C_MODE_END #error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile" #endif - -/* Fix a bug in gcc 2.8.0 on IRIX 6.2 */ -#if SIZEOF_LONG == 4 && defined(__LONG_MAX__) && (__GNUC__ == 2 && __GNUC_MINOR__ == 8) -#undef __LONG_MAX__ /* Is a longlong value in gcc 2.8.0 ??? */ -#define __LONG_MAX__ 2147483647 -#endif - -/* egcs 1.1.2 has a problem with memcpy on Alpha */ -#if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) -#define BAD_MEMCPY -#endif - #if defined(_lint) && !defined(lint) #define lint #endif @@ -557,16 +425,6 @@ C_MODE_END extern "C" int madvise(void *addr, size_t len, int behav); #endif -/* We can not live without the following defines */ - -#define USE_MYFUNC 1 /* Must use syscall indirection */ -#define MASTER 1 /* Compile without unireg */ -#define ENGLISH 1 /* Messages in English */ -#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */ -#define USE_REGEX 1 /* We want the use the regex library */ -/* Do not define for ultra sparcs */ -#define USE_BMOVE512 1 /* Use this unless system bmove is faster */ - #define QUOTE_ARG(x) #x /* Quote argument (before cpp) */ #define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */ @@ -608,12 +466,6 @@ extern "C" int madvise(void *addr, size_t len, int behav); #define UNINIT_VAR(x) x= x #endif -/* Define some useful general macros */ -#if !defined(max) -#define max(a, b) ((a) > (b) ? (a) : (b)) -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif - #if !defined(HAVE_UINT) #undef HAVE_UINT #define HAVE_UINT @@ -621,8 +473,6 @@ typedef unsigned int uint; typedef unsigned short ushort; #endif -#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) -#define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) #define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; } #define test(a) ((a) ? 1 : 0) #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) @@ -636,18 +486,6 @@ typedef unsigned short ushort; #define FALSE (0) /* Logical false */ #endif -#if defined(__GNUC__) -#define function_volatile volatile -#define my_reinterpret_cast(A) reinterpret_cast<A> -#define my_const_cast(A) const_cast<A> -# ifndef GCC_VERSION -# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) -# endif -#elif !defined(my_reinterpret_cast) -#define my_reinterpret_cast(A) (A) -#define my_const_cast(A) (A) -#endif - #include <my_compiler.h> /* @@ -674,9 +512,6 @@ C_MODE_END # endif #endif -#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/ -#define ASCII_BITS_USED 8 /* Bit char used */ - /* Some types that is different between systems */ typedef int File; /* File descriptor */ @@ -753,14 +588,7 @@ typedef SOCKET_SIZE_TYPE size_socket; #endif /* __WIN__ */ -/* #define USE_RECORD_LOCK */ - - /* Unsigned types supported by the compiler */ -#define UNSINT8 /* unsigned int8 (char) */ -#define UNSINT16 /* unsigned int16 */ -#define UNSINT32 /* unsigned int32 */ - - /* General constants */ +/* General constants */ #define FN_LEN 256 /* Max file name len */ #define FN_HEADLEN 253 /* Max length of filepart of file name */ #define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */ @@ -821,10 +649,6 @@ typedef SOCKET_SIZE_TYPE size_socket; #define OS_FILE_LIMIT UINT_MAX #endif -/* #define EXT_IN_LIBNAME */ -/* #define FN_NO_CASE_SENSE */ -/* #define FN_UPPER_CASE TRUE */ - /* Io buffer size; Must be a power of 2 and a multiple of 512. May be smaller what the disk page size. This influences the speed of the @@ -849,7 +673,6 @@ typedef SOCKET_SIZE_TYPE size_socket; /* Some things that this system doesn't have */ -#define NO_HASH /* Not needed anymore */ #ifdef _WIN32 #define NO_DIR_LIBRARY /* Not standard dir-library */ #endif @@ -896,7 +719,6 @@ inline unsigned long long my_double2ulonglong(double d) #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif #define ulong_to_double(X) ((double) (ulong) (X)) -#define SET_STACK_SIZE(X) /* Not needed on real machines */ #ifndef STACK_DIRECTION #error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS" @@ -915,7 +737,6 @@ inline unsigned long long my_double2ulonglong(double d) /* Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined. - Also on Windows we define these constants by hand in config-win.h. */ #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN) @@ -1013,9 +834,6 @@ typedef long long my_ptrdiff_t; #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1)) #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double)) /* Size to make adressable obj. */ -#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t))) - /* Offset of field f in structure t */ -#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f) #define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B)) @@ -1126,22 +944,6 @@ typedef long long intptr; #define MY_ERRPTR ((void*)(intptr)1) -#ifdef USE_RAID -/* - The following is done with a if to not get problems with pre-processors - with late define evaluation -*/ -#if SIZEOF_OFF_T == 4 -#define SYSTEM_SIZEOF_OFF_T 4 -#else -#define SYSTEM_SIZEOF_OFF_T 8 -#endif -#undef SIZEOF_OFF_T -#define SIZEOF_OFF_T 8 -#else -#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T -#endif /* USE_RAID */ - #if defined(_WIN32) typedef unsigned long long my_off_t; typedef unsigned long long os_off_t; @@ -1182,14 +984,10 @@ typedef ulong nesting_map; /* Used for flags of nesting constructs */ #define SOCKET_EMFILE EMFILE #endif -typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ -typedef short int15; /* Most effective integer 0 <= x <= 32767 */ typedef int myf; /* Type of MyFlags in my_funcs */ typedef char my_bool; /* Small bool */ - /* Macros for converting *constants* to the right type */ -#define INT8(v) (int8) (v) -#define INT16(v) (int16) (v) -#define INT32(v) (int32) (v) + +/* Macros for converting *constants* to the right type */ #define MYF(v) (myf) (v) #ifndef LL @@ -1233,23 +1031,9 @@ typedef char my_bool; /* Small bool */ #include <my_dbug.h> -/* - Sometimes we want to make sure that the variable is not put into - a register in debugging mode so we can see its value in the core -*/ - -#ifndef DBUG_OFF -#define dbug_volatile volatile -#else -#define dbug_volatile -#endif - /* Some helper macros */ #define YESNO(X) ((X) ? "yes" : "no") -/* Defines for time function */ -#define SCALE_SEC 100 -#define SCALE_USEC 10000 #define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ #define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ @@ -1447,8 +1231,8 @@ do { doubleget_union _tmp; \ ((uchar*) &def_temp)[7]=(M)[0];\ (V) = def_temp; } while(0) #else -#define float4get(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float)) -#define float4store(V,M) memcpy_fixed((uchar*) V,(uchar*) (&M),sizeof(float)) +#define float4get(V,M) memcpy(&V, (M), sizeof(float)) +#define float4store(V,M) memcpy(V, (&M), sizeof(float)) #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) #define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\ @@ -1518,12 +1302,12 @@ do { doubleget_union _tmp; \ *(((char*)T)+1)=(((A) >> 16));\ *(((char*)T)+0)=(((A) >> 24)); } while(0) -#define floatget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float)) -#define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*)(&V),sizeof(float)) -#define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double)) -#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double)) -#define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong)) +#define floatget(V,M) memcpy(&V, (M), sizeof(float)) +#define floatstore(T,V) memcpy((T), (void*) (&V), sizeof(float)) +#define doubleget(V,M) memcpy(&V, (M), sizeof(double)) +#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double)) +#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong)) +#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong)) #else @@ -1534,15 +1318,15 @@ do { doubleget_union _tmp; \ #define shortstore(T,V) int2store(T,V) #define longstore(T,V) int4store(T,V) #ifndef floatstore -#define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) (&V),sizeof(float)) -#define floatget(V,M) memcpy_fixed((uchar*) &V, (uchar*) (M), sizeof(float)) +#define floatstore(T,V) memcpy((T), (void *) (&V), sizeof(float)) +#define floatget(V,M) memcpy(&V, (M), sizeof(float)) #endif #ifndef doubleget -#define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double)) -#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double)) +#define doubleget(V,M) memcpy(&V, (M), sizeof(double)) +#define doublestore(T,V) memcpy((T), (void *) &V, sizeof(double)) #endif /* doubleget */ -#define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong)) +#define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong)) +#define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong)) #endif /* WORDS_BIGENDIAN */ @@ -1580,11 +1364,6 @@ do { doubleget_union _tmp; \ #endif #endif -/* FreeBSD 2.2.2 does not define RTLD_NOW) */ -#ifndef RTLD_NOW -#define RTLD_NOW 1 -#endif - #ifndef HAVE_DLERROR #define dlerror() "" #endif @@ -1700,8 +1479,6 @@ static inline double rint(double x) #undef HAVE_SMEM /* No shared memory */ #undef HAVE_NDBCLUSTER_DB /* No NDB cluster */ -#define DONT_USE_RAID - #endif /* EMBEDDED_LIBRARY */ #endif /* my_global_h */ diff --git a/include/my_net.h b/include/my_net.h index 1b8425984ae..5762f5da06e 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -14,9 +14,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - thread safe version of some common functions: - my_inet_ntoa - This file is also used to make handling of sockets and ioctl() portable accross systems. @@ -76,10 +73,6 @@ C_MODE_START #define in_addr_t uint32 #endif -/* Thread safe or portable version of some functions */ - -void my_inet_ntoa(struct in_addr in, char *buf); - /* Handling of gethostbyname_r() */ diff --git a/include/my_nosys.h b/include/my_nosys.h index ecb60333830..96ba6d4c464 100644 --- a/include/my_nosys.h +++ b/include/my_nosys.h @@ -30,7 +30,7 @@ extern "C" { #include <malloc.h> #endif -#undef my_read /* Can be predefined in raid.h */ +#undef my_read #undef my_write #undef my_seek #define my_read(a,b,c,d) my_quick_read(a,b,c,d) diff --git a/include/my_pthread.h b/include/my_pthread.h index e5ffa0db3bb..5cf181596ad 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -255,14 +255,13 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ we want to make sure that no such flags are set. */ #if defined(HAVE_SIGACTION) && !defined(my_sigset) -#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \ +#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; \ DBUG_ASSERT((A) != 0); \ sigemptyset(&l_set); \ l_s.sa_handler = (B); \ l_s.sa_mask = l_set; \ l_s.sa_flags = 0; \ - l_rc= sigaction((A), &l_s, (struct sigaction *) NULL);\ - DBUG_ASSERT(l_rc == 0); \ + sigaction((A), &l_s, NULL); \ } while (0) #elif defined(HAVE_SIGSET) && !defined(my_sigset) #define my_sigset(A,B) sigset((A),(B)) @@ -602,6 +601,8 @@ int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp); #define rw_trywrlock(A) my_rw_trywrlock((A)) #define rw_unlock(A) my_rw_unlock((A)) #define rwlock_destroy(A) my_rw_destroy((A)) +#define rw_lock_assert_write_owner(A) my_rw_lock_assert_write_owner((A)) +#define rw_lock_assert_not_write_owner(A) my_rw_lock_assert_not_write_owner((A)) #endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */ @@ -625,6 +626,8 @@ extern int rw_pr_init(rw_pr_lock_t *); #define rw_pr_trywrlock(A) pthread_rwlock_trywrlock(A) #define rw_pr_unlock(A) pthread_rwlock_unlock(A) #define rw_pr_destroy(A) pthread_rwlock_destroy(A) +#define rw_pr_lock_assert_write_owner(A) +#define rw_pr_lock_assert_not_write_owner(A) #else /* Otherwise we have to use our own implementation of read/write locks. */ #define NEED_MY_RW_LOCK 1 @@ -637,6 +640,8 @@ extern int rw_pr_init(struct st_my_rw_lock_t *); #define rw_pr_trywrlock(A) my_rw_trywrlock((A)) #define rw_pr_unlock(A) my_rw_unlock((A)) #define rw_pr_destroy(A) my_rw_destroy((A)) +#define rw_pr_lock_assert_write_owner(A) my_rw_lock_assert_write_owner((A)) +#define rw_pr_lock_assert_not_write_owner(A) my_rw_lock_assert_not_write_owner((A)) #endif /* defined(HAVE_PTHREAD_RWLOCK_RDLOCK) && defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) */ @@ -652,6 +657,9 @@ typedef struct st_my_rw_lock_t { int state; /* -1:writer,0:free,>0:readers */ int waiters; /* number of waiting writers */ my_bool prefer_readers; +#ifdef SAFE_MUTEX + pthread_t write_thread; +#endif } my_rw_lock_t; extern int my_rw_init(my_rw_lock_t *, my_bool *); @@ -661,6 +669,17 @@ extern int my_rw_wrlock(my_rw_lock_t *); extern int my_rw_unlock(my_rw_lock_t *); extern int my_rw_tryrdlock(my_rw_lock_t *); extern int my_rw_trywrlock(my_rw_lock_t *); +#ifdef SAFE_MUTEX +#define my_rw_lock_assert_write_owner(A) \ + DBUG_ASSERT((A)->state == -1 && pthread_equal(pthread_self(), \ + (A)->write_thread)) +#define my_rw_lock_assert_not_write_owner(A) \ + DBUG_ASSERT((A)->state >= 0 || ! pthread_equal(pthread_self(), \ + (A)->write_thread)) +#else +#define my_rw_lock_assert_write_owner(A) +#define my_rw_lock_assert_not_write_owner(A) +#endif #endif /* NEED_MY_RW_LOCK */ diff --git a/include/my_sys.h b/include/my_sys.h index c5702ec7395..95689535be5 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -78,7 +78,7 @@ extern int my_errno; /* Last error in mysys */ #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ #define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ #define MY_SYNC_DIR 8192 /* my_create/delete/rename: sync directory */ -#define MY_RAID 64 /* Support for RAID */ +#define MY_UNUSED 64 /* Unused (was support for RAID) */ #define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ #define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ @@ -101,10 +101,6 @@ extern int my_errno; /* Last error in mysys */ #define MY_GIVE_INFO 2 /* Give time info about process*/ #define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */ -#define MY_REMOVE_NONE 0 /* Params for modify_defaults_file */ -#define MY_REMOVE_OPTION 1 -#define MY_REMOVE_SECTION 2 - #define ME_HIGHBYTE 8 /* Shift for colours */ #define ME_NOCUR 1 /* Don't use curses message */ #define ME_OLDWIN 2 /* Use old window */ @@ -266,13 +262,6 @@ extern const char *my_defaults_file; extern my_bool timed_mutexes; -typedef struct wild_file_pack /* Struct to hold info when selecting files */ -{ - uint wilds; /* How many wildcards */ - uint not_pos; /* Start of not-theese-files */ - char * *wild; /* Pointer to wildcards */ -} WF_PACK; - enum loglevel { ERROR_LEVEL, WARNING_LEVEL, @@ -568,7 +557,6 @@ typedef int (*Process_option_func)(void *ctx, const char *group_name, /* Prototypes for mysys and my_func functions */ extern int my_copy(const char *from,const char *to,myf MyFlags); -extern int my_append(const char *from,const char *to,myf MyFlags); extern int my_delete(const char *name,myf MyFlags); extern int my_getwd(char * buf,size_t size,myf MyFlags); extern int my_setwd(const char *dir,myf MyFlags); @@ -584,7 +572,6 @@ extern File my_register_filename(File fd, const char *FileName, extern File my_create(const char *FileName,int CreateFlags, int AccessFlags, myf MyFlags); extern int my_close(File Filedes,myf MyFlags); -extern File my_dup(File file, myf MyFlags); extern int my_mkdir(const char *dir, int Flags, myf MyFlags); extern int my_readlink(char *to, const char *filename, myf MyFlags); extern int my_is_symlink(const char *filename); @@ -713,9 +700,6 @@ extern char * my_load_path(char * to, const char *path, const char *own_path_prefix); extern int wild_compare(const char *str,const char *wildstr, pbool str_is_pattern); -extern WF_PACK *wf_comp(char * str); -extern int wf_test(struct wild_file_pack *wf_pack,const char *name); -extern void wf_end(struct wild_file_pack *buffer); extern my_bool array_append_string_unique(const char *str, const char **array, size_t size); extern void get_date(char * to,int timeflag,time_t use_time); @@ -729,8 +713,6 @@ extern int end_record_cache(RECORD_CACHE *info); extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, const uchar *record,size_t length); extern int flush_write_cache(RECORD_CACHE *info); -extern long my_clock(void); -extern sig_handler sigtstp_handler(int signal_number); extern void handle_recived_signals(void); extern sig_handler my_set_alarm_variable(int signo); @@ -852,9 +834,6 @@ extern int my_load_defaults(const char *conf_file, const char **groups, int *argc, char ***argv, const char ***); extern int load_defaults(const char *conf_file, const char **groups, int *argc, char ***argv); -extern int modify_defaults_file(const char *file_location, const char *option, - const char *option_value, - const char *section_name, int remove_option); extern int my_search_option_files(const char *conf_file, int *argc, char ***argv, uint *args_used, Process_option_func func, void *func_ctx, diff --git a/include/my_trie.h b/include/my_trie.h deleted file mode 100644 index 72dd485af04..00000000000 --- a/include/my_trie.h +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (C) 2005 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef _trie_h -#define _trie_h -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct st_trie_node -{ - uint16 leaf; /* Depth from root node if match, 0 else */ - uchar c; /* Label on this edge */ - struct st_trie_node *next; /* Next label */ - struct st_trie_node *links; /* Array of edges leaving this node */ - struct st_trie_node *fail; /* AC failure function */ -} TRIE_NODE; - -typedef struct st_trie -{ - TRIE_NODE root; - MEM_ROOT mem_root; - CHARSET_INFO *charset; - uint32 nnodes; - uint32 nwords; -} TRIE; - -typedef struct st_ac_trie_state -{ - TRIE *trie; - TRIE_NODE *node; -} AC_TRIE_STATE; - -extern TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset); -extern void trie_free (TRIE *trie); -extern my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen); -extern my_bool ac_trie_prepare (TRIE *trie); -extern void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state); - - -/* `trie_goto' is internal function and shouldn't be used. */ - -static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, uchar c) -{ - TRIE_NODE *next; - DBUG_ENTER("trie_goto"); - for (next= node->links; next; next= next->next) - if (next->c == c) - DBUG_RETURN(next); - if (root == node) - DBUG_RETURN(root); - DBUG_RETURN(NULL); -} - - -/* - SYNOPSIS - int ac_trie_next (AC_TRIE_STATE *state, uchar *c); - state - valid pointer to `AC_TRIE_STATE' - c - character to lookup - - DESCRIPTION - Implementation of search using Aho-Corasick automaton. - Performs char-by-char search. - - RETURN VALUE - `ac_trie_next' returns length of matched word or 0. -*/ - -static inline int ac_trie_next (AC_TRIE_STATE *state, uchar *c) -{ - TRIE_NODE *root, *node; - DBUG_ENTER("ac_trie_next"); - DBUG_ASSERT(state && c); - root= &state->trie->root; - node= state->node; - while (! (state->node= trie_goto(root, node, *c))) - node= node->fail; - DBUG_RETURN(state->node->leaf); -} - - -/* - SYNOPSIS - my_bool trie_search (TRIE *trie, const uchar *key, uint keylen); - trie - valid pointer to `TRIE' - key - valid pointer to key to insert - keylen - non-0 key length - - DESCRIPTION - Performs key lookup in trie. - - RETURN VALUE - `trie_search' returns `true' if key is in `trie'. Otherwise, - `false' is returned. - - NOTES - Consecutive search here is "best by test". arrays are very short, so - binary search or hashing would add too much complexity that would - overweight speed gain. Especially because compiler can optimize simple - consecutive loop better (tested) -*/ - -static inline my_bool trie_search (TRIE *trie, const uchar *key, uint keylen) -{ - TRIE_NODE *node; - uint k; - DBUG_ENTER("trie_search"); - DBUG_ASSERT(trie && key && keylen); - node= &trie->root; - - for (k= 0; k < keylen; k++) - { - uchar p; - if (! (node= node->links)) - DBUG_RETURN(FALSE); - p= key[k]; - while (p != node->c) - if (! (node= node->next)) - DBUG_RETURN(FALSE); - } - - DBUG_RETURN(node->leaf > 0); -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/include/my_vle.h b/include/my_vle.h deleted file mode 100644 index c09f82229c4..00000000000 --- a/include/my_vle.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2005 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef VLE_H -#define VLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "my_global.h" - -/* - The size (in bytes) required to store the object ITEM, which can be - either an expression or a type (since sizeof() is used on the item). -*/ -#define my_vle_sizeof(ITEM) (((sizeof(ITEM) * CHAR_BIT) + 6) / 7) - -uchar *my_vle_encode(uchar *vle, size_t max, ulong value); -uchar const *my_vle_decode(ulong *value_ptr, uchar const *vle); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/myisam.h b/include/myisam.h index 7547f6b475e..3efc65a900a 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -252,7 +252,7 @@ extern ulong myisam_block_size; extern uint myisam_concurrent_insert; extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user; extern my_off_t myisam_max_temp_length; -extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size; +extern ulong myisam_data_pointer_size; /* usually used to check if a symlink points into the mysql data home */ /* which is normally forbidden */ @@ -481,8 +481,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, const char * name, int rep_quick); int change_to_newfile(const char * filename, const char * old_ext, - const char * new_ext, uint raid_chunks, - myf myflags); + const char * new_ext, myf myflags); int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type, const char *filetype, const char *filename); void lock_memory(MI_CHECK *param); diff --git a/include/mysql.h b/include/mysql.h index 7eef91cf55a..dc6e4eb19a6 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -44,7 +44,9 @@ extern "C" { #endif #ifndef _global_h /* If not standard header */ +#ifndef MYSQL_ABI_CHECK #include <sys/types.h> +#endif #ifdef __LCC__ #include <winsock2.h> /* For windows */ #endif diff --git a/include/mysql.h.pp b/include/mysql.h.pp index bc5d611ec84..531062aee80 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -1,4 +1,3 @@ -#include <sys/types.h> typedef char my_bool; typedef int my_socket; #include "mysql_version.h" diff --git a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp index 3a1b03742da..ce9902ee418 100644 --- a/include/mysql/plugin.h.pp +++ b/include/mysql/plugin.h.pp @@ -1,7 +1,5 @@ #include <mysql/services.h> #include <mysql/service_my_snprintf.h> -#include <stdarg.h> -#include <stdlib.h> extern struct my_snprintf_service_st { size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); @@ -9,7 +7,6 @@ extern struct my_snprintf_service_st { size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); #include <mysql/service_thd_alloc.h> -#include <stdlib.h> struct st_mysql_lex_string { char *str; diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index d133f2655fb..60b4f5d6ef4 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -215,6 +215,14 @@ typedef struct st_mysql_cond mysql_cond_t; #define mysql_mutex_assert_not_owner(M) \ safe_mutex_assert_not_owner(&(M)->m_mutex) +/** Wrappers for instrumented prlock objects. */ + +#define mysql_prlock_assert_write_owner(M) \ + rw_pr_lock_assert_write_owner(&(M)->m_prlock) + +#define mysql_prlock_assert_not_write_owner(M) \ + rw_pr_lock_assert_not_write_owner(&(M)->m_prlock) + /** @def mysql_mutex_init(K, M, A) Instrumented mutex_init. diff --git a/include/mysql/service_my_snprintf.h b/include/mysql/service_my_snprintf.h index 9e5fe7f9c9f..d7f8d07e110 100644 --- a/include/mysql/service_my_snprintf.h +++ b/include/mysql/service_my_snprintf.h @@ -70,8 +70,11 @@ extern "C" { #endif +#ifndef MYSQL_ABI_CHECK #include <stdarg.h> #include <stdlib.h> +#endif + extern struct my_snprintf_service_st { size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); diff --git a/include/mysql/service_thd_alloc.h b/include/mysql/service_thd_alloc.h index 86158ba1359..7061c2bd4d5 100644 --- a/include/mysql/service_thd_alloc.h +++ b/include/mysql/service_thd_alloc.h @@ -27,7 +27,9 @@ allocations - they are better served with my_malloc. */ +#ifndef MYSQL_ABI_CHECK #include <stdlib.h> +#endif #ifdef __cplusplus extern "C" { diff --git a/include/mysql_embed.h b/include/mysql_embed.h index b26b723381d..ae70b9723f8 100644 --- a/include/mysql_embed.h +++ b/include/mysql_embed.h @@ -28,7 +28,5 @@ #undef HAVE_SMEM /* No shared memory */ #undef HAVE_NDBCLUSTER_DB /* No NDB cluster */ -#define DONT_USE_RAID - #endif /* EMBEDDED_LIBRARY */ #endif /* MYSQL_EMBED_INCLUDED */ diff --git a/include/mysys_err.h b/include/mysys_err.h index 9629dfec014..4067a3cfbd1 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -63,7 +63,9 @@ extern const char *globerrs[]; /* my_error_messages is here */ #define EE_UNKNOWN_COLLATION 28 #define EE_FILENOTFOUND 29 #define EE_FILE_NOT_CLOSED 30 -#define EE_ERROR_LAST 30 /* Copy last error nr */ +#define EE_CHANGE_OWNERSHIP 31 +#define EE_CHANGE_PERMISSIONS 32 +#define EE_ERROR_LAST 32 /* Copy last error nr */ /* Add error numbers before EE_ERROR_LAST and change it accordingly. */ /* exit codes for all MySQL programs */ diff --git a/include/thr_lock.h b/include/thr_lock.h index 37dc37f8017..5626c067e5e 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -89,23 +89,11 @@ typedef struct st_thr_lock_info { pthread_t thread; my_thread_id thread_id; - ulong n_cursors; } THR_LOCK_INFO; -/* - Lock owner identifier. Globally identifies the lock owner within the - thread and among all the threads. The address of an instance of this - structure is used as id. -*/ - -typedef struct st_thr_lock_owner -{ - THR_LOCK_INFO *info; -} THR_LOCK_OWNER; - typedef struct st_thr_lock_data { - THR_LOCK_OWNER *owner; + THR_LOCK_INFO *owner; struct st_thr_lock_data *next,**prev; struct st_thr_lock *lock; mysql_cond_t *cond; @@ -141,19 +129,18 @@ extern LIST *thr_lock_thread_list; extern mysql_mutex_t THR_LOCK_lock; my_bool init_thr_lock(void); /* Must be called once/thread */ -#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg) void thr_lock_info_init(THR_LOCK_INFO *info); void thr_lock_init(THR_LOCK *lock); void thr_lock_delete(THR_LOCK *lock); void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *status_param); enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data, - THR_LOCK_OWNER *owner, + THR_LOCK_INFO *owner, enum thr_lock_type lock_type, ulong lock_wait_timeout); void thr_unlock(THR_LOCK_DATA *data); enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data, - uint count, THR_LOCK_OWNER *owner, + uint count, THR_LOCK_INFO *owner, ulong lock_wait_timeout); void thr_multi_unlock(THR_LOCK_DATA **data,uint count); void diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 8aa1648c834..07f66c28ddb 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -21,8 +21,8 @@ # This file is public domain and comes with NO WARRANTY of any kind target = libmysqlclient.la -target_defs = -DMYSQL_CLIENT_NO_THREADS -DDONT_USE_RAID \ - -DDISABLE_MYSQL_THREAD_H @LIB_EXTRA_CCFLAGS@ +target_defs = -DMYSQL_CLIENT_NO_THREADS -DDISABLE_MYSQL_THREAD_H \ + @LIB_EXTRA_CCFLAGS@ LIBS = @CLIENT_LIBS@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ @@ -33,7 +33,7 @@ include $(srcdir)/Makefile.shared libmysqlclient_la_SOURCES = $(target_sources) libmysqlclient_la_LIBADD = $(target_libadd) $(yassl_las) libmysqlclient_la_LDFLAGS = $(target_ldflags) -EXTRA_DIST = Makefile.shared libmysql.def dll.c CMakeLists.txt +EXTRA_DIST = Makefile.shared libmysql.def CMakeLists.txt noinst_HEADERS = client_settings.h link_sources: @@ -82,7 +82,7 @@ link_sources: # keep only the stubs for debug.c # # A list of needed headers collected from the deps information 000213 -nh = my_global.h config-win32.h dbug.h errmsg.h \ +nh = my_global.h dbug.h errmsg.h \ m_ctype.h m_string.h password.h \ my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \ mysql.h mysql_com.h mysql_version.h mysqld_error.h \ diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 53264f2e559..887af62229a 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -37,7 +37,7 @@ target_sources = libmysql.c password.c \ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \ strmake.lo strend.lo \ strnlen.lo strfill.lo is_prefix.lo \ - int2str.lo str2int.lo strinstr.lo strcont.lo \ + int2str.lo str2int.lo strcont.lo \ strcend.lo ctype-latin1.lo \ bchange.lo bmove.lo bmove_upp.lo longlong2str.lo \ strtoull.lo strtoll.lo llstr.lo my_vsnprintf.lo \ @@ -61,9 +61,8 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo \ mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \ my_symlink.lo my_fstream.lo mf_arr_appstr.lo \ mf_loadpath.lo my_pthread.lo my_thr_init.lo \ - thr_mutex.lo mulalloc.lo string.lo \ - default.lo default_modify.lo \ - my_compress.lo array.lo my_once.lo list.lo my_net.lo \ + thr_mutex.lo mulalloc.lo string.lo default.lo \ + my_compress.lo array.lo my_once.lo list.lo \ charset.lo charset-def.lo hash.lo mf_iocache.lo \ mf_iocache2.lo my_seek.lo my_sleep.lo \ my_pread.lo mf_cache.lo md5.lo sha1.lo \ diff --git a/libmysql/dll.c b/libmysql/dll.c deleted file mode 100644 index b5fcba13f91..00000000000 --- a/libmysql/dll.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (C) 2000-2004 MySQL AB - - 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. - - There are special exceptions to the terms and conditions of the GPL as it - is applied to this software. View the full text of the exception in file - EXCEPTIONS-CLIENT in the directory of this software distribution. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* -** Handling initialization of the dll library -*/ - -#include <my_global.h> -#include <my_sys.h> -#include <my_pthread.h> - -static my_bool libmysql_inited=0; - -void libmysql_init(void) -{ - if (libmysql_inited) - return; - libmysql_inited=1; - my_init(); - { - DBUG_ENTER("libmysql_init"); -#ifdef LOG_ALL - DBUG_PUSH("d:t:S:O,c::\\tmp\\libmysql.log"); -#else - if (getenv("LIBMYSQL_LOG") != NULL) - DBUG_PUSH(getenv("LIBMYSQL_LOG")); -#endif - DBUG_VOID_RETURN; - } -} - -#ifdef __WIN__ - -static int inited=0,threads=0; -HINSTANCE s_hModule; /* Saved module handle */ -DWORD main_thread; - -BOOL APIENTRY LibMain(HANDLE hInst,DWORD ul_reason_being_called, - LPVOID lpReserved) -{ - switch (ul_reason_being_called) { - case DLL_PROCESS_ATTACH: /* case of libentry call in win 3.x */ - if (!inited++) - { - s_hModule=hInst; - libmysql_init(); - main_thread=GetCurrentThreadId(); - } - break; - case DLL_THREAD_ATTACH: - threads++; - my_thread_init(); - break; - case DLL_PROCESS_DETACH: /* case of wep call in win 3.x */ - if (!--inited) /* Safety */ - { - /* my_thread_init() */ /* This may give extra safety */ - my_end(0); - } - break; - case DLL_THREAD_DETACH: - /* Main thread will free by my_end() */ - threads--; - if (main_thread != GetCurrentThreadId()) - my_thread_end(); - break; - default: - break; - } /* switch */ - - return TRUE; - - UNREFERENCED_PARAMETER(lpReserved); -} /* LibMain */ - - -static BOOL do_libmain; -int __stdcall DllMain(HANDLE hInst,DWORD ul_reason_being_called,LPVOID lpReserved) -{ - /* - Unless environment variable LIBMYSQL_DLLINIT is set, do nothing. - The environment variable is checked once, during the first call to DllMain() - (in DLL_PROCESS_ATTACH hook). - */ - if (ul_reason_being_called == DLL_PROCESS_ATTACH) - do_libmain = (getenv("LIBMYSQL_DLLINIT") != NULL); - if (do_libmain) - return LibMain(hInst,ul_reason_being_called,lpReserved); - return TRUE; -} - diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index d0ed44bd7aa..febbded6af2 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -24,139 +24,6 @@ #include <my_sys.h> #include "errmsg.h" -#ifdef GERMAN -const char *client_errors[]= -{ - "Unbekannter MySQL Fehler", - "Kann UNIX-Socket nicht anlegen (%d)", - "Keine Verbindung zu lokalem MySQL Server, socket: '%-.100s' (%d)", - "Keine Verbindung zu MySQL Server auf %-.100s (%d)", - "Kann TCP/IP-Socket nicht anlegen (%d)", - "Unbekannter MySQL Server Host (%-.100s) (%d)", - "MySQL Server nicht vorhanden", - "Protokolle ungleich; Server Version = %d, Client Version = %d", - "MySQL client ran out of memory", - "Wrong host info", - "Localhost via UNIX socket", - "%-.100s via TCP/IP", - "Error in server handshake", - "Lost connection to MySQL server during query", - "Commands out of sync; you can't run this command now", - "Verbindung ueber Named Pipe: %-.32s", - "Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)", - "Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)", - "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)", - "Can't initialize character set %-.32s (path: %-.100s)", - "Got packet bigger than 'max_allowed_packet' bytes", - "Embedded server", - "Error on SHOW SLAVE STATUS:", - "Error on SHOW SLAVE HOSTS:", - "Error connecting to slave:", - "Error connecting to master:", - "SSL connection error", - "Malformed packet", - "This client library is licensed only for use with MySQL servers having '%s' license", - "Invalid use of null pointer", - "Statement not prepared", - "No data supplied for parameters in prepared statement", - "Data truncated", - "No parameters exist in the statement", - "Invalid parameter number", - "Can't send long data for non-string/non-binary data types (parameter: %d)", - "Using unsupported buffer type: %d (parameter: %d)", - "Shared memory: %-.100s", - "Can't open shared memory; client could not create request event (%lu)", - "Can't open shared memory; no answer event received from server (%lu)", - "Can't open shared memory; server could not allocate file mapping (%lu)", - "Can't open shared memory; server could not get pointer to file mapping (%lu)", - "Can't open shared memory; client could not allocate file mapping (%lu)", - "Can't open shared memory; client could not get pointer to file mapping (%lu)", - "Can't open shared memory; client could not create %s event (%lu)", - "Can't open shared memory; no answer from server (%lu)", - "Can't open shared memory; cannot send request event to server (%lu)", - "Wrong or unknown protocol", - "Invalid connection handle", - "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)", - "Row retrieval was canceled by mysql_stmt_close() call", - "Attempt to read column without prior row fetch", - "Prepared statement contains no metadata", - "Attempt to read a row while there is no result set associated with the statement", - "This feature is not implemented yet", - "Lost connection to MySQL server at '%s', system error: %d", - "Statement closed indirectly because of a preceeding %s() call", - "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again", - "This handle is already connected. Use a separate handle for each connection." - "" -}; - -/* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ - -#elif defined PORTUGUESE -const char *client_errors[]= -{ - "Erro desconhecido do MySQL", - "Não pode criar 'UNIX socket' (%d)", - "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.100s' (%d)", - "Não pode se conectar ao servidor MySQL em '%-.100s' (%d)", - "Não pode criar 'socket TCP/IP' (%d)", - "'Host' servidor MySQL '%-.100s' (%d) desconhecido", - "Servidor MySQL desapareceu", - "Incompatibilidade de protocolos; versão do servidor = %d, versão do cliente = %d", - "Cliente do MySQL com falta de memória", - "Informação inválida de 'host'", - "Localhost via 'UNIX socket'", - "%-.100s via 'TCP/IP'", - "Erro na negociação de acesso ao servidor", - "Conexão perdida com servidor MySQL durante 'query'", - "Comandos fora de sincronismo; você não pode executar este comando agora", - "Named pipe: %-.32s", - "Não pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode inicializar conjunto de caracteres %-.32s (caminho %-.100s)", - "Obteve pacote maior do que 'max_allowed_packet' bytes", - "Embedded server" - "Error on SHOW SLAVE STATUS:", - "Error on SHOW SLAVE HOSTS:", - "Error connecting to slave:", - "Error connecting to master:", - "SSL connection error", - "Malformed packet", - "This client library is licensed only for use with MySQL servers having '%s' license", - "Invalid use of null pointer", - "Statement not prepared", - "No data supplied for parameters in prepared statement", - "Data truncated", - "No parameters exist in the statement", - "Invalid parameter number", - "Can't send long data for non-string/non-binary data types (parameter: %d)", - "Using unsupported buffer type: %d (parameter: %d)", - "Shared memory: %-.100s", - "Can't open shared memory; client could not create request event (%lu)", - "Can't open shared memory; no answer event received from server (%lu)", - "Can't open shared memory; server could not allocate file mapping (%lu)", - "Can't open shared memory; server could not get pointer to file mapping (%lu)", - "Can't open shared memory; client could not allocate file mapping (%lu)", - "Can't open shared memory; client could not get pointer to file mapping (%lu)", - "Can't open shared memory; client could not create %s event (%lu)", - "Can't open shared memory; no answer from server (%lu)", - "Can't open shared memory; cannot send request event to server (%lu)", - "Wrong or unknown protocol", - "Invalid connection handle", - "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)", - "Row retrieval was canceled by mysql_stmt_close() call", - "Attempt to read column without prior row fetch", - "Prepared statement contains no metadata", - "Attempt to read a row while there is no result set associated with the statement", - "This feature is not implemented yet", - "Lost connection to MySQL server at '%s', system error: %d", - "Statement closed indirectly because of a preceeding %s() call", - "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again", - "This handle is already connected. Use a separate handle for each connection." - "" -}; - -#else /* ENGLISH */ const char *client_errors[]= { "Unknown MySQL error", @@ -220,7 +87,6 @@ const char *client_errors[]= "This handle is already connected. Use a separate handle for each connection." "" }; -#endif const char** get_client_errmsgs() { diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 02ed93fa501..550b1b7b107 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -214,13 +214,6 @@ void STDCALL mysql_server_end() } mysql_client_init= org_my_init_done= 0; -#ifdef EMBEDDED_SERVER - if (stderror_file) - { - fclose(stderror_file); - stderror_file= 0; - } -#endif } static MYSQL_PARAMETERS mysql_internal_parameters= diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index dab45d93673..30aa2467dab 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -21,8 +21,7 @@ # This file is public domain and comes with NO WARRANTY of any kind target = libmysqlclient_r.la -target_defs = -DDISABLE_MYSQL_PRLOCK_H -DDONT_USE_RAID \ - -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@ +target_defs = -DDISABLE_MYSQL_PRLOCK_H -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@ LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@ diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 6f553ef9c11..a7efcb024ec 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -67,7 +67,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/sql_truncate.cc ../sql/sql_lex.cc ../sql/keycaches.cc ../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc - ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_map.cc + ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc ../sql/debug_sync.cc ../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 9d8c5edaa12..1ffa349bcfe 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -66,7 +66,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ sql_profile.cc sql_truncate.cc datadict.cc \ sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \ sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \ - sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \ + sql_lex.cc sql_list.cc sql_manager.cc \ scheduler.cc sql_connect.cc sql_parse.cc \ sql_prepare.cc sql_derived.cc sql_rename.cc \ sql_select.cc sql_do.cc sql_show.cc set_var.cc sys_vars.cc \ diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index 47167f0bf96..800044242ac 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -14,6 +14,7 @@ main.information_schema # Bug#47449 2009-09-19 alik main.inform main.lock_multi_bug38499 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically main.lock_multi_bug38691 @solaris # Bug#47792 2009-10-02 alik main.lock_multi_bug38691 times out sporadically on Solaris 10 main.log_tables # Bug#47924 2009-10-08 alik main.log_tables times out sporadically +main.lowercase_table2 @darwin # Bug#55509 2010-07-26 alik main.lowercase_table2 fails on Mac OSX (again) main.mysqlbinlog_row @solaris # Bug#52202 2010-03-22 alik mysqlbinlog_row* fail in daily-trunk on Sol10 x86_64 debug_max main.mysqlbinlog_row_innodb @solaris # Bug#52202 2010-03-22 alik mysqlbinlog_row* fail in daily-trunk on Sol10 x86_64 debug_max main.mysqlbinlog_row_myisam @solaris # Bug#52202 2010-03-22 alik mysqlbinlog_row* fail in daily-trunk on Sol10 x86_64 debug_max @@ -25,7 +26,6 @@ main.type_float @freebsd # Bug#38965 2010-05-04 alik test cases main.wait_timeout @solaris # Bug#51244 2010-04-26 alik wait_timeout fails on OpenSolaris parts.partition_alter4_innodb # Bug#45299 2010-06-28 alik Test "partition_alter4_innodb" is taking too long, timeout -perfschema.pfs_upgrade # Bug#53102 2010-06-15 alik perfschema.pfs_upgrade fails on sol10 sparc64 max in parallel mode rpl.rpl_heartbeat_basic # BUG#54820 2010-06-26 alik rpl.rpl_heartbeat_basic fails sporadically again rpl.rpl_heartbeat_2slaves # BUG#43828 2009-10-22 luis fails sporadically diff --git a/mysql-test/extra/rpl_tests/rpl_innodb.test b/mysql-test/extra/rpl_tests/rpl_innodb.test index 4bc1c004ba7..8b9b7e7ff39 100644 --- a/mysql-test/extra/rpl_tests/rpl_innodb.test +++ b/mysql-test/extra/rpl_tests/rpl_innodb.test @@ -153,7 +153,7 @@ connection master; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE info = "RENAME TABLE t1 TO t3, t2 TO t1" and - state = "Waiting for table"; + state = "Waiting for table metadata lock"; --source include/wait_condition.inc COMMIT; diff --git a/mysql-test/include/check_no_concurrent_insert.inc b/mysql-test/include/check_no_concurrent_insert.inc index 57772dddefc..c615ebd02cd 100644 --- a/mysql-test/include/check_no_concurrent_insert.inc +++ b/mysql-test/include/check_no_concurrent_insert.inc @@ -43,7 +43,8 @@ connection default; # of our statement. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "insert into $table (i) values (0)"; + where state = "Waiting for table level lock" and + info = "insert into $table (i) values (0)"; --source include/wait_condition.inc --disable_result_log diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index a8c62d3994f..65e9e61d077 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -523,7 +523,7 @@ connection waiter; --echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for table flush"; --source include/wait_condition.inc connection default; --echo connection: default @@ -557,7 +557,8 @@ connection waiter; --echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t0"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t0"; --source include/wait_condition.inc connection default; --echo connection: default @@ -743,7 +744,8 @@ send alter table t1 engine=memory; connection con2; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 engine=memory"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 engine=memory"; --source include/wait_condition.inc connection default; --error ER_ILLEGAL_HA @@ -764,7 +766,8 @@ send alter table t1 engine=memory; connection con2; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 engine=memory"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 engine=memory"; --source include/wait_condition.inc connection default; --echo # Since S metadata lock was already acquired at HANDLER OPEN time @@ -1024,7 +1027,9 @@ connection con1; --echo # --> connection con2 connection con2; --echo # Waitng for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1055,7 +1060,9 @@ connection con1; --echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1097,7 +1104,8 @@ send rename table t0 to t3, t1 to t0, t3 to t1; connection con1; --echo # Waiting for 'rename table ...' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='rename table t0 to t3, t1 to t0, t3 to t1'; + where state='Waiting for table metadata lock' and + info='rename table t0 to t3, t1 to t0, t3 to t1'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1137,7 +1145,9 @@ connection con2; --echo # --> connection con1 connection con1; --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # --> connection default connection default; @@ -1146,7 +1156,9 @@ send select * from t2; --echo # --> connection con1 connection con1; --echo # Waiting for 'select * from t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='select * from t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='select * from t2'; unlock tables; --echo # --> connection con2 connection con2; @@ -1190,10 +1202,14 @@ connection default; --echo # --> connection con3 connection con3; --echo # Waiting for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # Demonstrate that t2 lock was released and t2 was dropped --echo # after ROLLBACK TO SAVEPOINT @@ -1255,10 +1271,14 @@ connection default; --echo # --> connection con3 connection con3; --echo # Waiting for 'drop table t1' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t1'; --source include/wait_condition.inc --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # Demonstrate that t2 lock was released and t2 was dropped --echo # after ROLLBACK TO SAVEPOINT @@ -1314,7 +1334,9 @@ drop table t1, t2; --echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t3' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t3'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t3'; --source include/wait_condition.inc --echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler --echo # lock. @@ -1348,7 +1370,9 @@ send drop table t2; --echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t2' to get blocked... -let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +let $wait_condition=select count(*)=1 from information_schema.processlist + where state='Waiting for table metadata lock' and + info='drop table t2'; --source include/wait_condition.inc --echo # --> connection con1 connection con1; @@ -1400,7 +1424,8 @@ connection con2; --echo # has read from the table commits. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock tables t1 write"; + where state = "Waiting for table metadata lock" and + info = "lock tables t1 write"; --source include/wait_condition.inc --echo # --> connection default @@ -1427,7 +1452,8 @@ connection con1; --echo # Waiting for 'handler t1 read a next' to get blocked... let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "handler t1 read a next"; + where state = "Waiting for table level lock" and + info = "handler t1 read a next"; --source include/wait_condition.inc --echo # The below 'drop table t1' should be able to proceed without diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index fe6abe13892..d1afb8bcf0b 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1583,7 +1583,7 @@ connect (con1, localhost, root,,); --echo # Connection default connection default; let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='TRUNCATE TABLE t1'; + WHERE state='Waiting for table metadata lock' AND info='TRUNCATE TABLE t1'; --source include/wait_condition.inc SELECT * FROM t1 ORDER BY a; ROLLBACK; diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 685e1e5ba4b..028c8b32f87 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12775,3 +12775,29 @@ a 1 2 DROP TABLE t1; +# +# Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a int) ENGINE=ARCHIVE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (1); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +FLUSH TABLES; +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 ORDER BY a; +a +1 +2 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index 4251615a6e6..be6562f8ab6 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -206,10 +206,10 @@ insert into t2 (a) values (3); # --> connection default; unlock tables; # -# Check that "flush tables <list> with read lock" is -# compatible with active "flush tables with read lock". -# Vice versa is not true as tables read-locked by -# "flush tables <list> with read lock" can't be flushed. +# Check that "FLUSH TABLES <list> WITH READ LOCK" is +# compatible with active "FLUSH TABLES WITH READ LOCK". +# Vice versa it is not true, since tables read-locked by +# "FLUSH TABLES <list> WITH READ LOCK" can't be flushed. flush tables with read lock; # --> connection con1; flush table t1 with read lock; @@ -219,6 +219,37 @@ a unlock tables; # --> connection default; unlock tables; +# +# Check that FLUSH TABLES t1 WITH READ LOCK +# does not conflict with an existing FLUSH TABLES t2 +# WITH READ LOCK. +# +flush table t1 with read lock; +# --> connection con1 +flush table t2 with read lock; +unlock tables; +# --> connection default +unlock tables; +# +# Check that FLUSH TABLES t1 WITH READ LOCK +# does not conflict with SET GLOBAL read_only=1. +# +set global read_only=1; +# connection con1 +flush table t1 with read lock; +unlock tables; +# connection default +set global read_only=0; +# +# Check that it's possible to read-lock +# tables locked with FLUSH TABLE <list> WITH READ LOCK. +# +flush tables t1, t2 with read lock; +# connection con1 +lock table t1 read, t2 read; +unlock tables; +# connection default +unlock tables; # --> connection con1 drop table t1, t2, t3; # diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 6838dcf944c..45c93971852 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1714,3 +1714,14 @@ NULL NULL NULL NULL NULL drop table t1; # End of 5.1 tests +# +# Bug#55648: Server crash on MIX/MAX on maximum time value +# +CREATE TABLE t1(c1 TIME NOT NULL); +INSERT INTO t1 VALUES('837:59:59'); +INSERT INTO t1 VALUES('838:59:59'); +SELECT MAX(c1) FROM t1; +MAX(c1) +838:59:59 +DROP TABLE t1; +# End of the bug#55648 diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index cdf48376fb0..3416e368dff 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1812,3 +1812,32 @@ MAX(t2.a) DROP TABLE t1, t2; # # End of 5.1 tests +# +# Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00 +# +CREATE TABLE t1 (f1 int, f2 DATE); +INSERT INTO t1 VALUES (1,'2004-04-19'), (1,'0000-00-00'), (1,'2004-04-18'), +(2,'2004-05-19'), (2,'0001-01-01'), (3,'2004-04-10'); +SELECT MIN(f2),MAX(f2) FROM t1; +MIN(f2) MAX(f2) +0000-00-00 2004-05-19 +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; +f1 MIN(f2) MAX(f2) +1 0000-00-00 2004-04-19 +2 0001-01-01 2004-05-19 +3 2004-04-10 2004-04-10 +DROP TABLE t1; +CREATE TABLE t1 ( f1 int, f2 time); +INSERT INTO t1 VALUES (1,'01:27:35'), (1,'06:11:01'), (2,'19:53:05'), +(2,'21:44:25'), (3,'10:55:12'), (3,'05:45:11'), (4,'00:25:00'); +SELECT MIN(f2),MAX(f2) FROM t1; +MIN(f2) MAX(f2) +00:25:00 21:44:25 +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; +f1 MIN(f2) MAX(f2) +1 01:27:35 06:11:01 +2 19:53:05 21:44:25 +3 05:45:11 10:55:12 +4 00:25:00 00:25:00 +DROP TABLE t1; +#End of test#49771 diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result index 7cc76611fb8..e3a3e0e9740 100644 --- a/mysql-test/r/heap_hash.result +++ b/mysql-test/r/heap_hash.result @@ -382,3 +382,14 @@ INSERT INTO t1 VALUES('A ', 'A '); ERROR 23000: Duplicate entry 'A -A ' for key 'key1' DROP TABLE t1; End of 5.0 tests +# +# Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c +# on DELETE statement +# +CREATE TABLE t1 (col_int_nokey INT, +col_int_key INT, +INDEX(col_int_key) USING HASH) ENGINE = HEAP; +INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1); +DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2; +DROP TABLE t1; +End of 5.5 tests diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index 26a151b55aa..caee7a7662b 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -56,6 +56,7 @@ CREATE DATABASE `TEST_$1`; SHOW DATABASES LIKE "TEST%"; Database (TEST%) TEST_$1 +test DROP DATABASE `test_$1`; CREATE TABLE T1 (a int) engine=innodb; INSERT INTO T1 VALUES (1); @@ -171,7 +172,7 @@ create table myUC (i int); select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA ='mysqltest_LC2'; TABLE_SCHEMA TABLE_NAME -mysqltest_LC2 myUC +mysqltest_lc2 myUC use test; drop database mysqltest_LC2; # End of 5.1 tests diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result index 2e3195c5a53..d484ab77701 100644 --- a/mysql-test/r/mdl_sync.result +++ b/mysql-test/r/mdl_sync.result @@ -2035,21 +2035,21 @@ set debug_sync='now SIGNAL go2'; # Reaping ALTER. It should succeed and not produce ER_LOCK_DEADLOCK. drop table t1; # -# Now, test for situation in which deadlock involves waiting not +# Now, test for a situation in which deadlock involves waiting not # only in MDL subsystem but also for TDC. Such deadlocks should be -# successfully detected. If possible they should be resolved without +# successfully detected. If possible, they should be resolved without # resorting to ER_LOCK_DEADLOCK error. # create table t1(i int); create table t2(j int); # -# First, let us check how we handle simple scenario involving +# First, let us check how we handle a simple scenario involving # waits in MDL and TDC. # set debug_sync= 'RESET'; # Switching to connection 'deadlock_con1'. -# Start statement which will acquire SR metadata lock on t1, open it -# and then will stop, before trying to acquire SW lock and opening t2. +# Start a statement, which will acquire SR metadata lock on t1, open it +# and then stop, before trying to acquire SW lock on t2 and opening it. set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; # Sending: select * from t1 where i in (select j from t2 for update); @@ -2061,12 +2061,11 @@ set debug_sync='now WAIT_FOR parked'; # Sending: flush tables t1, t2 with read lock; # Switching to connection 'deadlock_con3'. -# Wait until FLUSH TABLES WITH READ LOCK starts waiting +# Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting # for SELECT to close t1. # Resume SELECT, so it tries to acquire SW lock on t1 and blocks, # creating a deadlock. This deadlock should be detected and resolved -# by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should -# be able to finish. +# by backing-off SELECT. As a result FTWRL should be able to finish. set debug_sync='now SIGNAL go'; # Switching to connection 'deadlock_con2'. # Reap FLUSH TABLES WITH READ LOCK. @@ -2095,9 +2094,9 @@ set debug_sync='now WAIT_FOR parked'; select * from t1 where i in (select j from t2 for update); # Switching to connection 'deadlock_con3'. # Wait till the above SELECT blocks. -# Resume FLUSH TABLES, so it tries to flush t1 creating a deadlock. -# This deadlock should be detected and resolved by backing-off SELECT. -# As result FLUSH TABLES WITH READ LOCK should be able to finish. +# Resume FLUSH TABLES, so it tries to flush t1, thus creating +# a deadlock. This deadlock should be detected and resolved by +# backing-off SELECT. As a result FTWRL should be able to finish. set debug_sync='now SIGNAL go'; # Switching to connection 'deadlock_con2'. # Reap FLUSH TABLES WITH READ LOCK. @@ -2106,13 +2105,13 @@ unlock tables; # Reap SELECT. i # -# Now more complex scenario involving two connections +# Now a more complex scenario involving two connections # waiting for MDL and one for TDC. # set debug_sync= 'RESET'; # Switching to connection 'deadlock_con1'. -# Start statement which will acquire SR metadata lock on t2, open it -# and then will stop, before trying to acquire SR lock and opening t1. +# Start a statement which will acquire SR metadata lock on t2, open it +# and then stop, before trying to acquire SR on t1 and opening it. set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; # Sending: select * from t2, t1; @@ -2134,8 +2133,7 @@ drop tables t1, t2; # Wait until DROP TABLES starts waiting for X lock on t2. # Resume SELECT, so it tries to acquire SR lock on t1 and blocks, # creating a deadlock. This deadlock should be detected and resolved -# by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should -# be able to finish. +# by backing-off SELECT. As a result, FTWRL should be able to finish. set debug_sync='now SIGNAL go'; # Switching to connection 'deadlock_con2'. # Reap FLUSH TABLES WITH READ LOCK. @@ -2149,8 +2147,8 @@ ERROR 42S02: Table 'test.t2' doesn't exist # Switching to connection 'default'. set debug_sync= 'RESET'; # -# Test for scenario in which FLUSH TABLES <list> WITH READ LOCK -# has been erroneously releasing metadata locks. +# Test for a scenario in which FLUSH TABLES <list> WITH READ LOCK +# used to erroneously release metadata locks. # drop tables if exists t1, t2; set debug_sync= 'RESET'; @@ -2159,15 +2157,15 @@ create table t2(j int); # Switching to connection 'con2'. set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; # The below FLUSH TABLES <list> WITH READ LOCK should acquire -# SNW locks on t1 and t2, open table t1 and wait on debug sync -# point. +# SNW locks on t1 and t2, open table t1 and block on the debug +# sync point. # Sending: flush tables t1, t2 with read lock; # Switching to connection 'con1'. # Wait till FLUSH TABLES <list> WITH READ LOCK stops. set debug_sync='now WAIT_FOR parked'; -# Start statement which will flush all tables and thus invalidate -# table t1 open by FLUSH TABLES <list> WITH READ LOCK. +# Start a statement which will flush all tables and thus +# invalidate table t1 open by FLUSH TABLES <list> WITH READ LOCK. # Sending: flush tables; # Switching to connection 'default'. @@ -2175,7 +2173,7 @@ flush tables; # Resume FLUSH TABLES <list> WITH READ LOCK, so it tries to open t2 # discovers that its t1 is obsolete and tries to reopen all tables. # Such reopen should not cause releasing of SNW metadata locks -# which will result in assertion failures. +# which would result in assertion failures. set debug_sync='now SIGNAL go'; # Switching to connection 'con2'. # Reap FLUSH TABLES <list> WITH READ LOCK. diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 112a86e0c88..f209e401764 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -701,6 +701,7 @@ drop table t1,t2,t3,t4; set query_cache_wlock_invalidate=1; create table t1 (a int not null); create table t2 (a int not null); +create view v1 as select * from t1; select * from t1; a select * from t2; @@ -713,6 +714,17 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 1 unlock table; +select * from t1; +a +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +lock table v1 write; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +unlock table; +drop view v1; drop table t1,t2; set query_cache_wlock_invalidate=default; CREATE TABLE t1 (id INT PRIMARY KEY); @@ -853,7 +865,7 @@ Variable_name Value Qcache_queries_in_cache 0 show status like "Qcache_inserts"; Variable_name Value -Qcache_inserts 18 +Qcache_inserts 19 show status like "Qcache_hits"; Variable_name Value Qcache_hits 6 @@ -866,7 +878,7 @@ Variable_name Value Qcache_queries_in_cache 1 show status like "Qcache_inserts"; Variable_name Value -Qcache_inserts 19 +Qcache_inserts 20 show status like "Qcache_hits"; Variable_name Value Qcache_hits 7 diff --git a/mysql-test/r/raid.result b/mysql-test/r/raid.result deleted file mode 100644 index 459da1cdf49..00000000000 --- a/mysql-test/r/raid.result +++ /dev/null @@ -1,208 +0,0 @@ -DROP TABLE IF EXISTS t1,t2; -DROP DATABASE IF EXISTS test_$1; -create database test_$1; -create table test_$1.r1 (i int) raid_type=1; -create table test_$1.r2 (i int) raid_type=1 raid_chunks=32; -drop database test_$1; -create database test_$1; -create table test_$1.r2 (i int) raid_type=1 raid_chunks=257; -show create table test_$1.r2; -Table Create Table -r2 CREATE TABLE `r2` ( - `i` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 RAID_TYPE=striped RAID_CHUNKS=255 RAID_CHUNKSIZE=256 -drop database test_$1; -CREATE TABLE t1 ( -id int unsigned not null auto_increment primary key, -c char(255) not null -) RAID_TYPE=STRIPED RAID_CHUNKS=2 RAID_CHUNKSIZE=123; -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -select count(*) from t1; -count(*) -450 -ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL; -ALTER TABLE t1 ADD KEY c (c); -ALTER TABLE t1 DROP KEY c; -ALTER TABLE t1 DROP COLUMN x; -ALTER TABLE t1 RENAME t2; -select count(*) from t2; -count(*) -450 -DROP TABLE t2; -/* variable rows */ -CREATE TABLE t1 ( -id int unsigned not null auto_increment primary key, -c varchar(255) not null -) RAID_TYPE=STRIPED RAID_CHUNKS=5 RAID_CHUNKSIZE=121; -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -select count(*) from t1; -count(*) -450 -ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL; -ALTER TABLE t1 ADD KEY c (c); -ALTER TABLE t1 DROP KEY c; -ALTER TABLE t1 DROP COLUMN x; -ALTER TABLE t1 RENAME t2; -ALTER TABLE t2 CHANGE COLUMN c c VARCHAR(251) NOT NULL; -select count(*) from t2; -count(*) -450 -DROP TABLE t2; diff --git a/mysql-test/r/schema.result b/mysql-test/r/schema.result index 853c3bcf575..809d652053e 100644 --- a/mysql-test/r/schema.result +++ b/mysql-test/r/schema.result @@ -16,21 +16,19 @@ drop schema foo; # Bug #48940 MDL deadlocks against mysql_rm_db # DROP SCHEMA IF EXISTS schema1; -DROP SCHEMA IF EXISTS schema2; # Connection default CREATE SCHEMA schema1; -CREATE SCHEMA schema2; CREATE TABLE schema1.t1 (a INT); SET autocommit= FALSE; INSERT INTO schema1.t1 VALUES (1); # Connection 2 DROP SCHEMA schema1; # Connection default -ALTER SCHEMA schema2 DEFAULT CHARACTER SET utf8; +ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8; +Got one of the listed errors SET autocommit= TRUE; # Connection 2 # Connection default -DROP SCHEMA schema2; # # Bug #49988 MDL deadlocks with mysql_create_db, reload_acl_and_cache # diff --git a/mysql-test/r/signal.result b/mysql-test/r/signal.result index 410abffcdf0..67bf9330451 100644 --- a/mysql-test/r/signal.result +++ b/mysql-test/r/signal.result @@ -1189,6 +1189,8 @@ end $$ call test_signal() $$ Caught by SQLSTATE Caught by SQLSTATE +Warnings: +Warning 1012 Raising a warning drop procedure test_signal $$ create procedure test_signal() begin @@ -1204,6 +1206,8 @@ end $$ call test_signal() $$ Caught by number Caught by number +Warnings: +Warning 1012 Raising a warning drop procedure test_signal $$ create procedure test_signal() begin @@ -1219,6 +1223,8 @@ end $$ call test_signal() $$ Caught by SQLWARNING Caught by SQLWARNING +Warnings: +Warning 1012 Raising a warning drop procedure test_signal $$ create procedure test_signal() begin @@ -1234,6 +1240,8 @@ end $$ call test_signal() $$ Caught by SQLSTATE Caught by SQLSTATE +Warnings: +Error 1012 Raising a not found drop procedure test_signal $$ create procedure test_signal() begin @@ -1249,6 +1257,8 @@ end $$ call test_signal() $$ Caught by number Caught by number +Warnings: +Error 1012 Raising a not found drop procedure test_signal $$ create procedure test_signal() begin @@ -1264,6 +1274,8 @@ end $$ call test_signal() $$ Caught by NOT FOUND Caught by NOT FOUND +Warnings: +Error 1012 Raising a not found drop procedure test_signal $$ create procedure test_signal() begin @@ -1279,6 +1291,8 @@ end $$ call test_signal() $$ Caught by SQLSTATE Caught by SQLSTATE +Warnings: +Error 1012 Raising an error drop procedure test_signal $$ create procedure test_signal() begin @@ -1294,6 +1308,8 @@ end $$ call test_signal() $$ Caught by number Caught by number +Warnings: +Error 1012 Raising an error drop procedure test_signal $$ create procedure test_signal() begin @@ -1309,6 +1325,8 @@ end $$ call test_signal() $$ Caught by SQLEXCEPTION Caught by SQLEXCEPTION +Warnings: +Error 1012 Raising an error drop procedure test_signal $$ # # Test where SIGNAL can be used @@ -1455,6 +1473,7 @@ after RESIGNAL after RESIGNAL Warnings: Warning 1012 Raising a warning +Warning 1012 Raising a warning drop procedure test_resignal $$ create procedure test_resignal() begin @@ -1509,6 +1528,7 @@ after RESIGNAL after RESIGNAL Warnings: Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 1 drop procedure test_resignal $$ create procedure test_resignal() begin @@ -1565,6 +1585,7 @@ before RESIGNAL after RESIGNAL after RESIGNAL Warnings: +Warning 1012 Raising a warning Warning 5555 RESIGNAL of a warning drop procedure test_resignal $$ create procedure test_resignal() @@ -1625,6 +1646,7 @@ before RESIGNAL after RESIGNAL after RESIGNAL Warnings: +Warning 1264 Out of range value for column 'a' at row 1 Warning 5555 RESIGNAL of a warning drop procedure test_resignal $$ create procedure test_resignal() @@ -2126,6 +2148,9 @@ CALL peter_p2() $$ ERROR 42000: Hi, I am a useless error message show warnings $$ Level Code Message +Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL' +Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL' +Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL' Error 9999 Hi, I am a useless error message drop procedure peter_p1 $$ drop procedure peter_p2 $$ @@ -2135,15 +2160,17 @@ DECLARE x CONDITION FOR SQLSTATE '42000'; DECLARE EXIT HANDLER FOR x BEGIN SELECT '2'; +SHOW WARNINGS; RESIGNAL x SET MYSQL_ERRNO = 9999; END; BEGIN DECLARE EXIT HANDLER FOR x BEGIN SELECT '1'; +SHOW WARNINGS; RESIGNAL x SET SCHEMA_NAME = 'test', -MYSQL_ERRNO= 1231; +MYSQL_ERRNO= 1232; END; /* Raises ER_WRONG_VALUE_FOR_VAR : 1231, SQLSTATE 42000 */ SET @@sql_mode=NULL; @@ -2156,6 +2183,7 @@ DECLARE x CONDITION for SQLSTATE '42000'; DECLARE EXIT HANDLER FOR x BEGIN SELECT '3'; +SHOW WARNINGS; RESIGNAL x SET MESSAGE_TEXT = 'Hi, I am a useless error message', MYSQL_ERRNO = 9999; @@ -2166,15 +2194,24 @@ $$ CALL peter_p2() $$ 1 1 +Level Code Message +Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL' 2 2 +Level Code Message +Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL' +Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL' 3 3 +Level Code Message +Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL' +Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL' +Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL' ERROR 42000: Hi, I am a useless error message show warnings $$ Level Code Message Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL' -Error 1231 Variable 'sql_mode' can't be set to the value of 'NULL' +Error 1232 Variable 'sql_mode' can't be set to the value of 'NULL' Error 9999 Variable 'sql_mode' can't be set to the value of 'NULL' Error 9999 Hi, I am a useless error message drop procedure peter_p1 $$ diff --git a/mysql-test/r/signal_demo3.result b/mysql-test/r/signal_demo3.result index aa769659e51..a89ce703d20 100644 --- a/mysql-test/r/signal_demo3.result +++ b/mysql-test/r/signal_demo3.result @@ -95,11 +95,11 @@ call proc_1(); ERROR 45000: Oops in proc_1 show warnings; Level Code Message -Error 1644 Oops in proc_5 -Error 1644 Oops in proc_4 -Error 1644 Oops in proc_3 -Error 1644 Oops in proc_2 -Error 1644 Oops in proc_1 +Error 1051 Unknown table 'oops_it_is_not_here' +Error 1644 Oops in proc_9 +Error 1644 Oops in proc_8 +Error 1644 Oops in proc_7 +Error 1644 Oops in proc_6 SET @@session.max_error_count = 7; SELECT @@session.max_error_count; @@session.max_error_count @@ -108,13 +108,13 @@ call proc_1(); ERROR 45000: Oops in proc_1 show warnings; Level Code Message +Error 1051 Unknown table 'oops_it_is_not_here' +Error 1644 Oops in proc_9 +Error 1644 Oops in proc_8 Error 1644 Oops in proc_7 Error 1644 Oops in proc_6 Error 1644 Oops in proc_5 Error 1644 Oops in proc_4 -Error 1644 Oops in proc_3 -Error 1644 Oops in proc_2 -Error 1644 Oops in proc_1 SET @@session.max_error_count = 9; SELECT @@session.max_error_count; @@session.max_error_count @@ -123,6 +123,7 @@ call proc_1(); ERROR 45000: Oops in proc_1 show warnings; Level Code Message +Error 1051 Unknown table 'oops_it_is_not_here' Error 1644 Oops in proc_9 Error 1644 Oops in proc_8 Error 1644 Oops in proc_7 @@ -131,7 +132,6 @@ Error 1644 Oops in proc_5 Error 1644 Oops in proc_4 Error 1644 Oops in proc_3 Error 1644 Oops in proc_2 -Error 1644 Oops in proc_1 drop database demo; SET @@global.max_error_count = @start_global_value; SELECT @@global.max_error_count; diff --git a/mysql-test/r/sp-big.result b/mysql-test/r/sp-big.result index 9765508859c..d28b7004330 100644 --- a/mysql-test/r/sp-big.result +++ b/mysql-test/r/sp-big.result @@ -46,6 +46,8 @@ end while; close cur1; end| call p1(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select count(*) from t1; count(*) 256 diff --git a/mysql-test/r/sp-bugs.result b/mysql-test/r/sp-bugs.result index 2374b433fba..a88c89537e2 100644 --- a/mysql-test/r/sp-bugs.result +++ b/mysql-test/r/sp-bugs.result @@ -43,6 +43,8 @@ END| SELECT f2 (); f2 () NULL +Warnings: +Error 1305 FUNCTION testdb.f_not_exists does not exist DROP SCHEMA testdb; USE test; # diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result index 0a0f620b80a..c7ea4cbb311 100644 --- a/mysql-test/r/sp-code.result +++ b/mysql-test/r/sp-code.result @@ -711,6 +711,8 @@ looping i looping 1 looping i looping 0 +Warnings: +Error 1062 Duplicate entry '1' for key 'a' call proc_26977_works(2); do something do something @@ -730,6 +732,8 @@ looping i looping 0 optimizer: keep hreturn optimizer: keep hreturn +Warnings: +Error 1062 Duplicate entry '2' for key 'a' drop table t1; drop procedure proc_26977_broken; drop procedure proc_26977_works; @@ -888,3 +892,56 @@ Pos Instruction 4 jump 6 5 error 1339 DROP PROCEDURE p1; +# +# Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP +# + +# - Case 4: check that "No Data trumps Warning". + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE PROCEDURE p1() +BEGIN +DECLARE c CURSOR FOR SELECT a FROM t1; +OPEN c; +BEGIN +DECLARE v INT; +DECLARE CONTINUE HANDLER FOR SQLWARNING +BEGIN +SELECT "Warning found!"; +SHOW WARNINGS; +END; +DECLARE EXIT HANDLER FOR NOT FOUND +BEGIN +SELECT "End of Result Set found!"; +SHOW WARNINGS; +END; +WHILE TRUE DO +FETCH c INTO v; +END WHILE; +END; +CLOSE c; +SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack +END| +SET SESSION debug="+d,bug23032_emit_warning"; +CALL p1(); +Warning found! +Warning found! +Level Code Message +Warning 1105 Unknown error +Warning found! +Warning found! +Level Code Message +Warning 1105 Unknown error +Warning found! +Warning found! +Level Code Message +Warning 1105 Unknown error +End of Result Set found! +End of Result Set found! +Level Code Message +Warning 1105 Unknown error +Error 1329 No data - zero rows fetched, selected, or processed +SET SESSION debug="-d,bug23032_emit_warning"; +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 0f658ee831e..7b8364379df 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1344,6 +1344,8 @@ set @in_func := 0; select func_20713_a(); func_20713_a() NULL +Warnings: +Error 1146 Table 'test.bogus_table_20713' doesn't exist select @in_func; @in_func 2 @@ -1351,6 +1353,8 @@ set @in_func := 0; select func_20713_b(); func_20713_b() NULL +Warnings: +Error 1146 Table 'test.bogus_table_20713' doesn't exist select @in_func; @in_func 2 @@ -1714,3 +1718,246 @@ DROP PROCEDURE p1; DROP VIEW v1; DROP TABLE t1; End of 5.1 tests +# +# Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP +# + +# - Case 1 + +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +DROP PROCEDURE IF EXISTS p5; +DROP PROCEDURE IF EXISTS p6; +CREATE PROCEDURE p1() +BEGIN +SELECT CAST('10 ' as unsigned integer); +SELECT 1; +CALL p2(); +END| +CREATE PROCEDURE p2() +BEGIN +SELECT CAST('10 ' as unsigned integer); +END| +CALL p1(); +CAST('10 ' as unsigned integer) +10 +1 +1 +CAST('10 ' as unsigned integer) +10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10 ' +DROP PROCEDURE p1; +DROP PROCEDURE p2; + +# - Case 2 + +CREATE PROCEDURE p1() +BEGIN +DECLARE c INT DEFAULT 0; +DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1; +CALL p2(); +CALL p3(); +CALL p4(); +SELECT c; +SELECT @@warning_count; +SHOW WARNINGS; +END| +CREATE PROCEDURE p2() +BEGIN +SELECT CAST('10 ' as unsigned integer); +END| +CREATE PROCEDURE p3() +BEGIN +SELECT CAST('10 ' as unsigned integer); +SELECT 1; +END| +CREATE PROCEDURE p4() +BEGIN +SELECT CAST('10 ' as unsigned integer); +CALL p2(); +END| +CREATE PROCEDURE p5() +BEGIN +SELECT CAST('10 ' as unsigned integer); +SHOW WARNINGS; +END| +CREATE PROCEDURE P6() +BEGIN +DECLARE c INT DEFAULT 0; +DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1; +CALL p5(); +SELECT c; +END| +CALL p1(); +CAST('10 ' as unsigned integer) +10 +CAST('10 ' as unsigned integer) +10 +1 +1 +CAST('10 ' as unsigned integer) +10 +CAST('10 ' as unsigned integer) +10 +c +3 +@@warning_count +1 +Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '10 ' +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10 ' +CALL p6(); +CAST('10 ' as unsigned integer) +10 +Level Code Message +Warning 1292 Truncated incorrect INTEGER value: '10 ' +c +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10 ' +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +DROP PROCEDURE p5; +DROP PROCEDURE p6; + +# - Case 3: check that "Exception trumps No Data". + +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE PROCEDURE p1() +BEGIN +DECLARE c CURSOR FOR SELECT a FROM t1; +OPEN c; +BEGIN +DECLARE v1 INT; +DECLARE v2 INT; +DECLARE EXIT HANDLER FOR SQLEXCEPTION +SELECT "Error caught (expected)"; +DECLARE EXIT HANDLER FOR NOT FOUND +SELECT "End of Result Set found!"; +WHILE TRUE DO +FETCH c INTO v1, v2; +END WHILE; +END; +CLOSE c; +SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack +END| +CALL p1(); +Error caught (expected) +Error caught (expected) +DROP PROCEDURE p1; +DROP TABLE t1; +# +# Bug#36185: Incorrect precedence for warning and exception handlers +# +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (a INT, b INT NOT NULL); +CREATE PROCEDURE p1() +BEGIN +DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning'; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception'; +INSERT INTO t1 VALUES (CAST('10 ' AS SIGNED), NULL); +END| +CALL p1(); +exception +exception +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10 ' +Error 1048 Column 'b' cannot be null +DROP TABLE t1; +DROP PROCEDURE p1; +# +# Bug#5889: Exit handler for a warning doesn't hide the warning in trigger +# + +# - Case 1 + +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1, 2); +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +BEGIN +DECLARE EXIT HANDLER FOR SQLWARNING +SET NEW.a = 10; +SET NEW.a = 99999999999; +END| +UPDATE t1 SET b = 20; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SHOW WARNINGS; +Level Code Message +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a b +10 20 +DROP TRIGGER t1_bu; +DROP TABLE t1; + +# - Case 2 + +CREATE TABLE t1(a INT); +CREATE TABLE t2(b CHAR(1)); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +BEGIN +INSERT INTO t2 VALUES('ab'); # Produces a warning. +INSERT INTO t2 VALUES('b'); # Does not produce a warning, +# previous warning should be cleared. +END| +INSERT INTO t1 VALUES(0); +SHOW WARNINGS; +Level Code Message +SELECT * FROM t1; +a +0 +SELECT * FROM t2; +b +a +b +DROP TRIGGER t1_bi; +DROP TABLE t1; +DROP TABLE t2; +# +# Bug#9857: Stored procedures: handler for sqlwarning ignored +# +SET @sql_mode_saved = @@sql_mode; +SET sql_mode = traditional; +CREATE PROCEDURE p1() +BEGIN +DECLARE CONTINUE HANDLER FOR SQLWARNING +SELECT 'warning caught (expected)'; +SELECT 5 / 0; +END| +CREATE PROCEDURE p2() +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION +SELECT 'error caught (unexpected)'; +SELECT 5 / 0; +END| +CALL p1(); +5 / 0 +NULL +warning caught (expected) +warning caught (expected) +Warnings: +Warning 1365 Division by 0 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 +CALL p2(); +5 / 0 +NULL +Warnings: +Warning 1365 Division by 0 +SHOW WARNINGS; +Level Code Message +Warning 1365 Division by 0 +DROP PROCEDURE p1; +DROP PROCEDURE p2; +SET sql_mode = @sql_mode_saved; diff --git a/mysql-test/r/sp-lock.result b/mysql-test/r/sp-lock.result index a7823175b3c..0d3e87f17e2 100644 --- a/mysql-test/r/sp-lock.result +++ b/mysql-test/r/sp-lock.result @@ -148,12 +148,12 @@ f1() # Sending 'drop procedure p1'... drop procedure p1; # --> connection con2 -# Waitng for 'drop procedure t1' to get blocked on MDL lock... +# Waiting for 'drop procedure t1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -174,12 +174,12 @@ f1() # Sending 'create procedure p1'... create procedure p1() begin end; # --> connection con2 -# Waitng for 'create procedure t1' to get blocked on MDL lock... +# Waiting for 'create procedure t1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -200,12 +200,12 @@ f1() # Sending 'alter procedure p1'... alter procedure p1 contains sql; # --> connection con2 -# Waitng for 'alter procedure t1' to get blocked on MDL lock... +# Waiting for 'alter procedure t1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -226,12 +226,12 @@ f1() # Sending 'drop function f1'... drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -252,12 +252,12 @@ f1() # Sending 'create function f1'... create function f1() returns int return 2; # --> connection con2 -# Waitng for 'create function f1' to get blocked on MDL lock... +# Waiting for 'create function f1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -279,12 +279,12 @@ f1() # Sending 'alter function f1'... alter function f1 contains sql; # --> connection con2 -# Waitng for 'alter function f1' to get blocked on MDL lock... +# Waiting for 'alter function f1' to get blocked on MDL lock... # Demonstrate that there is a pending exclusive lock. # Sending 'select f1()'... select f1(); # --> connection con3 -# Waitng for 'select f1()' to get blocked by a pending MDL lock... +# Waiting for 'select f1()' to get blocked by a pending MDL lock... # --> connection default commit; # --> connection con1 @@ -360,7 +360,7 @@ insert into t1 (a) values (1); # Sending 'drop function f1' drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -379,7 +379,7 @@ a # Sending 'drop function f1' drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -403,7 +403,7 @@ a # Sending 'drop procedure p1' drop procedure p1; # --> connection con2 -# Waitng for 'drop procedure p1' to get blocked on MDL lock... +# Waiting for 'drop procedure p1' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -424,7 +424,7 @@ insert into t1 (a) values (3); # Sending 'drop function f2' drop function f2; # --> connection con2 -# Waitng for 'drop function f2' to get blocked on MDL lock... +# Waiting for 'drop function f2' to get blocked on MDL lock... # --> connnection default commit; # --> connection con1 @@ -479,11 +479,11 @@ f2() # Sending 'drop function f1'... drop function f1; # --> connection con2 -# Waitng for 'drop function f1' to get blocked on MDL lock... +# Waiting for 'drop function f1' to get blocked on MDL lock... # Sending 'drop function f2'... drop function f2; # --> connection default -# Waitng for 'drop function f2' to get blocked on MDL lock... +# Waiting for 'drop function f2' to get blocked on MDL lock... rollback to savepoint sv; # --> connection con2 # Reaping 'drop function f2'... @@ -537,10 +537,10 @@ f1() # Sending 'alter function f1 ...'... alter function f1 comment "comment"; # --> connection con2 -# Waitng for 'alter function f1 ...' to get blocked on MDL lock... +# Waiting for 'alter function f1 ...' to get blocked on MDL lock... # Sending 'call p1()'... call p1(); -# Waitng for 'call p1()' to get blocked on MDL lock on f1... +# Waiting for 'call p1()' to get blocked on MDL lock on f1... # Let 'alter function f1 ...' go through... commit; # --> connection con1 @@ -573,7 +573,7 @@ f1() # Sending 'alter function f1 ...'... alter function f1 comment "comment"; # --> connection con2 -# Waitng for 'alter function f1 ...' to get blocked on MDL lock... +# Waiting for 'alter function f1 ...' to get blocked on MDL lock... # # We just mention p1() in the body of f2() to make # sure that p1() is prelocked for f2(). @@ -595,7 +595,7 @@ select f2() into @var; end| # Sending 'call p1()'... call p1(); -# Waitng for 'call p1()' to get blocked on MDL lock on f1... +# Waiting for 'call p1()' to get blocked on MDL lock on f1... # Let 'alter function f1 ...' go through... commit; # --> connection con1 @@ -634,7 +634,7 @@ get_lock("30977", 0) # Sending 'select f3()'... select f3(); # --> connection con1 -# Waitng for 'select f3()' to get blocked on the user level lock... +# Waiting for 'select f3()' to get blocked on the user level lock... # Do something to change the cache version. create function f4() returns int return 4; drop function f4; diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result index a14d099c673..9b458e25615 100644 --- a/mysql-test/r/sp-threads.result +++ b/mysql-test/r/sp-threads.result @@ -35,7 +35,7 @@ call bug9486(); show processlist; Id User Host db Command Time State Info # root localhost test Sleep # NULL -# root localhost test Query # Waiting for table update t1, t2 set val= 1 where id1=id2 +# root localhost test Query # Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2 # root localhost test Query # NULL show processlist # root localhost test Sleep # NULL unlock tables; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 76d4bf2dea0..243bfb6c07d 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -737,6 +737,8 @@ close c; end| insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)| call cur1()| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select * from t1| id data foo 40 @@ -772,6 +774,8 @@ close c1; close c2; end| call cur2()| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select * from t3 order by i,s| s i bar 3 @@ -861,6 +865,8 @@ end$ set @@sql_mode = ''| set sql_select_limit = 1| call modes(@c1, @c2)| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed set sql_select_limit = default| select @c1, @c2| @c1 @c2 @@ -1682,42 +1688,64 @@ end| call h_ee()| h_ee Inner (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_es()| h_es Outer (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_en()| h_en Outer (good) +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed call h_ew()| h_ew Outer (good) call h_ex()| h_ex Outer (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_se()| h_se Inner (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_ss()| h_ss Inner (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_sn()| h_sn Outer (good) +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed call h_sw()| h_sw Outer (good) call h_sx()| h_sx Outer (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_ne()| h_ne Inner (good) +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed call h_ns()| h_ns Inner (good) +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed call h_nn()| h_nn Inner (good) +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed call h_we()| h_we Inner (good) @@ -1730,12 +1758,18 @@ Inner (good) call h_xe()| h_xe Inner (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_xs()| h_xs Inner (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' call h_xx()| h_xx Inner (good) +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' drop table t3| drop procedure h_ee| drop procedure h_es| @@ -1884,6 +1918,8 @@ set @x2 = 2; close c1; end| call bug2260()| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select @x2| @x2 2 @@ -2027,6 +2063,8 @@ insert into t3 values (123456789012); insert into t3 values (0); end| call bug2780()| +Warnings: +Warning 1264 Out of range value for column 's1' at row 1 select @x| @x 1 @@ -2449,6 +2487,8 @@ declare continue handler for sqlstate 'HY000' begin end; select s1 from t3 union select s2 from t3; end| call bug4904()| +Warnings: +Error 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (latin2_general_ci,IMPLICIT) for operation 'UNION' drop procedure bug4904| drop table t3| drop procedure if exists bug336| @@ -2588,13 +2628,17 @@ select row_count()| row_count() 1 call bug4905()| +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' select row_count()| row_count() -0 +-1 call bug4905()| +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' select row_count()| row_count() -0 +-1 select * from t3| s1 1 @@ -2615,10 +2659,14 @@ insert into t3 values (1)| call bug6029()| sqlstate 23000 sqlstate 23000 +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' delete from t3| call bug6029()| 1136 1136 +Warnings: +Error 1136 Column count doesn't match value count at row 1 drop procedure bug6029| drop table t3| drop procedure if exists bug8540| @@ -2910,15 +2958,23 @@ end| call bug6900()| 2 2 +Warnings: +Error 1136 Column count doesn't match value count at row 1 call bug9074()| x1 x2 x3 x4 x5 x6 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' call bug6900_9074(0)| sqlexception sqlexception +Warnings: +Error 1136 Column count doesn't match value count at row 1 call bug6900_9074(1)| 23000 23000 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' drop procedure bug6900| drop procedure bug9074| drop procedure bug6900_9074| @@ -2961,9 +3017,13 @@ delete from t1| call bug9856()| 16 16 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed call bug9856()| 16 16 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed drop procedure bug9856| drop procedure if exists bug9674_1| drop procedure if exists bug9674_2| @@ -3194,6 +3254,8 @@ x 2 x 3 +Warnings: +Error 1326 Cursor is not open call bug10961()| x 1 @@ -3201,6 +3263,8 @@ x 2 x 3 +Warnings: +Error 1326 Cursor is not open drop procedure bug10961| DROP PROCEDURE IF EXISTS bug6866| DROP VIEW IF EXISTS tv| @@ -3316,7 +3380,11 @@ insert into t1 values ('Name4', 13), ('Name5', 14)| call bug11529()| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed call bug11529()| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed delete from t1| drop procedure bug11529| set character set utf8| @@ -3490,24 +3558,32 @@ end; end if; end| call bug12168('a')| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select * from t4| a 1 3 truncate t4| call bug12168('b')| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select * from t4| a 2 4 truncate t4| call bug12168('a')| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select * from t4| a 1 3 truncate t4| call bug12168('b')| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select * from t4| a 2 @@ -3807,6 +3883,8 @@ end| call bug7049_2()| Result Caught it +Warnings: +Error 1062 Duplicate entry '42' for key 'x' select * from t3| x 42 @@ -3814,12 +3892,16 @@ delete from t3| call bug7049_4()| Result Caught it +Warnings: +Error 1062 Duplicate entry '42' for key 'x' select * from t3| x 42 select bug7049_2()| bug7049_2() 1 +Warnings: +Error 1062 Duplicate entry '42' for key 'x' drop table t3| drop procedure bug7049_1| drop procedure bug7049_2| @@ -3947,6 +4029,8 @@ end| call bug14845()| a 0 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed drop procedure bug14845| drop procedure if exists bug13549_1| drop procedure if exists bug13549_2| @@ -4150,6 +4234,8 @@ end| call bug13729()| 55 55 +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' select * from t3| s1 1 @@ -4186,11 +4272,15 @@ Handler boo v isnull(v) NULL 1 +Warnings: +Error 1054 Unknown column 'undefined_var' in 'field list' call bug14643_2()| Handler boo Handler boo +Warnings: +Error 1054 Unknown column 'undefined_var' in 'field list' drop procedure bug14643_1| drop procedure bug14643_2| drop procedure if exists bug14304| @@ -4514,11 +4604,15 @@ Handler error End done +Warnings: +Error 1054 Unknown column 'v' in 'field list' call bug14498_2()| Handler error End done +Warnings: +Error 1054 Unknown column 'v' in 'field list' call bug14498_3()| v maybe @@ -4526,16 +4620,22 @@ Handler error End done +Warnings: +Error 1054 Unknown column 'v' in 'field list' call bug14498_4()| Handler error End done +Warnings: +Error 1054 Unknown column 'v' in 'field list' call bug14498_5()| Handler error End done +Warnings: +Error 1054 Unknown column 'v' in 'field list' drop procedure bug14498_1| drop procedure bug14498_2| drop procedure bug14498_3| @@ -4546,6 +4646,8 @@ drop procedure if exists bug15231_1| drop procedure if exists bug15231_2| drop procedure if exists bug15231_3| drop procedure if exists bug15231_4| +drop procedure if exists bug15231_5| +drop procedure if exists bug15231_6| create table t3 (id int not null)| create procedure bug15231_1() begin @@ -4568,7 +4670,7 @@ end| create procedure bug15231_3() begin declare exit handler for sqlwarning -select 'Caught it (wrong)' as 'Result'; +select 'Caught it (correct)' as 'Result'; call bug15231_4(); end| create procedure bug15231_4() @@ -4576,6 +4678,20 @@ begin declare x decimal(2,1); set x = 'zap'; select 'Missed it (correct)' as 'Result'; +show warnings; +end| +create procedure bug15231_5() +begin +declare exit handler for sqlwarning +select 'Caught it (wrong)' as 'Result'; +call bug15231_6(); +end| +create procedure bug15231_6() +begin +declare x decimal(2,1); +set x = 'zap'; +select 'Missed it (correct)' as 'Result'; +select id from t3; end| call bug15231_1()| 1 @@ -4583,19 +4699,29 @@ Before NOT FOUND condition is triggered 2 After NOT FOUND condtition is triggered xid xdone -1 0 +1 1 Warnings: Warning 1329 No data - zero rows fetched, selected, or processed call bug15231_3()| Result Missed it (correct) +Level Code Message +Warning 1366 Incorrect decimal value: 'zap' for column 'x' at row 1 +Result +Caught it (correct) Warnings: Warning 1366 Incorrect decimal value: 'zap' for column 'x' at row 1 -drop table if exists t3| -drop procedure if exists bug15231_1| -drop procedure if exists bug15231_2| -drop procedure if exists bug15231_3| -drop procedure if exists bug15231_4| +call bug15231_5()| +Result +Missed it (correct) +id +drop table t3| +drop procedure bug15231_1| +drop procedure bug15231_2| +drop procedure bug15231_3| +drop procedure bug15231_4| +drop procedure bug15231_5| +drop procedure bug15231_6| drop procedure if exists bug15011| create table t3 (c1 int primary key)| insert into t3 values (1)| @@ -4613,6 +4739,8 @@ end| call bug15011()| Handler Inner +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' drop procedure bug15011| drop table t3| drop procedure if exists bug17476| @@ -4688,6 +4816,8 @@ i 1 i 0 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed drop table t3| drop procedure bug16887| drop procedure if exists bug16474_1| @@ -4760,6 +4890,8 @@ declare continue handler for sqlexception begin end; select no_such_function(); end| call bug18787()| +Warnings: +Error 1305 FUNCTION test.no_such_function does not exist drop procedure bug18787| create database bug18344_012345678901| use bug18344_012345678901| @@ -5133,6 +5265,8 @@ statement failed statement failed statement after update statement after update +Warnings: +Error 1242 Subquery returns more than 1 row select * from t3| a 1 @@ -5144,6 +5278,8 @@ statement failed statement failed statement after update statement after update +Warnings: +Error 1242 Subquery returns more than 1 row select * from t3| a 1 @@ -5176,6 +5312,8 @@ in continue handler in continue handler reachable code a2 reachable code a2 +Warnings: +Error 1242 Subquery returns more than 1 row select * from t3| a 1 @@ -5191,6 +5329,8 @@ in continue handler in continue handler reachable code a2 reachable code a2 +Warnings: +Error 1242 Subquery returns more than 1 row select * from t3| a 1 @@ -5224,6 +5364,8 @@ in continue handler in continue handler reachable code a2 reachable code a2 +Warnings: +Error 1305 FUNCTION test.no_such_function does not exist drop procedure bug8153_proc_a| drop procedure bug8153_proc_b| drop table t3| @@ -5792,9 +5934,13 @@ end| select func_8407_a()| func_8407_a() NULL +Warnings: +Error 1146 Table 'test.no_such_view' doesn't exist select func_8407_b()| func_8407_b() 1500 +Warnings: +Error 1146 Table 'test.no_such_view' doesn't exist drop function func_8407_a| drop function func_8407_b| drop table if exists table_26503| @@ -5916,6 +6062,8 @@ looping i looping 0 leaving handler leaving handler +Warnings: +Error 1062 Duplicate entry '1' for key 'a' call proc_26503_ok_2(2)| do something do something @@ -5927,6 +6075,8 @@ looping i looping 4 leaving handler leaving handler +Warnings: +Error 1062 Duplicate entry '2' for key 'a' call proc_26503_ok_3(3)| do something do something @@ -5946,6 +6096,8 @@ looping i looping 0 leaving handler leaving handler +Warnings: +Error 1062 Duplicate entry '3' for key 'a' call proc_26503_ok_4(4)| do something do something @@ -5957,6 +6109,8 @@ looping i looping 4 leaving handler leaving handler +Warnings: +Error 1062 Duplicate entry '4' for key 'a' drop table table_26503| drop procedure proc_26503_ok_1| drop procedure proc_26503_ok_2| @@ -6670,6 +6824,8 @@ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @exception:= 'run'; SELECT x FROM t1; END| CALL bug29770(); +Warnings: +Error 1054 Unknown column 'x' in 'field list' SELECT @state, @exception; @state @exception run NULL @@ -6708,6 +6864,8 @@ end; end while; end// call proc_33618(20); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed drop table t_33618; drop procedure proc_33618; # diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index f55e535a293..4fa91121f50 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -99,6 +99,8 @@ return i; end| set @error_in_func:= 0| insert into t1 values (bug10015_6(5)), (bug10015_6(6))| +Warnings: +Error 1062 Duplicate entry '1' for key 'PRIMARY' select @error_in_func| @error_in_func 1 @@ -524,6 +526,8 @@ until done end repeat; close c; end| call bug14210()| +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed select count(*) from t4| count(*) 256 diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 4f259fc4d7d..79f8c20a150 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -1190,6 +1190,8 @@ select'a'; insert into t1 values (200); end;| call t1(); a a +Warnings: +Error 1264 Out of range value for column 'col1' at row 1 select * from t1; col1 drop procedure t1; diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 6c3f54fca38..05ab1b71018 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -527,3 +527,17 @@ ERROR HY000: You are using safe update mode and you tried to update a table with SET SESSION sql_safe_updates = DEFAULT; DROP TABLE t1; DROP VIEW v1; +# +# Bug#54734 assert in Diagnostics_area::set_ok_status +# +DROP TABLE IF EXISTS t1, not_exists; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk; +CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists); +CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13; +UPDATE v1 SET pk = 7 WHERE pk > 0; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v1; +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 96b45f0d5bb..777ac9c258f 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3946,6 +3946,8 @@ create view a as select 1; end| call p(); call p(); +Warnings: +Error 1050 Table 'a' already exists drop view a; drop procedure p; # diff --git a/mysql-test/suite/binlog/t/binlog_stm_row.test b/mysql-test/suite/binlog/t/binlog_stm_row.test index 6165048c7d4..87758d57725 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_row.test +++ b/mysql-test/suite/binlog/t/binlog_stm_row.test @@ -60,7 +60,7 @@ let $wait_condition= --echo # con1 let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE - state = "Table lock" and info = "INSERT INTO t2 VALUES (3)"; + state = "Waiting for table level lock" and info = "INSERT INTO t2 VALUES (3)"; --source include/wait_condition.inc SELECT RELEASE_LOCK('Bug#34306'); --connection con2 diff --git a/mysql-test/suite/federated/federated_server.result b/mysql-test/suite/federated/federated_server.result index 5079a4dcfa0..e5cff2bb2bf 100644 --- a/mysql-test/suite/federated/federated_server.result +++ b/mysql-test/suite/federated/federated_server.result @@ -54,7 +54,7 @@ PASSWORD '', PORT SLAVE_PORT, SOCKET '', OWNER 'root'); -select * from mysql.servers; +select * from mysql.servers order by Server_name; Server_name Host Db Username Password Port Socket Wrapper Owner server_one 127.0.0.1 first_db root SLAVE_PORT mysql root server_two 127.0.0.1 second_db root SLAVE_PORT mysql root @@ -154,7 +154,7 @@ id name drop table federated.t1; drop server 'server_one'; drop server 'server_two'; -select * from mysql.servers; +select * from mysql.servers order by Server_name; Server_name Host Db Username Password Port Socket Wrapper Owner drop table first_db.t1; drop table second_db.t1; @@ -254,6 +254,8 @@ password '', socket '', owner '', port 3306); drop server 's1'; # End of 5.1 tests use test; +create table t1(a int); +insert into t1 values (1); create procedure p1 () begin DECLARE v INT DEFAULT 0; @@ -268,11 +270,13 @@ ALTER SERVER s OPTIONS (USER 'Remote'); DROP SERVER s; SET v = v + 1; END WHILE; +select a into @a from t1; # Just reset warnings END// use test; call p1(); call p1(); drop procedure p1; +drop table t1; drop server if exists s; DROP TABLE IF EXISTS federated.t1; DROP DATABASE federated; diff --git a/mysql-test/suite/federated/federated_server.test b/mysql-test/suite/federated/federated_server.test index ec952d071f2..9e883743450 100644 --- a/mysql-test/suite/federated/federated_server.test +++ b/mysql-test/suite/federated/federated_server.test @@ -62,7 +62,7 @@ eval create server 'server_two' foreign data wrapper 'mysql' options OWNER 'root'); --replace_result $SLAVE_MYPORT SLAVE_PORT -eval select * from mysql.servers; +eval select * from mysql.servers order by Server_name; DROP TABLE IF EXISTS federated.old; --replace_result $SLAVE_MYPORT SLAVE_PORT @@ -147,7 +147,7 @@ drop table federated.t1; drop server 'server_one'; drop server 'server_two'; -select * from mysql.servers; +select * from mysql.servers order by Server_name; connection slave; drop table first_db.t1; @@ -301,6 +301,8 @@ drop server 's1'; connect (other,localhost,root,,); connection master; use test; +create table t1(a int); +insert into t1 values (1); delimiter //; create procedure p1 () begin @@ -316,6 +318,7 @@ begin DROP SERVER s; SET v = v + 1; END WHILE; + select a into @a from t1; # Just reset warnings END// delimiter ;// connection other; @@ -326,6 +329,7 @@ call p1(); connection other; reap; drop procedure p1; +drop table t1; drop server if exists s; diff --git a/mysql-test/suite/funcs_1/datadict/processlist_val.inc b/mysql-test/suite/funcs_1/datadict/processlist_val.inc index 9c6bd585fde..1327338e761 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc @@ -367,14 +367,14 @@ echo ; connection default; echo -# Poll till INFO is no more NULL and State = 'Waiting for table'. +# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. ; let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE INFO IS NOT NULL AND STATE = 'Waiting for table'; + WHERE INFO IS NOT NULL AND STATE = 'Waiting for table metadata lock'; --source include/wait_condition.inc # -# Expect to see the state 'Waiting for table' for the third connection because the SELECT -# collides with the WRITE TABLE LOCK. +# Expect to see the state 'Waiting for table metadata lock' for the third +# connection because the SELECT collides with the WRITE TABLE LOCK. --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; UNLOCK TABLES; @@ -422,10 +422,10 @@ echo ; connection default; echo -# Poll till INFO is no more NULL and State = 'Waiting for table'. +# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. ; let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE INFO IS NOT NULL AND STATE = 'Waiting for table'; + WHERE INFO IS NOT NULL AND STATE = 'Waiting for table metadata lock'; --source include/wait_condition.inc echo # Expect result: diff --git a/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result b/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result index 3e2d084aa0c..2bc9a75a13e 100644 --- a/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result +++ b/mysql-test/suite/funcs_1/r/innodb_storedproc_02.result @@ -347,6 +347,8 @@ CALL h1(); -7- 1 1 1 1 1 1 END x1 x2 x3 x4 x5 x6 END 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' DROP TABLE IF EXISTS tnull; DROP PROCEDURE IF EXISTS sp1; CREATE TABLE tnull(f1 int); @@ -445,6 +447,8 @@ END// CALL h2(); x1 x2 x3 x4 x5 x6 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' SELECT * FROM res_t1; w x a b @@ -550,6 +554,8 @@ exit handler 2 exit handler 2 exit handler 1 exit handler 1 +Warnings: +Error 1146 Table 'db_storedproc.tqq' doesn't exist create table res_t1(w char unique, x char); insert into res_t1 values ('a', 'b'); CREATE PROCEDURE h1 () @@ -580,6 +586,8 @@ END// CALL h1(); x1 x2 x3 x4 x5 x6 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' This will fail, SQLSTATE 00000 is not allowed CREATE PROCEDURE sp1() begin1_label:BEGIN @@ -623,6 +631,8 @@ CALL sp2(); NULL @x2 @x 1 2 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE sp1; DROP PROCEDURE sp2; @@ -654,6 +664,8 @@ ERROR 42000: Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expe CALL sp2(); -1- @x2 @x -1- 0 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 SELECT '-3-', @x2, @x; -3- @x2 @x -3- 1 1 @@ -696,6 +708,8 @@ CALL sp2(); -2- 1 20 -4- @x2 @x -4- 11 22 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE sp1; DROP PROCEDURE sp2; @@ -762,21 +776,33 @@ SELECT @done, @x; 0 1 INSERT INTO temp VALUES('1', NULL); CALL sp1(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 1 INSERT INTO temp VALUES('2', NULL); CALL sp2(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 1 INSERT INTO temp VALUES('3', NULL); CALL sp3(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 0 INSERT INTO temp VALUES('4', NULL); CALL sp4(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 0 @@ -885,18 +911,26 @@ SELECT @done, @x; @done @x 0 1 CALL sp1(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 2 CALL sp2(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 2 CALL sp3(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 1 CALL sp4(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 1 @@ -1031,6 +1065,8 @@ SQLSTATE 21000 SQLSTATE 24000 +Warnings: +Error 1326 Cursor is not open SELECT '-1-', @x; -1- @x -1- 6 @@ -1041,18 +1077,24 @@ SQLSTATE SQLEXCEPTION SQLSTATE 24000 +Warnings: +Error 1326 Cursor is not open SELECT '-2-', @x; -2- @x -2- 6 CALL sp3(); SQLSTATE 20000 +Warnings: +Error 1339 Case not found for CASE statement SELECT '-3-', @x; -3- @x -3- 1 CALL sp4(); SQLSTATE SQLEXCEPTION +Warnings: +Error 1339 Case not found for CASE statement SELECT '-4-', @x; -4- @x -4- 1 @@ -1335,6 +1377,8 @@ CLOSE cur1; CLOSE cur2; END// CALL sp_outer(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT * FROM temp1; f0 cnt f1 f2 f3 f4 _sp_out_ 1 a` a` 1000-01-01 -5000 diff --git a/mysql-test/suite/funcs_1/r/memory_storedproc_02.result b/mysql-test/suite/funcs_1/r/memory_storedproc_02.result index 16dde71400e..f18678e3896 100644 --- a/mysql-test/suite/funcs_1/r/memory_storedproc_02.result +++ b/mysql-test/suite/funcs_1/r/memory_storedproc_02.result @@ -348,6 +348,8 @@ CALL h1(); -7- 1 1 1 1 1 1 END x1 x2 x3 x4 x5 x6 END 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' DROP TABLE IF EXISTS tnull; DROP PROCEDURE IF EXISTS sp1; CREATE TABLE tnull(f1 int); @@ -446,6 +448,8 @@ END// CALL h2(); x1 x2 x3 x4 x5 x6 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' SELECT * FROM res_t1; w x a b @@ -551,6 +555,8 @@ exit handler 2 exit handler 2 exit handler 1 exit handler 1 +Warnings: +Error 1146 Table 'db_storedproc.tqq' doesn't exist create table res_t1(w char unique, x char); insert into res_t1 values ('a', 'b'); CREATE PROCEDURE h1 () @@ -581,6 +587,8 @@ END// CALL h1(); x1 x2 x3 x4 x5 x6 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' This will fail, SQLSTATE 00000 is not allowed CREATE PROCEDURE sp1() begin1_label:BEGIN @@ -624,6 +632,8 @@ CALL sp2(); NULL @x2 @x 1 2 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE sp1; DROP PROCEDURE sp2; @@ -655,6 +665,8 @@ ERROR 42000: Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expe CALL sp2(); -1- @x2 @x -1- 0 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 SELECT '-3-', @x2, @x; -3- @x2 @x -3- 1 1 @@ -697,6 +709,8 @@ CALL sp2(); -2- 1 20 -4- @x2 @x -4- 11 22 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE sp1; DROP PROCEDURE sp2; @@ -763,21 +777,33 @@ SELECT @done, @x; 0 1 INSERT INTO temp VALUES('1', NULL); CALL sp1(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 1 INSERT INTO temp VALUES('2', NULL); CALL sp2(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 1 INSERT INTO temp VALUES('3', NULL); CALL sp3(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 0 INSERT INTO temp VALUES('4', NULL); CALL sp4(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 0 @@ -886,18 +912,26 @@ SELECT @done, @x; @done @x 0 1 CALL sp1(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 2 CALL sp2(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 2 CALL sp3(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 1 CALL sp4(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 1 @@ -1032,6 +1066,8 @@ SQLSTATE 21000 SQLSTATE 24000 +Warnings: +Error 1326 Cursor is not open SELECT '-1-', @x; -1- @x -1- 6 @@ -1042,18 +1078,24 @@ SQLSTATE SQLEXCEPTION SQLSTATE 24000 +Warnings: +Error 1326 Cursor is not open SELECT '-2-', @x; -2- @x -2- 6 CALL sp3(); SQLSTATE 20000 +Warnings: +Error 1339 Case not found for CASE statement SELECT '-3-', @x; -3- @x -3- 1 CALL sp4(); SQLSTATE SQLEXCEPTION +Warnings: +Error 1339 Case not found for CASE statement SELECT '-4-', @x; -4- @x -4- 1 @@ -1336,6 +1378,8 @@ CLOSE cur1; CLOSE cur2; END// CALL sp_outer(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT * FROM temp1; f0 cnt f1 f2 f3 f4 _sp_out_ 1 a` a` 1000-01-01 -5000 diff --git a/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result b/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result index 16dde71400e..f18678e3896 100644 --- a/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result +++ b/mysql-test/suite/funcs_1/r/myisam_storedproc_02.result @@ -348,6 +348,8 @@ CALL h1(); -7- 1 1 1 1 1 1 END x1 x2 x3 x4 x5 x6 END 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' DROP TABLE IF EXISTS tnull; DROP PROCEDURE IF EXISTS sp1; CREATE TABLE tnull(f1 int); @@ -446,6 +448,8 @@ END// CALL h2(); x1 x2 x3 x4 x5 x6 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' SELECT * FROM res_t1; w x a b @@ -551,6 +555,8 @@ exit handler 2 exit handler 2 exit handler 1 exit handler 1 +Warnings: +Error 1146 Table 'db_storedproc.tqq' doesn't exist create table res_t1(w char unique, x char); insert into res_t1 values ('a', 'b'); CREATE PROCEDURE h1 () @@ -581,6 +587,8 @@ END// CALL h1(); x1 x2 x3 x4 x5 x6 1 1 1 1 1 1 +Warnings: +Error 1062 Duplicate entry 'a' for key 'w' This will fail, SQLSTATE 00000 is not allowed CREATE PROCEDURE sp1() begin1_label:BEGIN @@ -624,6 +632,8 @@ CALL sp2(); NULL @x2 @x 1 2 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE sp1; DROP PROCEDURE sp2; @@ -655,6 +665,8 @@ ERROR 42000: Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expe CALL sp2(); -1- @x2 @x -1- 0 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 SELECT '-3-', @x2, @x; -3- @x2 @x -3- 1 1 @@ -697,6 +709,8 @@ CALL sp2(); -2- 1 20 -4- @x2 @x -4- 11 22 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE sp1; DROP PROCEDURE sp2; @@ -763,21 +777,33 @@ SELECT @done, @x; 0 1 INSERT INTO temp VALUES('1', NULL); CALL sp1(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 1 INSERT INTO temp VALUES('2', NULL); CALL sp2(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 1 INSERT INTO temp VALUES('3', NULL); CALL sp3(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 0 INSERT INTO temp VALUES('4', NULL); CALL sp4(); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +Warning 1265 Data truncated for column 'f2' at row 1 SELECT @done, @x; @done @x 1 0 @@ -886,18 +912,26 @@ SELECT @done, @x; @done @x 0 1 CALL sp1(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 2 CALL sp2(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 2 CALL sp3(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 1 CALL sp4(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT @done, @x; @done @x 1 1 @@ -1032,6 +1066,8 @@ SQLSTATE 21000 SQLSTATE 24000 +Warnings: +Error 1326 Cursor is not open SELECT '-1-', @x; -1- @x -1- 6 @@ -1042,18 +1078,24 @@ SQLSTATE SQLEXCEPTION SQLSTATE 24000 +Warnings: +Error 1326 Cursor is not open SELECT '-2-', @x; -2- @x -2- 6 CALL sp3(); SQLSTATE 20000 +Warnings: +Error 1339 Case not found for CASE statement SELECT '-3-', @x; -3- @x -3- 1 CALL sp4(); SQLSTATE SQLEXCEPTION +Warnings: +Error 1339 Case not found for CASE statement SELECT '-4-', @x; -4- @x -4- 1 @@ -1336,6 +1378,8 @@ CLOSE cur1; CLOSE cur2; END// CALL sp_outer(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT * FROM temp1; f0 cnt f1 f2 f3 f4 _sp_out_ 1 a` a` 1000-01-01 -5000 diff --git a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result index 5f79fd04a90..fbc1f2d5015 100644 --- a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result +++ b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result @@ -193,11 +193,11 @@ LOCK TABLE test.t1 WRITE; SELECT COUNT(*) FROM test.t1; # ----- switch to connection default (user = root) ----- -# Poll till INFO is no more NULL and State = 'Waiting for table'. +# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; ID USER HOST DB COMMAND TIME STATE INFO -<ID> test_user <HOST_NAME> information_schema Query <TIME> Waiting for table SELECT COUNT(*) FROM test.t1 +<ID> test_user <HOST_NAME> information_schema Query <TIME> Waiting for table metadata lock SELECT COUNT(*) FROM test.t1 <ID> test_user <HOST_NAME> information_schema Sleep <TIME> NULL <ID> root <HOST_NAME> information_schema Query <TIME> executing SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST UNLOCK TABLES; @@ -221,7 +221,7 @@ LOCK TABLE test.t1 WRITE; SELECT count(*),'BEGIN-This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.-END' AS "Long string" FROM test.t1; # ----- switch to connection default (user = root) ----- -# Poll till INFO is no more NULL and State = 'Waiting for table'. +# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. # Expect result: # Statement Content of INFO diff --git a/mysql-test/suite/funcs_1/r/processlist_val_ps.result b/mysql-test/suite/funcs_1/r/processlist_val_ps.result index bb8e25c87ab..c003b5b66f6 100644 --- a/mysql-test/suite/funcs_1/r/processlist_val_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_val_ps.result @@ -193,11 +193,11 @@ LOCK TABLE test.t1 WRITE; SELECT COUNT(*) FROM test.t1; # ----- switch to connection default (user = root) ----- -# Poll till INFO is no more NULL and State = 'Waiting for table'. +# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; ID USER HOST DB COMMAND TIME STATE INFO -<ID> test_user <HOST_NAME> information_schema Query <TIME> Waiting for table SELECT COUNT(*) FROM test.t1 +<ID> test_user <HOST_NAME> information_schema Query <TIME> Waiting for table metadata lock SELECT COUNT(*) FROM test.t1 <ID> test_user <HOST_NAME> information_schema Sleep <TIME> NULL <ID> root <HOST_NAME> information_schema Execute <TIME> executing SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST UNLOCK TABLES; @@ -221,7 +221,7 @@ LOCK TABLE test.t1 WRITE; SELECT count(*),'BEGIN-This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.-END' AS "Long string" FROM test.t1; # ----- switch to connection default (user = root) ----- -# Poll till INFO is no more NULL and State = 'Waiting for table'. +# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. # Expect result: # Statement Content of INFO diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 082da9938f7..bdb3b285189 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -9325,6 +9325,8 @@ insert into t2 values (1); set @x = 3; END// CALL sp1(); +Warnings: +Error 1136 Column count doesn't match value count at row 1 DROP PROCEDURE sp1; DROP PROCEDURE IF EXISTS sp1; Warnings: @@ -13754,6 +13756,8 @@ END// CALL sp1(); x y @x NULL a 3 +Warnings: +Error 1305 PROCEDURE db_storedproc.nonsexist does not exist SELECT @v1, @v2; @v1 @v2 4 a @@ -14938,6 +14942,8 @@ NULL NULL NULL NULL @x @y NULL NULL +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DROP PROCEDURE sp1; Testcase 4.2.63: @@ -15097,6 +15103,8 @@ END; fetch cur1 into newf1, newf2, newf4, newf3; END// CALL sp1(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DROP PROCEDURE sp1; Testcase 4.2.70: @@ -22447,6 +22455,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE h1; DROP PROCEDURE sp1; @@ -22464,6 +22474,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1305 PROCEDURE db_storedproc.sp1 does not exist DROP PROCEDURE h1; Testcase 4.11.3: @@ -22483,6 +22495,8 @@ CALL sp1 (1); set @x=0; END// CALL h1(); +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 SELECT @x, @x2; @x @x2 1 1 @@ -22501,6 +22515,8 @@ CALL sp1 (1); set @x=0; END// CALL h1 (); +Warnings: +Error 1305 PROCEDURE db_storedproc.sp1 does not exist SELECT @x, @x2; @x @x2 1 1 @@ -22525,6 +22541,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE h1; DROP PROCEDURE sp1; @@ -22547,6 +22565,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE h1; DROP PROCEDURE sp1; @@ -22569,6 +22589,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE h1; DROP PROCEDURE sp1; @@ -22586,6 +22608,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1305 PROCEDURE db_storedproc.sp1 does not exist DROP PROCEDURE h1; Testcase 4.11.9: @@ -22605,6 +22629,8 @@ CALL sp1 (1); set @x=0; END// CALL h1(); +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 SELECT @x, @x2; @x @x2 1 1 @@ -22623,6 +22649,8 @@ CALL sp1 (1); set @x=0; END// CALL h1 (); +Warnings: +Error 1305 PROCEDURE db_storedproc.sp1 does not exist SELECT @x, @x2; @x @x2 1 1 @@ -22647,6 +22675,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE h1; DROP PROCEDURE sp1; @@ -22669,6 +22699,8 @@ END// CALL h1 (); @x @x2 1 1 +Warnings: +Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1 DROP PROCEDURE h1; DROP PROCEDURE sp1; @@ -22704,6 +22736,8 @@ done 1 done 1 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22777,6 +22811,8 @@ done 0 done 1 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22814,6 +22850,8 @@ done 0 done 1 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22844,6 +22882,8 @@ done 0 done 1 +Warnings: +Error 1328 Incorrect number of FETCH variables DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22874,6 +22914,8 @@ done 0 done 1 +Warnings: +Error 1328 Incorrect number of FETCH variables DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22904,6 +22946,8 @@ END// CALL h1(); done 0 +Warnings: +Error 1328 Incorrect number of FETCH variables DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22934,6 +22978,8 @@ END// CALL h1(); done 0 +Warnings: +Error 1328 Incorrect number of FETCH variables DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22964,6 +23010,8 @@ done 0 done 1 +Warnings: +Error 1325 Cursor is already open DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -22995,6 +23043,8 @@ done 0 done @x 1 1 +Warnings: +Error 1325 Cursor is already open DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -23025,6 +23075,8 @@ END// CALL h1(); done 0 +Warnings: +Error 1325 Cursor is already open DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -23055,6 +23107,8 @@ END// CALL h1(); done 0 +Warnings: +Error 1325 Cursor is already open DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -23082,6 +23136,8 @@ END// CALL h1(); done @x 1 1 +Warnings: +Error 1326 Cursor is not open DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -23109,6 +23165,8 @@ END// CALL h1(); done @x 1 1 +Warnings: +Error 1326 Cursor is not open DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -23134,6 +23192,8 @@ set @x=1; SELECT done, @x; END// CALL h1(); +Warnings: +Error 1326 Cursor is not open DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -23159,6 +23219,8 @@ set @x=1; SELECT done, @x; END// CALL h1(); +Warnings: +Error 1326 Cursor is not open DROP PROCEDURE IF EXISTS h1; drop table IF EXISTS res_t1; drop table IF EXISTS res_t2; @@ -23189,6 +23251,8 @@ END// CALL h1(); done @x 1 1 +Warnings: +Error 1339 Case not found for CASE statement DROP PROCEDURE IF EXISTS h1; drop table IF EXISTS res_t1; drop table IF EXISTS res_t2; @@ -23219,6 +23283,8 @@ END// CALL h1(); done @x 1 1 +Warnings: +Error 1339 Case not found for CASE statement DROP PROCEDURE IF EXISTS h1; drop table IF EXISTS res_t1; drop table IF EXISTS res_t2; @@ -23247,6 +23313,8 @@ set @x=1; SELECT done, @x; END// CALL h1(); +Warnings: +Error 1339 Case not found for CASE statement DROP PROCEDURE IF EXISTS h1; drop table IF EXISTS res_t1; drop table IF EXISTS res_t2; @@ -23275,6 +23343,8 @@ set @x=1; SELECT done, @x; END// CALL h1(); +Warnings: +Error 1339 Case not found for CASE statement DROP PROCEDURE IF EXISTS h1; DROP TABLE IF EXISTS res_t1; DROP TABLE IF EXISTS res_t2; @@ -23423,6 +23493,9 @@ CREATE TABLE res_t1(w CHAR, x CHAR); INSERT INTO res_t1 VALUES('a', 'b'); INSERT INTO res_t1 VALUES('c', 'd'); CALL h1(); +Warnings: +Warning 1265 Data truncated for column 'w' at row 1 +Warning 1265 Data truncated for column 'x' at row 1 SELECT @done, @x; @done @x 1 1 @@ -23445,6 +23518,9 @@ CREATE TABLE res_t1(w CHAR, x CHAR); INSERT INTO res_t1 VALUES('a', 'b'); INSERT INTO res_t1 VALUES('c', 'd'); CALL h1(); +Warnings: +Warning 1265 Data truncated for column 'w' at row 1 +Warning 1265 Data truncated for column 'x' at row 1 SELECT @done, @x; @done @x 1 1 diff --git a/mysql-test/suite/innodb/r/innodb_bug52199.result b/mysql-test/suite/innodb/r/innodb_bug52199.result new file mode 100644 index 00000000000..7e8c1ee46e0 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug52199.result @@ -0,0 +1,5 @@ +CREATE TABLE bug52199 (a INT NOT NULL, +b CHAR(125) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL +)ENGINE=InnoDB; +CREATE UNIQUE INDEX idx ON bug52199(a); +DROP TABLE bug52199; diff --git a/mysql-test/suite/innodb/r/innodb_bug54044.result b/mysql-test/suite/innodb/r/innodb_bug54044.result new file mode 100644 index 00000000000..90ab812f2ae --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug54044.result @@ -0,0 +1,3 @@ +CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB +AS SELECT IF(NULL IS NOT NULL, NULL, NULL); +ERROR HY000: Can't create table 'test.table_54044' (errno: -1) diff --git a/mysql-test/suite/innodb/r/innodb_bug54679.result b/mysql-test/suite/innodb/r/innodb_bug54679.result new file mode 100644 index 00000000000..948696fb31d --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug54679.result @@ -0,0 +1,88 @@ +SET GLOBAL innodb_file_format='Barracuda'; +SET GLOBAL innodb_file_per_table=ON; +SET innodb_strict_mode=ON; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +bug54679 Compressed row_format=COMPRESSED +ALTER TABLE bug54679 ADD COLUMN b INT; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +bug54679 Compressed row_format=COMPRESSED +DROP TABLE bug54679; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +bug54679 Compact +ALTER TABLE bug54679 KEY_BLOCK_SIZE=1; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +bug54679 Compressed KEY_BLOCK_SIZE=1 +ALTER TABLE bug54679 ROW_FORMAT=REDUNDANT; +ERROR HY000: Can't create table '#sql-temporary' (errno: 1478) +SHOW WARNINGS; +Level Code Message +Warning 1478 InnoDB: cannot specify ROW_FORMAT = REDUNDANT with KEY_BLOCK_SIZE. +Error 1005 Can't create table '#sql-temporary' (errno: 1478) +DROP TABLE bug54679; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +bug54679 Redundant row_format=REDUNDANT +ALTER TABLE bug54679 KEY_BLOCK_SIZE=2; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; +TABLE_NAME ROW_FORMAT CREATE_OPTIONS +bug54679 Compressed row_format=REDUNDANT KEY_BLOCK_SIZE=2 +SET GLOBAL innodb_file_format=Antelope; +ALTER TABLE bug54679 KEY_BLOCK_SIZE=4; +ERROR HY000: Can't create table '#sql-temporary' (errno: 1478) +SHOW WARNINGS; +Level Code Message +Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope. +Error 1005 Can't create table '#sql-temporary' (errno: 1478) +ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC; +ERROR HY000: Can't create table '#sql-temporary' (errno: 1478) +SHOW WARNINGS; +Level Code Message +Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope. +Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. +Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE. +Error 1005 Can't create table '#sql-temporary' (errno: 1478) +DROP TABLE bug54679; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +ERROR HY000: Can't create table 'test.bug54679' (errno: 1478) +SHOW WARNINGS; +Level Code Message +Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. +Error 1005 Can't create table 'test.bug54679' (errno: 1478) +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB; +SET GLOBAL innodb_file_format=Barracuda; +SET GLOBAL innodb_file_per_table=OFF; +ALTER TABLE bug54679 KEY_BLOCK_SIZE=4; +ERROR HY000: Can't create table '#sql-temporary' (errno: 1478) +SHOW WARNINGS; +Level Code Message +Warning 1478 InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table. +Error 1005 Can't create table '#sql-temporary' (errno: 1478) +ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC; +ERROR HY000: Can't create table '#sql-temporary' (errno: 1478) +SHOW WARNINGS; +Level Code Message +Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. +Error 1005 Can't create table '#sql-temporary' (errno: 1478) +DROP TABLE bug54679; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +ERROR HY000: Can't create table 'test.bug54679' (errno: 1478) +SHOW WARNINGS; +Level Code Message +Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. +Error 1005 Can't create table 'test.bug54679' (errno: 1478) +SET GLOBAL innodb_file_per_table=ON; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +DROP TABLE bug54679; diff --git a/mysql-test/suite/innodb/r/innodb_information_schema.result b/mysql-test/suite/innodb/r/innodb_information_schema.result index 1737dab2ff0..13de084bc09 100644 --- a/mysql-test/suite/innodb/r/innodb_information_schema.result +++ b/mysql-test/suite/innodb/r/innodb_information_schema.result @@ -42,21 +42,7 @@ trx_isolation_level varchar(16) NO trx_unique_checks int(1) NO 0 trx_foreign_key_checks int(1) NO 0 trx_last_foreign_key_error varchar(256) YES NULL -trx_apative_hash_latched int(1) NO 0 -trx_adaptive_hash_timeout bigint(21) unsigned NO 0 -trx_operation_state varchar(64) YES NULL -trx_tables_in_use bigint(21) unsigned NO 0 -trx_tables_locked bigint(21) unsigned NO 0 -trx_lock_structs bigint(21) unsigned NO 0 -trx_lock_memory_bytes bigint(21) unsigned NO 0 -trx_rows_locked bigint(21) unsigned NO 0 -trx_rows_modified bigint(21) unsigned NO 0 -trx_concurrency_tickets bigint(21) unsigned NO 0 -trx_isolation_level varchar(16) NO -trx_unique_checks int(1) NO 0 -trx_foreign_key_checks int(1) NO 0 -trx_last_foreign_key_error varchar(256) YES NULL -trx_apative_hash_latched int(1) NO 0 +trx_adaptive_hash_latched int(1) NO 0 trx_adaptive_hash_timeout bigint(21) unsigned NO 0 trx_state trx_weight trx_tables_in_use trx_tables_locked trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks RUNNING 4 0 0 7 1 0 REPEATABLE READ 1 1 diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index b418b62ec90..9a677f83080 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -2538,6 +2538,14 @@ ORDER BY f1 DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range f2,f4 f4 1 NULL 11 Using where DROP TABLE t1; +# +# Bug#54117 crash in thr_multi_unlock, temporary table +# +CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB; +LOCK TABLES t1 READ; +ALTER TABLE t1 COMMENT 'test'; +UNLOCK TABLES; +DROP TABLE t1; End of 5.1 tests # # Test for bug #39932 "create table fails if column for FK is in different diff --git a/mysql-test/suite/innodb/t/innodb-lock.test b/mysql-test/suite/innodb/t/innodb-lock.test index 05df3615822..96f555e3ecc 100644 --- a/mysql-test/suite/innodb/t/innodb-lock.test +++ b/mysql-test/suite/innodb/t/innodb-lock.test @@ -87,7 +87,8 @@ connection con1; --echo # Wait until LOCK TABLE is blocked on SQL-level lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock table t1 write"; + where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # We should be able to do UPDATEs and SELECTs within transaction. update t1 set x=1 where id = 0; diff --git a/mysql-test/suite/innodb/t/innodb_bug52199.test b/mysql-test/suite/innodb/t/innodb_bug52199.test new file mode 100644 index 00000000000..0fec64ba243 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug52199.test @@ -0,0 +1,7 @@ +-- source include/have_innodb.inc + +CREATE TABLE bug52199 (a INT NOT NULL, +b CHAR(125) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL +)ENGINE=InnoDB; +CREATE UNIQUE INDEX idx ON bug52199(a); +DROP TABLE bug52199; diff --git a/mysql-test/suite/innodb/t/innodb_bug54044.test b/mysql-test/suite/innodb/t/innodb_bug54044.test new file mode 100644 index 00000000000..a6722ed6399 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug54044.test @@ -0,0 +1,11 @@ +# This is the test for bug #54044. Special handle MYSQL_TYPE_NULL type +# during create table, so it will not trigger assertion failure. + +--source include/have_innodb.inc + +# This 'create table' operation should fail because of +# using NULL datatype +--error ER_CANT_CREATE_TABLE +CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB + AS SELECT IF(NULL IS NOT NULL, NULL, NULL); + diff --git a/mysql-test/suite/innodb/t/innodb_bug54679.test b/mysql-test/suite/innodb/t/innodb_bug54679.test new file mode 100644 index 00000000000..c5e308acb5e --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug54679.test @@ -0,0 +1,101 @@ +# Test Bug #54679 alter table causes compressed row_format to revert to compact + +--source include/have_innodb.inc + +let $file_format=`select @@innodb_file_format`; +let $file_format_max=`select @@innodb_file_format_max`; +let $file_per_table=`select @@innodb_file_per_table`; +SET GLOBAL innodb_file_format='Barracuda'; +SET GLOBAL innodb_file_per_table=ON; +SET innodb_strict_mode=ON; + +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; + +# The ROW_FORMAT of the table should be preserved when it is not specified +# in ALTER TABLE. +ALTER TABLE bug54679 ADD COLUMN b INT; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; + +DROP TABLE bug54679; + +# Check that the ROW_FORMAT conversion to/from COMPRESSED works. + +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; + +# KEY_BLOCK_SIZE implies COMPRESSED. +ALTER TABLE bug54679 KEY_BLOCK_SIZE=1; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; + +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +ALTER TABLE bug54679 ROW_FORMAT=REDUNDANT; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +SHOW WARNINGS; +DROP TABLE bug54679; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; + +ALTER TABLE bug54679 KEY_BLOCK_SIZE=2; +SELECT TABLE_NAME,ROW_FORMAT,CREATE_OPTIONS FROM information_schema.tables +WHERE TABLE_NAME='bug54679'; + +# This prevents other than REDUNDANT or COMPACT ROW_FORMAT for new tables. +SET GLOBAL innodb_file_format=Antelope; + +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +ALTER TABLE bug54679 KEY_BLOCK_SIZE=4; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +SHOW WARNINGS; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +SHOW WARNINGS; +DROP TABLE bug54679; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +SHOW WARNINGS; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB; + +SET GLOBAL innodb_file_format=Barracuda; +# This will prevent ROW_FORMAT=COMPRESSED, because the system tablespace +# cannot be compressed. +SET GLOBAL innodb_file_per_table=OFF; + +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +ALTER TABLE bug54679 KEY_BLOCK_SIZE=4; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +SHOW WARNINGS; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +ALTER TABLE bug54679 ROW_FORMAT=DYNAMIC; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +SHOW WARNINGS; +DROP TABLE bug54679; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +SHOW WARNINGS; +SET GLOBAL innodb_file_per_table=ON; +CREATE TABLE bug54679 (a INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +DROP TABLE bug54679; + +# restore original values, quietly so the test does not fail if those +# defaults are changed +-- disable_query_log +EVAL SET GLOBAL innodb_file_format=$file_format; +EVAL SET GLOBAL innodb_file_format_max=$file_format_max; +EVAL SET GLOBAL innodb_file_per_table=$file_per_table; +-- enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index fcd54075ecc..495d5c014ce 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -737,6 +737,20 @@ ORDER BY f1 DESC LIMIT 5; DROP TABLE t1; + +--echo # +--echo # Bug#54117 crash in thr_multi_unlock, temporary table +--echo # + +CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB; + +LOCK TABLES t1 READ; +ALTER TABLE t1 COMMENT 'test'; +UNLOCK TABLES; + +DROP TABLE t1; + + --echo End of 5.1 tests diff --git a/mysql-test/suite/perfschema/include/upgrade_check.inc b/mysql-test/suite/perfschema/include/upgrade_check.inc new file mode 100644 index 00000000000..935a71ab065 --- /dev/null +++ b/mysql-test/suite/perfschema/include/upgrade_check.inc @@ -0,0 +1,29 @@ +# Copyright (C) 2010 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Routine to be called by pfs_upgrade.test +# $out_file and $err_file must be set within pfs_upgrade.test. +# + +--error 1 +--exec $MYSQL_UPGRADE --skip-verbose > $out_file 2> $err_file + +# Verify that mysql_upgrade complained about the performance_schema +--cat_file $err_file +--error 0,1 +--remove_file $out_file +--error 0,1 +--remove_file $err_file + diff --git a/mysql-test/suite/perfschema/r/query_cache.result b/mysql-test/suite/perfschema/r/query_cache.result index f2fe8c727b2..a0aeac5a916 100644 --- a/mysql-test/suite/perfschema/r/query_cache.result +++ b/mysql-test/suite/perfschema/r/query_cache.result @@ -65,3 +65,4 @@ Variable_name Value Qcache_hits 1 SET GLOBAL query_cache_size= default; drop table t1; +flush status; diff --git a/mysql-test/suite/perfschema/r/selects.result b/mysql-test/suite/perfschema/r/selects.result index b5bef207303..9b91c6f0fc8 100644 --- a/mysql-test/suite/perfschema/r/selects.result +++ b/mysql-test/suite/perfschema/r/selects.result @@ -55,14 +55,21 @@ THREAD_ID EVENT_ID [THREAD_ID] [EVENT_ID] [THREAD_ID] [EVENT_ID] [THREAD_ID] [EVENT_ID] +DROP TABLE IF EXISTS t_event; +DROP EVENT IF EXISTS t_ps_event; +CREATE TABLE t_event AS +SELECT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT +WHERE 1 = 2; CREATE EVENT t_ps_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND -DO SELECT DISTINCT EVENT_ID +DO INSERT INTO t_event +SELECT DISTINCT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT JOIN performance_schema.EVENTS_WAITS_HISTORY USING (EVENT_ID) ORDER BY EVENT_ID LIMIT 1; ALTER TABLE t1 ADD COLUMN c INT; +DROP TRIGGER IF EXISTS t_ps_trigger; CREATE TRIGGER t_ps_trigger BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET NEW.c = (SELECT MAX(EVENT_ID) @@ -76,6 +83,7 @@ id c 12 [EVENT_ID] 13 [EVENT_ID] DROP TRIGGER t_ps_trigger; +DROP PROCEDURE IF EXISTS t_ps_proc; CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT) BEGIN SELECT id FROM performance_schema.PROCESSLIST @@ -83,6 +91,7 @@ WHERE THREAD_ID = tid INTO pid; END; | CALL t_ps_proc(0, @p_id); +DROP FUNCTION IF EXISTS t_ps_proc; CREATE FUNCTION t_ps_func(tid INT) RETURNS int BEGIN return (SELECT id FROM performance_schema.PROCESSLIST @@ -92,6 +101,10 @@ END; SELECT t_ps_func(0) = @p_id; t_ps_func(0) = @p_id 1 +SELECT * FROM t_event; +EVENT_ID +[EVENT_ID] DROP PROCEDURE t_ps_proc; DROP FUNCTION t_ps_func; DROP TABLE t1; +DROP TABLE t_event; diff --git a/mysql-test/suite/perfschema/r/server_init.result b/mysql-test/suite/perfschema/r/server_init.result index a73f12a0a20..5f3b071484d 100644 --- a/mysql-test/suite/perfschema/r/server_init.result +++ b/mysql-test/suite/perfschema/r/server_init.result @@ -48,10 +48,6 @@ where name like "wait/synch/mutex/sql/LOCK_thread_count"; count(name) 1 select count(name) from MUTEX_INSTANCES -where name like "wait/synch/mutex/sql/LOCK_mapped_file"; -count(name) -1 -select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_status"; count(name) 1 @@ -184,6 +180,10 @@ where name like "wait/synch/cond/sql/COND_server_started"; count(name) 1 select count(name) from COND_INSTANCES +where name like "wait/synch/cond/sql/COND_refresh"; +count(name) +0 +select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_thread_count"; count(name) 1 diff --git a/mysql-test/suite/perfschema/t/bad_option_1.test b/mysql-test/suite/perfschema/t/bad_option_1.test index 9962f327093..ee4f0d0d160 100644 --- a/mysql-test/suite/perfschema/t/bad_option_1.test +++ b/mysql-test/suite/perfschema/t/bad_option_1.test @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, 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 @@ -10,8 +10,8 @@ # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA # Tests for PERFORMANCE_SCHEMA # Check error handling for invalid server start options @@ -19,8 +19,11 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +let $outfile= $MYSQLTEST_VARDIR/tmp/bad_option_1.txt; +--error 0,1 +--remove_file $outfile --error 7 ---exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-enabled=maybe > $MYSQLTEST_VARDIR/tmp/bad_option_1.txt 2>&1 +--exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-enabled=maybe > $outfile 2>&1 perl; use strict; @@ -42,4 +45,5 @@ perl; } close FILE; EOF +--remove_file $outfile diff --git a/mysql-test/suite/perfschema/t/bad_option_2.test b/mysql-test/suite/perfschema/t/bad_option_2.test index a8d15764864..b8f45be3cdf 100644 --- a/mysql-test/suite/perfschema/t/bad_option_2.test +++ b/mysql-test/suite/perfschema/t/bad_option_2.test @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, 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 @@ -10,8 +10,8 @@ # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA # Tests for PERFORMANCE_SCHEMA # Check error handling for ambiguous server start options @@ -19,8 +19,11 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +let $outfile= $MYSQLTEST_VARDIR/tmp/bad_option_2.txt; +--error 0,1 +--remove_file $outfile --error 3 ---exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-max_=12 > $MYSQLTEST_VARDIR/tmp/bad_option_2.txt 2>&1 +--exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-max_=12 > $outfile 2>&1 perl; use strict; @@ -41,4 +44,5 @@ perl; } close FILE; EOF +--remove_file $outfile diff --git a/mysql-test/suite/perfschema/t/global_read_lock.test b/mysql-test/suite/perfschema/t/global_read_lock.test index 16971023cbb..b953ea32ce0 100644 --- a/mysql-test/suite/perfschema/t/global_read_lock.test +++ b/mysql-test/suite/perfschema/t/global_read_lock.test @@ -81,6 +81,7 @@ update performance_schema.SETUP_INSTRUMENTS set enabled='YES'; unlock tables; disconnect con1; +--source include/wait_until_disconnected.inc --echo connection default; connection default; diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade.test b/mysql-test/suite/perfschema/t/pfs_upgrade.test index 4902dc73e8a..b8d25d4a66e 100644 --- a/mysql-test/suite/perfschema/t/pfs_upgrade.test +++ b/mysql-test/suite/perfschema/t/pfs_upgrade.test @@ -22,6 +22,15 @@ --source include/have_perfschema.inc --source include/have_lowercase0.inc +# Some initial settings + Preemptive cleanup +let $MYSQLD_DATADIR= `SELECT @@datadir`; +let $err_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err; +let $out_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out; +--error 0,1 +--remove_file $out_file +--error 0,1 +--remove_file $err_file + --disable_warnings drop table if exists test.user_table; drop procedure if exists test.user_proc; @@ -29,22 +38,20 @@ drop function if exists test.user_func; drop event if exists test.user_event; --enable_warnings + --echo "Testing mysql_upgrade with TABLE performance_schema.user_table" create table test.user_table(a int); -let $MYSQLD_DATADIR= `SELECT @@datadir`; +--error 0,1 +--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm --copy_file $MYSQLD_DATADIR/test/user_table.frm $MYSQLD_DATADIR/performance_schema/user_table.frm # Make sure the table is visible use performance_schema; show tables like "user_table"; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc # Make sure the table is still visible show tables like "user_table"; @@ -54,22 +61,20 @@ use test; --remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm drop table test.user_table; + --echo "Testing mysql_upgrade with VIEW performance_schema.user_view" create view test.user_view as select "Not supposed to be here"; -let $MYSQLD_DATADIR= `SELECT @@datadir`; +--error 0,1 +--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm --copy_file $MYSQLD_DATADIR/test/user_view.frm $MYSQLD_DATADIR/performance_schema/user_view.frm # Make sure the view is visible use performance_schema; show tables like "user_view"; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc # Make sure the view is still visible show tables like "user_view"; @@ -79,6 +84,7 @@ use test; --remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm drop view test.user_view; + --echo "Testing mysql_upgrade with PROCEDURE performance_schema.user_proc" create procedure test.user_proc() @@ -86,17 +92,14 @@ create procedure test.user_proc() update mysql.proc set db='performance_schema' where name='user_proc'; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc select name from mysql.proc where db='performance_schema'; update mysql.proc set db='test' where name='user_proc'; drop procedure test.user_proc; + --echo "Testing mysql_upgrade with FUNCTION performance_schema.user_func" create function test.user_func() returns integer @@ -104,17 +107,14 @@ create function test.user_func() returns integer update mysql.proc set db='performance_schema' where name='user_func'; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc select name from mysql.proc where db='performance_schema'; update mysql.proc set db='test' where name='user_func'; drop function test.user_func; + --echo "Testing mysql_upgrade with EVENT performance_schema.user_event" create event test.user_event on schedule every 1 day do @@ -122,17 +122,10 @@ create event test.user_event on schedule every 1 day do update mysql.event set db='performance_schema' where name='user_event'; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc select name from mysql.event where db='performance_schema'; update mysql.event set db='test' where name='user_event'; drop event test.user_event; ---remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out ---remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - diff --git a/mysql-test/suite/perfschema/t/privilege.test b/mysql-test/suite/perfschema/t/privilege.test index d2f3c2a9e6b..2d682de2870 100644 --- a/mysql-test/suite/perfschema/t/privilege.test +++ b/mysql-test/suite/perfschema/t/privilege.test @@ -350,9 +350,9 @@ TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY; TRUNCATE TABLE performance_schema.EVENTS_WAITS_CURRENT; --echo # Clean up - ---connection default --disconnect pfs_user_4 +--source include/wait_until_disconnected.inc +--connection default REVOKE ALL PRIVILEGES, GRANT OPTION FROM pfs_user_4; DROP USER pfs_user_4; flush privileges; diff --git a/mysql-test/suite/perfschema/t/query_cache.test b/mysql-test/suite/perfschema/t/query_cache.test index 95f78d290ee..a48704dc9d6 100644 --- a/mysql-test/suite/perfschema/t/query_cache.test +++ b/mysql-test/suite/perfschema/t/query_cache.test @@ -1,4 +1,4 @@ -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (C) 2009 Sun Microsystems, Inc # # 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 @@ -10,8 +10,8 @@ # 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, -# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Tests for PERFORMANCE_SCHEMA @@ -33,7 +33,6 @@ SET GLOBAL query_cache_size=1355776; flush query cache; reset query cache; -# Reset Qcache_* to a known state flush status; select * from t1; @@ -67,4 +66,5 @@ show status like "Qcache_hits"; SET GLOBAL query_cache_size= default; drop table t1; +flush status; diff --git a/mysql-test/suite/perfschema/t/read_only.test b/mysql-test/suite/perfschema/t/read_only.test index 62631fa048f..73150207f66 100644 --- a/mysql-test/suite/perfschema/t/read_only.test +++ b/mysql-test/suite/perfschema/t/read_only.test @@ -85,6 +85,7 @@ update performance_schema.SETUP_INSTRUMENTS set enabled='YES'; --enable_result_log disconnect con1; +--source include/wait_until_disconnected.inc --echo connection default; connection default; diff --git a/mysql-test/suite/perfschema/t/selects-master.opt b/mysql-test/suite/perfschema/t/selects-master.opt new file mode 100644 index 00000000000..f93413a61e5 --- /dev/null +++ b/mysql-test/suite/perfschema/t/selects-master.opt @@ -0,0 +1 @@ +--event-scheduler diff --git a/mysql-test/suite/perfschema/t/selects.test b/mysql-test/suite/perfschema/t/selects.test index d5268e8465c..a0c000b80c1 100644 --- a/mysql-test/suite/perfschema/t/selects.test +++ b/mysql-test/suite/perfschema/t/selects.test @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2009 Sun Microsystems, Inc +# Copyright (c) 2008, 2010, 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 @@ -10,8 +10,8 @@ # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA --source include/not_embedded.inc --source include/have_perfschema.inc @@ -85,20 +85,32 @@ LIMIT 5; # EVENT +# Check that the event_scheduler is really running +--source include/running_event_scheduler.inc + +--disable_warnings +DROP TABLE IF EXISTS t_event; +DROP EVENT IF EXISTS t_ps_event; +--enable_warnings +CREATE TABLE t_event AS +SELECT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT +WHERE 1 = 2; CREATE EVENT t_ps_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND -DO SELECT DISTINCT EVENT_ID +DO INSERT INTO t_event + SELECT DISTINCT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT JOIN performance_schema.EVENTS_WAITS_HISTORY USING (EVENT_ID) ORDER BY EVENT_ID LIMIT 1; ---sleep 2 - # TRIGGER ALTER TABLE t1 ADD COLUMN c INT; +--disable_warnings +DROP TRIGGER IF EXISTS t_ps_trigger; +--enable_warnings delimiter |; CREATE TRIGGER t_ps_trigger BEFORE INSERT ON t1 @@ -119,6 +131,9 @@ DROP TRIGGER t_ps_trigger; # PROCEDURE +--disable_warnings +DROP PROCEDURE IF EXISTS t_ps_proc; +--enable_warnings delimiter |; CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT) @@ -135,6 +150,9 @@ CALL t_ps_proc(0, @p_id); # FUNCTION +--disable_warnings +DROP FUNCTION IF EXISTS t_ps_proc; +--enable_warnings delimiter |; CREATE FUNCTION t_ps_func(tid INT) RETURNS int @@ -149,8 +167,17 @@ delimiter ;| SELECT t_ps_func(0) = @p_id; -DROP PROCEDURE t_ps_proc; -DROP FUNCTION t_ps_func; +# We might reach this point too early which means the event scheduler has not +# execute our "t_ps_event". Therefore we poll till the record was inserted +# and run our test statement afterwards. +let $wait_timeout= 20; +let $wait_condition= SELECT COUNT(*) = 1 FROM t_event; +--source include/wait_condition.inc +--replace_column 1 [EVENT_ID] +SELECT * FROM t_event; # Clean up +DROP PROCEDURE t_ps_proc; +DROP FUNCTION t_ps_func; DROP TABLE t1; +DROP TABLE t_event; diff --git a/mysql-test/suite/perfschema/t/server_init.test b/mysql-test/suite/perfschema/t/server_init.test index 080509b944f..2e19d2c843a 100644 --- a/mysql-test/suite/perfschema/t/server_init.test +++ b/mysql-test/suite/perfschema/t/server_init.test @@ -75,9 +75,6 @@ select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_thread_count"; select count(name) from MUTEX_INSTANCES - where name like "wait/synch/mutex/sql/LOCK_mapped_file"; - -select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_status"; select count(name) from MUTEX_INSTANCES @@ -210,6 +207,9 @@ select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_server_started"; select count(name) from COND_INSTANCES + where name like "wait/synch/cond/sql/COND_refresh"; + +select count(name) from COND_INSTANCES where name like "wait/synch/cond/sql/COND_thread_count"; select count(name) from COND_INSTANCES diff --git a/mysql-test/suite/rpl/r/rpl_conditional_comments.result b/mysql-test/suite/rpl/r/rpl_conditional_comments.result new file mode 100644 index 00000000000..f3de3e5eb70 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_conditional_comments.result @@ -0,0 +1,67 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CREATE TABLE t1(c1 INT); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; CREATE TABLE t1(c1 INT) + +# Case 1: +# ------------------------------------------------------------------ +# In a statement, some CCs are applied while others are not. The CCs +# which are not applied on master will be binlogged as common comments. +/*!99999 --- */INSERT /*!INTO*/ /*!10000 t1 */ VALUES(10) /*!99999 ,(11)*/; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; /* 99999 --- */INSERT /*!INTO*/ /*!10000 t1 */ VALUES(10) /* 99999 ,(11)*/ +master-bin.000001 # Query # # COMMIT +Comparing tables master:test.t1 and slave:test.t1 + +# Case 2: +# ----------------------------------------------------------------- +# Verify whether it can be binlogged correctly when executing prepared +# statement. +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla*/ t1 VALUES(60) /*!99999 ,(61)*/'; +EXECUTE stmt; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt; +Comparing tables master:test.t1 and slave:test.t1 + +SET @value=62; +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla */ t1 VALUES(?) /*!99999 ,(63)*/'; +EXECUTE stmt USING @value; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt USING @value; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla*/ t1 VALUES(60) /* 99999 ,(61)*/ +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # use `test`; DROP TABLE t1 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1(c1 INT) +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla*/ t1 VALUES(60) /* 99999 ,(61)*/ +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla */ t1 VALUES(62) /* 99999 ,(63)*/ +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # use `test`; DROP TABLE t1 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1(c1 INT) +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla */ t1 VALUES(62) /* 99999 ,(63)*/ +master-bin.000001 # Query # # COMMIT +Comparing tables master:test.t1 and slave:test.t1 + +# Case 3: +# ----------------------------------------------------------------- +# Verify it can restore the '!', if the it is an uncomplete conditional +# comments +SELECT c1 FROM /*!99999 t1 WHEREN; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*!99999 t1 WHEREN' at line 1 +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/r/rpl_packet.result b/mysql-test/suite/rpl/r/rpl_packet.result index 0a9495751fe..1ec9259a1fb 100644 --- a/mysql-test/suite/rpl/r/rpl_packet.result +++ b/mysql-test/suite/rpl/r/rpl_packet.result @@ -49,6 +49,14 @@ Slave_IO_Running = No (expect No) SELECT "Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'" AS Last_IO_Error; Last_IO_Error Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master' +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +SET @max_allowed_packet_0= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_1= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_2= @@session.max_allowed_packet; ==== clean up ==== DROP TABLE t1; SET @@global.max_allowed_packet= 1024; diff --git a/mysql-test/suite/rpl/r/rpl_row_sp005.result b/mysql-test/suite/rpl/r/rpl_row_sp005.result index 01e1970e0df..58c53b394b2 100644 --- a/mysql-test/suite/rpl/r/rpl_row_sp005.result +++ b/mysql-test/suite/rpl/r/rpl_row_sp005.result @@ -77,6 +77,8 @@ id2 < ---- Master selects-- > ------------------------- CALL test.p1(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed SELECT * FROM test.t3 ORDER BY id3; id3 c 1 MySQL diff --git a/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result b/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result index 6792a701577..079e750e2eb 100644 --- a/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result +++ b/mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result @@ -38,6 +38,8 @@ INSERT INTO t1 VALUES ('MySQL','1993-02-04'),('ROCKS', '1990-08-27'),('Texas', ' END| CALL p2(); CALL p1(); +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DROP TABLE t1; DROP TABLE t2; DROP PROCEDURE p1; diff --git a/mysql-test/suite/rpl/r/rpl_row_trig003.result b/mysql-test/suite/rpl/r/rpl_row_trig003.result index 43c2ecde2b4..131af933b41 100644 --- a/mysql-test/suite/rpl/r/rpl_row_trig003.result +++ b/mysql-test/suite/rpl/r/rpl_row_trig003.result @@ -69,9 +69,15 @@ INSERT INTO test.t2 VALUES(NULL,0,'Testing MySQL databases is a cool ', 'MySQL C UPDATE test.t1 SET b1 = 0 WHERE b1 = 1; INSERT INTO test.t2 VALUES(NULL,1,'This is an after update test.', 'If this works, total will not be zero on the master or slave',1.4321,5.221,0,YEAR(NOW()),NOW()); UPDATE test.t2 SET b1 = 0 WHERE b1 = 1; +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed INSERT INTO test.t1 VALUES(NULL,1,'add some more test data test.', 'and hope for the best', 3.321,5.221,0,YEAR(NOW()),NOW()); DELETE FROM test.t1 WHERE id = 1; +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DELETE FROM test.t2 WHERE id = 1; +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed DROP TRIGGER test.t1_bi; DROP TRIGGER test.t2_ai; DROP TRIGGER test.t1_bu; diff --git a/mysql-test/suite/rpl/t/rpl_conditional_comments.test b/mysql-test/suite/rpl/t/rpl_conditional_comments.test new file mode 100644 index 00000000000..14251d5eb37 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_conditional_comments.test @@ -0,0 +1,74 @@ +############################################################################### +# After the patch for BUG#49124: +# - Use ' ' instead of '!' in the conditional comments which are not applied on +# master. So they become common comments and will not be applied on slave. +# +# - Example: +# 'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /*!99999 ,(3)*/ +# will be binlogged as +# 'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /* 99999 ,(3)*/'. +############################################################################### +source include/master-slave.inc; +source include/have_binlog_format_statement.inc; + +CREATE TABLE t1(c1 INT); +source include/show_binlog_events.inc; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); + +--echo +--echo # Case 1: +--echo # ------------------------------------------------------------------ +--echo # In a statement, some CCs are applied while others are not. The CCs +--echo # which are not applied on master will be binlogged as common comments. + +/*!99999 --- */INSERT /*!INTO*/ /*!10000 t1 */ VALUES(10) /*!99999 ,(11)*/; + +source include/show_binlog_events.inc; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); +sync_slave_with_master; +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +--echo +--echo # Case 2: +--echo # ----------------------------------------------------------------- +--echo # Verify whether it can be binlogged correctly when executing prepared +--echo # statement. +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla*/ t1 VALUES(60) /*!99999 ,(61)*/'; +EXECUTE stmt; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt; + +sync_slave_with_master; +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +--echo +SET @value=62; +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla */ t1 VALUES(?) /*!99999 ,(63)*/'; +EXECUTE stmt USING @value; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt USING @value; + +source include/show_binlog_events.inc; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); + +sync_slave_with_master; +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +--echo +--echo # Case 3: +--echo # ----------------------------------------------------------------- +--echo # Verify it can restore the '!', if the it is an uncomplete conditional +--echo # comments +--error 1064 +SELECT c1 FROM /*!99999 t1 WHEREN; + +DROP TABLE t1; +source include/master-slave-end.inc; diff --git a/mysql-test/suite/rpl/t/rpl_packet.test b/mysql-test/suite/rpl/t/rpl_packet.test index 61a1ad9d987..38b868cb59d 100644 --- a/mysql-test/suite/rpl/t/rpl_packet.test +++ b/mysql-test/suite/rpl/t/rpl_packet.test @@ -1,7 +1,12 @@ +# ==== Purpose ==== # # Check replication protocol packet size handling -# Bug#19402 SQL close to the size of the max_allowed_packet fails on slave # +# ==== Related bugs ==== +# Bug#19402 SQL close to the size of the max_allowed_packet fails on slave +# BUG#23755: Replicated event larger that max_allowed_packet infinitely re-transmits +# BUG#42914: No LAST_IO_ERROR for max_allowed_packet errors +# BUG#55322: SHOW BINLOG EVENTS increases @@SESSION.MAX_ALLOWED_PACKET # max-out size db name source include/master-slave.inc; @@ -114,6 +119,38 @@ let $slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1); let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1); eval SELECT "$last_io_error" AS Last_IO_Error; +# Remove the bad binlog and clear error status on slave. +STOP SLAVE; +RESET SLAVE; +--connection master +RESET MASTER; + + +# +# BUG#55322: SHOW BINLOG EVENTS increases @@SESSION.MAX_ALLOWED_PACKET +# +# In BUG#55322, @@session.max_allowed_packet increased each time SHOW +# BINLOG EVENTS was issued. To verify that this bug is fixed, we +# execute SHOW BINLOG EVENTS twice and check that max_allowed_packet +# never changes. We turn off the result log because we don't care +# about the contents of the binlog. + +--disable_result_log +SET @max_allowed_packet_0= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_1= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_2= @@session.max_allowed_packet; +--enable_result_log +if (`SELECT NOT(@max_allowed_packet_0 = @max_allowed_packet_1 AND @max_allowed_packet_1 = @max_allowed_packet_2)`) +{ + --echo ERROR: max_allowed_packet changed after executing SHOW BINLOG EVENTS + --source include/show_rpl_debug_info.inc + SELECT @max_allowed_packet_0, @max_allowed_packet_1, @max_allowed_packet_2; + --die @max_allowed_packet changed after executing SHOW BINLOG EVENTS +} + + --echo ==== clean up ==== connection master; DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_savepoint.test b/mysql-test/suite/rpl/t/rpl_savepoint.test index c3d1f44d162..7fe8a0da651 100644 --- a/mysql-test/suite/rpl/t/rpl_savepoint.test +++ b/mysql-test/suite/rpl/t/rpl_savepoint.test @@ -30,7 +30,7 @@ connection master1; connection master; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" AND info = "DROP TABLE tt"; + WHERE state = "Waiting for table metadata lock" AND info = "DROP TABLE tt"; --source include/wait_condition.inc ROLLBACK TO SAVEPOINT insert_statement; COMMIT; diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test index 8510f387111..b2e7418ce14 100644 --- a/mysql-test/suite/rpl/t/rpl_sp.test +++ b/mysql-test/suite/rpl/t/rpl_sp.test @@ -655,7 +655,8 @@ connection master; connection master1; --echo # Waitng for 'insert into t1 ...' to get blocked on table lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='insert into t1 (a) values (f1())'; +where state='Waiting for table metadata lock' and + info='insert into t1 (a) values (f1())'; --source include/wait_condition.inc --echo # Sending 'drop function f1'. It will wait till insert finishes. --send drop function f1; @@ -663,7 +664,7 @@ where state='Waiting for table' and info='insert into t1 (a) values (f1())'; connection default; --echo # Check that 'drop function f1' gets blocked. let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop function f1'; +where state='Waiting for stored function metadata lock' and info='drop function f1'; --source include/wait_condition.inc --echo # Now let's let 'insert' go through... unlock tables; diff --git a/mysql-test/suite/rpl/t/rpl_sync-slave.opt b/mysql-test/suite/rpl/t/rpl_sync-slave.opt index 7d6147ed59a..fba451a5b3e 100644 --- a/mysql-test/suite/rpl/t/rpl_sync-slave.opt +++ b/mysql-test/suite/rpl/t/rpl_sync-slave.opt @@ -1 +1 @@ ---sync-relay-log-info=1 --relay-log-recovery=1 --innodb_file_format_check='ON' --default-storage-engine=MyISAM --innodb-file-per-table=0 +--sync-relay-log-info=1 --relay-log-recovery=1 --innodb_file_format_check=1 --default-storage-engine=MyISAM --innodb-file-per-table=0 diff --git a/mysql-test/suite/rpl/t/rpl_view_multi.test b/mysql-test/suite/rpl/t/rpl_view_multi.test index 852d1d8d20c..5b3e7cf76f8 100644 --- a/mysql-test/suite/rpl/t/rpl_view_multi.test +++ b/mysql-test/suite/rpl/t/rpl_view_multi.test @@ -56,7 +56,7 @@ let $wait_condition= connection master; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "drop view v1"; + where state = "Waiting for table metadata lock" and info = "drop view v1"; --source include/wait_condition.inc select release_lock("lock_bg25144"); @@ -106,7 +106,7 @@ let $wait_condition= connection master; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "alter view v1 as select * from t2"; --source include/wait_condition.inc diff --git a/mysql-test/suite/sys_vars/r/concurrent_insert_func.result b/mysql-test/suite/sys_vars/r/concurrent_insert_func.result index 0b5b342e134..56e83d98872 100644 --- a/mysql-test/suite/sys_vars/r/concurrent_insert_func.result +++ b/mysql-test/suite/sys_vars/r/concurrent_insert_func.result @@ -37,9 +37,9 @@ INSERT INTO t1(name) VALUES('Record_7'); connection default; ## show processlist info and state ## SELECT state,info FROM INFORMATION_SCHEMA.PROCESSLIST -WHERE state= "Table lock" AND info LIKE "INSERT INTO t1%"; +WHERE state= "Waiting for table level lock" AND info LIKE "INSERT INTO t1%"; state info -Table lock INSERT INTO t1(name) VALUES('Record_7') +Waiting for table level lock INSERT INTO t1(name) VALUES('Record_7') ## table contents befor UNLOCK ## SELECT * FROM t1; name diff --git a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result index abb8fdcd2a0..6b90b61a035 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result +++ b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result @@ -11,7 +11,6 @@ CREATE TABLE t1(id int, value varchar(10)); INSERT INTO t1 VALUES(1, 'val1'); INSERT INTO t1 VALUES(2, 'val2'); INSERT INTO t1 VALUES(3, 'val3'); -CREATE VIEW v1 AS SELECT * FROM t1; SET GLOBAL query_cache_size = 131072; FLUSHING CACHE SET GLOBAL query_cache_size = 0; @@ -33,11 +32,11 @@ SHOW STATUS LIKE 'Qcache_queries_in_cache'; Variable_name Value Qcache_queries_in_cache 1 1 Expected -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; UNLOCK TABLES; SHOW STATUS LIKE 'Qcache_queries_in_cache'; Variable_name Value -Qcache_queries_in_cache 1 +Qcache_queries_in_cache 0 0 Expected '#----------------------------FN_DYNVARS_136_02-----------------------#' SELECT * FROM t1; @@ -49,13 +48,12 @@ id value 2 val2 3 val3 ** Connection con0 ** -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; ** Connection con1 ** ** Asynchronous Execution ** SELECT * FROM t1; ** Connection con0 ** wait until table is locked -Timeout in wait_condition.inc for SELECT count(*) > 0 FROM information_schema.processlist WHERE state= 'Table lock' UNLOCK TABLES; ** Connection con1 ** ** Asynchronous Result ** @@ -79,7 +77,7 @@ SHOW STATUS LIKE 'Qcache_queries_in_cache'; Variable_name Value Qcache_queries_in_cache 1 1 Expected -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; UNLOCK TABLES; SHOW STATUS LIKE 'Qcache_queries_in_cache'; Variable_name Value @@ -102,7 +100,7 @@ id value 2 val2 3 val3 ** Connection con0 ** -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; ** Connection con1 ** ** Should not be blocked ** SELECT * FROM t1; @@ -165,4 +163,3 @@ SET @@GLOBAL.query_cache_type = @old_cache_type; ** Connection default ** Disconnecting Connections con0, con1 DROP TABLE t1; -DROP VIEW v1; diff --git a/mysql-test/suite/sys_vars/t/concurrent_insert_func.test b/mysql-test/suite/sys_vars/t/concurrent_insert_func.test index 018247df3ff..b97c926e6b5 100644 --- a/mysql-test/suite/sys_vars/t/concurrent_insert_func.test +++ b/mysql-test/suite/sys_vars/t/concurrent_insert_func.test @@ -98,12 +98,13 @@ INSERT INTO t1(name) VALUES('Record_7'); connection default; # wait until INSERT will be locked (low performance) let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE state= "Table lock" AND info LIKE "INSERT INTO t1%"; + WHERE state= "Waiting for table level lock" AND + info LIKE "INSERT INTO t1%"; --source include/wait_condition.inc --echo ## show processlist info and state ## SELECT state,info FROM INFORMATION_SCHEMA.PROCESSLIST -WHERE state= "Table lock" AND info LIKE "INSERT INTO t1%"; +WHERE state= "Waiting for table level lock" AND info LIKE "INSERT INTO t1%"; --echo ## table contents befor UNLOCK ## SELECT * FROM t1; UNLOCK TABLES; diff --git a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test index 60092dbb8e8..427f2730e47 100644 --- a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test +++ b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test @@ -123,7 +123,7 @@ connection default; --echo ** Wait till con0 is blocked ** let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = 'Table lock' AND info = '$my_select'; + WHERE state = 'Waiting for table level lock' AND info = '$my_select'; --source include/wait_condition.inc UNLOCK TABLES; @@ -219,7 +219,7 @@ connection default; --echo ** Wait till con0 is blocked ** let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = 'Table lock' AND info = '$my_select'; + WHERE state = 'Waiting for table level lock' AND info = '$my_select'; --source include/wait_condition.inc UNLOCK TABLES; diff --git a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test index a72d73105a6..e7486614ec7 100644 --- a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test +++ b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test @@ -60,8 +60,6 @@ INSERT INTO t1 VALUES(1, 'val1'); INSERT INTO t1 VALUES(2, 'val2'); INSERT INTO t1 VALUES(3, 'val3'); -CREATE VIEW v1 AS SELECT * FROM t1; - # # Clearing the query cache and setting up cache size # @@ -101,7 +99,7 @@ SELECT * FROM t1; SHOW STATUS LIKE 'Qcache_queries_in_cache'; --echo 1 Expected -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; UNLOCK TABLES; @@ -129,7 +127,7 @@ SELECT * FROM t1; --echo ** Connection con0 ** connection con0; -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; --echo ** Connection con1 ** connection con1; @@ -141,7 +139,8 @@ send SELECT * FROM t1; connection con0; --echo wait until table is locked -let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE state= 'Table lock'; +let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist + WHERE state= 'Waiting for table metadata lock'; --source include/wait_condition.inc UNLOCK TABLES; @@ -177,7 +176,7 @@ SELECT * FROM t1; SHOW STATUS LIKE 'Qcache_queries_in_cache'; --echo 1 Expected -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; UNLOCK TABLES; @@ -201,7 +200,7 @@ SELECT * FROM t1; --echo ** Connection con0 ** connection con0; -LOCK TABLE v1 WRITE; +LOCK TABLE t1 WRITE; --echo ** Connection con1 ** connection con1; @@ -283,7 +282,6 @@ disconnect con0; disconnect con1; DROP TABLE t1; -DROP VIEW v1; --enable_ps_protocol diff --git a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test index 03f56f1fe16..ba13558a135 100644 --- a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test +++ b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test @@ -86,7 +86,9 @@ delimiter ;| --echo ** Connection con0 ** connection con0; -let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Table lock' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")'; +let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist + WHERE state='Waiting for table level lock' AND + info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")'; --source include/wait_condition.inc --echo ** Asynchronous Execution ** @@ -102,7 +104,8 @@ delimiter ;| --echo ** Connection default ** connection default; -let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Table lock'; +let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist + WHERE state LIKE 'Waiting for table level lock'; --source include/wait_condition.inc UNLOCK TABLES; @@ -157,7 +160,9 @@ delimiter ;| --echo ** Connection con0 ** connection con0; -let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Table lock' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")'; +let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist + WHERE state='Waiting for table level lock' AND + info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")'; --source include/wait_condition.inc --echo ** Asynchronous Execution ** @@ -173,7 +178,8 @@ delimiter ;| --echo ** Connection default ** connection default; -let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Table lock'; +let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist + WHERE state LIKE 'Waiting for table level lock'; --source include/wait_condition.inc UNLOCK TABLES; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index a3665e5f455..c3a080612a9 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1701,3 +1701,24 @@ SELECT * FROM t1; REPAIR TABLE t1 EXTENDED; SELECT * FROM t1; DROP TABLE t1; + + +--echo # +--echo # Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a int) ENGINE=ARCHIVE; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (1); +OPTIMIZE TABLE t1; +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/t1.frm; +FLUSH TABLES; +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 ORDER BY a; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 142f1b241d6..2bf0d5d2633 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -307,7 +307,7 @@ connection update; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where command = "Delayed insert" and state = "Table lock"; + where command = "Delayed insert" and state = "Waiting for table level lock"; --source include/wait_condition.inc connect (select,localhost,root,,); --echo connection: select diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 62d11e35922..46392f59633 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -17,3 +17,4 @@ plugin_load : Bug#42144 2009-12-21 alik plugin_load fails partition_innodb_plugin : Bug#53307 2010-04-30 VasilDimov valgrind warnings query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically sp_sync : Bug#48157 2010-02-06 5.5-m3 demands a differnt solution +ctype_utf8mb4_ndb : Bug#55799, Bug#51907, disabled by Konstantin 2010-08-06 diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 0157f2dc764..cd3df229f10 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -319,10 +319,10 @@ insert into t2 (a) values (3); connection default; unlock tables; --echo # ---echo # Check that "flush tables <list> with read lock" is ---echo # compatible with active "flush tables with read lock". ---echo # Vice versa is not true as tables read-locked by ---echo # "flush tables <list> with read lock" can't be flushed. +--echo # Check that "FLUSH TABLES <list> WITH READ LOCK" is +--echo # compatible with active "FLUSH TABLES WITH READ LOCK". +--echo # Vice versa it is not true, since tables read-locked by +--echo # "FLUSH TABLES <list> WITH READ LOCK" can't be flushed. flush tables with read lock; --echo # --> connection con1; connection con1; @@ -332,6 +332,44 @@ unlock tables; --echo # --> connection default; connection default; unlock tables; +--echo # +--echo # Check that FLUSH TABLES t1 WITH READ LOCK +--echo # does not conflict with an existing FLUSH TABLES t2 +--echo # WITH READ LOCK. +--echo # +flush table t1 with read lock; +--echo # --> connection con1 +connection con1; +flush table t2 with read lock; +unlock tables; +--echo # --> connection default +connection default; +unlock tables; +--echo # +--echo # Check that FLUSH TABLES t1 WITH READ LOCK +--echo # does not conflict with SET GLOBAL read_only=1. +--echo # +set global read_only=1; +--echo # connection con1 +connection con1; +flush table t1 with read lock; +unlock tables; +--echo # connection default +connection default; +set global read_only=0; +--echo # +--echo # Check that it's possible to read-lock +--echo # tables locked with FLUSH TABLE <list> WITH READ LOCK. +--echo # +flush tables t1, t2 with read lock; +--echo # connection con1 +connection con1; +lock table t1 read, t2 read; +unlock tables; +--echo # connection default +connection default; +unlock tables; + --echo # --> connection con1 connection con1; disconnect con1; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 6dbc8a05789..2914bb15d18 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1085,3 +1085,13 @@ drop table t1; --echo # --echo End of 5.1 tests +--echo # +--echo # Bug#55648: Server crash on MIX/MAX on maximum time value +--echo # +CREATE TABLE t1(c1 TIME NOT NULL); +INSERT INTO t1 VALUES('837:59:59'); +INSERT INTO t1 VALUES('838:59:59'); +SELECT MAX(c1) FROM t1; +DROP TABLE t1; +--echo # End of the bug#55648 + diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index f90c1dc3c58..f46a20b2db4 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1224,3 +1224,26 @@ DROP TABLE t1, t2; --echo # --echo # End of 5.1 tests + +--echo # +--echo # Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00 +--echo # +CREATE TABLE t1 (f1 int, f2 DATE); + +INSERT INTO t1 VALUES (1,'2004-04-19'), (1,'0000-00-00'), (1,'2004-04-18'), +(2,'2004-05-19'), (2,'0001-01-01'), (3,'2004-04-10'); + +SELECT MIN(f2),MAX(f2) FROM t1; +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; + +DROP TABLE t1; + +CREATE TABLE t1 ( f1 int, f2 time); +INSERT INTO t1 VALUES (1,'01:27:35'), (1,'06:11:01'), (2,'19:53:05'), +(2,'21:44:25'), (3,'10:55:12'), (3,'05:45:11'), (4,'00:25:00'); + +SELECT MIN(f2),MAX(f2) FROM t1; +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; + +DROP TABLE t1; +--echo #End of test#49771 diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test index 1e3491f89a9..748347021fc 100644 --- a/mysql-test/t/heap_hash.test +++ b/mysql-test/t/heap_hash.test @@ -284,3 +284,20 @@ INSERT INTO t1 VALUES('A ', 'A '); DROP TABLE t1; --echo End of 5.0 tests + +--echo # +--echo # Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c +--echo # on DELETE statement +--echo # + +CREATE TABLE t1 (col_int_nokey INT, + col_int_key INT, + INDEX(col_int_key) USING HASH) ENGINE = HEAP; +INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1); + +DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2; + +DROP TABLE t1; + +--echo End of 5.5 tests + diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 87022d65fcc..f5fab966bdd 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1470,7 +1470,8 @@ connection con3726_2; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info like "rename table t2 to t3"; + where state = "Waiting for table metadata lock" and + info like "rename table t2 to t3"; --source include/wait_condition.inc --echo # These statements should not be blocked by pending lock requests select table_name, column_name, data_type from information_schema.columns diff --git a/mysql-test/t/innodb_mysql_lock.test b/mysql-test/t/innodb_mysql_lock.test index c8ece729b19..975444a44b1 100644 --- a/mysql-test/t/innodb_mysql_lock.test +++ b/mysql-test/t/innodb_mysql_lock.test @@ -42,7 +42,7 @@ let $wait_condition= let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE info = "DROP TABLE t1" and - state = "Waiting for table"; + state = "Waiting for table metadata lock"; --source include/wait_condition.inc --echo # Connection 1 is now holding the lock. --echo # Issuing insert from connection 1 while connection 2&3 @@ -97,7 +97,8 @@ connection default; --echo # connection holds SW metadata lock on table to be altered. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column c4 int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c4 int"; --source include/wait_condition.inc --echo # The below statement should succeed. It should not @@ -196,7 +197,7 @@ connection default; --echo # Connection con1 connection con1; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='OPTIMIZE TABLE t1'; + WHERE state='Waiting for table metadata lock' AND info='OPTIMIZE TABLE t1'; --source include/wait_condition.inc SELECT * FROM t1; COMMIT; @@ -241,7 +242,7 @@ connection con2; --echo # Waiting for 'SELECT * FROM v1' to sync in. let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" AND info = "SELECT * FROM v1"; + WHERE state = "Waiting for table metadata lock" AND info = "SELECT * FROM v1"; --source include/wait_condition.inc # This should block due to v1 being locked. --echo # Sending: @@ -252,7 +253,8 @@ connection con3; --echo # Waiting for 'ALTER VIEW v1 AS SELECT 2 FROM t2' to sync in. let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" AND info = "ALTER VIEW v1 AS SELECT 2 FROM t2"; + WHERE state = "Waiting for table metadata lock" AND + info = "ALTER VIEW v1 AS SELECT 2 FROM t2"; --source include/wait_condition.inc # Unlock t1 allowing SELECT * FROM v1 to proceed. UNLOCK TABLES; diff --git a/mysql-test/t/innodb_mysql_lock2.test b/mysql-test/t/innodb_mysql_lock2.test index 4ad30b9f25b..b7259e771ae 100644 --- a/mysql-test/t/innodb_mysql_lock2.test +++ b/mysql-test/t/innodb_mysql_lock2.test @@ -799,8 +799,9 @@ connection default; --echo # table as it acquires LOCK_S locks on rows of old version, which --echo # are compatible with locks acquired by connection 'con1'. let $wait_condition= - select count(*) = 1 from information_schema.processlist where state = - "Waiting for table" and info = "alter table t1 add column j int"; + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column j int"; --source include/wait_condition.inc --echo # The below statement will deadlock because it will try to acquire @@ -844,7 +845,8 @@ connection default; --echo # Wait until ALTER is blocked because of active SR lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 rebuild partition p0"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 rebuild partition p0"; --source include/wait_condition.inc --echo # The below statement should succeed as transaction diff --git a/mysql-test/t/insert_notembedded.test b/mysql-test/t/insert_notembedded.test index 510dc56e8f7..4e5fe6f6755 100644 --- a/mysql-test/t/insert_notembedded.test +++ b/mysql-test/t/insert_notembedded.test @@ -174,7 +174,7 @@ connection default; # we must wait till the insert opens and locks the table let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and id = $ID; + where state = "Waiting for table level lock" and id = $ID; --source include/wait_condition.inc connect (select,localhost,root,,); --echo connection: select diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 7169ca5f7c3..706c2514d92 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -357,7 +357,8 @@ let $ID= `select connection_id()`; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --replace_result $ID ID eval kill query $ID; @@ -372,7 +373,7 @@ connection ddl; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "drop table t1"; --source include/wait_condition.inc --replace_result $ID ID @@ -388,7 +389,7 @@ connection ddl; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "create trigger t1_bi before insert on t1 for each row set @a:=1"; --source include/wait_condition.inc --replace_result $ID ID @@ -407,7 +408,7 @@ connection ddl; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "alter table t1 add column j int"; --source include/wait_condition.inc --replace_result $ID ID @@ -423,7 +424,7 @@ connection ddl; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "alter table t1 rename to t2"; --source include/wait_condition.inc --replace_result $ID ID @@ -437,7 +438,7 @@ connection ddl; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "alter table t1 disable keys"; --source include/wait_condition.inc --replace_result $ID ID @@ -452,7 +453,7 @@ connection ddl; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "alter table t1 alter column i set default 100"; --source include/wait_condition.inc --replace_result $ID ID @@ -474,7 +475,7 @@ connection ddl; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "alter table t2 alter column i set default 100"; --source include/wait_condition.inc --replace_result $ID ID @@ -499,7 +500,7 @@ connection ddl; connection dml; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "rename tables t1 to t3, t2 to t1"; --source include/wait_condition.inc let $ID2= `select connection_id()`; @@ -508,7 +509,7 @@ let $ID2= `select connection_id()`; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "insert into t2 values (1)"; --source include/wait_condition.inc --replace_result $ID2 ID2 @@ -536,7 +537,7 @@ connection ddl; connection dml; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table flush" and info = "flush tables"; --source include/wait_condition.inc --send select * from t1 @@ -544,7 +545,7 @@ let $wait_condition= connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table flush" and info = "select * from t1"; --source include/wait_condition.inc --replace_result $ID2 ID2 diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 2a31392e8f8..6bdb235903d 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -32,7 +32,8 @@ connection reader; # Sleep a bit till the update of connection writer is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "update low_priority t1 set n = 4"; + where state = "Waiting for table level lock" and + info = "update low_priority t1 set n = 4"; --source include/wait_condition.inc send select n from t1; @@ -40,7 +41,8 @@ connection locker2; # Sleep a bit till the select of connection reader is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "select n from t1"; + where state = "Waiting for table level lock" and + info = "select n from t1"; --source include/wait_condition.inc select release_lock("mysqltest_lock"); connection locker; @@ -72,7 +74,8 @@ connection reader; # Sleep a bit till the update of connection writer is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "update low_priority t1 set n = 4"; + where state = "Waiting for table level lock" and + info = "update low_priority t1 set n = 4"; --source include/wait_condition.inc select n from t1; connection locker2; @@ -120,7 +123,8 @@ insert t1 select * from t2; connection locker; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "insert t1 select * from t2"; + where state = "Waiting for table metadata lock" and + info = "insert t1 select * from t2"; --source include/wait_condition.inc drop table t2; unlock tables; @@ -145,7 +149,8 @@ connection locker; # Sleep a bit till the insert of connection reader is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "insert t1 select * from t2"; + where state = "Waiting for table metadata lock" and + info = "insert t1 select * from t2"; --source include/wait_condition.inc drop table t2; unlock tables; @@ -191,7 +196,7 @@ connection locker; # Sleep a bit till the select of connection reader is in work and hangs let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" AND info = + WHERE state = "Waiting for table metadata lock" AND info = "SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1"; --source include/wait_condition.inc # Make test case independent from earlier grants. @@ -223,7 +228,8 @@ connection writer; # Sleep a bit till the flush of connection locker is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "FLUSH TABLES WITH READ LOCK"; + where state = "Waiting for global metadata lock" and + info = "FLUSH TABLES WITH READ LOCK"; --source include/wait_condition.inc # This must not block. --error ER_TABLE_NOT_LOCKED @@ -254,7 +260,8 @@ connection writer; # Sleep a bit till the flush of connection locker is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "FLUSH TABLES WITH READ LOCK"; + where state = "Waiting for global metadata lock" and + info = "FLUSH TABLES WITH READ LOCK"; --source include/wait_condition.inc --error ER_TABLE_NOT_LOCKED CREATE TABLE t2 AS SELECT * FROM t1; @@ -326,7 +333,8 @@ connection reader; # Wait till connection writer is blocked let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 auto_increment=0"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 auto_increment=0"; --source include/wait_condition.inc send alter table t1 auto_increment=0; @@ -334,7 +342,8 @@ connection locker; # Wait till connection reader is blocked let $wait_condition= select count(*) = 2 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 auto_increment=0"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 auto_increment=0"; --source include/wait_condition.inc unlock tables; connection writer; @@ -367,7 +376,8 @@ connection con5; --echo # con5 let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "flush tables with read lock"; + where state = "Waiting for global metadata lock" and + info = "flush tables with read lock"; --source include/wait_condition.inc --echo # global read lock is taken connection con3; @@ -489,16 +499,20 @@ update t1 set i= 10; connection reader; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "update t1 set i= 10"; + where state = "Waiting for table level lock" and + info = "update t1 set i= 10"; --source include/wait_condition.inc send select * from t1; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "select * from t1"; + where state = "Waiting for table level lock" and + info = "select * from t1"; --source include/wait_condition.inc -let $ID= `select id from information_schema.processlist where state = "Table lock" and info = "update t1 set i= 10"`; +let $ID= `select id from information_schema.processlist + where state = "Waiting for table level lock" and + info = "update t1 set i= 10"`; --replace_result $ID ID eval kill query $ID; connection reader; @@ -557,7 +571,7 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for global metadata lock"; --source include/wait_condition.inc alter table t1 add column j int; connect (insert,localhost,root,,test,,); @@ -565,7 +579,7 @@ connection insert; --echo connection: insert let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for global metadata lock"; --source include/wait_condition.inc --send insert into t1 values (1,2); --echo connection: default @@ -615,12 +629,12 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for global metadata lock"; --source include/wait_condition.inc flush tables; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for global metadata lock"; --source include/wait_condition.inc unlock tables; connection flush; @@ -646,7 +660,8 @@ send insert into t1 values(1); connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "insert into t1 values(1)"; + where state = "Waiting for table level lock" and + info = "insert into t1 values(1)"; --source include/wait_condition.inc let $tlwb= `show status like 'Table_locks_waited'`; unlock tables; @@ -683,12 +698,12 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for global metadata lock"; --source include/wait_condition.inc flush tables; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for global metadata lock"; --source include/wait_condition.inc drop table t1; connection flush; @@ -725,7 +740,8 @@ connection default; --echo # connection holds SW metadata lock on table to be altered. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column c4 int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c4 int"; --source include/wait_condition.inc --echo # The below statement should succeed. It should not @@ -825,7 +841,8 @@ connection default; --echo # Wait until ALTER TABLE gets blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column j int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column j int"; --source include/wait_condition.inc --echo # The below statement should try to acquire SW lock on 't1' --echo # and therefore should get ER_LOCK_DEADLOCK error. Before @@ -855,7 +872,8 @@ connection default; --echo # Wait until ALTER TABLE gets blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 drop column j"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 drop column j"; --source include/wait_condition.inc --echo # The below statement should try to acquire SW lock on 't1' --echo # and therefore should get ER_LOCK_DEADLOCK error. Before @@ -982,7 +1000,7 @@ connection con3; connection con2; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" AND info = "FLUSH TABLES"; + WHERE state = "Waiting for table flush" AND info = "FLUSH TABLES"; --source include/wait_condition.inc --error ER_LOCK_WAIT_TIMEOUT SELECT * FROM t1; @@ -1014,7 +1032,8 @@ connection con3; connection con2; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" AND info = "DROP TABLE t1, t2"; + WHERE state = "Waiting for table metadata lock" AND + info = "DROP TABLE t1, t2"; --source include/wait_condition.inc # Note: This query causes two timeouts. # 1: try_acquire_high_prio_shared_mdl_lock on t1 @@ -1069,7 +1088,8 @@ connection default; --echo # Wait until RENAME TABLE is blocked on table 't3'. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename tables t1 to t2, t2 to t3"; + where state = "Waiting for table metadata lock" and + info = "rename tables t1 to t2, t2 to t3"; --source include/wait_condition.inc --echo # Kill RENAME TABLE. --replace_result $ID ID diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test index 2f35da9d1ee..49f8f59ec5a 100644 --- a/mysql-test/t/lock_sync.test +++ b/mysql-test/t/lock_sync.test @@ -898,7 +898,7 @@ set debug_sync= 'now WAIT_FOR parked'; connection default; --echo # Wait until this LOCK TABLES statement starts waiting for table lock. let $wait_condition= select count(*)= 1 from information_schema.processlist - where state= 'Table lock' and + where state= 'Waiting for table level lock' and info='lock table v1 write'; --source include/wait_condition.inc --echo # Allow SELECT ... FOR UPDATE to resume. @@ -972,7 +972,7 @@ connection default; connection con2; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" + WHERE state = "Waiting for table metadata lock" AND info = "ALTER TABLE t1 ADD COLUMN j INT"; --source include/wait_condition.inc diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index 13e6aef10be..55c04d7870b 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -128,7 +128,8 @@ connection mdl_con2; --echo # Check that the above RENAME is blocked because of S lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -158,7 +159,8 @@ connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of S lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column c2 int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -190,7 +192,8 @@ connection mdl_con2; --echo # because of S lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column c2 int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -245,7 +248,8 @@ connection mdl_con2; --echo # Check that the above RENAME is blocked because of SH lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. set debug_sync= 'now SIGNAL finish'; @@ -280,7 +284,8 @@ connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of SH lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column c2 int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. set debug_sync= 'now SIGNAL finish'; @@ -316,7 +321,8 @@ connection mdl_con2; --echo # because of S lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column c2 int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. set debug_sync= 'now SIGNAL finish'; @@ -367,7 +373,8 @@ connection default; --echo # Check that the above LOCK TABLES is blocked because of SR lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock table t1 write"; + where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Unblock LOCK TABLES. commit; @@ -395,7 +402,8 @@ connection mdl_con2; --echo # Check that the above RENAME is blocked because of SR lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -426,7 +434,8 @@ connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of SR lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column c2 int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -479,7 +488,8 @@ connection default; --echo # Check that the above ALTER TABLE is blocked because of SW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add primary key (c1)"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add primary key (c1)"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE. commit; @@ -506,7 +516,8 @@ connection default; --echo # Check that the above LOCK TABLES is blocked because of SW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock table t1 write"; + where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Unblock LOCK TABLES. commit; @@ -534,7 +545,8 @@ connection mdl_con2; --echo # Check that the above RENAME is blocked because of SW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -583,7 +595,8 @@ connection mdl_con2; --echo # Check that the above DELETE is blocked because of SNW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "delete from t1 limit 2"; + where state = "Waiting for table metadata lock" and + info = "delete from t1 limit 2"; --source include/wait_condition.inc --echo # Unblock ALTER and thus DELETE. set debug_sync= 'now SIGNAL finish'; @@ -617,7 +630,8 @@ connection mdl_con2; --echo # Check that the above ALTER is blocked because of SNW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add primary key (c1)"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add primary key (c1)"; --source include/wait_condition.inc --echo # Unblock ALTERs. set debug_sync= 'now SIGNAL finish'; @@ -652,7 +666,8 @@ connection mdl_con2; --echo # Check that the above LOCK TABLES is blocked because of SNW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock table t1 write"; + where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Unblock ALTER and thus LOCK TABLES. set debug_sync= 'now SIGNAL finish'; @@ -688,7 +703,8 @@ connection mdl_con2; --echo # Check that the above RENAME is blocked because of SNW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Unblock ALTER and thus RENAME TABLE. set debug_sync= 'now SIGNAL finish'; @@ -735,7 +751,8 @@ connection default; --echo # Check that the above SELECT is blocked because of SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "select count(*) from t1"; + where state = "Waiting for table metadata lock" and + info = "select count(*) from t1"; --source include/wait_condition.inc --echo # Unblock SELECT. unlock tables; @@ -760,7 +777,8 @@ connection default; --echo # Check that the above DELETE is blocked because of SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "delete from t1 limit 1"; + where state = "Waiting for table metadata lock" and + info = "delete from t1 limit 1"; --source include/wait_condition.inc --echo # Unblock DELETE. unlock tables; @@ -785,7 +803,8 @@ connection default; --echo # Check that the above ALTER is blocked because of UNWR lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add primary key (c1)"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add primary key (c1)"; --source include/wait_condition.inc --echo # Unblock ALTER. unlock tables; @@ -811,7 +830,8 @@ connection default; --echo # Check that the above LOCK TABLES is blocked because of SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock table t1 write"; + where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Unblock waiting LOCK TABLES. unlock tables; @@ -838,7 +858,8 @@ connection default; --echo # Check that the above RENAME is blocked because of SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -879,7 +900,8 @@ connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that S lock in incompatible with X lock. --echo # Sending: @@ -890,7 +912,8 @@ connection mdl_con2; --echo # Check that the above HANDLER statement is blocked because of X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "handler t1 open"; +where state = "Waiting for table metadata lock" and + info = "handler t1 open"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -922,7 +945,8 @@ connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SH lock in incompatible with X lock. --echo # Sending: @@ -934,7 +958,8 @@ connection mdl_con2; --echo # because of X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info like "select column_name from information_schema.columns%"; +where state = "Waiting for table metadata lock" and + info like "select column_name from information_schema.columns%"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -965,7 +990,8 @@ connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SR lock in incompatible with X lock. --echo # Sending: @@ -977,7 +1003,8 @@ connection mdl_con2; --echo # because of X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "select count(*) from t1"; +where state = "Waiting for table metadata lock" and + info = "select count(*) from t1"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -1008,7 +1035,8 @@ connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SW lock in incompatible with X lock. --echo # Sending: @@ -1020,7 +1048,8 @@ connection mdl_con2; --echo # because of X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "delete from t1 limit 1"; +where state = "Waiting for table metadata lock" and + info = "delete from t1 limit 1"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -1051,7 +1080,8 @@ connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SNW lock is incompatible with X lock. --echo # Sending: @@ -1063,7 +1093,8 @@ connection mdl_con2; --echo # because of X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "alter table t1 add primary key (c1)"; +where state = "Waiting for table metadata lock" and + info = "alter table t1 add primary key (c1)"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -1095,7 +1126,8 @@ connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SNRW lock is incompatible with X lock. --echo # Sending: @@ -1107,7 +1139,8 @@ connection mdl_con2; --echo # because of X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "lock table t1 write"; +where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -1139,7 +1172,8 @@ connection mdl_con1; --echo # Check that RENAME has acquired X lock on t1 and is waiting for t2. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that X lock is incompatible with X lock. --echo # Sending: @@ -1151,7 +1185,8 @@ connection mdl_con2; --echo # because of X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t3"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t3"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE unlock tables; @@ -1195,7 +1230,8 @@ connection mdl_con1; --echo # Check that ALTER TABLE is waiting with pending SNW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "alter table t1 add primary key (c1)"; +where state = "Waiting for table metadata lock" and + info = "alter table t1 add primary key (c1)"; --source include/wait_condition.inc --echo # Check that S, SH and SR locks are compatible with pending SNW handler t1 open t; @@ -1212,7 +1248,8 @@ connection mdl_con2; --echo # Check that the above DELETE is blocked because of pending SNW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "delete from t1 limit 1"; +where state = "Waiting for table metadata lock" and + info = "delete from t1 limit 1"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE. commit; @@ -1252,7 +1289,8 @@ connection mdl_con1; --echo # Check that LOCK TABLE is waiting with pending SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "lock table t1 write"; +where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Check that S and SH locks are compatible with pending SNRW handler t1 open t; @@ -1268,7 +1306,8 @@ connection mdl_con2; --echo # Check that the above SELECT is blocked because of pending SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "select count(*) from t1"; +where state = "Waiting for table metadata lock" and + info = "select count(*) from t1"; --source include/wait_condition.inc --echo # Unblock LOCK TABLE. commit; @@ -1300,7 +1339,8 @@ connection mdl_con1; --echo # Check that LOCK TABLE is waiting with pending SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "lock table t1 write"; +where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Check that SW is incompatible with pending SNRW --echo # Sending: @@ -1311,7 +1351,8 @@ connection mdl_con2; --echo # Check that the above INSERT is blocked because of pending SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "insert into t1 values (1)"; +where state = "Waiting for table metadata lock" and + info = "insert into t1 values (1)"; --source include/wait_condition.inc --echo # Unblock LOCK TABLE. commit; @@ -1343,7 +1384,8 @@ connection mdl_con1; --echo # Check that LOCK TABLE is waiting with pending SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "lock table t1 write"; +where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Check that SNW is compatible with pending SNRW --echo # So ALTER TABLE statements are not starved by LOCK TABLEs. @@ -1385,7 +1427,8 @@ connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SH locks are compatible with pending X select column_name from information_schema.columns where @@ -1399,7 +1442,8 @@ connection mdl_con2; --echo # Check that the above HANDLER OPEN is blocked because of pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "handler t1 open"; +where state = "Waiting for table metadata lock" and + info = "handler t1 open"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. commit; @@ -1433,7 +1477,8 @@ connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SR is incompatible with pending X --echo # Sending: @@ -1444,7 +1489,8 @@ connection mdl_con2; --echo # Check that the above SELECT is blocked because of pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "select count(*) from t1"; +where state = "Waiting for table metadata lock" and + info = "select count(*) from t1"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. commit; @@ -1477,7 +1523,8 @@ connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SW is incompatible with pending X --echo # Sending: @@ -1488,7 +1535,8 @@ connection mdl_con2; --echo # Check that the above DELETE is blocked because of pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "delete from t1 limit 1"; +where state = "Waiting for table metadata lock" and + info = "delete from t1 limit 1"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. commit; @@ -1521,7 +1569,8 @@ connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SNW is incompatible with pending X --echo # Sending: @@ -1532,7 +1581,8 @@ connection mdl_con2; --echo # Check that the above ALTER TABLE is blocked because of pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "alter table t1 add primary key (c1)"; +where state = "Waiting for table metadata lock" and + info = "alter table t1 add primary key (c1)"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. commit; @@ -1565,7 +1615,8 @@ connection mdl_con1; --echo # Check that RENAME TABLE is waiting with pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that SNRW is incompatible with pending X --echo # Sending: @@ -1576,7 +1627,8 @@ connection mdl_con3; --echo # Check that the above LOCK TABLES is blocked because of pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "lock table t1 write"; +where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'mdl_con2'. @@ -1642,7 +1694,8 @@ connection mdl_con2; --echo # Check that the above INSERT is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "insert into t2 values (1)"; +where state = "Waiting for table metadata lock" and + info = "insert into t2 values (1)"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE and thus INSERT. set debug_sync= 'now SIGNAL finish'; @@ -1691,7 +1744,8 @@ connection mdl_con2; --echo # Check that the above INSERT is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "insert into t1 values (1)"; +where state = "Waiting for table metadata lock" and + info = "insert into t1 values (1)"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE and thus INSERT. set debug_sync= 'now SIGNAL finish'; @@ -1726,7 +1780,8 @@ connection default; --echo # Wait until ALTER TABLE starts waiting for SNW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "alter table t1 add primary key (c1)"; +where state = "Waiting for table metadata lock" and + info = "alter table t1 add primary key (c1)"; --source include/wait_condition.inc --echo # We should still be able to get both SW and SR locks without waiting. select count(*) from t1; @@ -1769,7 +1824,8 @@ connection default; --echo # Wait until ALTER TABLE starts waiting X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "alter table t2 add column c2 int"; +where state = "Waiting for table metadata lock" and + info = "alter table t2 add column c2 int"; --source include/wait_condition.inc --echo # Check that attempt to acquire SR lock on t2 causes waiting. --echo # Sending: @@ -1780,7 +1836,8 @@ connection mdl_con2; --echo # Check that the above SELECT is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "select count(*) from t2"; +where state = "Waiting for table metadata lock" and + info = "select count(*) from t2"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE. commit; @@ -1817,7 +1874,8 @@ connection default; --echo # Wait until ALTER TABLE starts waiting X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "alter table t2 drop column c2"; +where state = "Waiting for table metadata lock" and + info = "alter table t2 drop column c2"; --source include/wait_condition.inc --echo # Check that attempt to acquire SW lock on t2 causes waiting. --echo # Sending: @@ -1828,7 +1886,8 @@ connection mdl_con2; --echo # Check that the above INSERT is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "insert into t2 values (1)"; +where state = "Waiting for table metadata lock" and + info = "insert into t2 values (1)"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE. commit; @@ -1861,7 +1920,8 @@ connection default; --echo # Wait until ALTER TABLE starts waiting X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "alter table t1 add column c2 int"; +where state = "Waiting for table metadata lock" and + info = "alter table t1 add column c2 int"; --source include/wait_condition.inc --echo # Check that transaction is still able to acquire SR lock. select count(*) from t1; @@ -1904,7 +1964,8 @@ connection mdl_con1; --echo # Check that the above SELECT is blocked let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "select count(*) from t2"; +where state = "Waiting for table metadata lock" and + info = "select count(*) from t2"; --source include/wait_condition.inc --echo # Unblock SELECT. unlock tables; @@ -1934,7 +1995,8 @@ connection mdl_con1; --echo # Check that the above DELETE is blocked let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "delete from t2 limit 1"; +where state = "Waiting for table metadata lock" and + info = "delete from t2 limit 1"; --source include/wait_condition.inc --echo # Unblock DELETE. unlock tables; @@ -1964,7 +2026,8 @@ connection default; --echo # Wait until LOCK TABLE is blocked creating pending request for X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "lock table t1 write"; +where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Check that another instance of SR lock is granted without waiting. select count(*) from t1; @@ -1999,7 +2062,8 @@ connection default; --echo # Wait until LOCK TABLE is blocked creating pending request for X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "lock table t1 write"; +where state = "Waiting for table metadata lock" and + info = "lock table t1 write"; --source include/wait_condition.inc --echo # Check that both SR and SW locks are granted without waiting --echo # and errors. @@ -2043,7 +2107,8 @@ connection default; --echo # Wait until RENAME TABLE starts waiting with pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t2 to t3"; +where state = "Waiting for table metadata lock" and + info = "rename table t2 to t3"; --source include/wait_condition.inc --echo # Check that attempt to acquire SR lock on t2 causes waiting. --echo # Sending: @@ -2054,7 +2119,8 @@ connection mdl_con2; --echo # Check that the above SELECT is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "select count(*) from t2"; +where state = "Waiting for table metadata lock" and + info = "select count(*) from t2"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. commit; @@ -2093,7 +2159,8 @@ connection default; --echo # Wait until RENAME TABLE starts waiting with pending X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t2 to t3"; +where state = "Waiting for table metadata lock" and + info = "rename table t2 to t3"; --source include/wait_condition.inc --echo # Check that attempt to acquire SW lock on t2 causes waiting. --echo # Sending: @@ -2104,7 +2171,8 @@ connection mdl_con2; --echo # Check that the above DELETE is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "delete from t2 limit 1"; +where state = "Waiting for table metadata lock" and + info = "delete from t2 limit 1"; --source include/wait_condition.inc --echo # Unblock RENAME TABLE. commit; @@ -2141,7 +2209,8 @@ connection default; --echo # Wait until RENAME TABLE is blocked creating pending request for X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that another instance of SR lock is granted without waiting. select count(*) from t1; @@ -2176,7 +2245,8 @@ connection default; --echo # Wait until RENAME TABLE is blocked creating pending request for X lock. let $wait_condition= select count(*) = 1 from information_schema.processlist -where state = "Waiting for table" and info = "rename table t1 to t2"; +where state = "Waiting for table metadata lock" and + info = "rename table t1 to t2"; --source include/wait_condition.inc --echo # Check that both SR and SW locks are granted without waiting --echo # and errors. @@ -2236,7 +2306,8 @@ connection handler_con2; --echo # Wait until ALTER is blocked during upgrade. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column j int"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column j int"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -2279,7 +2350,8 @@ connection handler_con1; --echo # Wait until INSERT is blocked on table-level lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "insert into t2 values (1)"; + where state = "Waiting for table level lock" and + info = "insert into t2 values (1)"; --source include/wait_condition.inc --echo # Sending 'alter table t1 drop column j'. It should not cause --echo # deadlock. @@ -2289,7 +2361,8 @@ connection handler_con2; --echo # Wait until ALTER is blocked during upgrade. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 drop column j"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 drop column j"; --source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. @@ -2328,7 +2401,8 @@ connection handler_con1; --echo # Wait until INSERT is blocked because of SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "insert into t1 values (1)"; + where state = "Waiting for table metadata lock" and + info = "insert into t1 values (1)"; --source include/wait_condition.inc --echo # The below ALTER TABLE will be blocked because of presence of HANDLER. --echo # Sending: @@ -2374,7 +2448,8 @@ connection handler_con1; --echo # Wait until INSERT is blocked because of SNRW lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "insert into t2 values (1)"; + where state = "Waiting for table metadata lock" and + info = "insert into t2 values (1)"; --source include/wait_condition.inc --echo # The below ALTER TABLE will be blocked because of presence of HANDLER. --echo # Sending: @@ -2451,7 +2526,8 @@ connection deadlock_con1; --echo # for 'deadlock_con2' which holds shared metadata lock on 't2'. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t2 to t0, t3 to t2, t0 to t3"; + where state = "Waiting for table metadata lock" and + info = "rename table t2 to t0, t3 to t2, t0 to t3"; --source include/wait_condition.inc --echo # The below statement should wait for exclusive metadata lock --echo # on 't2' to go away and should not produce ER_LOCK_DEADLOCK @@ -2466,7 +2542,8 @@ connection deadlock_con2; --echo # for an exclusive metadata lock to go away. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "select * from t2"; + where state = "Waiting for table metadata lock" and + info = "select * from t2"; --source include/wait_condition.inc --echo # --echo # Unblock RENAME TABLE by releasing shared metadata lock on t2. @@ -2502,7 +2579,8 @@ connection deadlock_con1; --echo # table 't1'. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t0, t3 to t1, t0 to t3"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t0, t3 to t1, t0 to t3"; --source include/wait_condition.inc --echo # Commit transaction to unblock RENAME TABLE. commit; @@ -2536,7 +2614,8 @@ connection deadlock_con1; --echo # for 'deadlock_con1' which holds shared metadata lock on 't2'. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t2 to t0, t1 to t2, t0 to t1"; + where state = "Waiting for table metadata lock" and + info = "rename table t2 to t0, t1 to t2, t0 to t1"; --source include/wait_condition.inc --echo # --echo # The below statement should not wait as doing so will cause deadlock. @@ -2549,7 +2628,8 @@ select * from t1; --echo # metadata lock on table 't1', i.e. that RENAME TABLE is still blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t2 to t0, t1 to t2, t0 to t1"; + where state = "Waiting for table metadata lock" and + info = "rename table t2 to t0, t1 to t2, t0 to t1"; --source include/wait_condition.inc --echo # Commit transaction to unblock RENAME TABLE. commit; @@ -2590,7 +2670,7 @@ connection deadlock_con2; --echo # for an UNRW metadata lock to go away. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "select * from t1"; + where state = "Waiting for table metadata lock" and info = "select * from t1"; --source include/wait_condition.inc --echo # Send RENAME TABLE statement that will deadlock with the @@ -2604,7 +2684,8 @@ connection default; --echo # pending X lock on t1. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t0, t2 to t1, t0 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t0, t2 to t1, t0 to t2"; --source include/wait_condition.inc --echo # Allow the above RENAME TABLE to acquire lock on t1 and --echo # create pending lock on t2 thus creating deadlock. @@ -2626,7 +2707,8 @@ connection deadlock_con1; --echo # is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t0, t2 to t1, t0 to t2"; + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t0, t2 to t1, t0 to t2"; --source include/wait_condition.inc --echo # Commit transaction to unblock this RENAME TABLE. commit; @@ -2674,7 +2756,8 @@ connection deadlock_con1; --echo # 'deadlock_con1' which holds shared lock on 't1'. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column j int, rename to t2"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column j int, rename to t2"; --source include/wait_condition.inc --echo # The below statement should not wait as it will cause deadlock. @@ -2687,7 +2770,8 @@ select * from t2; --echo # so ALTER TABLE ... RENAME is still blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column j int, rename to t2"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column j int, rename to t2"; --source include/wait_condition.inc --echo # Commit transaction to unblock ALTER TABLE ... RENAME. @@ -2732,7 +2816,8 @@ connection deadlock_con2; --echo # while trying to acquire SNRW lock on 't1'. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "lock tables t1 write, t2 write"; + where state = "Waiting for table metadata lock" and + info = "lock tables t1 write, t2 write"; --source include/wait_condition.inc --echo # Resume SELECT execution, this should eventually unblock LOCK TABLES. set debug_sync= 'now SIGNAL finish'; @@ -2801,7 +2886,8 @@ connection deadlock_con2; --echo # Wait until ALTER is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 drop column j"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 drop column j"; --source include/wait_condition.inc --echo # Resume INSERT so it can start deadlock detection. --echo # @@ -2830,24 +2916,24 @@ connection default; drop table t1; --echo # ---echo # Now, test for situation in which deadlock involves waiting not +--echo # Now, test for a situation in which deadlock involves waiting not --echo # only in MDL subsystem but also for TDC. Such deadlocks should be ---echo # successfully detected. If possible they should be resolved without +--echo # successfully detected. If possible, they should be resolved without --echo # resorting to ER_LOCK_DEADLOCK error. --echo # create table t1(i int); create table t2(j int); --echo # ---echo # First, let us check how we handle simple scenario involving +--echo # First, let us check how we handle a simple scenario involving --echo # waits in MDL and TDC. --echo # set debug_sync= 'RESET'; --echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; ---echo # Start statement which will acquire SR metadata lock on t1, open it ---echo # and then will stop, before trying to acquire SW lock and opening t2. +--echo # Start a statement, which will acquire SR metadata lock on t1, open it +--echo # and then stop, before trying to acquire SW lock on t2 and opening it. set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; --echo # Sending: --send select * from t1 where i in (select j from t2 for update) @@ -2859,33 +2945,33 @@ set debug_sync='now WAIT_FOR parked'; --echo # The below FLUSH TABLES WITH READ LOCK should acquire --echo # SNW locks on t1 and t2 and wait till SELECT closes t1. --echo # Sending: ---send flush tables t1, t2 with read lock +send flush tables t1, t2 with read lock; --echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; ---echo # Wait until FLUSH TABLES WITH READ LOCK starts waiting +--echo # Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting --echo # for SELECT to close t1. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "flush tables t1, t2 with read lock"; + where state = "Waiting for table flush" and + info = "flush tables t1, t2 with read lock"; --source include/wait_condition.inc --echo # Resume SELECT, so it tries to acquire SW lock on t1 and blocks, --echo # creating a deadlock. This deadlock should be detected and resolved ---echo # by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should ---echo # be able to finish. +--echo # by backing-off SELECT. As a result FTWRL should be able to finish. set debug_sync='now SIGNAL go'; --echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Reap FLUSH TABLES WITH READ LOCK. ---reap +reap; unlock tables; --echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reap SELECT. ---reap +reap; --echo # --echo # The same scenario with a slightly different order of events @@ -2901,7 +2987,7 @@ set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WA --echo # The below FLUSH TABLES WITH READ LOCK should acquire --echo # SNW locks on t1 and t2 and wait on debug sync point. --echo # Sending: ---send flush tables t1, t2 with read lock +send flush tables t1, t2 with read lock; --echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; @@ -2911,46 +2997,46 @@ set debug_sync='now WAIT_FOR parked'; --echo # Start statement which will acquire SR metadata lock on t1, open --echo # it and then will block while trying to acquire SW lock on t2. --echo # Sending: ---send select * from t1 where i in (select j from t2 for update) +send select * from t1 where i in (select j from t2 for update); --echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; --echo # Wait till the above SELECT blocks. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info = "select * from t1 where i in (select j from t2 for update)"; --source include/wait_condition.inc ---echo # Resume FLUSH TABLES, so it tries to flush t1 creating a deadlock. ---echo # This deadlock should be detected and resolved by backing-off SELECT. ---echo # As result FLUSH TABLES WITH READ LOCK should be able to finish. +--echo # Resume FLUSH TABLES, so it tries to flush t1, thus creating +--echo # a deadlock. This deadlock should be detected and resolved by +--echo # backing-off SELECT. As a result FTWRL should be able to finish. set debug_sync='now SIGNAL go'; --echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Reap FLUSH TABLES WITH READ LOCK. ---reap +reap; unlock tables; --echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reap SELECT. ---reap +reap; --echo # ---echo # Now more complex scenario involving two connections +--echo # Now a more complex scenario involving two connections --echo # waiting for MDL and one for TDC. --echo # set debug_sync= 'RESET'; --echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; ---echo # Start statement which will acquire SR metadata lock on t2, open it ---echo # and then will stop, before trying to acquire SR lock and opening t1. +--echo # Start a statement which will acquire SR metadata lock on t2, open it +--echo # and then stop, before trying to acquire SR on t1 and opening it. set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; --echo # Sending: ---send select * from t2, t1 +send select * from t2, t1; --echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; @@ -2959,7 +3045,7 @@ set debug_sync='now WAIT_FOR parked'; --echo # The below FLUSH TABLES WITH READ LOCK should acquire --echo # SNW locks on t2 and wait till SELECT closes t2. --echo # Sending: ---send flush tables t2 with read lock +send flush tables t2 with read lock; --echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; @@ -2967,45 +3053,46 @@ connection deadlock_con3; --echo # for SELECT to close t2. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "flush tables t2 with read lock"; + where state = "Waiting for table flush" and + info = "flush tables t2 with read lock"; --source include/wait_condition.inc --echo # The below DROP TABLES should acquire X lock on t1 and start --echo # waiting for X lock on t2. --echo # Sending: ---send drop tables t1, t2 +send drop tables t1, t2; --echo # Switching to connection 'default'. connection default; --echo # Wait until DROP TABLES starts waiting for X lock on t2. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "drop tables t1, t2"; + where state = "Waiting for table metadata lock" and + info = "drop tables t1, t2"; --source include/wait_condition.inc --echo # Resume SELECT, so it tries to acquire SR lock on t1 and blocks, --echo # creating a deadlock. This deadlock should be detected and resolved ---echo # by backing-off SELECT. As result FLUSH TABLES WITH READ LOCK should ---echo # be able to finish. +--echo # by backing-off SELECT. As a result, FTWRL should be able to finish. set debug_sync='now SIGNAL go'; --echo # Switching to connection 'deadlock_con2'. connection deadlock_con2; --echo # Reap FLUSH TABLES WITH READ LOCK. ---reap +reap; --echo # Unblock DROP TABLES. unlock tables; --echo # Switching to connection 'deadlock_con3'. connection deadlock_con3; --echo # Reap DROP TABLES. ---reap +reap; --echo # Switching to connection 'deadlock_con1'. connection deadlock_con1; --echo # Reap SELECT. It should emit error about missing table. --error ER_NO_SUCH_TABLE ---reap +reap; --echo # Switching to connection 'default'. connection default; @@ -3018,8 +3105,8 @@ disconnect deadlock_con3; --echo # ---echo # Test for scenario in which FLUSH TABLES <list> WITH READ LOCK ---echo # has been erroneously releasing metadata locks. +--echo # Test for a scenario in which FLUSH TABLES <list> WITH READ LOCK +--echo # used to erroneously release metadata locks. --echo # connect(con1,localhost,root,,); connect(con2,localhost,root,,); @@ -3036,46 +3123,46 @@ connection con2; set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go'; --echo # The below FLUSH TABLES <list> WITH READ LOCK should acquire ---echo # SNW locks on t1 and t2, open table t1 and wait on debug sync ---echo # point. +--echo # SNW locks on t1 and t2, open table t1 and block on the debug +--echo # sync point. --echo # Sending: ---send flush tables t1, t2 with read lock +send flush tables t1, t2 with read lock; --echo # Switching to connection 'con1'. connection con1; --echo # Wait till FLUSH TABLES <list> WITH READ LOCK stops. set debug_sync='now WAIT_FOR parked'; ---echo # Start statement which will flush all tables and thus invalidate ---echo # table t1 open by FLUSH TABLES <list> WITH READ LOCK. +--echo # Start a statement which will flush all tables and thus +--echo # invalidate table t1 open by FLUSH TABLES <list> WITH READ LOCK. --echo # Sending: ---send flush tables +send flush tables; --echo # Switching to connection 'default'. connection default; --echo # Wait till the above FLUSH TABLES blocks. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table flush" and info = "flush tables"; --source include/wait_condition.inc --echo # Resume FLUSH TABLES <list> WITH READ LOCK, so it tries to open t2 --echo # discovers that its t1 is obsolete and tries to reopen all tables. --echo # Such reopen should not cause releasing of SNW metadata locks ---echo # which will result in assertion failures. +--echo # which would result in assertion failures. set debug_sync='now SIGNAL go'; --echo # Switching to connection 'con2'. connection con2; --echo # Reap FLUSH TABLES <list> WITH READ LOCK. ---reap +reap; unlock tables; --echo # Switching to connection 'con1'. connection con1; --echo # Reap FLUSH TABLES. ---reap +reap; --echo # Clean-up. --echo # Switching to connection 'default'. @@ -3123,7 +3210,7 @@ connection default; --echo # metadata lock on its tables and blocks due to 't4' being used by LOCK --echo # TABLES. let $wait_condition= select count(*)= 1 from information_schema.processlist - where state= 'Waiting for table' and + where state= 'Waiting for table metadata lock' and info='rename table t3 to t5, t4 to t3'; --source include/wait_condition.inc --echo # Send : @@ -3134,7 +3221,7 @@ connection con1root; --echo # Wait until INSERT statement waits due to encountering pending --echo # exclusive metadata lock on 't3'. let $wait_condition= select count(*)= 1 from information_schema.processlist - where state= 'Waiting for table' and + where state= 'Waiting for table metadata lock' and info='insert into t1 values (1)'; --source include/wait_condition.inc unlock tables; @@ -3276,7 +3363,8 @@ connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "create table t2 select * from t1 for update"; + where state = "Waiting for table level lock" and + info = "create table t2 select * from t1 for update"; --source include/wait_condition.inc --echo # First let us check that SHOW FIELDS/DESCRIBE doesn't @@ -3329,7 +3417,8 @@ connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "create table t2 select * from t1 for update"; + where state = "Waiting for table level lock" and + info = "create table t2 select * from t1 for update"; --source include/wait_condition.inc --echo # Let us check that SHOW FIELDS/DESCRIBE gets blocked. @@ -3341,7 +3430,8 @@ connection con46044_2; --echo # Wait until SHOW FIELDS gets blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "show fields from t2"; + where state = "Waiting for table metadata lock" and + info = "show fields from t2"; --source include/wait_condition.inc unlock tables; @@ -3371,7 +3461,8 @@ connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "create table t2 select * from t1 for update"; + where state = "Waiting for table level lock" and + info = "create table t2 select * from t1 for update"; --source include/wait_condition.inc --echo # Check that I_S query which reads only .FRMs gets blocked. @@ -3383,7 +3474,7 @@ connection con46044_2; --echo # Wait until SELECT COLUMN_NAME FROM I_S.COLUMNS gets blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info like "select column_name from information_schema.columns%"; --source include/wait_condition.inc @@ -3414,7 +3505,8 @@ connection default; --echo # Waiting until CREATE TABLE ... SELECT ... is blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and info = "create table t2 select * from t1 for update"; + where state = "Waiting for table level lock" and + info = "create table t2 select * from t1 for update"; --source include/wait_condition.inc --echo # Finally, check that I_S query which does full-blown table open @@ -3427,7 +3519,7 @@ connection con46044_2; --echo # Wait until SELECT ... FROM I_S.TABLES gets blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and + where state = "Waiting for table metadata lock" and info like "select table_name, table_type, auto_increment, table_comment from information_schema.tables%"; --source include/wait_condition.inc @@ -3490,7 +3582,8 @@ update t1 set c3=c3+1 where c2 = 3; --echo # metadata lock on table 't1', i.e. that ALTER TABLE is still blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "alter table t1 add column e int, rename to t2"; + where state = "Waiting for table metadata lock" and + info = "alter table t1 add column e int, rename to t2"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE by commiting transaction and thus releasing @@ -3675,7 +3768,7 @@ connection con1; connection con3; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Table lock" and info = "SELECT 1"; + WHERE state = "Waiting for table level lock" and info = "SELECT 1"; --source include/wait_condition.inc # The ALTER below will try to abort the statement in connection con1, # since the latter waits on a table-level lock while having a HANDLER @@ -3745,7 +3838,8 @@ connection con50913_2; --echo # Wait until TRUNCATE TABLE is blocked on MDL lock. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "truncate table t1"; + where state = "Waiting for table metadata lock" and + info = "truncate table t1"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE. set debug_sync= 'now SIGNAL go'; @@ -3818,7 +3912,8 @@ connection con3; --echo # SW lock on the table. let $wait_condition= select count(*) = 2 from information_schema.processlist - where state = "Waiting for table" and info = "insert into t1 values (1)"; + where state = "Waiting for table metadata lock" and + info = "insert into t1 values (1)"; --source include/wait_condition.inc --echo # Unblock ALTER TABLE. Since it will try to upgrade SNW to X lock --echo # deadlock with two loops in waiting graph will occur. Both loops @@ -3988,7 +4083,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='CREATE DATABASE db1'; + WHERE state='Waiting for schema metadata lock' AND info='CREATE DATABASE db1'; --source include/wait_condition.inc # This should not block. CREATE DATABASE db2; @@ -4028,7 +4123,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' + WHERE state='Waiting for schema metadata lock' AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8'; --source include/wait_condition.inc # This should not block. @@ -4063,7 +4158,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='DROP DATABASE db1'; + WHERE state='Waiting for schema metadata lock' AND info='DROP DATABASE db1'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; @@ -4107,7 +4202,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' + WHERE state='Waiting for schema metadata lock' AND info='ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME'; --source include/wait_condition.inc # This should not block. @@ -4148,7 +4243,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='DROP DATABASE db1'; + WHERE state='Waiting for schema metadata lock' AND info='DROP DATABASE db1'; --source include/wait_condition.inc # This should not block. CREATE DATABASE db2; @@ -4184,7 +4279,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' + WHERE state='Waiting for schema metadata lock' AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; @@ -4197,7 +4292,9 @@ connection default; --echo # Connection con2 connection con2; --echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8 ---error 1,1 # Wrong error pending followup patch for bug#54360 +# Error 1 is from ALTER DATABASE when the database does not exist. +# Listing the error twice to prevent result diffences based on filename. +--error 1,1 --reap @@ -4223,7 +4320,8 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='CREATE TABLE db1.t1 (a INT)'; + WHERE state='Waiting for schema metadata lock' AND + info='CREATE TABLE db1.t1 (a INT)'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; @@ -4261,7 +4359,8 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='RENAME TABLE db1.t1 TO test.t1'; + WHERE state='Waiting for schema metadata lock' AND + info='RENAME TABLE db1.t1 TO test.t1'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; @@ -4294,7 +4393,8 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='RENAME TABLE test.t2 TO db1.t2'; + WHERE state='Waiting for schema metadata lock' AND + info='RENAME TABLE test.t2 TO db1.t2'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; @@ -4306,7 +4406,9 @@ connection default; --echo # Connection con2 connection con2; --echo # Reaping: RENAME TABLE test.t2 TO db1.t2 ---error 7, 7 # Wrong error pending followup patch for bug#54360 +# Error 7 is from RENAME TABLE where the target database does not exist. +# Listing the error twice to prevent result diffences based on filename. +--error 7, 7 --reap DROP TABLE test.t2; @@ -4334,7 +4436,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='DROP TABLE db1.t1'; + WHERE state='Waiting for schema metadata lock' AND info='DROP TABLE db1.t1'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL blocked'; diff --git a/mysql-test/t/merge-big.test b/mysql-test/t/merge-big.test index 509c7742dac..10d36bfe2a4 100644 --- a/mysql-test/t/merge-big.test +++ b/mysql-test/t/merge-big.test @@ -51,7 +51,7 @@ connection default; #--sleep 8 #SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST; let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE ID = $con1_id AND STATE = 'Waiting for table'; + WHERE ID = $con1_id AND STATE = 'Waiting for table metadata lock'; --source include/wait_condition.inc #SELECT NOW(); --echo # Kick INSERT out of thr_multi_lock(). @@ -61,7 +61,7 @@ FLUSH TABLES; #--sleep 8 #SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST; let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE ID = $con1_id AND STATE = 'Waiting for table'; + WHERE ID = $con1_id AND STATE = 'Waiting for table metadata lock'; --source include/wait_condition.inc #SELECT NOW(); --echo # Unlock and close table and wait for con1 to close too. diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 7a81ad496b4..166d36856a6 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -497,7 +497,7 @@ connection updater; # Wait till "alter table t1 ..." of session changer is in work. # = There is one session waiting. let $wait_condition= select count(*)= 1 from information_schema.processlist - where state= 'Waiting for table'; + where state= 'Waiting for table metadata lock'; --source include/wait_condition.inc send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a; @@ -508,7 +508,7 @@ connection locker; # are in work. # = There are two session waiting. let $wait_condition= select count(*)= 2 from information_schema.processlist - where state= 'Waiting for table'; + where state= 'Waiting for table metadata lock'; --source include/wait_condition.inc unlock tables; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index ce49ca89eca..51e362d4916 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -498,12 +498,20 @@ drop table t1,t2,t3,t4; set query_cache_wlock_invalidate=1; create table t1 (a int not null); create table t2 (a int not null); +create view v1 as select * from t1; select * from t1; select * from t2; show status like "Qcache_queries_in_cache"; lock table t1 write, t2 read; show status like "Qcache_queries_in_cache"; unlock table; +select * from t1; +# Implicit locking of t1 does not invalidate QC +show status like "Qcache_queries_in_cache"; +lock table v1 write; +show status like "Qcache_queries_in_cache"; +unlock table; +drop view v1; drop table t1,t2; set query_cache_wlock_invalidate=default; diff --git a/mysql-test/t/query_cache_28249.test b/mysql-test/t/query_cache_28249.test index c95d7553988..21768b27c2e 100644 --- a/mysql-test/t/query_cache_28249.test +++ b/mysql-test/t/query_cache_28249.test @@ -58,18 +58,18 @@ connection user3; # Typical information_schema.processlist content after sufficient sleep time # ID USER COMMAND TIME STATE INFO # .... -# 2 root Query 5 Table lock SELECT *, (SELECT COUNT(*) FROM t2) FROM t1 +# 2 root Query 5 Waiting for table level lock SELECT *, (SELECT COUNT(*) FROM t2) FROM t1 # .... # XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # The values marked with 'X' must be reached. --echo # Poll till the select of connection user1 is blocked by the write lock on t1. let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist -WHERE state = 'Table lock' +WHERE state = 'Waiting for table level lock' AND info = '$select_for_qc'; --source include/wait_condition.inc eval SELECT user,command,state,info FROM information_schema.processlist -WHERE state = 'Table lock' +WHERE state = 'Waiting for table level lock' AND info = '$select_for_qc'; INSERT INTO t1 VALUES (4); diff --git a/mysql-test/t/schema.test b/mysql-test/t/schema.test index ed3b98ec2f7..6af7ee20b02 100644 --- a/mysql-test/t/schema.test +++ b/mysql-test/t/schema.test @@ -23,7 +23,6 @@ drop schema foo; --disable_warnings DROP SCHEMA IF EXISTS schema1; -DROP SCHEMA IF EXISTS schema2; --enable_warnings connect(con2, localhost, root); @@ -32,7 +31,6 @@ connect(con2, localhost, root); connection default; CREATE SCHEMA schema1; -CREATE SCHEMA schema2; CREATE TABLE schema1.t1 (a INT); SET autocommit= FALSE; @@ -45,10 +43,13 @@ connection con2; --echo # Connection default connection default; let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist - WHERE state= 'Waiting for table' + WHERE state= 'Waiting for table metadata lock' AND info='DROP SCHEMA schema1'; --source include/wait_condition.inc -ALTER SCHEMA schema2 DEFAULT CHARACTER SET utf8; +# Error 1 is from ALTER DATABASE when the database does not exist. +# Listing the error twice to prevent result diffences based on filename. +--error 1,1 +ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8; SET autocommit= TRUE; --echo # Connection 2 @@ -57,7 +58,6 @@ connection con2; --echo # Connection default connection default; -DROP SCHEMA schema2; disconnect con2; @@ -84,7 +84,7 @@ connection con2; --echo # Connection default connection default; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' and info='DROP SCHEMA schema1'; + WHERE state='Waiting for schema metadata lock' and info='DROP SCHEMA schema1'; --source include/wait_condition.inc --echo # CREATE SCHEMA used to give a deadlock. @@ -124,7 +124,7 @@ connection default; --echo # Connection con2 connect (con2, localhost, root); let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' AND info='DROP DATABASE db1'; + WHERE state='Waiting for table metadata lock' AND info='DROP DATABASE db1'; --source include/wait_condition.inc --echo # Connection con1 @@ -172,7 +172,7 @@ connection con2; --echo # Connection 3 connection con3; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for table' and info='DROP DATABASE db1'; + WHERE state='Waiting for table metadata lock' and info='DROP DATABASE db1'; --source include/wait_condition.inc --echo # But it should still be possible to CREATE/ALTER/DROP other databases. CREATE DATABASE db2; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 0323f015e88..fa9dc7472fe 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -173,7 +173,7 @@ type_long_blob longblob, index(type_short) ) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" ENGINE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed CHARSET=latin1; -# Not tested above: RAID_# UNION INSERT_METHOD DATA DIRECTORY INDEX DIRECTORY +# Not tested above: UNION INSERT_METHOD DATA DIRECTORY INDEX DIRECTORY show create table t1; insert into t1 (type_timestamp) values ("2003-02-07 10:00:01"); select * from t1; diff --git a/mysql-test/t/signal.test b/mysql-test/t/signal.test index bdb6625ba32..4c8e6159371 100644 --- a/mysql-test/t/signal.test +++ b/mysql-test/t/signal.test @@ -2408,6 +2408,7 @@ BEGIN DECLARE EXIT HANDLER FOR x BEGIN SELECT '2'; + SHOW WARNINGS; RESIGNAL x SET MYSQL_ERRNO = 9999; END; @@ -2415,9 +2416,10 @@ BEGIN DECLARE EXIT HANDLER FOR x BEGIN SELECT '1'; + SHOW WARNINGS; RESIGNAL x SET SCHEMA_NAME = 'test', - MYSQL_ERRNO= 1231; + MYSQL_ERRNO= 1232; END; /* Raises ER_WRONG_VALUE_FOR_VAR : 1231, SQLSTATE 42000 */ SET @@sql_mode=NULL; @@ -2431,6 +2433,7 @@ BEGIN DECLARE EXIT HANDLER FOR x BEGIN SELECT '3'; + SHOW WARNINGS; RESIGNAL x SET MESSAGE_TEXT = 'Hi, I am a useless error message', MYSQL_ERRNO = 9999; diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test index 247c84fda39..90b4c18895a 100644 --- a/mysql-test/t/sp-code.test +++ b/mysql-test/t/sp-code.test @@ -649,3 +649,56 @@ END// DELIMITER ;// SHOW PROCEDURE CODE p1; DROP PROCEDURE p1; + +--echo # +--echo # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP +--echo # + +--echo +--echo # - Case 4: check that "No Data trumps Warning". +--echo + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1), (2), (3); + +delimiter |; + +CREATE PROCEDURE p1() +BEGIN + DECLARE c CURSOR FOR SELECT a FROM t1; + + OPEN c; + + BEGIN + DECLARE v INT; + + DECLARE CONTINUE HANDLER FOR SQLWARNING + BEGIN + SELECT "Warning found!"; + SHOW WARNINGS; + END; + + DECLARE EXIT HANDLER FOR NOT FOUND + BEGIN + SELECT "End of Result Set found!"; + SHOW WARNINGS; + END; + + WHILE TRUE DO + FETCH c INTO v; + END WHILE; + END; + + CLOSE c; + + SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack +END| + +delimiter ;| + +SET SESSION debug="+d,bug23032_emit_warning"; +CALL p1(); +SET SESSION debug="-d,bug23032_emit_warning"; + +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index c8b2595e23d..13ca55a0127 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2543,3 +2543,273 @@ DROP TABLE t1; --echo End of 5.1 tests +--echo # +--echo # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP +--echo # + +--echo +--echo # - Case 1 +--echo + +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +DROP PROCEDURE IF EXISTS p5; +DROP PROCEDURE IF EXISTS p6; +--enable_warnings + +delimiter |; + +CREATE PROCEDURE p1() + BEGIN + SELECT CAST('10 ' as unsigned integer); + SELECT 1; + CALL p2(); + END| + +CREATE PROCEDURE p2() + BEGIN + SELECT CAST('10 ' as unsigned integer); + END| + +delimiter ;| + +CALL p1(); + +DROP PROCEDURE p1; +DROP PROCEDURE p2; + +--echo +--echo # - Case 2 +--echo + +delimiter |; + +CREATE PROCEDURE p1() + BEGIN + DECLARE c INT DEFAULT 0; + DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1; + CALL p2(); + CALL p3(); + CALL p4(); + SELECT c; + SELECT @@warning_count; + SHOW WARNINGS; + END| + +CREATE PROCEDURE p2() + BEGIN + SELECT CAST('10 ' as unsigned integer); + END| + +CREATE PROCEDURE p3() + BEGIN + SELECT CAST('10 ' as unsigned integer); + SELECT 1; + END| + +CREATE PROCEDURE p4() + BEGIN + SELECT CAST('10 ' as unsigned integer); + CALL p2(); + END| + +CREATE PROCEDURE p5() + BEGIN + SELECT CAST('10 ' as unsigned integer); + SHOW WARNINGS; + END| + +CREATE PROCEDURE P6() + BEGIN + DECLARE c INT DEFAULT 0; + DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1; + CALL p5(); + SELECT c; + END| + +delimiter ;| + +CALL p1(); +CALL p6(); + +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +DROP PROCEDURE p5; +DROP PROCEDURE p6; + +--echo +--echo # - Case 3: check that "Exception trumps No Data". +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1), (2), (3); + +delimiter |; + +CREATE PROCEDURE p1() +BEGIN + DECLARE c CURSOR FOR SELECT a FROM t1; + + OPEN c; + + BEGIN + DECLARE v1 INT; + DECLARE v2 INT; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + SELECT "Error caught (expected)"; + + DECLARE EXIT HANDLER FOR NOT FOUND + SELECT "End of Result Set found!"; + + WHILE TRUE DO + FETCH c INTO v1, v2; + END WHILE; + END; + + CLOSE c; + + SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack +END| + +delimiter ;| + +CALL p1(); + +DROP PROCEDURE p1; +DROP TABLE t1; + +--echo # +--echo # Bug#36185: Incorrect precedence for warning and exception handlers +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +CREATE TABLE t1 (a INT, b INT NOT NULL); + +delimiter |; + +CREATE PROCEDURE p1() +BEGIN + DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning'; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception'; + INSERT INTO t1 VALUES (CAST('10 ' AS SIGNED), NULL); +END| + +delimiter ;| + +CALL p1(); + +DROP TABLE t1; +DROP PROCEDURE p1; + +--echo # +--echo # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger +--echo # + +--echo +--echo # - Case 1 +--echo + +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1, 2); + +delimiter |; + +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +BEGIN + DECLARE EXIT HANDLER FOR SQLWARNING + SET NEW.a = 10; + + SET NEW.a = 99999999999; +END| + +delimiter ;| + +UPDATE t1 SET b = 20; + +SHOW WARNINGS; + +SELECT * FROM t1; + +DROP TRIGGER t1_bu; +DROP TABLE t1; + +--echo +--echo # - Case 2 +--echo + +CREATE TABLE t1(a INT); +CREATE TABLE t2(b CHAR(1)); + +delimiter |; + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +BEGIN + INSERT INTO t2 VALUES('ab'); # Produces a warning. + + INSERT INTO t2 VALUES('b'); # Does not produce a warning, + # previous warning should be cleared. +END| + +delimiter ;| + +INSERT INTO t1 VALUES(0); + +SHOW WARNINGS; + +SELECT * FROM t1; +SELECT * FROM t2; + +DROP TRIGGER t1_bi; +DROP TABLE t1; +DROP TABLE t2; + +--echo # +--echo # Bug#9857: Stored procedures: handler for sqlwarning ignored +--echo # + +SET @sql_mode_saved = @@sql_mode; +SET sql_mode = traditional; + +delimiter |; + +CREATE PROCEDURE p1() +BEGIN + DECLARE CONTINUE HANDLER FOR SQLWARNING + SELECT 'warning caught (expected)'; + + SELECT 5 / 0; +END| + +CREATE PROCEDURE p2() +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + SELECT 'error caught (unexpected)'; + + SELECT 5 / 0; +END| + +delimiter ;| + +CALL p1(); +SHOW WARNINGS; + +CALL p2(); +SHOW WARNINGS; + +DROP PROCEDURE p1; +DROP PROCEDURE p2; +SET sql_mode = @sql_mode_saved; diff --git a/mysql-test/t/sp-lock.test b/mysql-test/t/sp-lock.test index 7297790a886..be8369d6994 100644 --- a/mysql-test/t/sp-lock.test +++ b/mysql-test/t/sp-lock.test @@ -183,18 +183,19 @@ connection con1; send drop procedure p1; --echo # --> connection con2 connection con2; ---echo # Waitng for 'drop procedure t1' to get blocked on MDL lock... +--echo # Waiting for 'drop procedure t1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop procedure p1'; +where state='Waiting for stored procedure metadata lock' and +info='drop procedure p1'; --source include/wait_condition.inc --echo # Demonstrate that there is a pending exclusive lock. --echo # Sending 'select f1()'... send select f1(); --echo # --> connection con3 connection con3; ---echo # Waitng for 'select f1()' to get blocked by a pending MDL lock... +--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1()'; +where state='Waiting for stored procedure metadata lock' and info='select f1()'; --echo # --> connection default connection default; commit; @@ -222,18 +223,19 @@ connection con1; send create procedure p1() begin end; --echo # --> connection con2 connection con2; ---echo # Waitng for 'create procedure t1' to get blocked on MDL lock... +--echo # Waiting for 'create procedure t1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='create procedure p1() begin end'; +where state='Waiting for stored procedure metadata lock' and +info='create procedure p1() begin end'; --source include/wait_condition.inc --echo # Demonstrate that there is a pending exclusive lock. --echo # Sending 'select f1()'... send select f1(); --echo # --> connection con3 connection con3; ---echo # Waitng for 'select f1()' to get blocked by a pending MDL lock... +--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1()'; +where state='Waiting for stored procedure metadata lock' and info='select f1()'; --echo # --> connection default connection default; commit; @@ -259,18 +261,19 @@ connection con1; send alter procedure p1 contains sql; --echo # --> connection con2 connection con2; ---echo # Waitng for 'alter procedure t1' to get blocked on MDL lock... +--echo # Waiting for 'alter procedure t1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='alter procedure p1 contains sql'; +where state='Waiting for stored procedure metadata lock' and +info='alter procedure p1 contains sql'; --source include/wait_condition.inc --echo # Demonstrate that there is a pending exclusive lock. --echo # Sending 'select f1()'... send select f1(); --echo # --> connection con3 connection con3; ---echo # Waitng for 'select f1()' to get blocked by a pending MDL lock... +--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1()'; +where state='Waiting for stored procedure metadata lock' and info='select f1()'; --echo # --> connection default connection default; commit; @@ -296,18 +299,19 @@ connection con1; send drop function f1; --echo # --> connection con2 connection con2; ---echo # Waitng for 'drop function f1' to get blocked on MDL lock... +--echo # Waiting for 'drop function f1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop function f1'; +where state='Waiting for stored function metadata lock' and +info='drop function f1'; --source include/wait_condition.inc --echo # Demonstrate that there is a pending exclusive lock. --echo # Sending 'select f1()'... send select f1(); --echo # --> connection con3 connection con3; ---echo # Waitng for 'select f1()' to get blocked by a pending MDL lock... +--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1()'; +where state='Waiting for stored function metadata lock' and info='select f1()'; --echo # --> connection default connection default; commit; @@ -335,18 +339,19 @@ connection con1; send create function f1() returns int return 2; --echo # --> connection con2 connection con2; ---echo # Waitng for 'create function f1' to get blocked on MDL lock... +--echo # Waiting for 'create function f1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='create function f1() returns int return 2'; +where state='Waiting for stored function metadata lock' and +info='create function f1() returns int return 2'; --source include/wait_condition.inc --echo # Demonstrate that there is a pending exclusive lock. --echo # Sending 'select f1()'... send select f1(); --echo # --> connection con3 connection con3; ---echo # Waitng for 'select f1()' to get blocked by a pending MDL lock... +--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1()'; +where state='Waiting for stored function metadata lock' and info='select f1()'; --echo # --> connection default connection default; commit; @@ -373,18 +378,19 @@ connection con1; send alter function f1 contains sql; --echo # --> connection con2 connection con2; ---echo # Waitng for 'alter function f1' to get blocked on MDL lock... +--echo # Waiting for 'alter function f1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='alter function f1 contains sql'; +where state='Waiting for stored function metadata lock' and +info='alter function f1 contains sql'; --source include/wait_condition.inc --echo # Demonstrate that there is a pending exclusive lock. --echo # Sending 'select f1()'... send select f1(); --echo # --> connection con3 connection con3; ---echo # Waitng for 'select f1()' to get blocked by a pending MDL lock... +--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1()'; +where state='Waiting for stored function metadata lock' and info='select f1()'; --echo # --> connection default connection default; commit; @@ -471,9 +477,10 @@ connection con1; send drop function f1; --echo # --> connection con2 connection con2; ---echo # Waitng for 'drop function f1' to get blocked on MDL lock... +--echo # Waiting for 'drop function f1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop function f1'; +where state='Waiting for stored function metadata lock' and +info='drop function f1'; --source include/wait_condition.inc --echo # --> connnection default connection default; @@ -497,9 +504,10 @@ connection con1; send drop function f1; --echo # --> connection con2 connection con2; ---echo # Waitng for 'drop function f1' to get blocked on MDL lock... +--echo # Waiting for 'drop function f1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop function f1'; +where state='Waiting for stored function metadata lock' and +info='drop function f1'; --source include/wait_condition.inc --echo # --> connnection default connection default; @@ -530,9 +538,10 @@ connection con1; send drop procedure p1; --echo # --> connection con2 connection con2; ---echo # Waitng for 'drop procedure p1' to get blocked on MDL lock... +--echo # Waiting for 'drop procedure p1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop procedure p1'; +where state='Waiting for stored procedure metadata lock' and +info='drop procedure p1'; --source include/wait_condition.inc --echo # --> connnection default connection default; @@ -561,9 +570,10 @@ connection con1; send drop function f2; --echo # --> connection con2 connection con2; ---echo # Waitng for 'drop function f2' to get blocked on MDL lock... +--echo # Waiting for 'drop function f2' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop function f2'; +where state='Waiting for stored function metadata lock' and +info='drop function f2'; --source include/wait_condition.inc --echo # --> connnection default connection default; @@ -623,17 +633,19 @@ connection con1; send drop function f1; --echo # --> connection con2 connection con2; ---echo # Waitng for 'drop function f1' to get blocked on MDL lock... +--echo # Waiting for 'drop function f1' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop function f1'; +where state='Waiting for stored function metadata lock' and +info='drop function f1'; --source include/wait_condition.inc --echo # Sending 'drop function f2'... send drop function f2; --echo # --> connection default connection default; ---echo # Waitng for 'drop function f2' to get blocked on MDL lock... +--echo # Waiting for 'drop function f2' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='drop function f2'; +where state='Waiting for stored function metadata lock' and +info='drop function f2'; --source include/wait_condition.inc rollback to savepoint sv; --echo # --> connection con2 @@ -699,16 +711,18 @@ connection con1; send alter function f1 comment "comment"; --echo # --> connection con2 connection con2; ---echo # Waitng for 'alter function f1 ...' to get blocked on MDL lock... +--echo # Waiting for 'alter function f1 ...' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info like 'alter function f1 comment%'; +where state='Waiting for stored function metadata lock' and +info like 'alter function f1 comment%'; --source include/wait_condition.inc --echo # Sending 'call p1()'... send call p1(); connection default; ---echo # Waitng for 'call p1()' to get blocked on MDL lock on f1... +--echo # Waiting for 'call p1()' to get blocked on MDL lock on f1... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1() into @var'; +where state='Waiting for stored function metadata lock' and +info='select f1() into @var'; --source include/wait_condition.inc --echo # Let 'alter function f1 ...' go through... commit; @@ -746,9 +760,10 @@ connection con1; send alter function f1 comment "comment"; --echo # --> connection con2 connection con2; ---echo # Waitng for 'alter function f1 ...' to get blocked on MDL lock... +--echo # Waiting for 'alter function f1 ...' to get blocked on MDL lock... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info like 'alter function f1 comment%'; +where state='Waiting for stored function metadata lock' and +info like 'alter function f1 comment%'; --source include/wait_condition.inc delimiter |; --echo # @@ -774,9 +789,10 @@ delimiter ;| --echo # Sending 'call p1()'... send call p1(); connection default; ---echo # Waitng for 'call p1()' to get blocked on MDL lock on f1... +--echo # Waiting for 'call p1()' to get blocked on MDL lock on f1... let $wait_condition=select count(*)=1 from information_schema.processlist -where state='Waiting for table' and info='select f1() into @var'; +where state='Waiting for stored function metadata lock' and +info='select f1() into @var'; --source include/wait_condition.inc --echo # Let 'alter function f1 ...' go through... commit; @@ -825,7 +841,7 @@ connection default; send select f3(); --echo # --> connection con1 connection con1; ---echo # Waitng for 'select f3()' to get blocked on the user level lock... +--echo # Waiting for 'select f3()' to get blocked on the user level lock... let $wait_condition=select count(*)=1 from information_schema.processlist where state='User lock' and info='select f1() into @var'; --source include/wait_condition.inc diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index da949016a03..11edeaf9811 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -5432,6 +5432,8 @@ drop procedure if exists bug15231_1| drop procedure if exists bug15231_2| drop procedure if exists bug15231_3| drop procedure if exists bug15231_4| +drop procedure if exists bug15231_5| +drop procedure if exists bug15231_6| --enable_warnings create table t3 (id int not null)| @@ -5461,7 +5463,7 @@ end| create procedure bug15231_3() begin declare exit handler for sqlwarning - select 'Caught it (wrong)' as 'Result'; + select 'Caught it (correct)' as 'Result'; call bug15231_4(); end| @@ -5472,16 +5474,37 @@ begin set x = 'zap'; select 'Missed it (correct)' as 'Result'; + show warnings; +end| + +create procedure bug15231_5() +begin + declare exit handler for sqlwarning + select 'Caught it (wrong)' as 'Result'; + + call bug15231_6(); +end| + +create procedure bug15231_6() +begin + declare x decimal(2,1); + + set x = 'zap'; + select 'Missed it (correct)' as 'Result'; + select id from t3; end| call bug15231_1()| call bug15231_3()| +call bug15231_5()| -drop table if exists t3| -drop procedure if exists bug15231_1| -drop procedure if exists bug15231_2| -drop procedure if exists bug15231_3| -drop procedure if exists bug15231_4| +drop table t3| +drop procedure bug15231_1| +drop procedure bug15231_2| +drop procedure bug15231_3| +drop procedure bug15231_4| +drop procedure bug15231_5| +drop procedure bug15231_6| # diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index 83accecabb5..b15f6351e59 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -322,7 +322,7 @@ set session low_priority_updates=on; connection rl_wait; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Table lock" and + where state = "Waiting for table level lock" and info = "update t1 set value='updated' where value='old'"; --source include/wait_condition.inc diff --git a/mysql-test/t/sp_sync.test b/mysql-test/t/sp_sync.test index 431db463b67..368a09eac8c 100644 --- a/mysql-test/t/sp_sync.test +++ b/mysql-test/t/sp_sync.test @@ -87,7 +87,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked'; --echo # Connection con3 connection con3; let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist - WHERE state= 'Waiting for table' + WHERE state= 'Waiting for stored function metadata lock' AND info='SHOW OPEN TABLES WHERE f1()=0'; --source include/wait_condition.inc --echo # Check that the IS query is blocked before releasing the x-lock diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test index cca54f6c762..9965875af55 100644 --- a/mysql-test/t/status.test +++ b/mysql-test/t/status.test @@ -58,7 +58,8 @@ let $ID= `select connection_id()`; connection con2; --echo # Switched to connection: con2 # wait for the other query to start executing -let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Table lock"; +let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST + where ID = $ID and STATE = "Waiting for table level lock"; --source include/wait_condition.inc unlock tables; diff --git a/mysql-test/t/trigger_notembedded.test b/mysql-test/t/trigger_notembedded.test index 8a570a7e87d..9728ae9a4ae 100644 --- a/mysql-test/t/trigger_notembedded.test +++ b/mysql-test/t/trigger_notembedded.test @@ -896,7 +896,7 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table"; + where state = "Waiting for global metadata lock"; --source include/wait_condition.inc create trigger t1_bi before insert on t1 for each row begin end; unlock tables; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index f6708828a6b..c515f8873d8 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -483,3 +483,23 @@ UPDATE IGNORE v1 SET a = 1; SET SESSION sql_safe_updates = DEFAULT; DROP TABLE t1; DROP VIEW v1; + +--echo # +--echo # Bug#54734 assert in Diagnostics_area::set_ok_status +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, not_exists; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +--enable_warnings + +CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk; +CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists); +CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13; +--error ER_VIEW_INVALID +UPDATE v1 SET pk = 7 WHERE pk > 0; + +DROP VIEW v1; +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index c0564a82b23..236f2e84770 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -4074,7 +4074,8 @@ connection default; connection con2; let $wait_condition= SELECT COUNT(*) = 1 from information_schema.processlist - WHERE state = "Table lock" AND info = "INSERT INTO t1 SELECT * FROM v1"; + WHERE state = "Waiting for table level lock" AND + info = "INSERT INTO t1 SELECT * FROM v1"; --source include/wait_condition.inc --echo # ... then try to drop the view. This should block. --echo # Sending: @@ -4084,7 +4085,7 @@ let $wait_condition= connection con3; let $wait_condition= SELECT COUNT(*) = 1 from information_schema.processlist - WHERE state = "Waiting for table" AND info = "DROP VIEW v1"; + WHERE state = "Waiting for table metadata lock" AND info = "DROP VIEW v1"; --source include/wait_condition.inc --echo # Now allow CALL p1() to complete UNLOCK TABLES; diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 83615c82e2a..ae41151a981 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -17,23 +17,23 @@ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys) -SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_modify.c - errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c +SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c + errors.c hash.c list.c md5.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_arr_appstr.c mf_tempdir.c - mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c - my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c - my_clock.c my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c + mf_tempfile.c mf_unixpath.c mf_wcomp.c mulalloc.c my_access.c + my_aes.c my_alloc.c my_bit.c my_bitmap.c my_chsize.c + my_compress.c my_copy.c my_create.c my_delete.c my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c - my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c - my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c + my_lib.c my_lock.c my_malloc.c my_mess.c + my_mkdir.c my_mmap.c my_once.c my_open.c my_pread.c my_pthread.c my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_write.c ptr_cmp.c queues.c stacktrace.c rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c - thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c + thr_rwlock.c tree.c typelib.c base64.c my_memmem.c my_getpagesize.c lf_alloc-pin.c lf_dynarray.c lf_hash.c my_atomic.c my_getncpus.c my_rdtsc.c) @@ -42,6 +42,10 @@ IF (WIN32) SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_winthread.c my_wincond.c my_winerr.c my_winfile.c my_windac.c my_conio.c) ENDIF() +IF(HAVE_ALARM) + SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_alarm.c) +ENDIF() + IF(NOT HAVE_CXX_NEW) # gcc as C++ compiler does not have new/delete SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_new.cc) @@ -58,10 +62,15 @@ IF(HAVE_LARGE_PAGES) SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_largepage.c) ENDIF() +IF(HAVE_MLOCK) + SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_lockmem.c) +ENDIF() + IF(UNIX) # some workarounds SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_port.c) ENDIF() + ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES}) TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY} ${LIBNSL} ${LIBM} ${LIBRT}) diff --git a/mysys/Makefile.am b/mysys/Makefile.am index a9e3f16c548..357fa321da6 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -24,31 +24,29 @@ LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ mf_path.c mf_loadpath.c my_file.c \ - my_open.c my_create.c my_dup.c my_seek.c my_read.c \ + my_open.c my_create.c my_seek.c my_read.c \ my_pread.c my_write.c my_getpagesize.c \ mf_keycaches.c my_crc32.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ my_malloc.c my_once.c mulalloc.c \ - my_alloc.c my_new.cc my_vle.c my_atomic.c lf_hash.c \ + my_alloc.c my_new.cc my_atomic.c lf_hash.c \ lf_dynarray.c lf_alloc-pin.c \ my_fopen.c my_fstream.c my_getsystime.c \ my_error.c errors.c my_div.c my_mess.c \ mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \ my_symlink.c my_symlink2.c \ mf_pack.c mf_unixpath.c mf_arr_appstr.c \ - mf_wcomp.c mf_wfile.c my_gethwaddr.c \ + mf_wcomp.c my_gethwaddr.c \ mf_qsort.c mf_qsort2.c mf_sort.c \ ptr_cmp.c mf_radix.c queues.c my_getncpus.c \ - tree.c trie.c list.c hash.c array.c string.c typelib.c \ - my_copy.c my_append.c my_lib.c \ + tree.c list.c hash.c array.c string.c typelib.c \ + my_copy.c my_lib.c \ my_delete.c my_rename.c my_redel.c \ - my_chsize.c my_clock.c \ - my_quick.c my_lockmem.c my_static.c \ + my_chsize.c my_quick.c my_lockmem.c my_static.c \ my_sync.c my_getopt.c my_mkdir.c \ - default_modify.c default.c \ - my_compress.c checksum.c \ - my_net.c my_port.c my_sleep.c \ + default.c my_compress.c checksum.c \ + my_port.c my_sleep.c \ charset.c charset-def.c my_bitmap.c my_bit.c md5.c \ my_gethostbyname.c rijndael.c my_aes.c sha1.c \ my_handler.c my_largepage.c \ diff --git a/mysys/checksum.c b/mysys/checksum.c index 1c7c9358d53..a96ea31ea0e 100644 --- a/mysys/checksum.c +++ b/mysys/checksum.c @@ -30,13 +30,6 @@ ha_checksum my_checksum(ha_checksum crc, const uchar *pos, size_t length) { -#ifdef NOT_USED - const uchar *end=pos+length; - for ( ; pos != end ; pos++) - crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8)); - return crc; -#else return (ha_checksum)crc32((uint)crc, pos, (uint)length); -#endif } diff --git a/mysys/default.c b/mysys/default.c index 8002a1a0307..0e0883e1fcf 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -575,7 +575,7 @@ int my_load_defaults(const char *conf_file, const char **groups, void free_defaults(char **argv) { MEM_ROOT ptr; - memcpy_fixed((char*) &ptr,(char *) argv - sizeof(ptr), sizeof(ptr)); + memcpy(&ptr, ((char *) argv) - sizeof(ptr), sizeof(ptr)); free_root(&ptr,MYF(0)); } diff --git a/mysys/default_modify.c b/mysys/default_modify.c deleted file mode 100644 index edf4907cd4b..00000000000 --- a/mysys/default_modify.c +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright (C) 2005 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "my_global.h" -#include "mysys_priv.h" -#include "m_string.h" -#include <my_dir.h> - -#define BUFF_SIZE 1024 -#define RESERVE 1024 /* Extend buffer with this extent */ - -#ifdef _WIN32 -#define NEWLINE "\r\n" -#define NEWLINE_LEN 2 -#else -#define NEWLINE "\n" -#define NEWLINE_LEN 1 -#endif - -static char *add_option(char *dst, const char *option_value, - const char *option, int remove_option); - - -/* - Add/remove option to the option file section. - - SYNOPSYS - modify_defaults_file() - file_location The location of configuration file to edit - option The name of the option to look for (can be NULL) - option value The value of the option we would like to set (can be NULL) - section_name The name of the section (must be NOT NULL) - remove_option This defines what we want to remove: - - MY_REMOVE_NONE -- nothing to remove; - - MY_REMOVE_OPTION -- remove the specified option; - - MY_REMOVE_SECTION -- remove the specified section; - IMPLEMENTATION - We open the option file first, then read the file line-by-line, - looking for the section we need. At the same time we put these lines - into a buffer. Then we look for the option within this section and - change/remove it. In the end we get a buffer with modified version of the - file. Then we write it to the file, truncate it if needed and close it. - Note that there is a small time gap, when the file is incomplete, - and this theoretically might introduce a problem. - - RETURN - 0 - ok - 1 - some error has occured. Probably due to the lack of resourses - 2 - cannot open the file -*/ - -int modify_defaults_file(const char *file_location, const char *option, - const char *option_value, - const char *section_name, int remove_option) -{ - FILE *cnf_file; - MY_STAT file_stat; - char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer; - size_t opt_len= 0, optval_len= 0, sect_len, new_opt_len, reserve_extended; - uint nr_newlines= 0, buffer_size; - my_bool in_section= FALSE, opt_applied= 0; - int reserve_occupied= 0; - DBUG_ENTER("modify_defaults_file"); - - if (!(cnf_file= my_fopen(file_location, O_RDWR | O_BINARY, MYF(0)))) - DBUG_RETURN(2); - - /* my_fstat doesn't use the flag parameter */ - if (my_fstat(my_fileno(cnf_file), &file_stat, MYF(0))) - goto malloc_err; - - if (option && option_value) - { - opt_len= strlen(option); - optval_len= strlen(option_value); - } - - new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN; - - /* calculate the size of the buffer we need */ - reserve_extended= (opt_len + - 1 + /* For '=' char */ - optval_len + /* Option value len */ - NEWLINE_LEN + /* Space for newline */ - RESERVE); /* Some additional space */ - - buffer_size= (file_stat.st_size + - 1); /* The ending zero */ - - /* - Reserve space to read the contents of the file and some more - for the option we want to add. - */ - if (!(file_buffer= (char*) my_malloc(buffer_size + reserve_extended, - MYF(MY_WME)))) - goto malloc_err; - - sect_len= strlen(section_name); - - for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); ) - { - /* Skip over whitespaces */ - for (src_ptr= linebuff; my_isspace(&my_charset_latin1, *src_ptr); - src_ptr++) - {} - - if (!*src_ptr) /* Empty line */ - { - nr_newlines++; - continue; - } - - /* correct the option (if requested) */ - if (option && in_section && !strncmp(src_ptr, option, opt_len) && - (*(src_ptr + opt_len) == '=' || - my_isspace(&my_charset_latin1, *(src_ptr + opt_len)) || - *(src_ptr + opt_len) == '\0')) - { - char *old_src_ptr= src_ptr; - src_ptr= strend(src_ptr+ opt_len); /* Find the end of the line */ - - /* could be negative */ - reserve_occupied+= (int) new_opt_len - (int) (src_ptr - old_src_ptr); - if (reserve_occupied >= (int) reserve_extended) - { - reserve_extended= (uint) reserve_occupied + RESERVE; - if (!(file_buffer= (char*) my_realloc(file_buffer, buffer_size + - reserve_extended, - MYF(MY_WME|MY_FREE_ON_ERROR)))) - goto malloc_err; - } - opt_applied= 1; - dst_ptr= add_option(dst_ptr, option_value, option, remove_option); - } - else - { - /* - If we are going to the new group and have an option to apply, do - it now. If we are removing a single option or the whole section - this will only trigger opt_applied flag. - */ - - if (in_section && !opt_applied && *src_ptr == '[') - { - dst_ptr= add_option(dst_ptr, option_value, option, remove_option); - opt_applied= 1; /* set the flag to do write() later */ - reserve_occupied= new_opt_len+ opt_len + 1 + NEWLINE_LEN; - } - - for (; nr_newlines; nr_newlines--) - dst_ptr= strmov(dst_ptr, NEWLINE); - - /* Skip the section if MY_REMOVE_SECTION was given */ - if (!in_section || remove_option != MY_REMOVE_SECTION) - dst_ptr= strmov(dst_ptr, linebuff); - } - /* Look for a section */ - if (*src_ptr == '[') - { - /* Copy the line to the buffer */ - if (!strncmp(++src_ptr, section_name, sect_len)) - { - src_ptr+= sect_len; - /* Skip over whitespaces. They are allowed after section name */ - for (; my_isspace(&my_charset_latin1, *src_ptr); src_ptr++) - {} - - if (*src_ptr != ']') - { - in_section= FALSE; - continue; /* Missing closing parenthesis. Assume this was no group */ - } - - if (remove_option == MY_REMOVE_SECTION) - dst_ptr= dst_ptr - strlen(linebuff); - - in_section= TRUE; - } - else - in_section= FALSE; /* mark that this section is of no interest to us */ - } - } - - /* - File ended. Apply an option or set opt_applied flag (in case of - MY_REMOVE_SECTION) so that the changes are saved. Do not do anything - if we are removing non-existent option. - */ - - if (!opt_applied && in_section && (remove_option != MY_REMOVE_OPTION)) - { - /* New option still remains to apply at the end */ - if (!remove_option && *(dst_ptr - 1) != '\n') - dst_ptr= strmov(dst_ptr, NEWLINE); - dst_ptr= add_option(dst_ptr, option_value, option, remove_option); - opt_applied= 1; - } - for (; nr_newlines; nr_newlines--) - dst_ptr= strmov(dst_ptr, NEWLINE); - - if (opt_applied) - { - /* Don't write the file if there are no changes to be made */ - if (my_chsize(my_fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0, - MYF(MY_WME)) || - my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) || - my_fwrite(cnf_file, (uchar*) file_buffer, (size_t) (dst_ptr - file_buffer), - MYF(MY_NABP))) - goto err; - } - if (my_fclose(cnf_file, MYF(MY_WME))) - DBUG_RETURN(1); - - my_free(file_buffer); - DBUG_RETURN(0); - -err: - my_free(file_buffer); -malloc_err: - my_fclose(cnf_file, MYF(0)); - DBUG_RETURN(1); /* out of resources */ -} - - -static char *add_option(char *dst, const char *option_value, - const char *option, int remove_option) -{ - if (!remove_option) - { - dst= strmov(dst, option); - if (*option_value) - { - *dst++= '='; - dst= strmov(dst, option_value); - } - /* add a newline */ - dst= strmov(dst, NEWLINE); - } - return dst; -} diff --git a/mysys/errors.c b/mysys/errors.c index 9342ab2d2dd..8bc310652f1 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -49,7 +49,9 @@ const char *globerrs[GLOBERRS]= "Can't sync file '%s' to disk (Errcode: %d)", "Collation '%s' is not a compiled collation and is not specified in the '%s' file", "File '%s' not found (Errcode: %d)", - "File '%s' (fileno: %d) was not closed" + "File '%s' (fileno: %d) was not closed", + "Can't change ownership of the file '%s' (Errcode: %d)", + "Can't change permissions of the file '%s' (Errcode: %d)", }; void init_glob_errs(void) @@ -90,6 +92,8 @@ void init_glob_errs() EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file"; EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)"; EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed"; + EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %d)"; + EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d)"; } #endif diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index c264d3ac4c5..4ed01ac8083 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -448,8 +448,6 @@ void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset) allocator->top= 0; allocator->mallocs= 0; allocator->element_size= size; - allocator->constructor= 0; - allocator->destructor= 0; DBUG_ASSERT(size >= sizeof(void*) + free_ptr_offset); } @@ -470,8 +468,6 @@ void lf_alloc_destroy(LF_ALLOCATOR *allocator) while (node) { uchar *tmp= anext_node(node); - if (allocator->destructor) - allocator->destructor(node); my_free(node); node= tmp; } @@ -500,8 +496,6 @@ void *_lf_alloc_new(LF_PINS *pins) if (!node) { node= (void *)my_malloc(allocator->element_size, MYF(MY_WME)); - if (allocator->constructor) - allocator->constructor(node); #ifdef MY_LF_EXTRA_DEBUG if (likely(node != 0)) my_atomic_add32(&allocator->mallocs, 1); diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index 9c51ff1766e..e7bf82fc6ca 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -41,8 +41,6 @@ typedef struct { */ } LF_SLIST; -const int LF_HASH_OVERHEAD= sizeof(LF_SLIST); - /* a structure to pass the context (pointers two the three successive elements in a list) from lfind to linsert/ldelete diff --git a/mysys/make-conf.c b/mysys/make-conf.c deleted file mode 100644 index 0dacde4dee0..00000000000 --- a/mysys/make-conf.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* make-conf.c - * make a charset .conf file out of a ctype-charset.c file. - */ - -#ifndef CHARSET -#error You must define the charset, e.g.: -DCHARSET=latin1 -#endif - -/* some pre-processor tricks to get us going */ -#define _STRINGIZE_HELPER(x) #x -#define STRINGIZE(x) _STRINGIZE_HELPER(x) - -#define _JOIN_WORDS_HELPER(a, b) a ## b -#define JOIN_WORDS(a, b) _JOIN_WORDS_HELPER(a, b) - -#define CH_SRC ctype- ## CHARSET ## .c -#define CH_INCLUDE STRINGIZE(CH_SRC) - -/* aaaah, that's better */ -#include <my_my_global.h> -#include CH_INCLUDE - -#include <stdio.h> -#include <stdlib.h> - -#define ROW_LEN 16 - -void print_array(const char *name, const uchar *array, uint size); - -int main(void) -{ - printf("# Configuration file for the " - STRINGIZE(CHARSET) - " character set.\n"); - - print_array("ctype", JOIN_WORDS(ctype_, CHARSET), 257); - print_array("to_lower", JOIN_WORDS(to_lower_, CHARSET), 256); - print_array("to_upper", JOIN_WORDS(to_upper_, CHARSET), 256); - print_array("sort_order", JOIN_WORDS(sort_order_, CHARSET), 256); - - exit(EXIT_SUCCESS); -} - -void print_array(const char *name, const uchar *array, uint size) -{ - uint i; - - printf("\n# The %s array must have %d elements.\n", name, size); - - for (i = 0; i < size; ++i) { - printf(" %02X", array[i]); - - if ((i+1) % ROW_LEN == size % ROW_LEN) - printf("\n"); - } -} diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 4902a5a8bce..173b678cdd1 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -47,7 +47,6 @@ TODO: write buffer to the read buffer before we start to reuse it. */ -#define MAP_TO_USE_RAID #include "mysys_priv.h" #include <m_string.h> #ifdef HAVE_AIOWAIT @@ -1747,16 +1746,19 @@ int my_block_write(register IO_CACHE *info, const uchar *Buffer, size_t Count, #endif -int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) +int my_b_flush_io_cache(IO_CACHE *info, + int need_append_buffer_lock __attribute__((unused))) { size_t length; - my_bool append_cache; my_off_t pos_in_file; + my_bool append_cache= (info->type == SEQ_READ_APPEND); DBUG_ENTER("my_b_flush_io_cache"); DBUG_PRINT("enter", ("cache: 0x%lx", (long) info)); - if (!(append_cache = (info->type == SEQ_READ_APPEND))) - need_append_buffer_lock=0; +#ifdef THREAD + if (!append_cache) + need_append_buffer_lock= 0; +#endif if (info->type == WRITE_CACHE || append_cache) { diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 5e34bff2b51..7a40ea8a86f 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -17,7 +17,6 @@ More functions to be used with IO_CACHE files */ -#define MAP_TO_USE_RAID #include "mysys_priv.h" #include <m_string.h> #include <stdarg.h> @@ -71,6 +70,16 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file) my_off_t my_b_append_tell(IO_CACHE* info) { /* + Sometimes we want to make sure that the variable is not put into + a register in debugging mode so we can see its value in the core + */ +#ifndef DBUG_OFF +# define dbug_volatile volatile +#else +# define dbug_volatile +#endif + + /* Prevent optimizer from putting res in a register when debugging we need this to be able to see the value of res when the assert fails */ diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index c42c3d469e6..fc62d3d8a8e 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -2683,10 +2683,7 @@ uchar *key_cache_read(KEY_CACHE *keycache, #endif /* Copy data from the cache buffer */ - if (!(read_length & 511)) - bmove512(buff, block->buffer+offset, read_length); - else - memcpy(buff, block->buffer+offset, (size_t) read_length); + memcpy(buff, block->buffer+offset, (size_t) read_length); #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_lock(&keycache->cache_lock); @@ -2920,10 +2917,7 @@ int key_cache_insert(KEY_CACHE *keycache, #endif /* Copy data from buff */ - if (!(read_length & 511)) - bmove512(block->buffer+offset, buff, read_length); - else - memcpy(block->buffer+offset, buff, (size_t) read_length); + memcpy(block->buffer+offset, buff, (size_t) read_length); #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_lock(&keycache->cache_lock); @@ -3246,10 +3240,7 @@ int key_cache_write(KEY_CACHE *keycache, #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_unlock(&keycache->cache_lock); #endif - if (!(read_length & 511)) - bmove512(block->buffer+offset, buff, read_length); - else - memcpy(block->buffer+offset, buff, (size_t) read_length); + memcpy(block->buffer+offset, buff, (size_t) read_length); #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_lock(&keycache->cache_lock); diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c deleted file mode 100644 index 95c4c006b2c..00000000000 --- a/mysys/mf_wfile.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Functions for finding files with wildcards */ - -/* - The following file-name-test is supported: - - "name [[,] name...] ; Matches any of used filenames. - Each name can have "*" and/or "?" - wild-cards. - - [wildspec [,]] !wildspec2 ; File that matches wildspec and not - wildspec2. -*/ - -#include "mysys_priv.h" -#include <m_string.h> - - /* Store wildcard-string in a easyer format */ - -WF_PACK *wf_comp(char * str) -{ - uint ant; - int not_pos; - register char * pos; - char * buffer; - WF_PACK *ret; - DBUG_ENTER("wf_comp"); - - not_pos= -1; /* Skip space and '!' in front */ - while (*str == ' ') - str++; - if (*str == '!') - { - not_pos=0; - while (*++str == ' ') {}; - } - if (*str == 0) /* Empty == everything */ - DBUG_RETURN((WF_PACK *) NULL); - - ant=1; /* Count filespecs */ - for (pos=str ; *pos ; pos++) - ant+= test(*pos == ' ' || *pos == ','); - - if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(char **)+2)+ - sizeof(WF_PACK)+ (uint) strlen(str)+1, - MYF(MY_WME))) - == 0) - DBUG_RETURN((WF_PACK *) NULL); - ret->wild= (char **) (ret+1); - buffer= (char *) (ret->wild+ant); - - ant=0; - for (pos=str ; *pos ; str= pos) - { - ret->wild[ant++]=buffer; - while (*pos != ' ' && *pos != ',' && *pos != '!' && *pos) - *buffer++ = *pos++; - - *buffer++ = '\0'; - while (*pos == ' ' || *pos == ',' || *pos == '!' ) - if (*pos++ == '!' && not_pos <0) - not_pos=(int) ant; - } - - ret->wilds=ant; - if (not_pos <0) - ret->not_pos=ant; - else - ret->not_pos=(uint) not_pos; - - DBUG_PRINT("exit",("antal: %d not_pos: %d",ret->wilds,ret->not_pos)); - DBUG_RETURN(ret); -} /* wf_comp */ - - - /* Test if a given filename is matched */ - -int wf_test(register WF_PACK *wf_pack, register const char *name) -{ - reg2 uint i; - reg3 uint not_pos; - DBUG_ENTER("wf_test"); - - if (! wf_pack || wf_pack->wilds == 0) - DBUG_RETURN(0); /* Everything goes */ - - not_pos=wf_pack->not_pos; - for (i=0 ; i < not_pos; i++) - if (wild_compare(name,wf_pack->wild[i],0) == 0) - goto found; - if (i) - DBUG_RETURN(1); /* No-match */ - -found: -/* Test that it isn't in not-list */ - - for (i=not_pos ; i < wf_pack->wilds; i++) - if (wild_compare(name,wf_pack->wild[i],0) == 0) - DBUG_RETURN(1); - DBUG_RETURN(0); -} /* wf_test */ - - - /* We need this because program don't know with malloc we used */ - -void wf_end(WF_PACK *buffer) -{ - DBUG_ENTER("wf_end"); - my_free(buffer); - DBUG_VOID_RETURN; -} /* wf_end */ diff --git a/mysys/my_append.c b/mysys/my_append.c deleted file mode 100644 index 1ef3905b6f5..00000000000 --- a/mysys/my_append.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mysys_priv.h" -#include <sys/stat.h> -#include <m_string.h> -#if defined(HAVE_UTIME_H) -#include <utime.h> -#elif defined(HAVE_SYS_UTIME_H) -#include <sys/utime.h> -#elif !defined(HPUX10) -struct utimbuf { - time_t actime; - time_t modtime; -}; -#endif - -/* - Append a file to another - - NOTES - Don't set MY_FNABP or MY_NABP bits on when calling this function -*/ - -int my_append(const char *from, const char *to, myf MyFlags) -{ - size_t Count; - File from_file,to_file; - uchar buff[IO_SIZE]; - DBUG_ENTER("my_append"); - DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); - - from_file= to_file= -1; - - if ((from_file=my_open(from,O_RDONLY,MyFlags)) >= 0) - { - if ((to_file=my_open(to,O_APPEND | O_WRONLY,MyFlags)) >= 0) - { - while ((Count=my_read(from_file,buff,IO_SIZE,MyFlags)) != 0) - if (Count == (uint) -1 || - my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP))) - goto err; - if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags)) - DBUG_RETURN(-1); /* Error on close */ - DBUG_RETURN(0); - } - } -err: - if (from_file >= 0) (void) my_close(from_file,MyFlags); - if (to_file >= 0) (void) my_close(to_file,MyFlags); - DBUG_RETURN(-1); -} diff --git a/mysys/my_atomic.c b/mysys/my_atomic.c index 6bc76f0de3c..7cbe15cfb74 100644 --- a/mysys/my_atomic.c +++ b/mysys/my_atomic.c @@ -16,13 +16,6 @@ #include <my_global.h> #include <my_sys.h> -#ifndef HAVE_INLINE -/* the following will cause all inline functions to be instantiated */ -#define HAVE_INLINE -#undef STATIC_INLINE -#define STATIC_INLINE extern -#endif - #include <my_atomic.h> /* diff --git a/mysys/my_bit.c b/mysys/my_bit.c index 2881eb1ebd2..f072f243765 100644 --- a/mysys/my_bit.c +++ b/mysys/my_bit.c @@ -15,13 +15,6 @@ #include <my_global.h> -#ifndef HAVE_INLINE -/* the following will cause all inline functions to be instantiated */ -#define HAVE_INLINE -#undef STATIC_INLINE -#define STATIC_INLINE extern -#endif - #include <my_bit.h> const char _my_bits_nbits[256] = { diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 3de05fa8664..3401c7301e9 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -566,192 +566,6 @@ void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit) bitmap_unlock(map); } - -#ifdef NOT_USED -my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size) -{ - my_bool res; - bitmap_lock((MY_BITMAP *)map); - res= bitmap_is_prefix(map, prefix_size); - bitmap_unlock((MY_BITMAP *)map); - return res; -} - - -void bitmap_lock_set_all(MY_BITMAP *map) -{ - bitmap_lock(map); - bitmap_set_all(map); - bitmap_unlock(map); -} - - -void bitmap_lock_clear_all(MY_BITMAP *map) -{ - bitmap_lock(map); - bitmap_clear_all(map); - bitmap_unlock(map); -} - - -void bitmap_lock_set_prefix(MY_BITMAP *map, uint prefix_size) -{ - bitmap_lock(map); - bitmap_set_prefix(map, prefix_size); - bitmap_unlock(map); -} - - -my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map) -{ - uint res; - bitmap_lock((MY_BITMAP *)map); - res= bitmap_is_clear_all(map); - bitmap_unlock((MY_BITMAP *)map); - return res; -} - - -my_bool bitmap_lock_is_set_all(const MY_BITMAP *map) -{ - uint res; - bitmap_lock((MY_BITMAP *)map); - res= bitmap_is_set_all(map); - bitmap_unlock((MY_BITMAP *)map); - return res; -} - - -my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit) -{ - my_bool res; - DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits); - bitmap_lock((MY_BITMAP *)map); - res= bitmap_is_set(map, bitmap_bit); - bitmap_unlock((MY_BITMAP *)map); - return res; -} - - -my_bool bitmap_lock_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2) -{ - uint res; - bitmap_lock((MY_BITMAP *)map1); - bitmap_lock((MY_BITMAP *)map2); - res= bitmap_is_subset(map1, map2); - bitmap_unlock((MY_BITMAP *)map2); - bitmap_unlock((MY_BITMAP *)map1); - return res; -} - - -my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2) -{ - uint res; - - DBUG_ASSERT(map1->bitmap && map2->bitmap && - map1->n_bits==map2->n_bits); - bitmap_lock((MY_BITMAP *)map1); - bitmap_lock((MY_BITMAP *)map2); - res= bitmap_cmp(map1, map2); - bitmap_unlock((MY_BITMAP *)map2); - bitmap_unlock((MY_BITMAP *)map1); - return res; -} - - -void bitmap_lock_intersect(MY_BITMAP *map, const MY_BITMAP *map2) -{ - bitmap_lock(map); - bitmap_lock((MY_BITMAP *)map2); - bitmap_intersect(map, map2); - bitmap_unlock((MY_BITMAP *)map2); - bitmap_unlock(map); -} - - -void bitmap_lock_subtract(MY_BITMAP *map, const MY_BITMAP *map2) -{ - bitmap_lock(map); - bitmap_lock((MY_BITMAP *)map2); - bitmap_subtract(map, map2); - bitmap_unlock((MY_BITMAP *)map2); - bitmap_unlock(map); -} - - -void bitmap_lock_union(MY_BITMAP *map, const MY_BITMAP *map2) -{ - bitmap_lock(map); - bitmap_lock((MY_BITMAP *)map2); - bitmap_union(map, map2); - bitmap_unlock((MY_BITMAP *)map2); - bitmap_unlock(map); -} - - -/* - SYNOPSIS - bitmap_bits_set() - map - RETURN - Number of set bits in the bitmap. -*/ -uint bitmap_lock_bits_set(const MY_BITMAP *map) -{ - uint res; - bitmap_lock((MY_BITMAP *)map); - DBUG_ASSERT(map->bitmap); - res= bitmap_bits_set(map); - bitmap_unlock((MY_BITMAP *)map); - return res; -} - - -/* - SYNOPSIS - bitmap_get_first() - map - RETURN - Number of first unset bit in the bitmap or MY_BIT_NONE if all bits are set. -*/ -uint bitmap_lock_get_first(const MY_BITMAP *map) -{ - uint res; - bitmap_lock((MY_BITMAP*)map); - res= bitmap_get_first(map); - bitmap_unlock((MY_BITMAP*)map); - return res; -} - - -uint bitmap_lock_get_first_set(const MY_BITMAP *map) -{ - uint res; - bitmap_lock((MY_BITMAP*)map); - res= bitmap_get_first_set(map); - bitmap_unlock((MY_BITMAP*)map); - return res; -} - - -void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit) -{ - DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits); - bitmap_lock(map); - bitmap_set_bit(map, bitmap_bit); - bitmap_unlock(map); -} - - -void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit) -{ - DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits); - bitmap_lock(map); - bitmap_flip_bit(map, bitmap_bit); - bitmap_unlock(map); -} -#endif #ifdef MAIN uint get_rand_bit(uint bitsize) diff --git a/mysys/my_clock.c b/mysys/my_clock.c deleted file mode 100644 index da04feb462f..00000000000 --- a/mysys/my_clock.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "my_global.h" - -#if !defined(_MSC_VER) && !defined(__BORLANDC__) -#include "mysys_priv.h" -#include <sys/times.h> -#endif - -long my_clock(void) -{ -#if !defined(__WIN__) - struct tms tmsbuf; - (void) times(&tmsbuf); - return (tmsbuf.tms_utime + tmsbuf.tms_stime); -#else - return clock(); -#endif -} diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 878aebd3684..35324dd4cef 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -16,6 +16,7 @@ #include "mysys_priv.h" #include <my_dir.h> /* for stat */ #include <m_string.h> +#include "mysys_err.h" #if defined(HAVE_UTIME_H) #include <utime.h> #elif defined(HAVE_SYS_UTIME_H) @@ -56,7 +57,6 @@ int my_copy(const char *from, const char *to, myf MyFlags) File from_file,to_file; uchar buff[IO_SIZE]; MY_STAT stat_buff,new_stat_buff; - int res; DBUG_ENTER("my_copy"); DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); @@ -102,9 +102,23 @@ int my_copy(const char *from, const char *to, myf MyFlags) if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat) DBUG_RETURN(0); /* File copyed but not stat */ - res= chmod(to, stat_buff.st_mode & 07777); /* Copy modes */ + /* Copy modes */ + if (chmod(to, stat_buff.st_mode & 07777)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno); + goto err; + } #if !defined(__WIN__) - res= chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */ + /* Copy ownership */ + if (chown(to, stat_buff.st_uid, stat_buff.st_gid)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno); + goto err; + } #endif if (MyFlags & MY_COPYTIME) diff --git a/mysys/my_dup.c b/mysys/my_dup.c deleted file mode 100644 index 5fdd6e9f364..00000000000 --- a/mysys/my_dup.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mysys_priv.h" -#include "mysys_err.h" -#include <my_dir.h> -#include <errno.h> -#if defined(__WIN__) -#include <share.h> -#endif - - /* Open a file */ - -File my_dup(File file, myf MyFlags) -{ - File fd; - const char *filename; - DBUG_ENTER("my_dup"); - DBUG_PRINT("my",("file: %d MyFlags: %d", file, MyFlags)); -#ifdef _WIN32 - fd= my_win_dup(file); -#else - fd= dup(file); -#endif - filename= (((uint) file < my_file_limit) ? - my_file_info[(int) file].name : "Unknown"); - DBUG_RETURN(my_register_filename(fd, filename, FILE_BY_DUP, - EE_FILENOTFOUND, MyFlags)); -} /* my_open */ diff --git a/mysys/my_handler.c b/mysys/my_handler.c index 48d100f2d3f..bd1e313d066 100644 --- a/mysys/my_handler.c +++ b/mysys/my_handler.c @@ -23,6 +23,8 @@ #include "my_handler_errors.h" +#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) + int ha_compare_text(CHARSET_INFO *charset_info, uchar *a, uint a_length, uchar *b, uint b_length, my_bool part_key, my_bool skip_end_space) diff --git a/mysys/my_init.c b/mysys/my_init.c index dbf1bfe761c..d2371278b0c 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -33,6 +33,9 @@ static my_bool win32_init_tcp_ip(); #define my_win_init() #endif +#define SCALE_SEC 100 +#define SCALE_USEC 10000 + my_bool my_init_done= 0; /** True if @c my_basic_init() has been called. */ my_bool my_basic_init_done= 0; @@ -138,9 +141,6 @@ my_bool my_init(void) #ifdef THREAD if (my_thread_global_init()) return 1; -#if !defined(__WIN__) - sigfillset(&my_signals); /* signals blocked by mf_brkhant */ -#endif #endif /* THREAD */ { DBUG_ENTER("my_init"); diff --git a/mysys/my_net.c b/mysys/my_net.c deleted file mode 100644 index e584e541175..00000000000 --- a/mysys/my_net.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* thread safe version of some common functions */ - -#include "mysys_priv.h" -#include <m_string.h> - -/* for thread safe my_inet_ntoa */ -#if !defined(__WIN__) -#include <netdb.h> -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#endif /* !defined(__WIN__) */ - -void my_inet_ntoa(struct in_addr in, char *buf) -{ - char *ptr; - mysql_mutex_lock(&THR_LOCK_net); - ptr=inet_ntoa(in); - strmov(buf,ptr); - mysql_mutex_unlock(&THR_LOCK_net); -} diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index 270d13928e3..dee34d10b38 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -138,7 +138,7 @@ void sigwait_setup(sigset_t *set) sact.sa_flags = 0; sact.sa_handler = px_handle_sig; - memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */ + memcpy(&sact.sa_mask, set, sizeof(*set)); /* handler isn't thread_safe */ sigemptyset(&unblock_mask); pthread_sigmask(SIG_UNBLOCK,(sigset_t*) 0,&rev_sigwait_set); @@ -164,7 +164,7 @@ void sigwait_setup(sigset_t *set) } } } - memcpy_fixed(&sigwait_set,set,sizeof(*set)); + memcpy(&sigwait_set, set, sizeof(*set)); pthread_sigmask(SIG_BLOCK,(sigset_t*) set,(sigset_t*) 0); pthread_sigmask(SIG_UNBLOCK,&unblock_mask,(sigset_t*) 0); } @@ -252,7 +252,7 @@ void *sigwait_thread(void *set_arg) struct sigaction sact; sact.sa_flags = 0; sact.sa_handler = sigwait_handle_sig; - memcpy_fixed(&sact.sa_mask,set,sizeof(*set)); /* handler isn't thread_safe */ + memcpy(&sact.sa_mask, set, sizeof(*set)); /* handler isn't thread_safe */ sigemptyset(&pending_set); for (i = 1; i <= sizeof(pending_set)*8; i++) diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 300bac6e296..92aa6e42073 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -76,11 +76,8 @@ end: int my_copystat(const char *from, const char *to, int MyFlags) { struct stat statbuf; -#if !defined(__WIN__) - int res; -#endif - if (stat((char*) from, &statbuf)) + if (stat(from, &statbuf)) { my_errno=errno; if (MyFlags & (MY_FAE+MY_WME)) @@ -89,7 +86,15 @@ int my_copystat(const char *from, const char *to, int MyFlags) } if ((statbuf.st_mode & S_IFMT) != S_IFREG) return 1; - (void) chmod(to, statbuf.st_mode & 07777); /* Copy modes */ + + /* Copy modes */ + if (chmod(to, statbuf.st_mode & 07777)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno); + return -1; + } #if !defined(__WIN__) if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING) @@ -97,7 +102,14 @@ int my_copystat(const char *from, const char *to, int MyFlags) if (MyFlags & MY_LINK_WARNING) my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink); } - res= chown(to, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */ + /* Copy ownership */ + if (chown(to, statbuf.st_uid, statbuf.st_gid)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno); + return -1; + } #endif /* !__WIN__ */ if (MyFlags & MY_COPYTIME) diff --git a/mysys/my_static.c b/mysys/my_static.c index 2869b43543a..d7354555f3d 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -43,9 +43,6 @@ struct st_my_file_info *my_file_info= my_file_info_default; int my_dont_interrupt=0; volatile int _my_signals=0; struct st_remember _my_sig_remember[MAX_SIGNALS]={{0,0}}; -#ifdef THREAD -sigset_t my_signals; /* signals blocked by mf_brkhant */ -#endif /* from mf_reccache.c */ ulong my_default_record_cache_size=RECORD_CACHE_SIZE; diff --git a/mysys/my_static.h b/mysys/my_static.h index 2c9cef0f101..7fde15ff133 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -25,9 +25,6 @@ C_MODE_START #include <signal.h> #define MAX_SIGNALS 10 /* Max signals under a dont-allow */ -#define MIN_KEYBLOCK (min(IO_SIZE,1024)) -#define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */ -#define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK struct st_remember { int number; @@ -48,9 +45,6 @@ extern struct st_my_file_info my_file_info_default[MY_NFILE]; extern ulonglong query_performance_frequency, query_performance_offset; -#if defined(THREAD) && !defined(__WIN__) -extern sigset_t my_signals; /* signals blocked by mf_brkhant */ -#endif C_MODE_END #endif /* MYSYS_MY_STATIC_INCLUDED */ diff --git a/mysys/my_vle.c b/mysys/my_vle.c deleted file mode 100644 index 09f297eb553..00000000000 --- a/mysys/my_vle.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2005 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - Variable length encoding. - - A method to store an arbitrary-size non-negative integer. We let the - most significant bit of the number indicate that the next byte - should be contatenated to form the real number. -*/ - -#include "my_vle.h" - -/* - Function to encode an unsigned long as VLE. The bytes for the VLE - will be written to the location pointed to by 'out'. The maximum - number of bytes written will be 'max'. - - PARAMETERS - - out Pointer to beginning of where to store VLE bytes. - max Maximum number of bytes to write. - n Number to encode. - - RETURN VALUE - On success, one past the end of the array containing the VLE - bytes. On failure, the 'out' pointer is returned. -*/ - -uchar* -my_vle_encode(uchar* out, size_t max, ulong n) -{ - uchar buf[my_vle_sizeof(n)]; - uchar *ptr= buf; - size_t len; - - do - { - *ptr++= (uchar) (n & 0x7F); - n>>= 7; - } - while (n > 0); - - len= ptr - buf; - - if (len <= max) - { - /* - The bytes are stored in reverse order in 'buf'. Let's write them - in correct order to the output buffer and set the MSB at the - same time. - */ - while (ptr-- > buf) - { - uchar v= *ptr; - if (ptr > buf) - v|= 0x80; - *out++= v; - } - } - - return out; -} - -/* - Function to decode a VLE representation of an integral value. - - - PARAMETERS - - result_ptr Pointer to an unsigned long where the value will be written. - vle Pointer to the VLE bytes. - - RETURN VALUE - - One-past the end of the VLE bytes. The routine will never read - more than sizeof(*result_ptr) + 1 bytes. -*/ - -uchar const* -my_vle_decode(ulong *result_ptr, uchar const *vle) -{ - ulong result= 0; - size_t cnt= 1; - - do - { - result<<= 7; - result|= (*vle & 0x7F); - } - while ((*vle++ & 0x80) && ++cnt <= sizeof(*result_ptr) + 1); - - if (cnt <= sizeof(*result_ptr) + 1) - *result_ptr= result; - - return vle; -} diff --git a/mysys/rijndael.c b/mysys/rijndael.c index 2b12753c4e5..2d622efad82 100644 --- a/mysys/rijndael.c +++ b/mysys/rijndael.c @@ -32,22 +32,6 @@ #define FULL_UNROLL */ - -#ifdef NOT_USED -Te0[x] = S [x].[02, 01, 01, 03]; -Te1[x] = S [x].[03, 02, 01, 01]; -Te2[x] = S [x].[01, 03, 02, 01]; -Te3[x] = S [x].[01, 01, 03, 02]; -Te4[x] = S [x].[01, 01, 01, 01]; - -Td0[x] = Si[x].[0e, 09, 0d, 0b]; -Td1[x] = Si[x].[0b, 0e, 09, 0d]; -Td2[x] = Si[x].[0d, 0b, 0e, 09]; -Td3[x] = Si[x].[09, 0d, 0b, 0e]; -Td4[x] = Si[x].[01, 01, 01, 01]; -#endif - - static const uint32 Te0[256]= { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, diff --git a/mysys/test_charset.c b/mysys/test_charset.c index 5b399071d11..39df1b02d7b 100644 --- a/mysys/test_charset.c +++ b/mysys/test_charset.c @@ -77,15 +77,5 @@ int main(int argc, char **argv) { _print_csinfo(cs); fflush(stdout); -#ifdef NOT_USED_ANYMORE - cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG)); - printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list); - my_free(cs_list); - - cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED)); - printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list); - my_free(cs_list); -#endif - return 0; } diff --git a/mysys/test_fn.c b/mysys/test_fn.c deleted file mode 100644 index 249cc878390..00000000000 --- a/mysys/test_fn.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include "mysys_priv.h" - -const char *test_names[]= -{ - "/usr/my/include/srclib/myfunc/dbug/test", - "test", - "dbug/test", - "/usr/my/srclib/myfunc/dbug/test", - "/usr/monty/oldcopy/jazz/setupp.frm", - "~/monty.tst", - "~/dbug/monty.tst", - "./hejsan", - "./dbug/test", - "../dbug/test", - "../myfunc/test", - "../../monty/rutedit", - "/usr/monty//usr/monty/rutedit", - "/usr/./monty/rutedit", - "/usr/my/../monty/rutedit", - "/usr/my/~/rutedit", - "~/../my", - "~/../my/srclib/myfunc/test", - "~/../my/srclib/myfunc/./dbug/test", - "/../usr/my/srclib/dbug", - "c/../my", - "/c/../my", - NullS, -}; - -int main(int argc __attribute__((unused)), char **argv) -{ - const char **pos; - char buff[FN_REFLEN],buff2[FN_REFLEN]; - DBUG_ENTER ("main"); - DBUG_PROCESS (argv[0]); - MY_INIT(argv[0]); - - if (argv[1] && argv[1][1] == '#') - DBUG_PUSH(argv[1]+2); - - for (pos=test_names; *pos ; pos++) - { - printf("org : '%s'\n",*pos); - printf("pack: '%s'\n",fn_format(buff,*pos,"","",8)); - printf("unpack: '%s'\n",fn_format(buff2,*pos,"","",4)); - unpack_filename(buff,buff); - if (strcmp(buff,buff2) != 0) - { - printf("error on cmp: '%s' != '%s'\n",buff,buff2); - } - puts(""); - } - DBUG_RETURN(0); -} diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 9ca18eeaf1b..54eef693558 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -903,11 +903,6 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) sigaddset(&set,THR_SERVER_ALARM); sigdelset(&set, thr_client_alarm); (void) pthread_sigmask(SIG_SETMASK,&set,NULL); -#ifdef NOT_USED - sigemptyset(&set); - sigaddset(&set, thr_client_alarm); - pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0); -#endif pthread_attr_init(&thr_attr); pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS); diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 9d10ba1fb01..5d870bbc151 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -107,7 +107,7 @@ my_bool init_thr_lock() } static inline my_bool -thr_lock_owner_equal(THR_LOCK_OWNER *rhs, THR_LOCK_OWNER *lhs) +thr_lock_owner_equal(THR_LOCK_INFO *rhs, THR_LOCK_INFO *lhs) { return rhs == lhs; } @@ -122,7 +122,7 @@ static int check_lock(struct st_lock_list *list, const char* lock_type, { THR_LOCK_DATA *data,**prev; uint count=0; - THR_LOCK_OWNER *UNINIT_VAR(first_owner); + THR_LOCK_INFO *UNINIT_VAR(first_owner); prev= &list->data; if (list->data) @@ -341,7 +341,6 @@ void thr_lock_info_init(THR_LOCK_INFO *info) struct st_my_thread_var *tmp= my_thread_var; info->thread= tmp->pthread_self; info->thread_id= tmp->id; - info->n_cursors= 0; } /* Initialize a lock instance */ @@ -357,7 +356,7 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *param) static inline my_bool -has_old_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner) +has_old_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner) { for ( ; data ; data=data->next) { @@ -429,7 +428,7 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, thread_var->current_cond= cond; data->cond= cond; - old_proc_info= proc_info_hook(NULL, "Table lock", + old_proc_info= proc_info_hook(NULL, "Waiting for table level lock", __func__, __FILE__, __LINE__); set_timespec(wait_timeout, lock_wait_timeout); @@ -506,13 +505,12 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, enum enum_thr_lock_result -thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, +thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, enum thr_lock_type lock_type, ulong lock_wait_timeout) { THR_LOCK *lock=data->lock; enum enum_thr_lock_result result= THR_LOCK_SUCCESS; struct st_lock_list *wait_queue; - THR_LOCK_DATA *lock_owner; DBUG_ENTER("thr_lock"); data->next=0; @@ -521,7 +519,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, data->owner= owner; /* Must be reset ! */ mysql_mutex_lock(&lock->mutex); DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx type: %d", - (long) data, data->owner->info->thread_id, + (long) data, data->owner->thread_id, (long) lock, (int) lock_type)); check_locks(lock,(uint) lock_type <= (uint) TL_READ_NO_INSERT ? "enter read_lock" : "enter write_lock",0); @@ -558,7 +556,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, */ DBUG_PRINT("lock",("write locked 1 by thread: 0x%lx", - lock->write.data->owner->info->thread_id)); + lock->write.data->owner->thread_id)); if (thr_lock_owner_equal(data->owner, lock->write.data->owner) || (lock->write.data->type <= TL_WRITE_DELAYED && (((int) lock_type <= (int) TL_READ_HIGH_PRIORITY) || @@ -707,7 +705,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, goto end; } DBUG_PRINT("lock",("write locked 2 by thread: 0x%lx", - lock->write.data->owner->info->thread_id)); + lock->write.data->owner->thread_id)); } else { @@ -743,23 +741,10 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, } } DBUG_PRINT("lock",("write locked 3 by thread: 0x%lx type: %d", - lock->read.data->owner->info->thread_id, data->type)); + lock->read.data->owner->thread_id, data->type)); } wait_queue= &lock->write_wait; } - /* - Try to detect a trivial deadlock when using cursors: attempt to - lock a table that is already locked by an open cursor within the - same connection. lock_owner can be zero if we succumbed to a high - priority writer in the write_wait queue. - */ - lock_owner= lock->read.data ? lock->read.data : lock->write.data; - if (lock_owner && lock_owner->owner->info == owner->info) - { - DBUG_PRINT("lock",("deadlock")); - result= THR_LOCK_DEADLOCK; - goto end; - } /* Can't get lock yet; Wait for it */ DBUG_RETURN(wait_for_lock(wait_queue, data, 0, lock_wait_timeout)); end: @@ -807,7 +792,7 @@ static inline void free_all_read_locks(THR_LOCK *lock, } /* purecov: begin inspected */ DBUG_PRINT("lock",("giving read lock to thread: 0x%lx", - data->owner->info->thread_id)); + data->owner->thread_id)); /* purecov: end */ data->cond=0; /* Mark thread free */ mysql_cond_signal(cond); @@ -826,7 +811,7 @@ void thr_unlock(THR_LOCK_DATA *data) enum thr_lock_type lock_type=data->type; DBUG_ENTER("thr_unlock"); DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx", - (long) data, data->owner->info->thread_id, (long) lock)); + (long) data, data->owner->thread_id, (long) lock)); mysql_mutex_lock(&lock->mutex); check_locks(lock,"start of release lock",0); @@ -915,7 +900,7 @@ static void wake_up_waiters(THR_LOCK *lock) data->type=TL_WRITE; /* Upgrade lock */ /* purecov: begin inspected */ DBUG_PRINT("lock",("giving write lock of type %d to thread: 0x%lx", - data->type, data->owner->info->thread_id)); + data->type, data->owner->thread_id)); /* purecov: end */ { mysql_cond_t *cond= data->cond; @@ -1020,7 +1005,7 @@ static void sort_locks(THR_LOCK_DATA **data,uint count) enum enum_thr_lock_result -thr_multi_lock(THR_LOCK_DATA **data, uint count, THR_LOCK_OWNER *owner, +thr_multi_lock(THR_LOCK_DATA **data, uint count, THR_LOCK_INFO *owner, ulong lock_wait_timeout) { THR_LOCK_DATA **pos,**end; @@ -1144,7 +1129,7 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count) else { DBUG_PRINT("lock",("Free lock: data: 0x%lx thread: 0x%lx lock: 0x%lx", - (long) *pos, (*pos)->owner->info->thread_id, + (long) *pos, (*pos)->owner->thread_id, (long) (*pos)->lock)); } } @@ -1200,7 +1185,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id) mysql_mutex_lock(&lock->mutex); for (data= lock->read_wait.data; data ; data= data->next) { - if (data->owner->info->thread_id == thread_id) /* purecov: tested */ + if (data->owner->thread_id == thread_id) /* purecov: tested */ { DBUG_PRINT("info",("Aborting read-wait lock")); data->type= TL_UNLOCK; /* Mark killed */ @@ -1217,7 +1202,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id) } for (data= lock->write_wait.data; data ; data= data->next) { - if (data->owner->info->thread_id == thread_id) /* purecov: tested */ + if (data->owner->thread_id == thread_id) /* purecov: tested */ { DBUG_PRINT("info",("Aborting write-wait lock")); data->type= TL_UNLOCK; @@ -1387,7 +1372,7 @@ static void thr_print_lock(const char* name,struct st_lock_list *list) prev= &list->data; for (data=list->data; data && count++ < MAX_LOCKS ; data=data->next) { - printf("0x%lx (%lu:%d); ", (ulong) data, data->owner->info->thread_id, + printf("0x%lx (%lu:%d); ", (ulong) data, data->owner->thread_id, (int) data->type); if (data->prev != prev) printf("\nWarning: prev didn't point at previous lock\n"); @@ -1525,7 +1510,6 @@ static void *test_thread(void *arg) { int i,j,param=*((int*) arg); THR_LOCK_DATA data[MAX_LOCK_COUNT]; - THR_LOCK_OWNER owner; THR_LOCK_INFO lock_info; THR_LOCK_DATA *multi_locks[MAX_LOCK_COUNT]; my_thread_init(); @@ -1534,7 +1518,6 @@ static void *test_thread(void *arg) thr_lock_info_init(&lock_info); - thr_lock_owner_init(&owner, &lock_info); for (i=0; i < lock_counts[param] ; i++) thr_lock_data_init(locks+tests[param][i].lock_nr,data+i,NULL); for (j=1 ; j < 10 ; j++) /* try locking 10 times */ @@ -1544,7 +1527,7 @@ static void *test_thread(void *arg) multi_locks[i]= &data[i]; data[i].type= tests[param][i].lock_type; } - thr_multi_lock(multi_locks, lock_counts[param], &owner, TEST_TIMEOUT); + thr_multi_lock(multi_locks, lock_counts[param], &lock_info, TEST_TIMEOUT); mysql_mutex_lock(&LOCK_thread_count); { int tmp=rand() & 7; /* Do something from 0-2 sec */ diff --git a/mysys/thr_rwlock.c b/mysys/thr_rwlock.c index 2ac4a00695e..ecd12849822 100644 --- a/mysys/thr_rwlock.c +++ b/mysys/thr_rwlock.c @@ -71,6 +71,9 @@ int my_rw_init(my_rw_lock_t *rwp, my_bool *prefer_readers_attr) rwp->state = 0; rwp->waiters = 0; +#ifdef SAFE_MUTEX + rwp->write_thread = 0; +#endif /* If attribute argument is NULL use default value - prefer writers. */ rwp->prefer_readers= prefer_readers_attr ? *prefer_readers_attr : FALSE; @@ -80,6 +83,7 @@ int my_rw_init(my_rw_lock_t *rwp, my_bool *prefer_readers_attr) int my_rw_destroy(my_rw_lock_t *rwp) { + DBUG_ASSERT(rwp->state == 0); pthread_mutex_destroy( &rwp->lock ); pthread_cond_destroy( &rwp->readers ); pthread_cond_destroy( &rwp->writers ); @@ -123,10 +127,15 @@ int my_rw_wrlock(my_rw_lock_t *rwp) pthread_mutex_lock(&rwp->lock); rwp->waiters++; /* another writer queued */ + my_rw_lock_assert_not_write_owner(rwp); + while (rwp->state) pthread_cond_wait(&rwp->writers, &rwp->lock); rwp->state = -1; rwp->waiters--; +#ifdef SAFE_MUTEX + rwp->write_thread= pthread_self(); +#endif pthread_mutex_unlock(&rwp->lock); return(0); } @@ -142,6 +151,9 @@ int my_rw_trywrlock(my_rw_lock_t *rwp) { res=0; rwp->state = -1; +#ifdef SAFE_MUTEX + rwp->write_thread= pthread_self(); +#endif } pthread_mutex_unlock(&rwp->lock); return(res); @@ -154,9 +166,15 @@ int my_rw_unlock(my_rw_lock_t *rwp) ("state: %d waiters: %d", rwp->state, rwp->waiters)); pthread_mutex_lock(&rwp->lock); + DBUG_ASSERT(rwp->state != 0); + if (rwp->state == -1) /* writer releasing */ { + my_rw_lock_assert_write_owner(rwp); rwp->state= 0; /* mark as available */ +#ifdef SAFE_MUTEX + rwp->write_thread= 0; +#endif if ( rwp->waiters ) /* writers queued */ pthread_cond_signal( &rwp->writers ); diff --git a/mysys/trie.c b/mysys/trie.c deleted file mode 100644 index b2e93fcceac..00000000000 --- a/mysys/trie.c +++ /dev/null @@ -1,236 +0,0 @@ -/* Copyright (C) 2005 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - Implementation of trie and Aho-Corasick automaton. - Supports only charsets that can be compared byte-wise. - - TODO: - Add character frequencies. Can increase lookup speed - up to 30%. - Implement character-wise comparision. -*/ - - -#include "mysys_priv.h" -#include <m_string.h> -#include <my_trie.h> -#include <my_base.h> - - -/* - SYNOPSIS - TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset); - - DESCRIPTION - Allocates or initializes a `TRIE' object. If `trie' is a `NULL' - pointer, the function allocates, initializes, and returns a new - object. Otherwise, the object is initialized and the address of - the object is returned. If `trie_init()' allocates a new object, - it will be freed when `trie_free()' is called. - - RETURN VALUE - An initialized `TRIE*' object. `NULL' if there was insufficient - memory to allocate a new object. -*/ - -TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset) -{ - MEM_ROOT mem_root; - DBUG_ENTER("trie_init"); - DBUG_ASSERT(charset); - init_alloc_root(&mem_root, - (sizeof(TRIE_NODE) * 128) + ALLOC_ROOT_MIN_BLOCK_SIZE, - sizeof(TRIE_NODE) * 128); - if (! trie) - { - if (! (trie= (TRIE *)alloc_root(&mem_root, sizeof(TRIE)))) - { - free_root(&mem_root, MYF(0)); - DBUG_RETURN(NULL); - } - } - - memcpy(&trie->mem_root, &mem_root, sizeof(MEM_ROOT)); - trie->root.leaf= 0; - trie->root.c= 0; - trie->root.next= NULL; - trie->root.links= NULL; - trie->root.fail= NULL; - trie->charset= charset; - trie->nnodes= 0; - trie->nwords= 0; - DBUG_RETURN(trie); -} - - -/* - SYNOPSIS - void trie_free (TRIE *trie); - trie - valid pointer to `TRIE' - - DESCRIPTION - Frees the memory allocated for a `trie'. - - RETURN VALUE - None. -*/ - -void trie_free (TRIE *trie) -{ - MEM_ROOT mem_root; - DBUG_ENTER("trie_free"); - DBUG_ASSERT(trie); - memcpy(&mem_root, &trie->mem_root, sizeof(MEM_ROOT)); - free_root(&mem_root, MYF(0)); - DBUG_VOID_RETURN; -} - - -/* - SYNOPSIS - my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen); - trie - valid pointer to `TRIE' - key - valid pointer to key to insert - keylen - non-0 key length - - DESCRIPTION - Inserts new key into trie. - - RETURN VALUE - Upon successful completion, `trie_insert' returns `FALSE'. Otherwise - `TRUE' is returned. - - NOTES - If this function fails you must assume `trie' is broken. - However it can be freed with trie_free(). -*/ - -my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen) -{ - TRIE_NODE *node; - TRIE_NODE *next; - uchar p; - uint k; - DBUG_ENTER("trie_insert"); - DBUG_ASSERT(trie && key && keylen); - node= &trie->root; - trie->root.fail= NULL; - for (k= 0; k < keylen; k++) - { - p= key[k]; - for (next= node->links; next; next= next->next) - if (next->c == p) - break; - - if (! next) - { - TRIE_NODE *tmp= (TRIE_NODE *)alloc_root(&trie->mem_root, - sizeof(TRIE_NODE)); - if (! tmp) - DBUG_RETURN(TRUE); - tmp->leaf= 0; - tmp->c= p; - tmp->links= tmp->fail= tmp->next= NULL; - trie->nnodes++; - if (! node->links) - { - node->links= tmp; - } - else - { - for (next= node->links; next->next; next= next->next) /* no-op */; - next->next= tmp; - } - node= tmp; - } - else - { - node= next; - } - } - node->leaf= keylen; - trie->nwords++; - DBUG_RETURN(FALSE); -} - - -/* - SYNOPSIS - my_bool trie_prepare (TRIE *trie); - trie - valid pointer to `TRIE' - - DESCRIPTION - Constructs Aho-Corasick automaton. - - RETURN VALUE - Upon successful completion, `trie_prepare' returns `FALSE'. Otherwise - `TRUE' is returned. -*/ - -my_bool ac_trie_prepare (TRIE *trie) -{ - TRIE_NODE **tmp_nodes; - TRIE_NODE *node; - uint32 fnode= 0; - uint32 lnode= 0; - DBUG_ENTER("trie_prepare"); - DBUG_ASSERT(trie); - - tmp_nodes= (TRIE_NODE **)my_malloc(trie->nnodes * sizeof(TRIE_NODE *), MYF(0)); - if (! tmp_nodes) - DBUG_RETURN(TRUE); - - trie->root.fail= &trie->root; - for (node= trie->root.links; node; node= node->next) - { - node->fail= &trie->root; - tmp_nodes[lnode++]= node; - } - - while (fnode < lnode) - { - TRIE_NODE *current= (TRIE_NODE *)tmp_nodes[fnode++]; - for (node= current->links; node; node= node->next) - { - TRIE_NODE *fail= current->fail; - tmp_nodes[lnode++]= node; - while (! (node->fail= trie_goto(&trie->root, fail, node->c))) - fail= fail->fail; - } - } - my_free(tmp_nodes); - DBUG_RETURN(FALSE); -} - - -/* - SYNOPSIS - void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state); - trie - valid pointer to `TRIE' - state - value pointer to `AC_TRIE_STATE' - - DESCRIPTION - Initializes `AC_TRIE_STATE' object. -*/ - -void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state) -{ - DBUG_ENTER("ac_trie_init"); - DBUG_ASSERT(trie && state); - state->trie= trie; - state->node= &trie->root; - DBUG_VOID_RETURN; -} diff --git a/packaging/Makefile.am b/packaging/Makefile.am new file mode 100644 index 00000000000..3e6a79367b6 --- /dev/null +++ b/packaging/Makefile.am @@ -0,0 +1,14 @@ +EXTRA_DIST = \ + WiX/AdminBackground.jpg \ + WiX/AdminHeader.jpg \ + WiX/CMakeLists.txt \ + WiX/extra.wxs.in \ + WiX/CPackWixConfig.cmake \ + WiX/create_msi.cmake.in \ + WiX/custom_ui.wxs \ + WiX/MySQLServer.ico \ + WiX/mysql_server.wxs.in \ + WiX/ca/CMakeLists.txt \ + WiX/ca/CustomAction.cpp \ + WiX/ca/CustomAction.def \ + WiX/ca/CustomAction.rc diff --git a/packaging/WiX/CMakeLists.txt b/packaging/WiX/CMakeLists.txt index 8a6a4ae4c41..052887f10a1 100644 --- a/packaging/WiX/CMakeLists.txt +++ b/packaging/WiX/CMakeLists.txt @@ -41,11 +41,13 @@ FOREACH(dir mysql performance_schema) FILE(GLOB files ${CMAKE_BINARY_DIR}/sql/data/${dir}/*) SET(filelist) FOREACH(f ${files}) + IF(NOT f MATCHES ".rule") FILE(TO_NATIVE_PATH "${f}" file_native_path) GET_FILENAME_COMPONENT(file_name "${f}" NAME) SET(filelist "${filelist} <File Id='${file_name}' Source='${file_native_path}'/>") + ENDIF() ENDFOREACH() STRING(TOUPPER ${dir} DIR_UPPER) SET(DATADIR_${DIR_UPPER}_FILES "${filelist}") @@ -56,15 +58,34 @@ FIND_PROGRAM(HEAT_EXECUTABLE heat ${WIX_DIR}) FIND_PROGRAM(CANDLE_EXECUTABLE candle ${WIX_DIR}) FIND_PROGRAM(LIGHT_EXECUTABLE light ${WIX_DIR}) +# WiX wants the license text as rtf; if there is no rtf license, +# we create a fake one from the plain text COPYING file. +IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf") + SET(COPYING_RTF "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf") +ELSE() + FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/../../COPYING" CONTENTS) + STRING(REGEX REPLACE "\n" "\\\\par\n" CONTENTS "${CONTENTS}") + STRING(REGEX REPLACE "\t" "\\\\tab" CONTENTS "${CONTENTS}") + FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs15") + FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}") + FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "\n}\n") + SET(COPYING_RTF "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf") +ENDIF() +GET_TARGET_PROPERTY(WIXCA_LOCATION wixca LOCATION) +SET(CPACK_WIX_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake) +SET(CPACK_WIX_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/extra.wxs;${CMAKE_CURRENT_SOURCE_DIR}/custom_ui.wxs") + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake @ONLY) + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(WixWin64 " Win64='yes'") ELSE() SET(WixWin64) ENDIF() + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/extra.wxs.in ${CMAKE_CURRENT_BINARY_DIR}/extra.wxs) @@ -72,28 +93,11 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio") SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}") ENDIF() -# WiX wants the license text as rtf; if there is no rtf license, -# we create a fake one from the plain text COPYING file. -IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf") - MESSAGE("copying COPYING.rtf") - FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf" CONTENTS) - FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}") -ELSE() - MESSAGE("creating COPYING.rtf") - FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/../../COPYING" CONTENTS) - STRING(REGEX REPLACE "\n" "\\\\par\n" CONTENTS "${CONTENTS}") - STRING(REGEX REPLACE "\t" "\\\\tab" CONTENTS "${CONTENTS}") - FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs15") - FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "${CONTENTS}") - FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf" "\n}\n") -ENDIF() ADD_CUSTOM_TARGET( MSI COMMAND set VS_UNICODE_OUTPUT= COMMAND ${CMAKE_COMMAND} - -DCPACK_WIX_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake - -DCPACK_WIX_INCLUDE=${CMAKE_CURRENT_BINARY_DIR}/extra.wxs ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake ) @@ -103,10 +107,8 @@ ADD_CUSTOM_TARGET( MSI_ESSENTIALS COMMAND set VS_UNICODE_OUTPUT= COMMAND ${CMAKE_COMMAND} -DESSENTIALS=1 - -DCPACK_WIX_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake - -DCPACK_WIX_INCLUDE=${CMAKE_CURRENT_BINARY_DIR}/extra.wxs ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake ) -ADD_DEPENDENCIES(MSI wixca) +ADD_DEPENDENCIES(MSI_ESSENTIALS wixca) diff --git a/packaging/WiX/CPackWixConfig.cmake b/packaging/WiX/CPackWixConfig.cmake index 6fdc5b46f9a..f49406b5787 100644 --- a/packaging/WiX/CPackWixConfig.cmake +++ b/packaging/WiX/CPackWixConfig.cmake @@ -1,10 +1,12 @@ IF(ESSENTIALS)
- MESSAGE("Essentials!")
SET(CPACK_COMPONENTS_USED "Server;Client;DataFiles")
SET(CPACK_WIX_UI "WixUI_InstallDir")
- MATH(EXPR bits ${CMAKE_SIZEOF_VOID_P}*8)
- SET(CPACK_PACKAGE_FILE_NAME "mysql-essentials-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH}-win${bits}")
+ IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
+ SET(CPACK_PACKAGE_FILE_NAME "mysql-essential-${VERSION}-winx64")
+ ELSE()
+ SET(CPACK_PACKAGE_FILE_NAME "mysql-essential-${VERSION}-win32")
+ ENDIF()
ELSE()
SET(CPACK_COMPONENTS_USED
"Server;Client;DataFiles;Development;SharedLibraries;Embedded;Debuginfo;Documentation;IniFiles;Readme;Server_Scripts;DebugBinaries")
@@ -57,6 +59,7 @@ SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install MySQL Server") SET(CPACK_COMPONENT_DATAFILES_GROUP "MySQLServer")
SET(CPACK_COMPONENT_DATAFILES_DISPLAY_NAME "Server data files")
SET(CPACK_COMPONENT_DATAFILES_DESCRIPTION "Server data files" )
+ SET(CPACK_COMPONENT_DATAFILES_HIDDEN 1)
#Feature "Devel"
diff --git a/packaging/WiX/create_msi.cmake.in b/packaging/WiX/create_msi.cmake.in index ff18009fd0c..adc3cf4c4dd 100644 --- a/packaging/WiX/create_msi.cmake.in +++ b/packaging/WiX/create_msi.cmake.in @@ -4,11 +4,16 @@ SET(CANDLE_EXECUTABLE "@CANDLE_EXECUTABLE@") SET(LIGHT_EXECUTABLE "@LIGHT_EXECUTABLE@")
SET(CMAKE_COMMAND "@CMAKE_COMMAND@")
SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@")
+SET(VERSION "@VERSION@")
SET(MAJOR_VERSION "@MAJOR_VERSION@")
SET(MINOR_VERSION "@MINOR_VERSION@")
SET(PATCH "@PATCH@")
SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)
SET(MANUFACTURER "@MANUFACTURER@")
+SET(WIXCA_LOCATION "@WIXCA_LOCATION@")
+SET(COPYING_RTF "@COPYING_RTF@")
+SET(CPACK_WIX_CONFIG "@CPACK_WIX_CONFIG@")
+SET(CPACK_WIX_INCLUDE "@CPACK_WIX_INCLUDE@")
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(Win64 " Win64='yes'")
@@ -29,7 +34,7 @@ IF(CPACK_WIX_CONFIG) ENDIF()
IF(NOT CPACK_WIX_UI)
- SET(CPACK_WIX_UI "WixUI_Mondo")
+ SET(CPACK_WIX_UI "WixUI_Mondo_Custom")
ENDIF()
SET(WIX_FEATURES)
@@ -143,15 +148,16 @@ FOREACH(f ${WIX_FEATURES}) ENDFOREACH()
+IF(CMAKE_INSTALL_CONFIG_NAME)
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" "${CMAKE_INSTALL_CONFIG_NAME}"
+ WIXCA_LOCATION "${WIXCA_LOCATION}")
+ SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}")
+ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_server.wxs.in
${CMAKE_CURRENT_BINARY_DIR}/mysql_server.wxs)
-IF(CMAKE_INSTALL_CONFIG_NAME)
- SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}")
-ENDIF()
-
FOREACH(comp ${CPACK_COMPONENTS_ALL})
SET(ENV{DESTDIR} testinstall/${comp})
SET(DIRS ${DIRS} testinstall/${comp})
@@ -261,9 +267,12 @@ FOREACH(d ${DIRS}) SET(COMP_NAME ${d_name})
TRAVERSE_FILES(${d} ${d} ${abs}/${d_name}.wxs ${abs}/${d_name}_component_group.wxs "${abs}/dirs")
FILE(APPEND ${abs}/${d_name}_component_group.wxs "</ComponentGroup>")
- FILE(READ ${d_name}.wxs WIX_TMP)
- SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}")
- FILE(REMOVE ${d_name}.wxs)
+ IF(EXISTS ${d_name}.wxs)
+ FILE(READ ${d_name}.wxs WIX_TMP)
+ SET(CPACK_WIX_COMPONENTS "${CPACK_WIX_COMPONENTS}\n${WIX_TMP}")
+ FILE(REMOVE ${d_name}.wxs)
+ ENDIF()
+
FILE(READ ${d_name}_component_group.wxs WIX_TMP)
SET(CPACK_WIX_COMPONENT_GROUPS "${CPACK_WIX_COMPONENT_GROUPS}\n${WIX_TMP}")
diff --git a/packaging/WiX/custom_ui.wxs b/packaging/WiX/custom_ui.wxs new file mode 100644 index 00000000000..90db5c416fe --- /dev/null +++ b/packaging/WiX/custom_ui.wxs @@ -0,0 +1,81 @@ +<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"
+ xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+ <WixVariable Id="WixUICostingPopupOptOut" Value="1" Overridable="yes" />
+ <UI Id="WixUI_Mondo_Custom">
+ <Dialog Id="UpgradeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
+ <Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="Upgrade">
+ <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
+ <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
+ <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)">
+ <Condition Action="default">WixUI_InstallMode = "Remove"</Condition>
+ </Control>
+ <Control Id="InstallTitle" Type="Text" X="15" Y="15" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallTitle)">
+ <Condition Action="show">NOT Installed</Condition>
+ </Control>
+ <Control Id="InstallText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="yes" Text="!(loc.VerifyReadyDlgInstallText)">
+ <Condition Action="show">NOT Installed</Condition>
+ </Control>
+ <Control Id="UpgradeText" Type="Text" X="25" Y="70" Width="320" Height="80" Hidden="no" NoPrefix="yes"
+ Text="Click Upgrade to upgrade your installation from version [OLDERVERSION] to version [ProductVersion]. Click Cancel to exit the upgrade."/>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.VerifyReadyDlgBannerBitmap)" />
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ </Dialog>
+
+ <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
+ <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
+ <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
+
+ <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
+ <Property Id="WixUI_Mode" Value="Mondo" />
+
+ <DialogRef Id="ErrorDlg" />
+ <DialogRef Id="FatalError" />
+ <DialogRef Id="FilesInUse" />
+ <DialogRef Id="MsiRMFilesInUse" />
+ <DialogRef Id="PrepareDlg" />
+ <DialogRef Id="ProgressDlg" />
+ <DialogRef Id="ResumeDlg" />
+ <DialogRef Id="UserExit" />
+
+ <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
+
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg" Order="1">NOT OLDERVERSIONBEINGUPGRADED</Publish>
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="UpgradeDlg" Order="2">OLDERVERSIONBEINGUPGRADED</Publish>
+
+ <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
+ <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="2">LicenseAccepted = "1"</Publish>
+
+ <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
+ <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
+ <Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+
+ <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">WixUI_InstallMode = "Change"</Publish>
+ <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallCustom"</Publish>
+ <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">WixUI_InstallMode = "InstallCustom"</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete"</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">WixUI_InstallMode = "Change"</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="4">WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove"</Publish>
+
+ <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
+
+ <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
+
+ <Publish Dialog="UpgradeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
+ </UI>
+
+ <UIRef Id="WixUI_Common" />
+</Include>
diff --git a/packaging/WiX/extra.wxs.in b/packaging/WiX/extra.wxs.in index b6c42136129..fe2e73c3340 100644 --- a/packaging/WiX/extra.wxs.in +++ b/packaging/WiX/extra.wxs.in @@ -48,7 +48,11 @@ </Directory>
</DirectoryRef>
- <Feature Id="UserEditableDatafiles" Level='1' Display='hidden' ConfigurableDirectory="DATADIR">
+ <Feature Id='UserEditableDataFiles'
+ Title='Server data files'
+ Description='Server data files'
+ ConfigurableDirectory='DATADIR'
+ Level='1'>
<ComponentRef Id="component.datadir"/>
<ComponentRef Id="component.datadir.mysql"/>
<ComponentRef Id="component.datadir.performance_schema"/>
diff --git a/packaging/WiX/mysql_server.wxs.in b/packaging/WiX/mysql_server.wxs.in index 8b20644e58d..59cc817a302 100644 --- a/packaging/WiX/mysql_server.wxs.in +++ b/packaging/WiX/mysql_server.wxs.in @@ -26,7 +26,9 @@ Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.0"
IncludeMinimum="yes"
Maximum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@"
- Property="OLDERVERSIONBEINGUPGRADED" />
+ Property="OLDERVERSIONBEINGUPGRADED"
+ MigrateFeatures="yes"
+ />
<UpgradeVersion
Minimum="@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@"
OnlyDetect="yes"
@@ -39,6 +41,53 @@ <RemoveExistingProducts After="InstallInitialize"/>
</InstallExecuteSequence>
+ <!-- Save/restore install location -->
+ <CustomAction Id="SaveTargetDir" Property="ARPINSTALLLOCATION" Value="[INSTALLDIR]" />
+ <InstallExecuteSequence>
+ <Custom Action="SaveTargetDir" After="InstallValidate">
+ NOT
+ Installed
+ </Custom>
+ </InstallExecuteSequence>
+ <InstallUISequence>
+ <!-- App search is what does FindInstallLocation, and it is dependent on FindRelatedProducts -->
+ <AppSearch After="FindRelatedProducts"/>
+ </InstallUISequence>
+
+ <!-- Find previous installation -->
+ <Property Id="INSTALLDIR">
+ <RegistrySearch Id="FindInstallLocation"
+ Root="HKLM"
+ Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]"
+ Name="InstallLocation"
+ Type="raw" />
+ </Property>
+ <Property Id="OLDERVERSION">
+ <RegistrySearch Id="FindOlderVersion"
+ Root="HKLM"
+ Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]"
+ Name="DisplayVersion"
+ Type="raw" />
+ </Property>
+ <Property Id="DATADIR">
+ <RegistrySearch Id="FindDataDir"
+ Root="HKLM"
+ Key="SOFTWARE\MySQL AB\[ProductName]"
+ Name="DataLocation"
+ Type="raw" />
+ </Property>
+ <Property Id="INSTALLDIR2">
+ <RegistrySearch Id="FindInstallLocation2"
+ Root="HKLM"
+ Key="SOFTWARE\MySQL AB\[ProductName]"
+ Name="Location"
+ Type="raw" />
+ </Property>
+ <CustomAction Id="SetInstallDir2" Property="INSTALLDIR" Value="[INSTALLDIR2]" />
+ <InstallUISequence>
+ <Custom Action="SetInstallDir2" After="AppSearch">INSTALLDIR2</Custom>
+ </InstallUISequence>
+
<!-- UI -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"></Property>
@@ -60,10 +109,10 @@ <!-- License -->
<WixVariable
Id="WixUILicenseRtf"
- Value="@CMAKE_CURRENT_BINARY_DIR@/COPYING.rtf"/>
+ Value="@COPYING_RTF@"/>
<!-- How to remove the service on uninstall -->
- <Binary Id='wixca.dll' SourceFile='@CMAKE_CURRENT_BINARY_DIR@/ca/RelWithDebInfo/wixca.dll' />
+ <Binary Id='wixca.dll' SourceFile='@WIXCA_LOCATION@' />
<CustomAction Id="UnregisterProperty" Property="UnregisterService" Value="[INSTALLDIR]" Return="check" />
<CustomAction Id="UnregisterPropertySilent" Property="UnregisterServiceSilently" Value="[INSTALLDIR]" Return="check" />
<CustomAction Id="UnregisterService"
@@ -81,8 +130,8 @@ <InstallExecuteSequence>
<Custom Action="UnregisterProperty" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE</Custom>
<Custom Action="UnregisterPropertySilent" After="InstallInitialize">Installed And Not UPGRADINGPRODUCTCODE</Custom>
- <Custom Action="UnregisterService" After="UnregisterProperty">Installed And Not UPGRADINGPRODUCTCODE And UILevel>2</Custom>
- <Custom Action="UnregisterServiceSilently" After="UnregisterPropertySilent">Installed And Not UPGRADINGPRODUCTCODE And UILevel<=2</Custom>
+ <Custom Action="UnregisterService" After="UnregisterProperty">Installed And Not UPGRADINGPRODUCTCODE And UILevel>4</Custom>
+ <Custom Action="UnregisterServiceSilently" After="UnregisterPropertySilent">Installed And Not UPGRADINGPRODUCTCODE And UILevel<=4</Custom>
</InstallExecuteSequence>
<!-- Installation root-->
diff --git a/regex/engine.c b/regex/engine.c index 1968ca61a96..be08adf8601 100644 --- a/regex/engine.c +++ b/regex/engine.c @@ -256,7 +256,6 @@ sopno stopst; register char *ssp; /* start of string matched by subsubRE */ register char *sep; /* end of string matched by subsubRE */ register char *oldssp; /* previous ssp */ - register char *dp; /* used in debug mode to check asserts */ AT("diss", start, stop, startst, stopst); sp = start; @@ -314,11 +313,9 @@ sopno stopst; ssub = ss + 1; esub = es - 1; /* did innards match? */ - if (slow(charset, m, sp, rest, ssub, esub) != NULL) { - dp = dissect(charset, m, sp, rest, ssub, esub); - assert(dp == rest); - } else /* no */ - assert(sp == rest); + if (slow(charset, m, sp, rest, ssub, esub) != NULL) + sp = dissect(charset, m, sp, rest, ssub, esub); + assert(sp == rest); sp = rest; break; case OPLUS_: @@ -353,8 +350,8 @@ sopno stopst; } assert(sep == rest); /* must exhaust substring */ assert(slow(charset, m, ssp, sep, ssub, esub) == rest); - dp = dissect(charset, m, ssp, sep, ssub, esub); - assert(dp == sep); + sp = dissect(charset, m, ssp, sep, ssub, esub); + assert(sp == sep); sp = rest; break; case OCH_: @@ -388,8 +385,8 @@ sopno stopst; else assert(OP(m->g->strip[esub]) == O_CH); } - dp = dissect(charset, m, sp, rest, ssub, esub); - assert(dp == rest); + sp = dissect(charset, m, sp, rest, ssub, esub); + assert(sp == rest); sp = rest; break; case O_PLUS: diff --git a/regex/regcomp.c b/regex/regcomp.c index 81c435ed552..b41a1ae6da9 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -285,18 +285,6 @@ register struct parse *p; EMIT(ORPAREN, subno); if(MUSTEAT(')', REG_EPAREN)) {} break; -#ifndef POSIX_MISTAKE - case ')': /* happens only if no current unmatched ( */ - /* - * You may ask, why the ifndef? Because I didn't notice - * this until slightly too late for 1003.2, and none of the - * other 1003.2 regular-expression reviewers noticed it at - * all. So an unmatched ) is legal POSIX, at least until - * we can get it fixed. - */ - SETERROR(REG_EPAREN); - break; -#endif case '^': EMIT(OBOL, 0); p->g->iflags |= USEBOL; @@ -1228,66 +1216,6 @@ register char *cp; } #endif -#ifdef NOT_USED -/* - - mcsub - subtract a collating element from a cset - == static void mcsub(register cset *cs, register char *cp); - */ -static void -mcsub(cs, cp) -register cset *cs; -register char *cp; -{ - register char *fp = mcfind(cs, cp); - register size_t len = strlen(fp); - - assert(fp != NULL); - (void) memmove(fp, fp + len + 1, - cs->smultis - (fp + len + 1 - cs->multis)); - cs->smultis -= len; - - if (cs->smultis == 0) { - free(cs->multis); - cs->multis = NULL; - return; - } - - cs->multis = realloc(cs->multis, cs->smultis); - assert(cs->multis != NULL); -} - -/* - - mcin - is a collating element in a cset? - == static int mcin(register cset *cs, register char *cp); - */ -static int -mcin(cs, cp) -register cset *cs; -register char *cp; -{ - return(mcfind(cs, cp) != NULL); -} - -/* - - mcfind - find a collating element in a cset - == static char *mcfind(register cset *cs, register char *cp); - */ -static char * -mcfind(cs, cp) -register cset *cs; -register char *cp; -{ - register char *p; - - if (cs->multis == NULL) - return(NULL); - for (p = cs->multis; *p != '\0'; p += strlen(p) + 1) - if (strcmp(cp, p) == 0) - return(p); - return(NULL); -} -#endif - /* - mcinvert - invert the list of collating elements in a cset == static void mcinvert(register struct parse *p, register cset *cs); diff --git a/regex/regcomp.ih b/regex/regcomp.ih index 5deba89217a..cb93286e32f 100644 --- a/regex/regcomp.ih +++ b/regex/regcomp.ih @@ -30,11 +30,6 @@ static int nch(register struct parse *p, register cset *cs); #ifdef USE_ORIG_REGEX_CODE static void mcadd(register struct parse *p, register cset *cs, register char *cp); #endif -#ifdef NOT_USED -static void mcsub(register cset *cs, register char *cp); -static int mcin(register cset *cs, register char *cp); -static char *mcfind(register cset *cs, register char *cp); -#endif static void mcinvert(register struct parse *p, register cset *cs); static void mccase(register struct parse *p, register cset *cs); static int isinsets(register struct re_guts *g, int c); diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index be25386c68f..188bd4bdaa5 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -24,6 +24,7 @@ ENDIF() # Build mysql_fix_privilege_tables.sql (concatenate 2 sql scripts) IF(NOT WIN32 OR CMAKE_CROSSCOMPILING) FIND_PROGRAM(CAT_EXECUTABLE cat DOC "path to the executable") + MARK_AS_ADVANCED(CAT_EXECUTABLE) ENDIF() IF(CAT_EXECUTABLE) @@ -90,16 +91,14 @@ IF(MALLOC_LIB) ENDIF() IF(CMAKE_GENERATOR MATCHES "Makefiles") - # No multiconfig build - use CMAKE_C_FLAGS # Strip maintainer mode options if necessary - STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS}") - STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS}") + 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() - # Multiconfig build - use CMAKE_C_FLAGS_RELWITHDEBINFO # 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}") @@ -142,6 +141,43 @@ ENDIF() SET(HOSTNAME "hostname") +# Required for mysqlbug until autotools are deprecated, once done remove these +# and expand default cmake variables +SET(CC ${CMAKE_C_COMPILER}) +SET(CXX ${CMAKE_CXX_COMPILER}) +SET(SAVE_CC ${CMAKE_C_COMPILER}) +SET(SAVE_CXX ${CMAKE_CXX_COMPILER}) +SET(SAVE_CFLAGS ${CFLAGS}) +SET(SAVE_CXXFLAGS ${CXXFLAGS}) +# XXX no cmake equivalent for this, just make one up +SET(CONFIGURE_LINE "Built using CMake") + +# Also required for mysqlbug, autoconf only supports --version so for now we +# just explicitly require GNU +IF(CMAKE_COMPILER_IS_GNUCC) + EXECUTE_PROCESS( + COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version + COMMAND sed 1q + OUTPUT_VARIABLE CC_VERSION) +ELSE() + SET(CC_VERSION "") +ENDIF() +IF(CMAKE_COMPILER_IS_GNUCXX) + EXECUTE_PROCESS( + COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version + COMMAND sed 1q + OUTPUT_VARIABLE CXX_VERSION) +ELSE() + SET(CXX_VERSION "") +ENDIF() + +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysqlbug.sh + ${CMAKE_CURRENT_BINARY_DIR}/mysqlbug ESCAPE_QUOTES @ONLY) +INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/mysqlbug + DESTINATION ${INSTALL_BINDIR} + COMPONENT Server + ) + ENDIF(UNIX) # Really ugly, one script, "mysql_install_db", needs prefix set to ".", @@ -198,9 +234,9 @@ SET(localstatedir ${MYSQL_DATADIR}) # some scripts use @TARGET_LINUX@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") - SET(TARGET_LINUX 1) + SET(TARGET_LINUX "true") ELSE() - SET(TARGET_LINUX 0) + SET(TARGET_LINUX "false") ENDIF() # Use cmake variables to inspect dependencies for @@ -294,7 +330,6 @@ ELSE() mysql_zap mysqlaccess mysqlaccess.conf - mysqlbug mysql_convert_table_format mysql_find_rows mysqlhotcopy diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 9af722f7afc..4fb57b06d71 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -264,7 +264,6 @@ cp include/mysql.h \ include/sql_state.h \ include/mysqld_ername.h \ include/mysql_version.h \ - include/config-win.h \ libmysql/libmysql.def \ $DESTDIR/include/ diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 0840a99e6e2..10755fc698b 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -88,6 +88,8 @@ pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"` fix_path pkglibdir $pkglibdir_rel lib/mysql lib plugindir='@pkgplugindir@' +plugindir_rel=`echo $plugindir | sed -e "s;^$basedir/;;"` +fix_path plugindir $plugindir_rel lib/mysql/plugin lib/plugin pkgincludedir='@pkgincludedir@' fix_path pkgincludedir include/mysql include diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 562732e7387..a537bf27aad 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -413,6 +413,29 @@ else DATADIR=@localstatedir@ fi +# +# Try to find the plugin directory +# + +# Use user-supplied argument +if [ -n "${PLUGIN_DIR}" ]; then + plugin_dir="${PLUGIN_DIR}" +else + # Try to find plugin dir relative to basedir + for dir in lib/mysql/plugin lib/plugin + do + if [ -d "${MY_BASEDIR_VERSION}/${dir}" ]; then + plugin_dir="${MY_BASEDIR_VERSION}/${dir}" + break + fi + done + # Give up and use compiled-in default + if [ -z "${plugin_dir}" ]; then + plugin_dir='@pkgplugindir@' + fi +fi +plugin_dir="${plugin_dir}${PLUGIN_VARIANT}" + if test -z "$MYSQL_HOME" then if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf" @@ -704,8 +727,6 @@ fi cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS" -plugin_dir="${PLUGIN_DIR:-$MY_BASEDIR_VERSION/lib/mysql/plugin}${PLUGIN_VARIANT}" - for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION" do diff --git a/sql-bench/CMakeLists.txt b/sql-bench/CMakeLists.txt index be0aeca70b0..95f69fd2a8e 100644 --- a/sql-bench/CMakeLists.txt +++ b/sql-bench/CMakeLists.txt @@ -14,12 +14,6 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Install sql-bench files -FILE(GLOB all_files -${CMAKE_SOURCE_DIR}/sql-bench/* -${CMAKE_SOURCE_DIR}/sql-bench/Data/ATIS/* -${CMAKE_SOURCE_DIR}/sql-bench/Data/Wisconsin/* -${CMAKE_SOURCE_DIR}/sql-bench/limits/* -) IF(NOT INSTALL_SQLBENCHDIR) RETURN() @@ -31,30 +25,39 @@ ELSE() SET(prefix ${INSTALL_SQLBENCHDIR}/) ENDIF() -GET_FILENAME_COMPONENT(basedir ${CMAKE_SOURCE_DIR} ABSOLUTE) +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Data/ATIS + DESTINATION ${prefix}sql-bench/Data) + +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Data/Wisconsin + DESTINATION ${prefix}sql-bench/Data) + +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/limits + DESTINATION ${prefix}sql-bench) + +FILE(GLOB all_files ${CMAKE_CURRENT_SOURCE_DIR}/*) + FOREACH(file ${all_files}) IF(NOT IS_DIRECTORY ${file} AND NOT ${file} MATCHES "Make|as3ap|/example$" ) - FILE(RELATIVE_PATH relpath ${basedir} ${file}) - SET(target_relpath ${relpath}) GET_FILENAME_COMPONENT(ext ${file} EXT) - GET_FILENAME_COMPONENT(dir ${relpath} PATH) + GET_FILENAME_COMPONENT(name ${file} NAME) + SET(target ${name}) IF(ext MATCHES ".sh$") # Those are perl files actually - STRING(REPLACE ".sh" "" target_relpath ${target_relpath} ) + STRING(REPLACE ".sh" "" target ${target} ) IF(WIN32) IF(NOT ext MATCHES ".pl") - SET(target_relpath "${target_relpath}.pl") + SET(target "${target}.pl") ENDIF() ENDIF() ENDIF() - SET(target "${CMAKE_BINARY_DIR}/${target_relpath}") + SET(target "${CMAKE_CURRENT_BINARY_DIR}/${target}") CONFIGURE_FILE(${file} ${target} COPYONLY) IF (ext MATCHES ".bat") IF(WIN32) - INSTALL(FILES ${target} DESTINATION ${prefix}${dir}) + INSTALL(FILES ${target} DESTINATION ${prefix}sql-bench) ENDIF() ELSE() - INSTALL(FILES ${target} DESTINATION ${prefix}${dir}) + INSTALL(FILES ${target} DESTINATION ${prefix}sql-bench) ENDIF() ENDIF() ENDFOREACH() diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 7107a68ee84..879e1bbed90 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -42,8 +42,7 @@ SET (SQL_SOURCE ../sql-common/client.c derror.cc des_key_file.cc discover.cc ../libmysql/errmsg.c field.cc field_conv.cc filesort.cc gstream.cc sha2.cc - ha_partition.cc - handler.cc hash_filo.cc hash_filo.h sql_plugin_services.h + handler.cc hash_filo.h sql_plugin_services.h hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc item_create.cc item_func.cc item_geofunc.cc item_row.cc item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc @@ -60,7 +59,7 @@ SET (SQL_SOURCE sql_cache.cc sql_class.cc sql_client.cc sql_crypt.cc sql_crypt.h sql_cursor.cc sql_db.cc sql_delete.cc sql_derived.cc sql_do.cc sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc - sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc + sql_list.cc sql_load.cc sql_manager.cc sql_parse.cc sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc debug_sync.cc debug_sync.h sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc @@ -185,22 +184,15 @@ RUN_BISON( # Gen_lex_hash ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) -TARGET_LINK_LIBRARIES(gen_lex_hash mysys) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h - COMMAND gen_lex_hash ARGS > lex_hash.h.tmp && - ${CMAKE_COMMAND} -E copy_if_different lex_hash.h.tmp lex_hash.h - COMMAND ${CMAKE_COMMAND} -E remove -f lex_hash.h.tmp - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_lex_hash.cc) + COMMAND gen_lex_hash > lex_hash.h +) MYSQL_ADD_EXECUTABLE(mysql_tzinfo_to_sql tztime.cc) SET_TARGET_PROPERTIES(mysql_tzinfo_to_sql PROPERTIES COMPILE_FLAGS "-DTZINFO2SQL") -TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql ${MYSQLD_STATIC_PLUGIN_LIBS} - mysys dbug strings vio regex - ${LIBWRAP} ${LIBCRYPT} ${LIBDL} - ${SSL_LIBRARIES}) +TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql mysys) ADD_CUSTOM_TARGET( GenServerSource @@ -273,18 +265,20 @@ IF(WIN32 AND MYSQLD_EXECUTABLE) ENDIF() MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/data/mysql/user.frm + OUTPUT initdb.dep COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data + COMMAND ${CMAKE_COMMAND} -E touch initdb.dep + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS mysqld ) ADD_CUSTOM_TARGET(initial_database ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/data/mysql/user.frm + DEPENDS initdb.dep ) - INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data DESTINATION . COMPONENT DataFiles - PATTERN "bootstrap.sql" EXCLUDE) + INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data DESTINATION . + COMPONENT DataFiles PATTERN "initdb.dep" EXCLUDE PATTERN "bootstrap.sql" EXCLUDE) ELSE() # Not windows or cross compiling, just install an empty directory INSTALL(FILES ${DUMMY_FILE} DESTINATION data/mysql) diff --git a/sql/Makefile.am b/sql/Makefile.am index 4b1ecbbc8da..7fed55f3cd6 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -90,7 +90,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ item_create.h item_subselect.h item_row.h \ sql_priv.h item_geofunc.h sql_bitmap.h \ procedure.h sql_class.h sql_lex.h sql_list.h \ - sql_map.h sql_string.h unireg.h \ + sql_string.h unireg.h \ sql_error.h field.h handler.h mysqld_suffix.h \ sql_profile.h mysqld.h sql_help.h frm_crypt.h \ ha_ndbcluster.h ha_ndbcluster_cond.h \ @@ -135,7 +135,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ item_row.cc item_geofunc.cc item_xmlfunc.cc \ field.cc strfunc.cc key.cc sql_class.cc sql_list.cc \ net_serv.cc protocol.cc sql_state.c \ - lock.cc sql_string.cc sql_manager.cc sql_map.cc \ + lock.cc sql_string.cc sql_manager.cc \ main.cc mysqld.cc password.c hash_filo.cc hostname.cc \ sql_connect.cc scheduler.cc sql_parse.cc \ keycaches.cc set_var.cc sql_yacc.yy sys_vars.cc \ @@ -160,8 +160,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ rpl_reporting.cc \ sql_union.cc sql_derived.cc \ sql_client.cc \ - repl_failsafe.h repl_failsafe.cc \ - sql_olap.cc sql_view.cc \ + repl_failsafe.h repl_failsafe.cc sql_view.cc \ gstream.cc spatial.cc sql_help.cc sql_cursor.cc \ tztime.cc my_decimal.cc\ sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \ diff --git a/sql/datadict.cc b/sql/datadict.cc index 33c3b6bc700..7eea977fd5d 100644 --- a/sql/datadict.cc +++ b/sql/datadict.cc @@ -152,9 +152,7 @@ bool dd_recreate_table(THD *thd, const char *db, const char *table_name) build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0); /* Attempt to reconstruct the table. */ - mysql_mutex_lock(&LOCK_open); error= ha_create_table(thd, path, db, table_name, &create_info, TRUE); - mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(error); } diff --git a/sql/field.cc b/sql/field.cc index 56d60ff5b28..3c93ffadac5 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1277,61 +1277,6 @@ int Field::warn_if_overflow(int op_result) } -#ifdef NOT_USED -static bool test_if_real(const char *str,int length, CHARSET_INFO *cs) -{ - cs= system_charset_info; // QQ move test_if_real into CHARSET_INFO struct - - while (length && my_isspace(cs,*str)) - { // Allow start space - length--; str++; - } - if (!length) - return 0; - if (*str == '+' || *str == '-') - { - length--; str++; - if (!length || !(my_isdigit(cs,*str) || *str == '.')) - return 0; - } - while (length && my_isdigit(cs,*str)) - { - length--; str++; - } - if (!length) - return 1; - if (*str == '.') - { - length--; str++; - while (length && my_isdigit(cs,*str)) - { - length--; str++; - } - } - if (!length) - return 1; - if (*str == 'E' || *str == 'e') - { - if (length < 3 || (str[1] != '+' && str[1] != '-') || - !my_isdigit(cs,str[2])) - return 0; - length-=3; - str+=3; - while (length && my_isdigit(cs,*str)) - { - length--; str++; - } - } - for (; length ; length--, str++) - { // Allow end space - if (!my_isspace(cs,*str)) - return 0; - } - return 1; -} -#endif - - /** Interpret field value as an integer but return the result as a string. @@ -4198,7 +4143,7 @@ int Field_float::store(double nr) } else #endif - memcpy_fixed(ptr,(uchar*) &j,sizeof(j)); + memcpy(ptr, &j, sizeof(j)); return error; } @@ -4221,7 +4166,7 @@ double Field_float::val_real(void) } else #endif - memcpy_fixed((uchar*) &j,ptr,sizeof(j)); + memcpy(&j, ptr, sizeof(j)); return ((double) j); } @@ -4235,7 +4180,7 @@ longlong Field_float::val_int(void) } else #endif - memcpy_fixed((uchar*) &j,ptr,sizeof(j)); + memcpy(&j, ptr, sizeof(j)); return (longlong) rint(j); } @@ -4252,7 +4197,7 @@ String *Field_float::val_str(String *val_buffer, } else #endif - memcpy_fixed((uchar*) &nr,ptr,sizeof(nr)); + memcpy(&nr, ptr, sizeof(nr)); uint to_length=max(field_length,70); val_buffer->alloc(to_length); @@ -4290,8 +4235,8 @@ int Field_float::cmp(const uchar *a_ptr, const uchar *b_ptr) else #endif { - memcpy_fixed(&a,a_ptr,sizeof(float)); - memcpy_fixed(&b,b_ptr,sizeof(float)); + memcpy(&a, a_ptr, sizeof(float)); + memcpy(&b, b_ptr, sizeof(float)); } return (a < b) ? -1 : (a > b) ? 1 : 0; } @@ -4308,7 +4253,7 @@ void Field_float::sort_string(uchar *to,uint length __attribute__((unused))) } else #endif - memcpy_fixed(&nr,ptr,sizeof(float)); + memcpy(&nr, ptr, sizeof(float)); uchar *tmp= to; if (nr == (float) 0.0) @@ -4319,7 +4264,7 @@ void Field_float::sort_string(uchar *to,uint length __attribute__((unused))) else { #ifdef WORDS_BIGENDIAN - memcpy_fixed(tmp,&nr,sizeof(nr)); + memcpy(tmp, &nr, sizeof(nr)); #else tmp[0]= ptr[3]; tmp[1]=ptr[2]; tmp[2]= ptr[1]; tmp[3]=ptr[0]; #endif @@ -5501,7 +5446,6 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) int Field_date::store(double nr) { longlong tmp; - int error= 0; if (nr >= 19000000000000.0 && nr <= 99991231235959.0) nr=floor(nr/1000000.0); // Timestamp to date if (nr < 0.0 || nr > 99991231.0) @@ -5510,7 +5454,6 @@ int Field_date::store(double nr) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_DATE); - error= 1; } else tmp= (longlong) rint(nr); @@ -7497,7 +7440,7 @@ double Field_blob::val_real(void) uint32 length; CHARSET_INFO *cs; - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); if (!blob) return 0.0; length= get_length(ptr); @@ -7511,7 +7454,7 @@ longlong Field_blob::val_int(void) ASSERT_COLUMN_MARKED_FOR_READ; int not_used; char *blob; - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); if (!blob) return 0; uint32 length=get_length(ptr); @@ -7523,7 +7466,7 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)), { ASSERT_COLUMN_MARKED_FOR_READ; char *blob; - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); if (!blob) val_ptr->set("",0,charset()); // A bit safer than ->length(0) else @@ -7537,7 +7480,7 @@ my_decimal *Field_blob::val_decimal(my_decimal *decimal_value) ASSERT_COLUMN_MARKED_FOR_READ; const char *blob; size_t length; - memcpy_fixed(&blob, ptr+packlength, sizeof(const uchar*)); + memcpy(&blob, ptr+packlength, sizeof(const uchar*)); if (!blob) { blob= ""; @@ -7565,8 +7508,8 @@ int Field_blob::cmp_max(const uchar *a_ptr, const uchar *b_ptr, uint max_length) { uchar *blob1,*blob2; - memcpy_fixed(&blob1,a_ptr+packlength,sizeof(char*)); - memcpy_fixed(&blob2,b_ptr+packlength,sizeof(char*)); + memcpy(&blob1, a_ptr+packlength, sizeof(char*)); + memcpy(&blob2, b_ptr+packlength, sizeof(char*)); uint a_len= get_length(a_ptr), b_len= get_length(b_ptr); set_if_smaller(a_len, max_length); set_if_smaller(b_len, max_length); @@ -7580,8 +7523,8 @@ int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr, char *a,*b; uint diff; uint32 a_length,b_length; - memcpy_fixed(&a,a_ptr+packlength,sizeof(char*)); - memcpy_fixed(&b,b_ptr+packlength,sizeof(char*)); + memcpy(&a, a_ptr+packlength, sizeof(char*)); + memcpy(&b, b_ptr+packlength, sizeof(char*)); a_length=get_length(a_ptr); if (a_length > max_length) a_length=max_length; @@ -7662,7 +7605,7 @@ int Field_blob::key_cmp(const uchar *key_ptr, uint max_key_length) { uchar *blob1; uint blob_length=get_length(ptr); - memcpy_fixed(&blob1,ptr+packlength,sizeof(char*)); + memcpy(&blob1, ptr+packlength, sizeof(char*)); CHARSET_INFO *cs= charset(); uint local_char_length= max_key_length / cs->mbmaxlen; local_char_length= my_charpos(cs, blob1, blob1+blob_length, @@ -7740,7 +7683,7 @@ void Field_blob::sort_string(uchar *to,uint length) break; } } - memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); + memcpy(&blob, ptr+packlength, sizeof(char*)); blob_length=my_strnxfrm(field_charset, to, length, blob, blob_length); @@ -8709,7 +8652,7 @@ String *Field_bit::val_str(String *val_buffer, mi_int8store(buff,bits); val_buffer->alloc(length); - memcpy_fixed((char*) val_buffer->ptr(), buff+8-length, length); + memcpy((char *) val_buffer->ptr(), buff+8-length, length); val_buffer->length(length); val_buffer->set_charset(&my_charset_bin); return val_buffer; diff --git a/sql/field.h b/sql/field.h index 46d8a2aa6d9..7b250c34fe4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -32,7 +32,6 @@ #include "sql_error.h" /* MYSQL_ERROR */ #define DATETIME_DEC 6 -const uint32 max_field_size= (uint32) 4294967295U; class Send_field; class Protocol; @@ -1763,22 +1762,22 @@ public: void put_length(uchar *pos, uint32 length); inline void get_ptr(uchar **str) { - memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*)); + memcpy(str, ptr+packlength, sizeof(uchar*)); } inline void get_ptr(uchar **str, uint row_offset) { - memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*)); + memcpy(str, ptr+packlength+row_offset, sizeof(char*)); } inline void set_ptr(uchar *length, uchar *data) { memcpy(ptr,length,packlength); - memcpy_fixed(ptr+packlength,&data,sizeof(char*)); + memcpy(ptr+packlength, &data,sizeof(char*)); } void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data) { uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*); store_length(ptr_ofs, packlength, length); - memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*)); + memcpy(ptr_ofs+packlength, &data, sizeof(char*)); } inline void set_ptr(uint32 length, uchar *data) { @@ -1797,7 +1796,7 @@ public: return 1; } tmp=(uchar*) value.ptr(); - memcpy_fixed(ptr+packlength,&tmp,sizeof(char*)); + memcpy(ptr+packlength, &tmp, sizeof(char*)); return 0; } virtual uchar *pack(uchar *to, const uchar *from, diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 299865e6114..ea6ff82e0aa 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -286,7 +286,7 @@ static void do_copy_blob(Copy_field *copy) { ulong length=((Field_blob*) copy->from_field)->get_length(); ((Field_blob*) copy->to_field)->store_length(length); - memcpy_fixed(copy->to_ptr,copy->from_ptr,sizeof(char*)); + memcpy(copy->to_ptr, copy->from_ptr, sizeof(char*)); } static void do_conv_blob(Copy_field *copy) diff --git a/sql/filesort.cc b/sql/filesort.cc index 2398785a038..419f18263cc 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -511,6 +511,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, volatile THD::killed_state *killed= &thd->killed; handler *file; MY_BITMAP *save_read_set, *save_write_set; + bool skip_record; DBUG_ENTER("find_all_keys"); DBUG_PRINT("info",("using: %s", (select ? select->quick ? "ranges" : "where": @@ -603,7 +604,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, } if (error == 0) param->examined_rows++; - if (error == 0 && (!select || select->skip_record() == 0)) + if (!error && (!select || + (!select->skip_record(thd, &skip_record) && !skip_record))) { if (idx == param->keys) { @@ -1663,7 +1665,7 @@ void change_double_for_sort(double nr,uchar *to) else { #ifdef WORDS_BIGENDIAN - memcpy_fixed(tmp,&nr,sizeof(nr)); + memcpy(tmp, &nr, sizeof(nr)); #else { uchar *ptr= (uchar*) &nr; diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 5a0904f87b9..a9c03f7e2a7 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -77,33 +77,12 @@ So, we can read full search-structure as 32-bit word */ #define NO_YACC_SYMBOLS -#include "my_global.h" -#include "my_sys.h" -#include "m_string.h" -#ifndef __GNU_LIBRARY__ -#define __GNU_LIBRARY__ // Skip warnings in getopt.h -#endif -#include <my_getopt.h> +#include <my_global.h> #include "mysql_version.h" #include "lex.h" - -const char *default_dbug_option="d:t:o,/tmp/gen_lex_hash.trace"; - -struct my_option my_long_options[] = -{ -#ifdef DBUG_OFF - {"debug", '#', "This is a non-debug version. Catch this and exit", - 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#else - {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, - (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#endif - {"help", '?', "Display help and exit", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"version", 'V', "Output version information and exit", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} -}; +#include <stdlib.h> +#include <stdio.h> +#include <string.h> struct hash_lex_struct { @@ -340,57 +319,6 @@ void print_find_structs() } -static void usage(int version) -{ - printf("%s Ver 3.6 Distrib %s, for %s (%s)\n", - my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); - if (version) - return; - puts("Copyright (C) 2001 MySQL AB, by VVA and Monty"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ -and you are welcome to modify and redistribute it under the GPL license\n"); - puts("This program generates a perfect hashing function for the sql_lex.cc"); - printf("Usage: %s [OPTIONS]\n\n", my_progname); - my_print_help(my_long_options); -} - - -extern "C" my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument __attribute__((unused))) -{ - switch(optid) { - case 'V': - usage(1); - exit(0); - case 'I': - case '?': - usage(0); - exit(0); - case '#': - DBUG_PUSH(argument ? argument : default_dbug_option); - break; - } - return 0; -} - - -static int get_options(int argc, char **argv) -{ - int ho_error; - - if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) - exit(ho_error); - - if (argc >= 1) - { - usage(0); - exit(1); - } - return(0); -} - - int check_dup_symbols(SYMBOL *s1, SYMBOL *s2) { if (s1->length!=s2->length || strncmp(s1->name,s2->name,s1->length)) @@ -441,11 +369,7 @@ int check_duplicates() int main(int argc,char **argv) { - MY_INIT(argv[0]); - DBUG_PROCESS(argv[0]); - if (get_options(argc,(char **) argv)) - exit(1); /* Broken up to indicate that it's not advice to you, gentle reader. */ printf("/*\n\n Do " "not " "edit " "this " "file " "directly!\n\n*/\n"); @@ -562,7 +486,6 @@ static SYMBOL *get_hash_symbol(const char *s,\n\ }\n\ }\n" ); - my_end(0); exit(0); } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index e3bafe36fb7..15b017ece81 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -36,6 +36,7 @@ #include "discover.h" // readfrm #include "sql_acl.h" // wild_case_compare #include "rpl_mi.h" +#include "transaction.h" /* There is an incompatibility between GNU ar and the Solaris linker @@ -679,7 +680,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) bzero((char*) &table_list,sizeof(table_list)); table_list.db= m_dbname; table_list.alias= table_list.table_name= m_tabname; - close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); + close_cached_tables(thd, &table_list, FALSE, LONG_TIMEOUT); break; } default: @@ -5701,7 +5702,7 @@ int ha_ndbcluster::create(const char *name, m_table->getObjectVersion(), (is_truncate) ? SOT_TRUNCATE_TABLE : SOT_CREATE_TABLE, - 0, 0, 1); + 0, 0); break; } } @@ -6142,7 +6143,7 @@ int ha_ndbcluster::rename_table(const char *from, const char *to) old_dbname, m_tabname, ndb_table_id, ndb_table_version, SOT_RENAME_TABLE, - m_dbname, new_tabname, 1); + m_dbname, new_tabname); } // If we are moving tables between databases, we need to recreate @@ -6336,7 +6337,7 @@ retry_temporary_error1: thd->query(), thd->query_length(), share->db, share->table_name, ndb_table_id, ndb_table_version, - SOT_DROP_TABLE, 0, 0, 1); + SOT_DROP_TABLE, 0, 0); } else if (table_dropped && share && share->op) /* ndbcluster_log_schema_op will do a force GCP */ @@ -7018,7 +7019,6 @@ int ndbcluster_drop_database_impl(const char *path) while ((tabname=it++)) { tablename_to_filename(tabname, tmp, FN_REFLEN - (tmp - full_path)-1); - mysql_mutex_lock(&LOCK_open); if (ha_ndbcluster::delete_table(0, ndb, full_path, dbname, tabname)) { const NdbError err= dict->getNdbError(); @@ -7028,7 +7028,6 @@ int ndbcluster_drop_database_impl(const char *path) ret= ndb_to_mysql_error(&err); } } - mysql_mutex_unlock(&LOCK_open); } DBUG_RETURN(ret); } @@ -7055,7 +7054,7 @@ static void ndbcluster_drop_database(handlerton *hton, char *path) ha_ndbcluster::set_dbname(path, db); ndbcluster_log_schema_op(thd, 0, thd->query(), thd->query_length(), - db, "", 0, 0, SOT_DROP_DB, 0, 0, 0); + db, "", 0, 0, SOT_DROP_DB, 0, 0); #endif DBUG_VOID_RETURN; } @@ -7180,7 +7179,6 @@ int ndbcluster_find_all_files(THD *thd) my_free(data); my_free(pack_data); - mysql_mutex_lock(&LOCK_open); if (discover) { /* ToDo 4.1 database needs to be created if missing */ @@ -7198,7 +7196,6 @@ int ndbcluster_find_all_files(THD *thd) TRUE); } #endif - mysql_mutex_unlock(&LOCK_open); } } while (unhandled && retries); @@ -7291,19 +7288,16 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, file_name->str, reg_ext, 0); if (my_access(name, F_OK)) { - mysql_mutex_lock(&LOCK_open); DBUG_PRINT("info", ("Table %s listed and need discovery", file_name->str)); if (ndb_create_table_from_engine(thd, db, file_name->str)) { - mysql_mutex_unlock(&LOCK_open); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TABLE_EXISTS_ERROR, "Discover of table %s.%s failed", db, file_name->str); continue; } - mysql_mutex_unlock(&LOCK_open); } DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str)); file_on_disk= TRUE; @@ -7360,10 +7354,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, file_name_str= (char*)my_hash_element(&ok_tables, i); end= end1 + tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name)); - mysql_mutex_lock(&LOCK_open); ndbcluster_create_binlog_setup(ndb, name, end-name, db, file_name_str, TRUE); - mysql_mutex_unlock(&LOCK_open); } } #endif @@ -7425,7 +7417,6 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, } /* Lock mutex before creating .FRM files. */ - mysql_mutex_lock(&LOCK_open); /* Create new files. */ List_iterator_fast<char> it2(create_list); while ((file_name_str=it2++)) @@ -7440,8 +7431,6 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, } } - mysql_mutex_unlock(&LOCK_open); - my_hash_free(&ok_tables); my_hash_free(&ndb_tables); @@ -8451,8 +8440,7 @@ int handle_trailing_share(NDB_SHARE *share) bzero((char*) &table_list,sizeof(table_list)); table_list.db= share->db; table_list.alias= table_list.table_name= share->table_name; - mysql_mutex_assert_owner(&LOCK_open); - close_cached_tables(thd, &table_list, TRUE, FALSE, LONG_TIMEOUT); + close_cached_tables(thd, &table_list, FALSE, LONG_TIMEOUT); mysql_mutex_lock(&ndbcluster_mutex); /* ndb_share reference temporary free */ @@ -10611,13 +10599,13 @@ int ndbcluster_alter_tablespace(handlerton *hton, thd->query(), thd->query_length(), "", alter_info->tablespace_name, 0, 0, - SOT_TABLESPACE, 0, 0, 0); + SOT_TABLESPACE, 0, 0); else ndbcluster_log_schema_op(thd, 0, thd->query(), thd->query_length(), "", alter_info->logfile_group_name, 0, 0, - SOT_LOGFILE_GROUP, 0, 0, 0); + SOT_LOGFILE_GROUP, 0, 0); #endif DBUG_RETURN(FALSE); diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index e7ec6d67d52..861b44f74b1 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -36,6 +36,7 @@ #include "lock.h" // MYSQL_LOCK_IGNORE_FLUSH, // mysql_unlock_tables #include "sql_parse.h" // mysql_parse +#include "transaction.h" #ifdef ndb_dynamite #undef assert @@ -359,7 +360,6 @@ ndbcluster_binlog_open_table(THD *thd, NDB_SHARE *share, int error; DBUG_ENTER("ndbcluster_binlog_open_table"); - mysql_mutex_assert_owner(&LOCK_open); init_tmp_table_share(thd, table_share, share->db, 0, share->table_name, share->key); if ((error= open_table_def(thd, table_share, 0))) @@ -375,7 +375,9 @@ ndbcluster_binlog_open_table(THD *thd, NDB_SHARE *share, free_table_share(table_share); DBUG_RETURN(error); } + mysql_mutex_lock(&LOCK_open); assign_new_table_id(table_share); + mysql_mutex_unlock(&LOCK_open); if (!reopen) { @@ -624,7 +626,7 @@ ndbcluster_binlog_log_query(handlerton *hton, THD *thd, enum_binlog_command binl { ndbcluster_log_schema_op(thd, 0, query, query_length, db, table_name, 0, 0, type, - 0, 0, 0); + 0, 0); } DBUG_VOID_RETURN; } @@ -907,9 +909,7 @@ int ndbcluster_setup_binlog_table_shares(THD *thd) if (!ndb_schema_share && ndbcluster_check_ndb_schema_share() == 0) { - mysql_mutex_lock(&LOCK_open); ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_SCHEMA_TABLE); - mysql_mutex_unlock(&LOCK_open); if (!ndb_schema_share) { ndbcluster_create_schema_table(thd); @@ -921,9 +921,7 @@ int ndbcluster_setup_binlog_table_shares(THD *thd) if (!ndb_apply_status_share && ndbcluster_check_ndb_apply_status_share() == 0) { - mysql_mutex_lock(&LOCK_open); ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_APPLY_TABLE); - mysql_mutex_unlock(&LOCK_open); if (!ndb_apply_status_share) { ndbcluster_create_ndb_apply_status_table(thd); @@ -933,12 +931,10 @@ int ndbcluster_setup_binlog_table_shares(THD *thd) } if (!ndbcluster_find_all_files(thd)) { - mysql_mutex_lock(&LOCK_open); ndb_binlog_tables_inited= TRUE; if (opt_ndb_extra_logging) sql_print_information("NDB Binlog: ndb tables writable"); - close_cached_tables(NULL, NULL, TRUE, FALSE, LONG_TIMEOUT); - mysql_mutex_unlock(&LOCK_open); + close_cached_tables(NULL, NULL, FALSE, LONG_TIMEOUT); /* Signal injector thread that all is setup */ mysql_cond_signal(&injector_cond); } @@ -1275,8 +1271,7 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share, uint32 ndb_table_id, uint32 ndb_table_version, enum SCHEMA_OP_TYPE type, - const char *new_db, const char *new_table_name, - int have_lock_open) + const char *new_db, const char *new_table_name) { DBUG_ENTER("ndbcluster_log_schema_op"); Thd_ndb *thd_ndb= get_thd_ndb(thd); @@ -1579,11 +1574,6 @@ end: int max_timeout= DEFAULT_SYNC_TIMEOUT; mysql_mutex_lock(&ndb_schema_object->mutex); - if (have_lock_open) - { - mysql_mutex_assert_owner(&LOCK_open); - mysql_mutex_unlock(&LOCK_open); - } while (1) { struct timespec abstime; @@ -1639,10 +1629,6 @@ end: "distributing", ndb_schema_object->key); } } - if (have_lock_open) - { - mysql_mutex_lock(&LOCK_open); - } mysql_mutex_unlock(&ndb_schema_object->mutex); } @@ -1725,7 +1711,6 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, { DBUG_DUMP("frm", (uchar*) altered_table->getFrmData(), altered_table->getFrmLength()); - mysql_mutex_lock(&LOCK_open); Ndb_table_guard ndbtab_g(dict, tabname); const NDBTAB *old= ndbtab_g.get_table(); if (!old && @@ -1751,7 +1736,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, bzero((char*) &table_list,sizeof(table_list)); table_list.db= (char *)dbname; table_list.alias= table_list.table_name= (char *)tabname; - close_cached_tables(thd, &table_list, TRUE, FALSE, LONG_TIMEOUT); + close_cached_tables(thd, &table_list, FALSE, LONG_TIMEOUT); if ((error= ndbcluster_binlog_open_table(thd, share, table_share, table, 1))) @@ -1762,8 +1747,6 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, table_share= share->table_share; dbname= table_share->db.str; tabname= table_share->table_name.str; - - mysql_mutex_unlock(&LOCK_open); } my_free(data); my_free(pack_data); @@ -1857,7 +1840,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, bzero((char*) &table_list,sizeof(table_list)); table_list.db= (char *)dbname; table_list.alias= table_list.table_name= (char *)tabname; - close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); + close_cached_tables(thd, &table_list, FALSE, LONG_TIMEOUT); /* ndb_share reference create free */ DBUG_PRINT("NDB_SHARE", ("%s create free use_count: %u", share->key, share->use_count)); @@ -1978,7 +1961,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, bzero((char*) &table_list,sizeof(table_list)); table_list.db= schema->db; table_list.alias= table_list.table_name= schema->name; - close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); + close_cached_tables(thd, &table_list, FALSE, LONG_TIMEOUT); } /* ndb_share reference temporary free */ if (share) @@ -1990,7 +1973,6 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, } // fall through case SOT_CREATE_TABLE: - mysql_mutex_lock(&LOCK_open); if (ndbcluster_check_if_local_table(schema->db, schema->name)) { DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'", @@ -2004,7 +1986,6 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, { print_could_not_discover_error(thd, schema); } - mysql_mutex_unlock(&LOCK_open); log_query= 1; break; case SOT_DROP_DB: @@ -2095,7 +2076,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, mysql_mutex_unlock(&ndb_schema_share_mutex); /* end protect ndb_schema_share */ - close_cached_tables(NULL, NULL, FALSE, FALSE, LONG_TIMEOUT); + close_cached_tables(NULL, NULL, FALSE, LONG_TIMEOUT); // fall through case NDBEVENT::TE_ALTER: ndb_handle_schema_change(thd, ndb, pOp, tmp_share); @@ -2252,7 +2233,7 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, bzero((char*) &table_list,sizeof(table_list)); table_list.db= schema->db; table_list.alias= table_list.table_name= schema->name; - close_cached_tables(thd, &table_list, FALSE, FALSE, LONG_TIMEOUT); + close_cached_tables(thd, &table_list, FALSE, LONG_TIMEOUT); } if (schema_type != SOT_ALTER_TABLE) break; @@ -2273,7 +2254,6 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, free_share(&share); share= 0; } - mysql_mutex_lock(&LOCK_open); if (ndbcluster_check_if_local_table(schema->db, schema->name)) { DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'", @@ -2287,7 +2267,6 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, { print_could_not_discover_error(thd, schema); } - mysql_mutex_unlock(&LOCK_open); } break; default: @@ -3153,8 +3132,6 @@ ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name, #ifdef SYNC_DROP_ thd->proc_info= "Syncing ndb table schema operation and binlog"; mysql_mutex_lock(&share->mutex); - mysql_mutex_assert_owner(&LOCK_open); - mysql_mutex_unlock(&LOCK_open); int max_timeout= DEFAULT_SYNC_TIMEOUT; while (share->op) { @@ -3180,7 +3157,6 @@ ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name, type_str, share->key); } } - mysql_mutex_lock(&LOCK_open); mysql_mutex_unlock(&share->mutex); #else mysql_mutex_lock(&share->mutex); @@ -3962,9 +3938,9 @@ restart: !ndb_binlog_running)) break; /* Shutting down server */ - if (ndb_binlog_index && ndb_binlog_index->s->needs_reopen()) + if (ndb_binlog_index && ndb_binlog_index->s->has_old_version()) { - if (ndb_binlog_index->s->needs_reopen()) + if (ndb_binlog_index->s->has_old_version()) { trans_commit_stmt(thd); close_thread_tables(thd); diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h index 4d2a49588b4..5dbcf0fa43f 100644 --- a/sql/ha_ndbcluster_binlog.h +++ b/sql/ha_ndbcluster_binlog.h @@ -158,8 +158,7 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share, uint32 ndb_table_version, enum SCHEMA_OP_TYPE type, const char *new_db, - const char *new_table_name, - int have_lock_open); + const char *new_table_name); int ndbcluster_handle_drop_table(Ndb *ndb, const char *event_name, NDB_SHARE *share, const char *type_str); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index bd3cd780bc5..7891f658f45 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -64,10 +64,6 @@ #include "debug_sync.h" static const char *ha_par_ext= ".par"; -#ifdef NOT_USED -static int free_share(PARTITION_SHARE * share); -static PARTITION_SHARE *get_share(const char *table_name, TABLE * table); -#endif /**************************************************************************** MODULE create/delete handler object @@ -1129,13 +1125,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, part= i * num_subparts + j; DBUG_PRINT("info", ("Optimize subpartition %u (%s)", part, sub_elem->partition_name)); -#ifdef NOT_USED - if (print_admin_msg(thd, "note", table_share->db.str, table->alias, - opt_op_name[flag], - "Start to operate on subpartition %s", - sub_elem->partition_name)) - DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); -#endif if ((error= handle_opt_part(thd, check_opt, m_file[part], flag))) { /* print a line which partition the error belongs to */ @@ -1162,13 +1151,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, { DBUG_PRINT("info", ("Optimize partition %u (%s)", i, part_elem->partition_name)); -#ifdef NOT_USED - if (print_admin_msg(thd, "note", table_share->db.str, table->alias, - opt_op_name[flag], - "Start to operate on partition %s", - part_elem->partition_name)) - DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); -#endif if ((error= handle_opt_part(thd, check_opt, m_file[i], flag))) { /* print a line which partition the error belongs to */ diff --git a/sql/ha_partition.h b/sql/ha_partition.h index cdbfb2163c7..cfab2dde394 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -143,9 +143,6 @@ private: Variables for lock structures. */ THR_LOCK_DATA lock; /* MySQL lock */ -#ifdef NOT_USED - PARTITION_SHARE *share; /* Shared lock info */ -#endif /* TRUE <=> this object was created with ha_partition::clone and doesn't diff --git a/sql/handler.cc b/sql/handler.cc index e67f5d6862c..567dbe6ea49 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -190,15 +190,6 @@ plugin_ref ha_lock_engine(THD *thd, const handlerton *hton) } -#ifdef NOT_USED -static handler *create_default(TABLE_SHARE *table, MEM_ROOT *mem_root) -{ - handlerton *hton= ha_default_handlerton(current_thd); - return (hton && hton->create) ? hton->create(hton, table, mem_root) : NULL; -} -#endif - - handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type) { plugin_ref plugin; @@ -239,10 +230,6 @@ handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type, RUN_HOOK(transaction, after_rollback, (thd, FALSE)); switch (database_type) { -#ifndef NO_HASH - case DB_TYPE_HASH: - return ha_resolve_by_legacy_type(thd, DB_TYPE_HASH); -#endif case DB_TYPE_MRG_ISAM: return ha_resolve_by_legacy_type(thd, DB_TYPE_MRG_MYISAM); default: @@ -3683,6 +3670,34 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) DBUG_RETURN(error != 0); } + +/** + Try to find a table in a storage engine. + + @param db Normalized table schema name + @param name Normalized table name. + @param[out] exists Only valid if the function succeeded. + + @retval TRUE An error is found + @retval FALSE Success, check *exists +*/ + +bool +ha_check_if_table_exists(THD* thd, const char *db, const char *name, + bool *exists) +{ + uchar *frmblob= NULL; + size_t frmlen; + DBUG_ENTER("ha_check_if_table_exists"); + + *exists= ! ha_discover(thd, db, name, &frmblob, &frmlen); + if (*exists) + my_free(frmblob); + + DBUG_RETURN(FALSE); +} + + void st_ha_check_opt::init() { flags= sql_flags= 0; diff --git a/sql/handler.h b/sql/handler.h index 9f262542a4f..4229769290d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -33,10 +33,6 @@ #include <ft_global.h> #include <keycache.h> -#ifndef NO_HASH -#define NO_HASH /* Not yet implemented */ -#endif - // the following is for checking tables #define HA_ADMIN_ALREADY_DONE 1 @@ -2124,6 +2120,8 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat); /* discovery */ int ha_create_table_from_engine(THD* thd, const char *db, const char *name); +bool ha_check_if_table_exists(THD* thd, const char *db, const char *name, + bool *exists); int ha_discover(THD* thd, const char* dbname, const char* name, uchar** frmblob, size_t* frmlen); int ha_find_files(THD *thd,const char *db,const char *path, diff --git a/sql/hostname.cc b/sql/hostname.cc index d309efc4196..5311d9ada73 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -126,7 +126,7 @@ static void prepare_hostname_cache_key(const char *ip_string, DBUG_ASSERT(ip_string_length < HOST_ENTRY_KEY_SIZE); memset(ip_key, 0, HOST_ENTRY_KEY_SIZE); - memcpy_fixed(ip_key, ip_string, ip_string_length); + memcpy(ip_key, ip_string, ip_string_length); } static inline Host_entry *hostname_cache_search(const char *ip_key) @@ -148,7 +148,7 @@ static bool add_hostname_impl(const char *ip_key, const char *hostname) char *hostname_copy; - memcpy_fixed(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE); + memcpy(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE); if (hostname_size) { diff --git a/sql/item.cc b/sql/item.cc index 13b4aa96c76..1decb5ec426 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -301,11 +301,10 @@ my_decimal *Item::val_decimal_from_int(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value) { String *res; - char *end_ptr; + if (!(res= val_str(&str_value))) - return 0; // NULL or EOM + return NULL; - end_ptr= (char*) res->ptr()+ res->length(); if (str2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_BAD_NUM, res->ptr(), res->length(), res->charset(), decimal_value) & E_DEC_BAD_NUM) @@ -4914,11 +4913,8 @@ Item *Item_field::equal_fields_propagator(uchar *arg) e.g. <bin_col> = <int_col> AND <bin_col> = <hex_string>) since Items don't know the context they are in and there are functions like IF (<hex_string>, 'yes', 'no'). - The same problem occurs when comparing a DATE/TIME field with a - DATE/TIME represented as an int and as a string. */ - if (!item || - (cmp_context != (Item_result)-1 && item->cmp_context != cmp_context)) + if (!item || !has_compatible_context(item)) item= this; else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type())) { @@ -4982,8 +4978,7 @@ Item *Item_field::replace_equal_field(uchar *arg) Item *const_item= item_equal->get_const(); if (const_item) { - if (cmp_context != (Item_result)-1 && - const_item->cmp_context != cmp_context) + if (!has_compatible_context(const_item)) return this; return const_item; } @@ -5053,21 +5048,6 @@ enum_field_types Item::field_type() const } -bool Item::is_datetime() -{ - switch (field_type()) - { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: - return TRUE; - default: - break; - } - return FALSE; -} - - String *Item::check_well_formed_result(String *str, bool send_error) { /* Check whether we got a well-formed string */ @@ -7468,6 +7448,8 @@ bool Item_cache_datetime::cache_value_int() return FALSE; value_cached= TRUE; + // Mark cached string value obsolete + str_value_cached= FALSE; /* Assume here that the underlying item will do correct conversion.*/ int_value= example->val_int_result(); null_value= example->null_value; @@ -7480,7 +7462,13 @@ bool Item_cache_datetime::cache_value() { if (!example) return FALSE; + + if (cmp_context == INT_RESULT) + return cache_value_int(); + str_value_cached= TRUE; + // Mark cached int value obsolete + value_cached= FALSE; /* Assume here that the underlying item will do correct conversion.*/ String *res= example->str_result(&str_value); if (res && res != &str_value) @@ -7504,8 +7492,47 @@ void Item_cache_datetime::store(Item *item, longlong val_arg) String *Item_cache_datetime::val_str(String *str) { DBUG_ASSERT(fixed == 1); - if (!str_value_cached && !cache_value()) - return NULL; + if (!str_value_cached) + { + /* + When it's possible the Item_cache_datetime uses INT datetime + representation due to speed reasons. But still, it always has the STRING + result type and thus it can be asked to return a string value. + It is possible that at this time cached item doesn't contain correct + string value, thus we have to convert cached int value to string and + return it. + */ + if (value_cached) + { + MYSQL_TIME ltime; + if (str_value.alloc(MAX_DATE_STRING_REP_LENGTH)) + return NULL; + if (cached_field_type == MYSQL_TYPE_TIME) + { + ulonglong time= int_value; + DBUG_ASSERT(time <= TIME_MAX_VALUE); + set_zero_time(<ime, MYSQL_TIMESTAMP_TIME); + ltime.second= time % 100; + time/= 100; + ltime.minute= time % 100; + time/= 100; + ltime.hour= time; + } + else + { + int was_cut; + longlong res; + res= number_to_datetime(val_int(), <ime, TIME_FUZZY_DATE, &was_cut); + if (res == -1) + return NULL; + } + str_value.length(my_TIME_to_str(<ime, + const_cast<char*>(str_value.ptr()))); + str_value_cached= TRUE; + } + else if (!cache_value()) + return NULL; + } return &str_value; } diff --git a/sql/item.h b/sql/item.h index 35a0e8373f2..c7a97ca716a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1171,7 +1171,40 @@ public: representation is more precise than the string one). */ virtual bool result_as_longlong() { return FALSE; } - bool is_datetime(); + inline bool is_datetime() const + { + switch (field_type()) + { + case MYSQL_TYPE_DATE: + case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_TIMESTAMP: + return TRUE; + default: + break; + } + return FALSE; + } + /** + Check whether this and the given item has compatible comparison context. + Used by the equality propagation. See Item_field::equal_fields_propagator. + + @return + TRUE if the context is the same or if fields could be + compared as DATETIME values by the Arg_comparator. + FALSE otherwise. + */ + inline bool has_compatible_context(Item *item) const + { + /* Same context. */ + if (cmp_context == (Item_result)-1 || item->cmp_context == cmp_context) + return TRUE; + /* DATETIME comparison context. */ + if (is_datetime()) + return item->is_datetime() || item->cmp_context == STRING_RESULT; + if (item->is_datetime()) + return is_datetime() || cmp_context == STRING_RESULT; + return FALSE; + } virtual Field::geometry_type get_geometry_type() const { return Field::GEOM_GEOMETRY; }; String *check_well_formed_result(String *str, bool send_error= 0); @@ -3232,6 +3265,7 @@ public: virtual bool cache_value()= 0; bool basic_const_item() const { return test(example && example->basic_const_item());} + virtual void clear() { null_value= TRUE; value_cached= FALSE; } }; @@ -3412,6 +3446,7 @@ public: */ bool cache_value_int(); bool cache_value(); + void clear() { Item_cache::clear(); str_value_cached= FALSE; } }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d31799d7e60..85565b735d4 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -876,8 +876,10 @@ get_time_value(THD *thd, Item ***item_arg, Item **cache_arg, Do not cache GET_USER_VAR() function as its const_item() may return TRUE for the current thread but it still may change during the execution. */ - if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM || - ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) + if (item->const_item() && cache_arg && + item->type() != Item::CACHE_ITEM && + (item->type() != Item::FUNC_ITEM || + ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) { Item_cache_int *cache= new Item_cache_int(); /* Mark the cache as non-const to prevent re-caching. */ @@ -937,6 +939,7 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg, get_value_a_func= &get_datetime_value; get_value_b_func= &get_datetime_value; cmp_collation.set(&my_charset_numeric); + set_cmp_context_for_datetime(); return 0; } else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME && @@ -949,6 +952,7 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg, func= &Arg_comparator::compare_datetime; get_value_a_func= &get_time_value; get_value_b_func= &get_time_value; + set_cmp_context_for_datetime(); return 0; } else if (type == STRING_RESULT && @@ -1005,6 +1009,7 @@ bool Arg_comparator::try_year_cmp_func(Item_result type) is_nulls_eq= is_owner_equal_func(); func= &Arg_comparator::compare_datetime; + set_cmp_context_for_datetime(); return TRUE; } @@ -1058,6 +1063,7 @@ void Arg_comparator::set_datetime_cmp_func(Item_result_field *owner_arg, func= &Arg_comparator::compare_datetime; get_value_a_func= &get_datetime_value; get_value_b_func= &get_datetime_value; + set_cmp_context_for_datetime(); } @@ -1144,8 +1150,10 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, Do not cache GET_USER_VAR() function as its const_item() may return TRUE for the current thread but it still may change during the execution. */ - if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM || - ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) + if (item->const_item() && cache_arg && + item->type() != Item::CACHE_ITEM && + (item->type() != Item::FUNC_ITEM || + ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) { Item_cache_int *cache= new Item_cache_int(MYSQL_TYPE_DATETIME); /* Mark the cache as non-const to prevent re-caching. */ @@ -4712,8 +4720,6 @@ void Item_func_like::cleanup() Item_bool_func2::cleanup(); } -#ifdef USE_REGEX - /** @brief Compile regular expression. @@ -4865,9 +4871,6 @@ void Item_func_regex::cleanup() } -#endif /* USE_REGEX */ - - #ifdef LIKE_CMP_TOUPPER #define likeconv(cs,A) (uchar) (cs)->toupper(A) #else diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 8813324262c..f9851011563 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -25,6 +25,7 @@ #include "thr_malloc.h" /* sql_calloc */ #include "item_func.h" /* Item_int_func, Item_bool_func */ +#include "my_regex.h" extern Item_result item_cmp_type(Item_result a,Item_result b); class Item_bool_func2; @@ -123,7 +124,17 @@ public: delete [] comparators; comparators= 0; } - + /* + Set correct cmp_context if items would be compared as INTs. + */ + inline void set_cmp_context_for_datetime() + { + DBUG_ASSERT(func == &Arg_comparator::compare_datetime); + if ((*a)->result_as_longlong()) + (*a)->cmp_context= INT_RESULT; + if ((*b)->result_as_longlong()) + (*b)->cmp_context= INT_RESULT; + } friend class Item_func; }; @@ -258,7 +269,7 @@ protected: my_bool result_for_null_param; public: Item_in_optimizer(Item *a, Item_in_subselect *b): - Item_bool_func(a, my_reinterpret_cast(Item *)(b)), cache(0), + Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0), save_cache(0), result_for_null_param(UNKNOWN) {} bool fix_fields(THD *, Item **); @@ -1424,9 +1435,6 @@ public: void cleanup(); }; -#ifdef USE_REGEX - -#include "my_regex.h" class Item_func_regex :public Item_bool_func { @@ -1455,23 +1463,6 @@ public: CHARSET_INFO *compare_collation() { return cmp_collation.collation; } }; -#else - -class Item_func_regex :public Item_bool_func -{ -public: - Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b) {} - longlong val_int() { return 0;} - const char *func_name() const { return "regex"; } - - virtual inline void print(String *str, enum_query_type query_type) - { - print_op(str, query_type); - } -}; - -#endif /* USE_REGEX */ - typedef class Item COND; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index e046087b16a..d734b55a970 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -49,7 +49,7 @@ void Item_geometry_func::fix_length_and_dec() { collation.set(&my_charset_bin); decimals=0; - max_length= max_field_size; + max_length= (uint32) 4294967295U; maybe_null= 1; } diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 34b09ca6fdc..d8d18fd8ef6 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -184,7 +184,7 @@ public: void fix_length_and_dec(); uint cols(); - Item* element_index(uint i) { return my_reinterpret_cast(Item*)(row[i]); } + Item* element_index(uint i) { return reinterpret_cast<Item*>(row[i]); } Item** addr(uint i) { return (Item**)row + i; } bool check_cols(uint c); bool null_inside(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 77c45ea85f7..b05d845dead 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1214,8 +1214,7 @@ void Item_sum_hybrid::setup_hybrid(Item *item, Item *value_arg) { value= Item_cache::get_cache(item); value->setup(item); - if (value_arg) - value->store(value_arg); + value->store(value_arg); cmp= new Arg_comparator(); cmp->set_cmp_func(this, args, (Item**)&value, FALSE); collation.set(item->collation); @@ -1903,7 +1902,7 @@ void Item_sum_variance::update_field() void Item_sum_hybrid::clear() { - value->null_value= 1; + value->clear(); null_value= 1; } diff --git a/sql/item_sum.h b/sql/item_sum.h index b4539995632..2a722b93165 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1010,6 +1010,11 @@ protected: void no_rows_in_result(); Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length); + /* + MIN/MAX uses Item_cache_datetime for storing DATETIME values, thus + in this case a correct INT value can be provided. + */ + bool result_as_longlong() { return args[0]->result_as_longlong(); } }; diff --git a/sql/lock.cc b/sql/lock.cc index 24566a04463..0181a544824 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -313,7 +313,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags) rc= thr_lock_errno_to_mysql[(int) thr_multi_lock(sql_lock->locks + sql_lock->lock_count, sql_lock->lock_count, - thd->lock_id, timeout)]; + &thd->lock_info, timeout)]; if (rc) { if (sql_lock->table_count) diff --git a/sql/log.cc b/sql/log.cc index 6eab16bc3a4..1e4682e4bc3 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5447,6 +5447,22 @@ void sql_perror(const char *message) } +/* + Unfortunately, there seems to be no good way + to restore the original streams upon failure. +*/ +static bool redirect_std_streams(const char *file) +{ + if (freopen(file, "a+", stdout) && freopen(file, "a+", stderr)) + { + setbuf(stderr, NULL); + return FALSE; + } + + return TRUE; +} + + bool flush_error_log() { bool result=0; @@ -5474,11 +5490,7 @@ bool flush_error_log() setbuf(stderr, NULL); my_delete(err_renamed, MYF(0)); my_rename(log_error_file, err_renamed, MYF(0)); - if (freopen(log_error_file,"a+",stdout)) - { - freopen(log_error_file,"a+",stderr); - setbuf(stderr, NULL); - } + redirect_std_streams(log_error_file); if ((fd= my_open(err_temp, O_RDONLY, MYF(0))) >= 0) { @@ -5493,13 +5505,7 @@ bool flush_error_log() result= 1; #else my_rename(log_error_file, err_renamed, MYF(0)); - if (freopen(log_error_file,"a+",stdout)) - { - FILE *reopen; - reopen= freopen(log_error_file,"a+",stderr); - setbuf(stderr, NULL); - } - else + if (redirect_std_streams(log_error_file)) result= 1; #endif mysql_mutex_unlock(&LOCK_error_log); @@ -5551,25 +5557,9 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, #endif /* _WIN32 */ -/** - Prints a printf style message to the error log and, under NT, to the - Windows event log. - - This function prints the message into a buffer and then sends that buffer - to other functions to write that message to other logging sources. - - @param event_type Type of event to write (Error, Warning, or Info) - @param format Printf style format of message - @param args va_list list of arguments for the message - - @returns - The function always returns 0. The return value is present in the - signature to be compatible with other logging routines, which could - return an error (e.g. logging to the log tables) -*/ - #ifndef EMBEDDED_LIBRARY -static void print_buffer_to_file(enum loglevel level, const char *buffer) +static void print_buffer_to_file(enum loglevel level, const char *buffer, + size_t length) { time_t skr; struct tm tm_tmp; @@ -5583,7 +5573,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) localtime_r(&skr, &tm_tmp); start=&tm_tmp; - fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", + fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %.*s\n", start->tm_year % 100, start->tm_mon+1, start->tm_mday, @@ -5592,7 +5582,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) start->tm_sec, (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "Warning" : "Note"), - buffer); + (int) length, buffer); fflush(stderr); @@ -5600,7 +5590,22 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) DBUG_VOID_RETURN; } +/** + Prints a printf style message to the error log and, under NT, to the + Windows event log. + This function prints the message into a buffer and then sends that buffer + to other functions to write that message to other logging sources. + + @param level The level of the msg significance + @param format Printf style format of message + @param args va_list list of arguments for the message + + @returns + The function always returns 0. The return value is present in the + signature to be compatible with other logging routines, which could + return an error (e.g. logging to the log tables) +*/ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; @@ -5608,7 +5613,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) DBUG_ENTER("vprint_msg_to_log"); length= my_vsnprintf(buff, sizeof(buff), format, args); - print_buffer_to_file(level, buff); + print_buffer_to_file(level, buff, length); #ifdef _WIN32 print_buffer_to_nt_eventlog(level, buff, length, sizeof(buff)); @@ -5616,7 +5621,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) DBUG_RETURN(0); } -#endif /*EMBEDDED_LIBRARY*/ +#endif /* EMBEDDED_LIBRARY */ void sql_print_error(const char *format, ...) diff --git a/sql/log.h b/sql/log.h index 4a58c3081d8..6e87b6cbade 100644 --- a/sql/log.h +++ b/sql/log.h @@ -637,7 +637,6 @@ enum enum_binlog_format { BINLOG_FORMAT_ROW= 2, ///< row-based BINLOG_FORMAT_UNSPEC=3 ///< thd_binlog_format() returns it when binlog is closed }; -extern TYPELIB binlog_format_typelib; int query_error_code(THD *thd, bool not_killed); uint purge_log_get_error_code(int res); diff --git a/sql/log_event.cc b/sql/log_event.cc index 8f70282ce79..ea7f4b4b245 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -3714,6 +3714,7 @@ bool Start_log_event_v3::write(IO_CACHE* file) int Start_log_event_v3::do_apply_event(Relay_log_info const *rli) { DBUG_ENTER("Start_log_event_v3::do_apply_event"); + int error= 0; switch (binlog_version) { case 3: @@ -3726,7 +3727,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli) */ if (created) { - close_temporary_tables(thd); + error= close_temporary_tables(thd); cleanup_load_tmpdir(); } else @@ -3754,7 +3755,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli) Can distinguish, based on the value of 'created': this event was generated at master startup. */ - close_temporary_tables(thd); + error= close_temporary_tables(thd); } /* Otherwise, can't distinguish a Start_log_event generated at @@ -3766,7 +3767,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli) /* this case is impossible */ DBUG_RETURN(1); } - DBUG_RETURN(0); + DBUG_RETURN(error); } #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ diff --git a/sql/mdl.cc b/sql/mdl.cc index 61a43c83409..d53ddcee0c8 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -71,6 +71,21 @@ static void init_mdl_psi_keys(void) void notify_shared_lock(THD *thd, MDL_ticket *conflicting_ticket); +/** + Thread state names to be used in case when we have to wait on resource + belonging to certain namespace. +*/ + +const char *MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]= +{ + "Waiting for global metadata lock", + "Waiting for schema metadata lock", + "Waiting for table metadata lock", + "Waiting for stored function metadata lock", + "Waiting for stored procedure metadata lock", + NULL +}; + static bool mdl_initialized= 0; @@ -99,33 +114,102 @@ private: /** + A context of the recursive traversal through all contexts + in all sessions in search for deadlock. +*/ + +class Deadlock_detection_visitor: public MDL_wait_for_graph_visitor +{ +public: + Deadlock_detection_visitor(MDL_context *start_node_arg) + : m_start_node(start_node_arg), + m_victim(NULL), + m_current_search_depth(0), + m_found_deadlock(FALSE) + {} + virtual bool enter_node(MDL_context *node); + virtual void leave_node(MDL_context *node); + + virtual bool inspect_edge(MDL_context *dest); + + MDL_context *get_victim() const { return m_victim; } +private: + /** + Change the deadlock victim to a new one if it has lower deadlock + weight. + */ + void opt_change_victim_to(MDL_context *new_victim); +private: + /** + The context which has initiated the search. There + can be multiple searches happening in parallel at the same time. + */ + MDL_context *m_start_node; + /** If a deadlock is found, the context that identifies the victim. */ + MDL_context *m_victim; + /** Set to the 0 at start. Increased whenever + we descend into another MDL context (aka traverse to the next + wait-for graph node). When MAX_SEARCH_DEPTH is reached, we + assume that a deadlock is found, even if we have not found a + loop. + */ + uint m_current_search_depth; + /** TRUE if we found a deadlock. */ + bool m_found_deadlock; + /** + Maximum depth for deadlock searches. After this depth is + achieved we will unconditionally declare that there is a + deadlock. + + @note This depth should be small enough to avoid stack + being exhausted by recursive search algorithm. + + TODO: Find out what is the optimal value for this parameter. + Current value is safe, but probably sub-optimal, + as there is an anecdotal evidence that real-life + deadlocks are even shorter typically. + */ + static const uint MAX_SEARCH_DEPTH= 32; +}; + + +/** Enter a node of a wait-for graph. After a node is entered, inspect_edge() will be called for all wait-for destinations of this node. Then leave_node() will be called. - We call "enter_node()" for all nodes we inspect, + We call "enter_node()" for all nodes we inspect, including the starting node. @retval TRUE Maximum search depth exceeded. @retval FALSE OK. */ -bool Deadlock_detection_visitor::enter_node(MDL_context * /* unused */) +bool Deadlock_detection_visitor::enter_node(MDL_context *node) { - if (++m_current_search_depth >= MAX_SEARCH_DEPTH) - return TRUE; - return FALSE; + m_found_deadlock= ++m_current_search_depth >= MAX_SEARCH_DEPTH; + if (m_found_deadlock) + { + DBUG_ASSERT(! m_victim); + opt_change_victim_to(node); + } + return m_found_deadlock; } /** Done inspecting this node. Decrease the search - depth. Clear the node for debug safety. + depth. If a deadlock is found, and we are + backtracking to the start node, optionally + change the deadlock victim to one with lower + deadlock weight. */ -void Deadlock_detection_visitor::leave_node(MDL_context * /* unused */) +void Deadlock_detection_visitor::leave_node(MDL_context *node) { --m_current_search_depth; + if (m_found_deadlock) + opt_change_victim_to(node); } @@ -138,7 +222,8 @@ void Deadlock_detection_visitor::leave_node(MDL_context * /* unused */) bool Deadlock_detection_visitor::inspect_edge(MDL_context *node) { - return node == m_start_node; + m_found_deadlock= node == m_start_node; + return m_found_deadlock; } @@ -150,7 +235,7 @@ bool Deadlock_detection_visitor::inspect_edge(MDL_context *node) @retval !new_victim New victim became the current. */ -MDL_context * +void Deadlock_detection_visitor::opt_change_victim_to(MDL_context *new_victim) { if (m_victim == NULL || @@ -159,10 +244,10 @@ Deadlock_detection_visitor::opt_change_victim_to(MDL_context *new_victim) /* Swap victims, unlock the old one. */ MDL_context *tmp= m_victim; m_victim= new_victim; - return tmp; + m_victim->lock_deadlock_victim(); + if (tmp) + tmp->unlock_deadlock_victim(); } - /* No change, unlock the current context. */ - return new_victim; } @@ -285,8 +370,8 @@ public: void remove_ticket(Ticket_list MDL_lock::*queue, MDL_ticket *ticket); - bool find_deadlock(MDL_ticket *waiting_ticket, - Deadlock_detection_visitor *dvisitor); + bool visit_subgraph(MDL_ticket *waiting_ticket, + MDL_wait_for_graph_visitor *gvisitor); /** List of granted tickets for this lock. */ Ticket_list m_granted; @@ -415,14 +500,6 @@ mdl_locks_key(const uchar *record, size_t *length, the associated condition variable: LOCK_mdl and COND_mdl. These locking primitives are implementation details of the MDL subsystem and are private to it. - - Note, that even though the new implementation adds acquisition - of a new global mutex to the execution flow of almost every SQL - statement, the design capitalizes on that to later save on - look ups in the table definition cache. This leads to reduced - contention overall and on LOCK_open in particular. - Please see the description of MDL_context::acquire_lock() - for details. */ void mdl_init() @@ -813,7 +890,7 @@ uint MDL_ticket::get_deadlock_weight() const { return (m_lock->key.mdl_namespace() == MDL_key::GLOBAL || m_type >= MDL_SHARED_NO_WRITE ? - MDL_DEADLOCK_WEIGHT_DDL : MDL_DEADLOCK_WEIGHT_DML); + DEADLOCK_WEIGHT_DDL : DEADLOCK_WEIGHT_DML); } @@ -882,17 +959,18 @@ void MDL_wait::reset_status() Wait for the status to be assigned to this wait slot. @param abs_timeout Absolute time after which waiting should stop. - @param set_status_on_tiemout TRUE - If in case of timeout waiting - context should close the wait slot by - sending TIMEOUT to itself. - FALSE - Otherwise. + @param set_status_on_timeout TRUE - If in case of timeout waiting + context should close the wait slot by + sending TIMEOUT to itself. + FALSE - Otherwise. + @param wait_state_name Thread state name to be set for duration of wait. @returns Signal posted. */ MDL_wait::enum_wait_status MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout, - bool set_status_on_timeout) + bool set_status_on_timeout, const char *wait_state_name) { const char *old_msg; enum_wait_status result; @@ -901,7 +979,7 @@ MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout, mysql_mutex_lock(&m_LOCK_wait_status); old_msg= thd_enter_cond(thd, &m_COND_wait_status, &m_LOCK_wait_status, - "Waiting for table"); + wait_state_name); while (!m_wait_status && !thd_killed(thd) && wait_result != ETIMEDOUT && wait_result != ETIME) @@ -1316,6 +1394,15 @@ bool MDL_lock::has_pending_conflicting_lock(enum_mdl_type type) } +MDL_wait_for_graph_visitor::~MDL_wait_for_graph_visitor() +{ +} + + +MDL_wait_for_subgraph::~MDL_wait_for_subgraph() +{ +} + /** Check if ticket represents metadata lock of "stronger" or equal type than specified one. I.e. if metadata lock represented by ticket won't @@ -1681,7 +1768,8 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout) while (cmp_timespec(abs_shortwait, abs_timeout) <= 0) { /* abs_timeout is far away. Wait a short while and notify locks. */ - wait_status= m_wait.timed_wait(m_thd, &abs_shortwait, FALSE); + wait_status= m_wait.timed_wait(m_thd, &abs_shortwait, FALSE, + mdl_request->key.get_wait_state_name()); if (wait_status != MDL_wait::EMPTY) break; @@ -1692,10 +1780,12 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout) set_timespec(abs_shortwait, 1); } if (wait_status == MDL_wait::EMPTY) - wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE); + wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE, + mdl_request->key.get_wait_state_name()); } else - wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE); + wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE, + mdl_request->key.get_wait_state_name()); done_waiting_for(); @@ -1887,8 +1977,17 @@ MDL_context::upgrade_shared_lock_to_exclusive(MDL_ticket *mdl_ticket, } -bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, - Deadlock_detection_visitor *dvisitor) +/** + A fragment of recursive traversal of the wait-for graph + in search for deadlocks. Direct the deadlock visitor to all + contexts that own the lock the current node in the wait-for + graph is waiting for. + As long as the initial node is remembered in the visitor, + a deadlock is found when the same node is seen twice. +*/ + +bool MDL_lock::visit_subgraph(MDL_ticket *waiting_ticket, + MDL_wait_for_graph_visitor *gvisitor) { MDL_ticket *ticket; MDL_context *src_ctx= waiting_ticket->get_ctx(); @@ -1957,7 +2056,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, are visiting it but this is OK: in the worst case we might do some extra work and one more context might be chosen as a victim. */ - if (dvisitor->enter_node(src_ctx)) + if (gvisitor->enter_node(src_ctx)) goto end; /* @@ -1971,7 +2070,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, /* Filter out edges that point to the same node. */ if (ticket->get_ctx() != src_ctx && ticket->is_incompatible_when_granted(waiting_ticket->get_type()) && - dvisitor->inspect_edge(ticket->get_ctx())) + gvisitor->inspect_edge(ticket->get_ctx())) { goto end_leave_node; } @@ -1982,7 +2081,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, /* Filter out edges that point to the same node. */ if (ticket->get_ctx() != src_ctx && ticket->is_incompatible_when_waiting(waiting_ticket->get_type()) && - dvisitor->inspect_edge(ticket->get_ctx())) + gvisitor->inspect_edge(ticket->get_ctx())) { goto end_leave_node; } @@ -1994,7 +2093,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, { if (ticket->get_ctx() != src_ctx && ticket->is_incompatible_when_granted(waiting_ticket->get_type()) && - ticket->get_ctx()->find_deadlock(dvisitor)) + ticket->get_ctx()->visit_subgraph(gvisitor)) { goto end_leave_node; } @@ -2005,7 +2104,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, { if (ticket->get_ctx() != src_ctx && ticket->is_incompatible_when_waiting(waiting_ticket->get_type()) && - ticket->get_ctx()->find_deadlock(dvisitor)) + ticket->get_ctx()->visit_subgraph(gvisitor)) { goto end_leave_node; } @@ -2014,7 +2113,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, result= FALSE; end_leave_node: - dvisitor->leave_node(src_ctx); + gvisitor->leave_node(src_ctx); end: mysql_prlock_unlock(&m_rwlock); @@ -2023,50 +2122,47 @@ end: /** - Traverse portion of wait-for graph which is reachable through edge - represented by this ticket in search for deadlocks. + Traverse a portion of wait-for graph which is reachable + through the edge represented by this ticket and search + for deadlocks. - @retval TRUE A deadlock is found. A victim is remembered - by the visitor. + @retval TRUE A deadlock is found. A pointer to deadlock + victim is saved in the visitor. @retval FALSE */ -bool MDL_ticket::find_deadlock(Deadlock_detection_visitor *dvisitor) +bool MDL_ticket::accept_visitor(MDL_wait_for_graph_visitor *gvisitor) { - return m_lock->find_deadlock(this, dvisitor); + return m_lock->visit_subgraph(this, gvisitor); } /** - Recursively traverse the wait-for graph of MDL contexts - in search for deadlocks. + A fragment of recursive traversal of the wait-for graph of + MDL contexts in the server in search for deadlocks. + Assume this MDL context is a node in the wait-for graph, + and direct the visitor to all adjacent nodes. As long + as the starting node is remembered in the visitor, a + deadlock is found when the same node is visited twice. + One MDL context is connected to another in the wait-for + graph if it waits on a resource that is held by the other + context. - @retval TRUE A deadlock is found. A victim is remembered - by the visitor. + @retval TRUE A deadlock is found. A pointer to deadlock + victim is saved in the visitor. @retval FALSE */ -bool MDL_context::find_deadlock(Deadlock_detection_visitor *dvisitor) +bool MDL_context::visit_subgraph(MDL_wait_for_graph_visitor *gvisitor) { - MDL_context *m_unlock_ctx= this; bool result= FALSE; mysql_prlock_rdlock(&m_LOCK_waiting_for); if (m_waiting_for) - { - result= m_waiting_for->find_deadlock(dvisitor); - if (result) - m_unlock_ctx= dvisitor->opt_change_victim_to(this); - } - /* - We may recurse into the same MDL_context more than once - in case this is not the starting node. Make sure we release the - read lock as it's been taken, except for 1 read lock for - the deadlock victim. - */ - if (m_unlock_ctx) - mysql_prlock_unlock(&m_unlock_ctx->m_LOCK_waiting_for); + result= m_waiting_for->accept_visitor(gvisitor); + + mysql_prlock_unlock(&m_LOCK_waiting_for); return result; } @@ -2088,14 +2184,14 @@ void MDL_context::find_deadlock() while (1) { /* - The fact that we use fresh instance of dvisitor for each + The fact that we use fresh instance of gvisitor for each search performed by find_deadlock() below is important, the code responsible for victim selection relies on this. */ Deadlock_detection_visitor dvisitor(this); MDL_context *victim; - if (! find_deadlock(&dvisitor)) + if (! visit_subgraph(&dvisitor)) { /* No deadlocks are found! */ break; @@ -2116,7 +2212,7 @@ void MDL_context::find_deadlock() context was waiting is concurrently satisfied. */ (void) victim->m_wait.set_status(MDL_wait::VICTIM); - mysql_prlock_unlock(&victim->m_LOCK_waiting_for); + victim->unlock_deadlock_victim(); if (victim == this) break; diff --git a/sql/mdl.h b/sql/mdl.h index d7fbb14a140..7938d833eac 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -183,7 +183,9 @@ public: TABLE, FUNCTION, PROCEDURE, - TRIGGER }; + TRIGGER, + /* This should be the last ! */ + NAMESPACE_END }; const uchar *ptr() const { return (uchar*) m_ptr; } uint length() const { return m_length; } @@ -250,10 +252,20 @@ public: } MDL_key() {} /* To use when part of MDL_request. */ + /** + Get thread state name to be used in case when we have to + wait on resource identified by key. + */ + const char * get_wait_state_name() const + { + return m_namespace_to_wait_state_name[(int)mdl_namespace()]; + } + private: uint16 m_length; uint16 m_db_name_length; char m_ptr[MAX_MDLKEY_LENGTH]; + static const char * m_namespace_to_wait_state_name[NAMESPACE_END]; private: MDL_key(const MDL_key &); /* not implemented */ MDL_key &operator=(const MDL_key &); /* not implemented */ @@ -360,91 +372,54 @@ public: typedef void (*mdl_cached_object_release_hook)(void *); -enum enum_deadlock_weight -{ - MDL_DEADLOCK_WEIGHT_DML= 0, - MDL_DEADLOCK_WEIGHT_DDL= 100 -}; - - /** - A context of the recursive traversal through all contexts - in all sessions in search for deadlock. + An abstract class for inspection of a connected + subgraph of the wait-for graph. */ -class Deadlock_detection_visitor +class MDL_wait_for_graph_visitor { public: - Deadlock_detection_visitor(MDL_context *start_node_arg) - : m_start_node(start_node_arg), - m_victim(NULL), - m_current_search_depth(0), - m_table_shares_visited(0) - {} - bool enter_node(MDL_context * /* unused */); - void leave_node(MDL_context * /* unused */); - - bool inspect_edge(MDL_context *dest); - - MDL_context *get_victim() const { return m_victim; } - - /** - Change the deadlock victim to a new one if it has lower deadlock - weight. - */ - MDL_context *opt_change_victim_to(MDL_context *new_victim); -private: - /** - The context which has initiated the search. There - can be multiple searches happening in parallel at the same time. - */ - MDL_context *m_start_node; - /** If a deadlock is found, the context that identifies the victim. */ - MDL_context *m_victim; - /** Set to the 0 at start. Increased whenever - we descend into another MDL context (aka traverse to the next - wait-for graph node). When MAX_SEARCH_DEPTH is reached, we - assume that a deadlock is found, even if we have not found a - loop. - */ - uint m_current_search_depth; - /** - Maximum depth for deadlock searches. After this depth is - achieved we will unconditionally declare that there is a - deadlock. - - @note This depth should be small enough to avoid stack - being exhausted by recursive search algorithm. - - TODO: Find out what is the optimal value for this parameter. - Current value is safe, but probably sub-optimal, - as there is an anecdotal evidence that real-life - deadlocks are even shorter typically. - */ - static const uint MAX_SEARCH_DEPTH= 32; + virtual bool enter_node(MDL_context *node) = 0; + virtual void leave_node(MDL_context *node) = 0; + virtual bool inspect_edge(MDL_context *dest) = 0; + virtual ~MDL_wait_for_graph_visitor(); + MDL_wait_for_graph_visitor() :m_lock_open_count(0) {} public: /** - Number of TABLE_SHARE objects visited by deadlock detector so far. - Used by TABLE_SHARE::find_deadlock() method to implement recursive - locking for LOCK_open mutex. + XXX, hack: During deadlock search, we may need to + inspect TABLE_SHAREs and acquire LOCK_open. Since + LOCK_open is not a recursive mutex, count here how many + times we "took" it (but only take and release once). + Not using a native recursive mutex or rwlock in 5.5 for + LOCK_open since it has significant performance impacts. */ - uint m_table_shares_visited; + uint m_lock_open_count; }; - /** - Abstract class representing edge in waiters graph to be - traversed by deadlock detection algorithm. + Abstract class representing an edge in the waiters graph + to be traversed by deadlock detection algorithm. */ -class Wait_for_edge +class MDL_wait_for_subgraph { public: - virtual ~Wait_for_edge() {}; + virtual ~MDL_wait_for_subgraph(); - virtual bool find_deadlock(Deadlock_detection_visitor *dvisitor) = 0; + /** + Accept a wait-for graph visitor to inspect the node + this edge is leading to. + */ + virtual bool accept_visitor(MDL_wait_for_graph_visitor *gvisitor) = 0; + enum enum_deadlock_weight + { + DEADLOCK_WEIGHT_DML= 0, + DEADLOCK_WEIGHT_DDL= 100 + }; + /* A helper used to determine which lock request should be aborted. */ virtual uint get_deadlock_weight() const = 0; }; @@ -469,7 +444,7 @@ public: threads/contexts. */ -class MDL_ticket : public Wait_for_edge +class MDL_ticket : public MDL_wait_for_subgraph { public: /** @@ -503,9 +478,9 @@ public: bool is_incompatible_when_granted(enum_mdl_type type) const; bool is_incompatible_when_waiting(enum_mdl_type type) const; - bool find_deadlock(Deadlock_detection_visitor *dvisitor); - /* A helper used to determine which lock request should be aborted. */ - uint get_deadlock_weight() const; + /** Implement MDL_wait_for_subgraph interface. */ + virtual bool accept_visitor(MDL_wait_for_graph_visitor *dvisitor); + virtual uint get_deadlock_weight() const; private: friend class MDL_context; @@ -552,7 +527,7 @@ public: enum_wait_status get_status(); void reset_status(); enum_wait_status timed_wait(THD *thd, struct timespec *abs_timeout, - bool signal_timeout); + bool signal_timeout, const char *wait_state_name); private: /** Condvar which is used for waiting until this context's pending @@ -672,8 +647,6 @@ public: { return m_needs_thr_lock_abort; } - - bool find_deadlock(Deadlock_detection_visitor *dvisitor); public: /** If our request for a lock is scheduled, or aborted by the deadlock @@ -765,12 +738,13 @@ private: */ mysql_prlock_t m_LOCK_waiting_for; /** - Tell the deadlock detector what lock this session is waiting for. + Tell the deadlock detector what metadata lock or table + definition cache entry this session is waiting for. In principle, this is redundant, as information can be found by inspecting waiting queues, but we'd very much like it to be readily available to the wait-for graph iterator. */ - Wait_for_edge *m_waiting_for; + MDL_wait_for_subgraph *m_waiting_for; private: MDL_ticket *find_ticket(MDL_request *mdl_req, bool *is_transactional); @@ -781,11 +755,13 @@ private: public: void find_deadlock(); + bool visit_subgraph(MDL_wait_for_graph_visitor *dvisitor); + /** Inform the deadlock detector there is an edge in the wait-for graph. */ - void will_wait_for(Wait_for_edge *pending_ticket) + void will_wait_for(MDL_wait_for_subgraph *waiting_for_arg) { mysql_prlock_wrlock(&m_LOCK_waiting_for); - m_waiting_for= pending_ticket; + m_waiting_for= waiting_for_arg; mysql_prlock_unlock(&m_LOCK_waiting_for); } @@ -796,6 +772,14 @@ public: m_waiting_for= NULL; mysql_prlock_unlock(&m_LOCK_waiting_for); } + void lock_deadlock_victim() + { + mysql_prlock_rdlock(&m_LOCK_waiting_for); + } + void unlock_deadlock_victim() + { + mysql_prlock_unlock(&m_LOCK_waiting_for); + } private: MDL_context(const MDL_context &rhs); /* not implemented */ MDL_context &operator=(MDL_context &rhs); /* not implemented */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2b4547a299c..278d1688c21 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -183,7 +183,7 @@ typedef fp_except fp_except_t; # define fpu_control_t unsigned int # define _FPU_EXTENDED 0x300 # define _FPU_DOUBLE 0x200 -# if defined(__GNUC__) || defined(__SUNPRO_CC) +# if defined(__GNUC__) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590) # define _FPU_GETCW(cw) asm volatile ("fnstcw %0" : "=m" (*&cw)) # define _FPU_SETCW(cw) asm volatile ("fldcw %0" : : "m" (*&cw)) # else @@ -294,12 +294,6 @@ arg_cmp_func Arg_comparator::comparator_matrix[5][2] = {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}, {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}}; -const char *log_output_names[] = { "NONE", "FILE", "TABLE", NullS}; -static const unsigned int log_output_names_len[]= { 4, 4, 5, 0 }; -TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"", - log_output_names, - (unsigned int *) log_output_names_len}; - /* static variables */ #ifdef HAVE_PSI_INTERFACE @@ -395,8 +389,8 @@ my_bool opt_skip_slave_start = 0; ///< If set, slave is not autostarted my_bool opt_reckless_slave = 0; my_bool opt_enable_named_pipe= 0; my_bool opt_local_infile, opt_slave_compressed_protocol; -my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; -my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; +my_bool opt_safe_user_create = 0; +my_bool opt_show_slave_auth_info; my_bool opt_log_slave_updates= 0; char *opt_slave_skip_errors; @@ -440,9 +434,6 @@ my_bool sp_automatic_privileges= 1; ulong opt_binlog_rows_event_max_size; const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS}; -TYPELIB binlog_format_typelib= - { array_elements(binlog_format_names) - 1, "", - binlog_format_names, NULL }; #ifdef HAVE_INITGROUPS static bool calling_initgroups= FALSE; /**< Used in SIGSEGV handler. */ #endif @@ -458,7 +449,7 @@ ulong thread_created; ulong back_log, connect_timeout, concurrency, server_id; ulong table_cache_size, table_def_size; ulong what_to_log; -ulong query_buff_size, slow_launch_time, slave_open_temp_tables; +ulong slow_launch_time, slave_open_temp_tables; ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong slave_trans_retries; uint slave_net_timeout; @@ -547,7 +538,6 @@ char mysql_real_data_home[FN_REFLEN], mysql_charsets_dir[FN_REFLEN], *opt_init_file, *opt_tc_log_file; char *lc_messages_dir_ptr, *log_error_file_ptr; -char err_shared_dir[FN_REFLEN]; char mysql_unpacked_real_data_home[FN_REFLEN]; int mysql_unpacked_real_data_home_len; uint mysql_real_data_home_len, mysql_data_home_len= 1; @@ -581,7 +571,6 @@ Le_creator le_creator; MYSQL_FILE *bootstrap_file; int bootstrap_error; -FILE *stderror_file=0; I_List<THD> threads; Rpl_filter* rpl_filter; @@ -612,8 +601,8 @@ SHOW_COMP_OPTION have_profiling; pthread_key(MEM_ROOT**,THR_MALLOC); pthread_key(THD*, THR_THD); mysql_mutex_t LOCK_thread_count; -mysql_mutex_t LOCK_open, - LOCK_mapped_file, LOCK_status, LOCK_global_read_lock, +mysql_mutex_t + LOCK_status, LOCK_global_read_lock, LOCK_error_log, LOCK_uuid_generator, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, @@ -1476,9 +1465,7 @@ void clean_up(bool print_message) delete rpl_filter; end_ssl(); vio_end(); -#ifdef USE_REGEX my_regex_end(); -#endif #if defined(ENABLED_DEBUG_SYNC) /* End the debug sync facility. See debug_sync.cc. */ debug_sync_end(); @@ -1539,9 +1526,7 @@ static void wait_for_signal_thread_to_end() static void clean_up_mutexes() { mysql_rwlock_destroy(&LOCK_grant); - mysql_mutex_destroy(&LOCK_open); mysql_mutex_destroy(&LOCK_thread_count); - mysql_mutex_destroy(&LOCK_mapped_file); mysql_mutex_destroy(&LOCK_status); mysql_mutex_destroy(&LOCK_delayed_insert); mysql_mutex_destroy(&LOCK_delayed_status); @@ -1941,7 +1926,7 @@ static void network_init(void) (void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg, sizeof(arg)); umask(0); - if (bind(unix_sock, my_reinterpret_cast(struct sockaddr *) (&UNIXaddr), + if (bind(unix_sock, reinterpret_cast<struct sockaddr *>(&UNIXaddr), sizeof(UNIXaddr)) < 0) { sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */ @@ -3352,9 +3337,7 @@ static int init_common_variables() if (item_create_init()) return 1; item_init(); -#ifdef USE_REGEX my_regex_init(&my_charset_latin1); -#endif /* Process a comma-separated character set list and choose the first available character set. This is mostly for @@ -3515,9 +3498,7 @@ You should consider changing lower_case_table_names to 1 or 2", static int init_thread_environment() { - mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_LOCK_mapped_file, &LOCK_mapped_file, MY_MUTEX_INIT_SLOW); mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_delayed_insert, &LOCK_delayed_insert, MY_MUTEX_INIT_FAST); @@ -3713,7 +3694,6 @@ static void end_ssl() static int init_server_components() { - FILE *reopen; DBUG_ENTER("init_server_components"); /* We need to call each of these following functions to ensure that @@ -3761,8 +3741,8 @@ static int init_server_components() if (freopen(log_error_file, "a+", stdout)) #endif { - reopen= freopen(log_error_file, "a+", stderr); - setbuf(stderr, NULL); + if (freopen(log_error_file, "a+", stderr)) + setbuf(stderr, NULL); } } } @@ -6977,7 +6957,7 @@ mysqld_get_one_option(int optid, *val= 0; val+= 2; while (*val && my_isspace(mysqld_charset, *val)) - *val++; + val++; if (!*val) { sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db!\n"); @@ -7695,8 +7675,8 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables, - key_LOCK_manager, key_LOCK_mapped_file, - key_LOCK_open, key_LOCK_prepared_stmt_count, + key_LOCK_manager, + key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status, key_LOCK_system_variables_hash, key_LOCK_table_share, key_LOCK_thd_data, key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log, @@ -7735,8 +7715,6 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_global_read_lock, "LOCK_global_read_lock", PSI_FLAG_GLOBAL}, { &key_LOCK_global_system_variables, "LOCK_global_system_variables", PSI_FLAG_GLOBAL}, { &key_LOCK_manager, "LOCK_manager", PSI_FLAG_GLOBAL}, - { &key_LOCK_mapped_file, "LOCK_mapped_file", PSI_FLAG_GLOBAL}, - { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL}, { &key_LOCK_prepared_stmt_count, "LOCK_prepared_stmt_count", PSI_FLAG_GLOBAL}, { &key_LOCK_rpl_status, "LOCK_rpl_status", PSI_FLAG_GLOBAL}, { &key_LOCK_server_started, "LOCK_server_started", PSI_FLAG_GLOBAL}, diff --git a/sql/mysqld.h b/sql/mysqld.h index 74d840d55cb..eecaecac429 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -78,9 +78,6 @@ extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ; extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info; extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset; -extern TYPELIB log_output_typelib; -extern const char *log_output_names[]; - /** Character set of the buildin error messages loaded from errmsg.sys. */ @@ -105,7 +102,7 @@ extern bool volatile abort_loop; extern bool in_bootstrap; extern uint volatile thread_count, global_read_lock; extern uint connection_count; -extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; +extern my_bool opt_safe_user_create; extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap; extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern uint slave_exec_mode_options; @@ -173,7 +170,6 @@ extern ulong slave_trans_retries; extern uint slave_net_timeout; extern uint max_user_connections; extern ulong what_to_log,flush_time; -extern ulong query_buff_size; extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong binlog_cache_size, open_files_limit; extern ulonglong max_binlog_cache_size; @@ -210,9 +206,7 @@ extern MYSQL_FILE *bootstrap_file; extern my_bool old_mode; extern LEX_STRING opt_init_connect, opt_init_slave; extern int bootstrap_error; -extern FILE *stderror_file; extern I_List<THD> threads; -extern char err_shared_dir[]; extern scheduler_functions thread_scheduler; extern TYPELIB thread_handling_typelib; extern my_decimal decimal_zero; @@ -234,8 +228,8 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables, - key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file, - key_LOCK_open, key_LOCK_prepared_stmt_count, + key_LOCK_logger, key_LOCK_manager, + key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status, key_LOCK_table_share, key_LOCK_thd_data, key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log, @@ -313,7 +307,6 @@ extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[]; extern char mysql_unpacked_real_data_home[]; extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables; extern char default_logfile_name[FN_REFLEN]; -extern char err_shared_dir[]; #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list)) @@ -323,8 +316,8 @@ extern MYSQL_PLUGIN_IMPORT key_map key_map_full; /* Should be threaded /* Server mutex locks and condition variables. */ -extern mysql_mutex_t LOCK_open, - LOCK_mapped_file, LOCK_user_locks, LOCK_status, +extern mysql_mutex_t + LOCK_user_locks, LOCK_status, LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock, diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index 76dc2846ed0..1f1b7f0c20f 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -375,29 +375,6 @@ void NTService::ServiceCtrlHandler(DWORD ctrlCode) dwState=pService->dwState; // get current state switch(ctrlCode) { - -#ifdef NOT_USED /* do we need this ? */ - case SERVICE_CONTROL_PAUSE: - if (pService->bRunning && ! pService->bPause) - { - dwState = SERVICE_PAUSED; - pService->SetStatus(SERVICE_PAUSE_PENDING,NO_ERROR, 0, 1, - pService->nPauseTimeOut); - pService->PauseService(); - } - break; - - case SERVICE_CONTROL_CONTINUE: - if (pService->bRunning && pService->bPause) - { - dwState = SERVICE_RUNNING; - pService->SetStatus(SERVICE_CONTINUE_PENDING,NO_ERROR, 0, 1, - pService->nResumeTimeOut); - pService->ResumeService(); - } - break; -#endif - case SERVICE_CONTROL_SHUTDOWN: case SERVICE_CONTROL_STOP: dwState = SERVICE_STOP_PENDING; diff --git a/sql/opt_range.h b/sql/opt_range.h index 0d4000002b0..33b3d561ad8 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -825,7 +825,11 @@ class SQL_SELECT :public Sql_alloc { tmp.set_all(); return test_quick_select(thd, tmp, 0, limit, force_quick_range) < 0; } - inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; } + inline bool skip_record(THD *thd, bool *skip_record) + { + *skip_record= cond ? cond->val_int() == FALSE : FALSE; + return thd->is_error(); + } int test_quick_select(THD *thd, key_map keys, table_map prev_tables, ha_rows limit, bool force_quick_range); }; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 43934551016..caf28fdd83e 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1535,13 +1535,11 @@ bool partition_info::set_up_charset_field_preps() i= 0; while ((field= *(ptr++))) { - CHARSET_INFO *cs; uchar *field_buf; LINT_INIT(field_buf); if (!field_is_partition_charset(field)) continue; - cs= ((Field_str*)field)->charset(); size= field->pack_length(); if (!(field_buf= (uchar*) sql_calloc(size))) goto error; diff --git a/sql/protocol.cc b/sql/protocol.cc index 3f957dcc2de..953656d3a4f 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -658,7 +658,11 @@ void Protocol::end_partial_result_set(THD *thd_arg) bool Protocol::flush() { #ifndef EMBEDDED_LIBRARY - return net_flush(&thd->net); + bool error; + thd->stmt_da->can_overwrite_status= TRUE; + error= net_flush(&thd->net); + thd->stmt_da->can_overwrite_status= FALSE; + return error; #else return 0; #endif @@ -698,7 +702,8 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags) if (flags & SEND_NUM_ROWS) { // Packet with number of elements uchar *pos= net_store_length(buff, list->elements); - (void) my_net_write(&thd->net, buff, (size_t) (pos-buff)); + if (my_net_write(&thd->net, buff, (size_t) (pos-buff))) + DBUG_RETURN(1); } #ifndef DBUG_OFF @@ -790,37 +795,20 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags) local_packet->realloc(local_packet->length()+10)) goto err; pos= (char*) local_packet->ptr()+local_packet->length(); - -#ifdef TO_BE_DELETED_IN_6 - if (!(thd->client_capabilities & CLIENT_LONG_FLAG)) - { - pos[0]=3; - int3store(pos+1,field.length); - pos[4]=1; - pos[5]=field.type; - pos[6]=2; - pos[7]= (char) field.flags; - pos[8]= (char) field.decimals; - pos+= 9; - } - else -#endif - { - pos[0]=3; - int3store(pos+1,field.length); - pos[4]=1; - pos[5]=field.type; - pos[6]=3; - int2store(pos+7,field.flags); - pos[9]= (char) field.decimals; - pos+= 10; - } + pos[0]=3; + int3store(pos+1,field.length); + pos[4]=1; + pos[5]=field.type; + pos[6]=3; + int2store(pos+7,field.flags); + pos[9]= (char) field.decimals; + pos+= 10; } local_packet->length((uint) (pos - local_packet->ptr())); if (flags & SEND_DEFAULTS) item->send(&prot, &tmp); // Send default value if (prot.write()) - break; /* purecov: inspected */ + DBUG_RETURN(1); #ifndef DBUG_OFF field_types[count++]= field.type; #endif @@ -833,8 +821,9 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags) to show that there is no cursor. Send no warning information, as it will be sent at statement end. */ - write_eof_packet(thd, &thd->net, thd->server_status, - thd->warning_info->statement_warn_count()); + if (write_eof_packet(thd, &thd->net, thd->server_status, + thd->warning_info->statement_warn_count())) + DBUG_RETURN(1); } DBUG_RETURN(prepare_for_send(list->elements)); diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 9a1f7fb826b..47eb2f7031d 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -55,9 +55,6 @@ const char* rpl_status_type[]= "AUTH_MASTER","IDLE_SLAVE","ACTIVE_SLAVE","LOST_SOLDIER","TROOP_SOLDIER", "RECOVERY_CAPTAIN","NULL",NullS }; -TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"", - rpl_status_type, NULL}; - static Slave_log_event* find_slave_event(IO_CACHE* log, const char* log_file_name, @@ -71,42 +68,6 @@ static Slave_log_event* find_slave_event(IO_CACHE* log, functions like register_slave()) are working. */ -#if NOT_USED -static int init_failsafe_rpl_thread(THD* thd) -{ - DBUG_ENTER("init_failsafe_rpl_thread"); - thd->system_thread = SYSTEM_THREAD_DELAYED_INSERT; - /* - thd->bootstrap is to report errors barely to stderr; if this code is - enable again one day, one should check if bootstrap is still needed (maybe - this thread has no other error reporting method). - */ - thd->bootstrap = 1; - thd->security_ctx->skip_grants(); - my_net_init(&thd->net, 0); - thd->net.read_timeout = slave_net_timeout; - thd->max_client_packet_length=thd->net.max_packet; - mysql_mutex_lock(&LOCK_thread_count); - thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; - mysql_mutex_unlock(&LOCK_thread_count); - - if (init_thr_lock() || thd->store_globals()) - { - /* purecov: begin inspected */ - close_connection(thd, ER_OUT_OF_RESOURCES, 1); // is this needed? - statistic_increment(aborted_connects,&LOCK_status); - one_thread_per_connection_end(thd,0); - DBUG_RETURN(-1); - /* purecov: end */ - } - - thd->mem_root->free= thd->mem_root->used= 0; - thd_proc_info(thd, "Thread initialized"); - thd->set_time(); - DBUG_RETURN(0); -} -#endif - void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status) { mysql_mutex_lock(&LOCK_rpl_status); @@ -623,66 +584,6 @@ err: } -#if NOT_USED -int find_recovery_captain(THD* thd, MYSQL* mysql) -{ - return 0; -} -#endif - -#if NOT_USED -pthread_handler_t handle_failsafe_rpl(void *arg) -{ - DBUG_ENTER("handle_failsafe_rpl"); - THD *thd = new THD; - thd->thread_stack = (char*)&thd; - MYSQL* recovery_captain = 0; - const char* msg; - - pthread_detach_this_thread(); - if (init_failsafe_rpl_thread(thd) || !(recovery_captain=mysql_init(0))) - { - sql_print_error("Could not initialize failsafe replication thread"); - goto err; - } - mysql_mutex_lock(&LOCK_rpl_status); - msg= thd->enter_cond(&COND_rpl_status, - &LOCK_rpl_status, "Waiting for request"); - while (!thd->killed && !abort_loop) - { - bool break_req_chain = 0; - mysql_cond_wait(&COND_rpl_status, &LOCK_rpl_status); - thd_proc_info(thd, "Processing request"); - while (!break_req_chain) - { - switch (rpl_status) { - case RPL_LOST_SOLDIER: - if (find_recovery_captain(thd, recovery_captain)) - rpl_status=RPL_TROOP_SOLDIER; - else - rpl_status=RPL_RECOVERY_CAPTAIN; - break_req_chain=1; /* for now until other states are implemented */ - break; - default: - break_req_chain=1; - break; - } - } - } - thd->exit_cond(msg); -err: - if (recovery_captain) - mysql_close(recovery_captain); - delete thd; - - DBUG_LEAVE; // Must match DBUG_ENTER() - my_thread_end(); - pthread_exit(0); - return 0; // Avoid compiler warnings -} -#endif - - /** Execute a SHOW SLAVE HOSTS statement. diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h index 94b151aaee7..c6d00de47cb 100644 --- a/sql/repl_failsafe.h +++ b/sql/repl_failsafe.h @@ -30,7 +30,7 @@ extern RPL_STATUS rpl_status; extern mysql_mutex_t LOCK_rpl_status; extern mysql_cond_t COND_rpl_status; -extern TYPELIB rpl_role_typelib, rpl_status_typelib; +extern TYPELIB rpl_role_typelib; extern const char* rpl_role_type[], *rpl_status_type[]; pthread_handler_t handle_failsafe_rpl(void *arg); diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index ced5c0943dd..8219f70727e 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -238,7 +238,8 @@ unpack_row(Relay_log_info const *rli, conv_field ? conv_field : *field_ptr; DBUG_PRINT("debug", ("Conversion %srequired for field '%s' (#%ld)", conv_field ? "" : "not ", - (*field_ptr)->field_name, field_ptr - begin_ptr)); + (*field_ptr)->field_name, + (long) (field_ptr - begin_ptr))); DBUG_ASSERT(f != NULL); /* diff --git a/sql/set_var.h b/sql/set_var.h index 1b415567659..5f1f889c4ce 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -169,7 +169,6 @@ protected: { return ((uchar*)&global_system_variables) + offset; } }; -#include "log.h" /* binlog_format_typelib */ #include "sql_plugin.h" /* SHOW_HA_ROWS, SHOW_MY_BOOL */ /**************************************************************************** diff --git a/sql/slave.cc b/sql/slave.cc index a6199854e48..dff6b6946d4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -83,7 +83,6 @@ ulonglong relay_log_space_limit = 0; */ int disconnect_slave_event_count = 0, abort_slave_event_count = 0; -int events_till_abort = -1; static pthread_key(Master_info*, RPL_MASTER_INFO); @@ -798,17 +797,6 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, } -#ifdef NOT_USED_YET -static int end_slave_on_walk(Master_info* mi, uchar* /*unused*/) -{ - DBUG_ENTER("end_slave_on_walk"); - - end_master_info(mi); - DBUG_RETURN(0); -} -#endif - - /* Release slave threads at time of executing shutdown. @@ -3274,11 +3262,8 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, mysql_mutex_lock(&rli->data_lock); if (rli->slave_skip_counter) { - char *pos; - pos= strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1); - pos= '\0'; - pos= strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1); - pos= '\0'; + strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1); + strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1); saved_log_pos= rli->group_relay_log_pos; saved_master_log_pos= rli->group_master_log_pos; saved_skip= rli->slave_skip_counter; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 11f138e67be..2d3a32c7f7f 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1076,6 +1076,104 @@ void sp_head::recursion_level_error(THD *thd) /** + Find an SQL handler for any condition (warning or error) after execution + of a stored routine instruction. Basically, this function looks for an + appropriate SQL handler in RT-contexts. If an SQL handler is found, it is + remembered in the RT-context for future activation (the context can be + inactive at the moment). + + If there is no pending condition, the function just returns. + + If there was an error during the execution, an SQL handler for it will be + searched within the current and outer scopes. + + There might be several errors in the Warning Info (that's possible by using + SIGNAL/RESIGNAL in nested scopes) -- the function is looking for an SQL + handler for the latest (current) error only. + + If there was a warning during the execution, an SQL handler for it will be + searched within the current scope only. + + If several warnings were thrown during the execution and there are different + SQL handlers for them, it is not determined which SQL handler will be chosen. + Only one SQL handler will be executed. + + If warnings and errors were thrown during the execution, the error takes + precedence. I.e. error handler will be executed. If there is no handler + for that error, condition will remain unhandled. + + Once a warning or an error has been handled it is not removed from + Warning Info. + + According to The Standard (quoting PeterG): + + An SQL procedure statement works like this ... + SQL/Foundation 13.5 <SQL procedure statement> + (General Rules) (greatly summarized) says: + (1) Empty diagnostics area, thus clearing the condition. + (2) Execute statement. + During execution, if Exception Condition occurs, + set Condition Area = Exception Condition and stop + statement. + During execution, if No Data occurs, + set Condition Area = No Data Condition and continue + statement. + During execution, if Warning occurs, + and Condition Area is not already full due to + an earlier No Data condition, set Condition Area + = Warning and continue statement. + (3) Finish statement. + At end of execution, if Condition Area is not + already full due to an earlier No Data or Warning, + set Condition Area = Successful Completion. + In effect, this system means there is a precedence: + Exception trumps No Data, No Data trumps Warning, + Warning trumps Successful Completion. + + NB: "Procedure statements" include any DDL or DML or + control statements. So CREATE and DELETE and WHILE + and CALL and RETURN are procedure statements. But + DECLARE and END are not procedure statements. + + @param thd thread handle + @param ctx runtime context of the stored routine +*/ + +static void +find_handler_after_execution(THD *thd, sp_rcontext *ctx) +{ + if (thd->is_error()) + { + ctx->find_handler(thd, + thd->stmt_da->sql_errno(), + thd->stmt_da->get_sqlstate(), + MYSQL_ERROR::WARN_LEVEL_ERROR, + thd->stmt_da->message()); + } + else if (thd->warning_info->statement_warn_count()) + { + List_iterator<MYSQL_ERROR> it(thd->warning_info->warn_list()); + MYSQL_ERROR *err; + while ((err= it++)) + { + if (err->get_level() != MYSQL_ERROR::WARN_LEVEL_WARN && + err->get_level() != MYSQL_ERROR::WARN_LEVEL_NOTE) + continue; + + if (ctx->find_handler(thd, + err->get_sql_errno(), + err->get_sqlstate(), + err->get_level(), + err->get_message_text())) + { + break; + } + } + } +} + + +/** Execute the routine. The main instruction jump loop is there. Assume the parameters already set. @todo @@ -1096,7 +1194,7 @@ sp_head::execute(THD *thd) LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed= FALSE; - sp_rcontext *ctx; + sp_rcontext *ctx= thd->spcont; bool err_status= FALSE; uint ip= 0; ulong save_sql_mode; @@ -1157,8 +1255,6 @@ sp_head::execute(THD *thd) goto done; } - if ((ctx= thd->spcont)) - ctx->clear_handler(); thd->is_slave_error= 0; old_arena= thd->stmt_arena; @@ -1243,7 +1339,6 @@ sp_head::execute(THD *thd) do { sp_instr *i; - uint hip; #if defined(ENABLED_PROFILING) /* @@ -1265,6 +1360,9 @@ sp_head::execute(THD *thd) break; } + /* Reset number of warnings for this query. */ + thd->warning_info->reset_for_next_command(); + DBUG_PRINT("execute", ("Instruction %u", ip)); /* @@ -1309,40 +1407,28 @@ sp_head::execute(THD *thd) free_root(&execute_mem_root, MYF(0)); /* - Check if an exception has occurred and a handler has been found - Note: We have to check even if err_status == FALSE, since warnings (and - some errors) don't return a non-zero value. We also have to check even - if thd->killed != 0, since some errors return with this even when a - handler has been found (e.g. "bad data"). + Find and process SQL handlers unless it is a fatal error (fatal + errors are not catchable by SQL handlers) or the connection has been + killed during execution. */ - if (ctx) + if (!thd->is_fatal_error && !thd->killed_errno()) { - uint handler_index; + /* + Find SQL handler in the appropriate RT-contexts: + - warnings can be handled by SQL handlers within + the current scope only; + - errors can be handled by any SQL handler from outer scope. + */ + find_handler_after_execution(thd, ctx); - switch (ctx->found_handler(& hip, & handler_index)) { - case SP_HANDLER_NONE: - break; - case SP_HANDLER_CONTINUE: - thd->restore_active_arena(&execute_arena, &backup_arena); - thd->set_n_backup_active_arena(&execute_arena, &backup_arena); - ctx->push_hstack(i->get_cont_dest()); - /* Fall through */ - default: - if (ctx->end_partial_result_set) - thd->protocol->end_partial_result_set(thd); - ip= hip; + /* If found, activate handler for the current scope. */ + if (ctx->activate_handler(thd, &ip, i, &execute_arena, &backup_arena)) err_status= FALSE; - ctx->clear_handler(); - ctx->enter_handler(hip, handler_index); - thd->clear_error(); - thd->is_fatal_error= 0; - thd->killed= THD::NOT_KILLED; - thd->mysys_var->abort= 0; - continue; - } - - ctx->end_partial_result_set= FALSE; } + + /* Reset sp_rcontext::end_partial_result_set flag. */ + ctx->end_partial_result_set= FALSE; + } while (!err_status && !thd->killed && !thd->is_fatal_error); #if defined(ENABLED_PROFILING) @@ -3037,23 +3123,14 @@ sp_instr_set::exec_core(THD *thd, uint *nextp) { int res= thd->spcont->set_variable(thd, m_offset, &m_value); - if (res && thd->spcont->found_handler_here()) + if (res) { - /* - Failed to evaluate the value, and a handler has been found. Reset the - variable to NULL. - */ + /* Failed to evaluate the value. Reset the variable to NULL. */ if (thd->spcont->set_variable(thd, m_offset, 0)) { /* If this also failed, let's abort. */ - - sp_rcontext *spcont= thd->spcont; - - thd->spcont= NULL; /* Avoid handlers */ - my_error(ER_OUT_OF_RESOURCES, MYF(0)); - spcont->clear_handler(); - thd->spcont= spcont; + my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR)); } } @@ -3586,18 +3663,6 @@ sp_instr_copen::execute(THD *thd, uint *nextp) if (thd->stmt_arena->free_list) cleanup_items(thd->stmt_arena->free_list); thd->stmt_arena= old_arena; - /* - Work around the fact that errors in selects are not returned properly - (but instead converted into a warning), so if a condition handler - caught, we have lost the result code. - */ - if (!res) - { - uint dummy1, dummy2; - - if (thd->spcont->found_handler(&dummy1, &dummy2)) - res= -1; - } /* TODO: Assert here that we either have an error or a cursor */ } DBUG_RETURN(res); @@ -3773,13 +3838,11 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) { int res= thd->spcont->set_case_expr(thd, m_case_expr_id, &m_case_expr); - if (res && - !thd->spcont->get_case_expr(m_case_expr_id) && - thd->spcont->found_handler_here()) + if (res && !thd->spcont->get_case_expr(m_case_expr_id)) { /* Failed to evaluate the value, the case expression is still not - initialized, and a handler has been found. Set to NULL so we can continue. + initialized. Set to NULL so we can continue. */ Item *null_item= new Item_null(); @@ -3788,13 +3851,7 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) thd->spcont->set_case_expr(thd, m_case_expr_id, &null_item)) { /* If this also failed, we have to abort. */ - - sp_rcontext *spcont= thd->spcont; - - thd->spcont= NULL; /* Avoid handlers */ - my_error(ER_OUT_OF_RESOURCES, MYF(0)); - spcont->clear_handler(); - thd->spcont= spcont; + my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR)); } } else diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index b12d5362c6b..c27c7d22da2 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -332,13 +332,6 @@ public: int push_cond(LEX_STRING *name, sp_cond_type_t *val); - inline void - pop_cond(uint num) - { - while (num--) - pop_dynamic(&m_conds); - } - sp_cond_type_t * find_cond(LEX_STRING *name, my_bool scoped=0); diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 047cec76486..e76a5e9ebde 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -171,48 +171,50 @@ sp_rcontext::set_return_value(THD *thd, Item **return_value_item) #define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2') #define IS_EXCEPTION_CONDITION(S) ((S)[0] != '0' || (S)[1] > '2') -/* - Find a handler for the given errno. - This is called from all error message functions (e.g. push_warning, - net_send_error, et al) when a sp_rcontext is in effect. If a handler - is found, no error is sent, and the the SP execution loop will instead - invoke the found handler. - This might be called several times before we get back to the execution - loop, so m_hfound can be >= 0 if a handler has already been found. - (In which case we don't search again - the first found handler will - be used.) - Handlers are pushed on the stack m_handler, with the latest/innermost +/** + Find an SQL handler for the given error. + + SQL handlers are pushed on the stack m_handler, with the latest/innermost one on the top; we then search for matching handlers from the top and down. + We search through all the handlers, looking for the most specific one (sql_errno more specific than sqlstate more specific than the rest). Note that mysql error code handlers is a MySQL extension, not part of the standard. - SYNOPSIS - sql_errno The error code - level Warning level + SQL handlers for warnings are searched in the current scope only. - RETURN - 1 if a handler was found, m_hfound is set to its index (>= 0) - 0 if not found, m_hfound is -1 + SQL handlers for errors are searched in the current and in outer scopes. + That's why finding and activation of handler must be separated: an errror + handler might be located in the outer scope, which is not active at the + moment. Before such handler can be activated, execution flow should + unwind to that scope. + + Found SQL handler is remembered in m_hfound for future activation. + If no handler is found, m_hfound is -1. + + @param thd Thread handle + @param sql_errno The error code + @param sqlstate The error SQL state + @param level The error level + @param msg The error message + + @retval TRUE if an SQL handler was found + @retval FALSE otherwise */ bool sp_rcontext::find_handler(THD *thd, uint sql_errno, - const char* sqlstate, + const char *sqlstate, MYSQL_ERROR::enum_warning_level level, - const char* msg, - MYSQL_ERROR ** cond_hdl) + const char *msg) { - if (m_hfound >= 0) - { - *cond_hdl= NULL; - return TRUE; // Already got one - } + int i= m_hcount; - int i= m_hcount, found= -1; + /* Reset previously found handler. */ + m_hfound= -1; /* If this is a fatal sub-statement error, and this runtime @@ -240,105 +242,56 @@ sp_rcontext::find_handler(THD *thd, { case sp_cond_type_t::number: if (sql_errno == cond->mysqlerr && - (found < 0 || m_handler[found].cond->type > sp_cond_type_t::number)) - found= i; // Always the most specific + (m_hfound < 0 || m_handler[m_hfound].cond->type > sp_cond_type_t::number)) + m_hfound= i; // Always the most specific break; case sp_cond_type_t::state: if (strcmp(sqlstate, cond->sqlstate) == 0 && - (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state)) - found= i; + (m_hfound < 0 || m_handler[m_hfound].cond->type > sp_cond_type_t::state)) + m_hfound= i; break; case sp_cond_type_t::warning: if ((IS_WARNING_CONDITION(sqlstate) || level == MYSQL_ERROR::WARN_LEVEL_WARN) && - found < 0) - found= i; + m_hfound < 0) + m_hfound= i; break; case sp_cond_type_t::notfound: - if (IS_NOT_FOUND_CONDITION(sqlstate) && found < 0) - found= i; + if (IS_NOT_FOUND_CONDITION(sqlstate) && m_hfound < 0) + m_hfound= i; break; case sp_cond_type_t::exception: if (IS_EXCEPTION_CONDITION(sqlstate) && level == MYSQL_ERROR::WARN_LEVEL_ERROR && - found < 0) - found= i; + m_hfound < 0) + m_hfound= i; break; } } - if (found < 0) - { - /* - Only "exception conditions" are propagated to handlers in calling - contexts. If no handler is found locally for a "completion condition" - (warning or "not found") we will simply resume execution. - */ - if (m_prev_runtime_ctx && IS_EXCEPTION_CONDITION(sqlstate) && - level == MYSQL_ERROR::WARN_LEVEL_ERROR) - return m_prev_runtime_ctx->find_handler(thd, - sql_errno, - sqlstate, - level, - msg, - cond_hdl); - *cond_hdl= NULL; - return FALSE; - } - - m_hfound= found; - MYSQL_ERROR *raised= NULL; - DBUG_ASSERT(m_hfound >= 0); - DBUG_ASSERT((uint) m_hfound < m_root_parsing_ctx->max_handler_index()); - raised= & m_raised_conditions[m_hfound]; - raised->clear(); - raised->set(sql_errno, sqlstate, level, msg); - - *cond_hdl= raised; - return TRUE; -} - -/* - Handle the error for a given errno. - The severity of the error is adjusted depending of the current sql_mode. - If an handler is present for the error (see find_handler()), - this function will return true. - If a handler is found and if the severity of the error indicate - that the current instruction executed should abort, - the flag thd->net.report_error is also set. - This will cause the execution of the current instruction in a - sp_instr* to fail, and give control to the handler code itself - in the sp_head::execute() loop. - - SYNOPSIS - sql_errno The error code - level Warning level - thd The current thread + if (m_hfound >= 0) + { + DBUG_ASSERT((uint) m_hfound < m_root_parsing_ctx->max_handler_index()); - RETURN - TRUE if a handler was found. - FALSE if no handler was found. -*/ -bool -sp_rcontext::handle_condition(THD *thd, - uint sql_errno, - const char* sqlstate, - MYSQL_ERROR::enum_warning_level level, - const char* msg, - MYSQL_ERROR ** cond_hdl) -{ - MYSQL_ERROR::enum_warning_level elevated_level= level; + m_raised_conditions[m_hfound].clear(); + m_raised_conditions[m_hfound].set(sql_errno, sqlstate, level, msg); + return TRUE; + } - /* Depending on the sql_mode of execution, - warnings may be considered errors */ - if ((level == MYSQL_ERROR::WARN_LEVEL_WARN) && - thd->really_abort_on_warning()) + /* + Only "exception conditions" are propagated to handlers in calling + contexts. If no handler is found locally for a "completion condition" + (warning or "not found") we will simply resume execution. + */ + if (m_prev_runtime_ctx && IS_EXCEPTION_CONDITION(sqlstate) && + level == MYSQL_ERROR::WARN_LEVEL_ERROR) { - elevated_level= MYSQL_ERROR::WARN_LEVEL_ERROR; + return m_prev_runtime_ctx->find_handler(thd, sql_errno, sqlstate, + level, msg); } - return find_handler(thd, sql_errno, sqlstate, elevated_level, msg, cond_hdl); + return FALSE; } void @@ -384,7 +337,9 @@ sp_rcontext::pop_handlers(uint count) { DBUG_ENTER("sp_rcontext::pop_handlers"); DBUG_ASSERT(m_hcount >= count); + m_hcount-= count; + DBUG_PRINT("info", ("m_hcount: %d", m_hcount)); DBUG_VOID_RETURN; } @@ -394,7 +349,9 @@ sp_rcontext::push_hstack(uint h) { DBUG_ENTER("sp_rcontext::push_hstack"); DBUG_ASSERT(m_hsp < m_root_parsing_ctx->max_handler_index()); + m_hstack[m_hsp++]= h; + DBUG_PRINT("info", ("m_hsp: %d", m_hsp)); DBUG_VOID_RETURN; } @@ -405,21 +362,74 @@ sp_rcontext::pop_hstack() uint handler; DBUG_ENTER("sp_rcontext::pop_hstack"); DBUG_ASSERT(m_hsp); + handler= m_hstack[--m_hsp]; + DBUG_PRINT("info", ("m_hsp: %d", m_hsp)); DBUG_RETURN(handler); } -void -sp_rcontext::enter_handler(uint hip, uint hindex) +/** + Prepare found handler to be executed. + + @retval TRUE if an SQL handler is activated (was found) and IP of the + first handler instruction. + @retval FALSE if there is no active handler +*/ + +bool +sp_rcontext::activate_handler(THD *thd, + uint *ip, + sp_instr *instr, + Query_arena *execute_arena, + Query_arena *backup_arena) { - DBUG_ENTER("sp_rcontext::enter_handler"); - DBUG_ASSERT(m_ihsp < m_root_parsing_ctx->max_handler_index()); - m_in_handler[m_ihsp].ip= hip; - m_in_handler[m_ihsp].index= hindex; - m_ihsp++; - DBUG_PRINT("info", ("m_ihsp: %d", m_ihsp)); - DBUG_VOID_RETURN; + if (m_hfound < 0) + return FALSE; + + switch (m_handler[m_hfound].type) { + case SP_HANDLER_NONE: + break; + + case SP_HANDLER_CONTINUE: + thd->restore_active_arena(execute_arena, backup_arena); + thd->set_n_backup_active_arena(execute_arena, backup_arena); + push_hstack(instr->get_cont_dest()); + + /* Fall through */ + + default: + /* End aborted result set. */ + + if (end_partial_result_set) + thd->protocol->end_partial_result_set(thd); + + /* Enter handler. */ + + DBUG_ASSERT(m_ihsp < m_root_parsing_ctx->max_handler_index()); + DBUG_ASSERT(m_hfound >= 0); + + m_in_handler[m_ihsp].ip= m_handler[m_hfound].handler; + m_in_handler[m_ihsp].index= m_hfound; + m_ihsp++; + + DBUG_PRINT("info", ("Entering handler...")); + DBUG_PRINT("info", ("m_ihsp: %d", m_ihsp)); + + /* Reset error state. */ + + thd->clear_error(); + thd->killed= THD::NOT_KILLED; // Some errors set thd->killed + // (e.g. "bad data"). + + /* Return IP of the activated SQL handler. */ + *ip= m_handler[m_hfound].handler; + + /* Reset found handler. */ + m_hfound= -1; + } + + return TRUE; } void @@ -427,9 +437,11 @@ sp_rcontext::exit_handler() { DBUG_ENTER("sp_rcontext::exit_handler"); DBUG_ASSERT(m_ihsp); + uint hindex= m_in_handler[m_ihsp-1].index; m_raised_conditions[hindex].clear(); m_ihsp-= 1; + DBUG_PRINT("info", ("m_ihsp: %d", m_ihsp)); DBUG_VOID_RETURN; } @@ -525,8 +537,7 @@ sp_cursor::open(THD *thd) MYF(0)); return -1; } - if (mysql_open_cursor(thd, (uint) ALWAYS_MATERIALIZED_CURSOR, &result, - &server_side_cursor)) + if (mysql_open_cursor(thd, &result, &server_side_cursor)) return -1; return 0; } @@ -568,6 +579,11 @@ sp_cursor::fetch(THD *thd, List<struct sp_variable> *vars) return -1; } + DBUG_EXECUTE_IF("bug23032_emit_warning", + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_UNKNOWN_ERROR, + ER(ER_UNKNOWN_ERROR));); + result.set_spvar_list(vars); /* Attempt to fetch one row */ diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index fad253706cb..1af758ed0af 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -131,67 +131,40 @@ class sp_rcontext : public Sql_alloc return m_return_value_set; } + /* + SQL handlers support. + */ + void push_handler(struct sp_cond_type *cond, uint h, int type); void pop_handlers(uint count); - // Returns 1 if a handler was found, 0 otherwise. bool find_handler(THD *thd, uint sql_errno, - const char* sqlstate, + const char *sqlstate, MYSQL_ERROR::enum_warning_level level, - const char* msg, - MYSQL_ERROR ** cond_hdl); + const char *msg); - // If there is an error handler for this error, handle it and return TRUE. - bool - handle_condition(THD *thd, - uint sql_errno, - const char* sqlstate, - MYSQL_ERROR::enum_warning_level level, - const char* msg, - MYSQL_ERROR ** cond_hdl); - - // Returns handler type and sets *ip to location if one was found - inline int - found_handler(uint *ip, uint *index) - { - if (m_hfound < 0) - return SP_HANDLER_NONE; - *ip= m_handler[m_hfound].handler; - *index= m_hfound; - return m_handler[m_hfound].type; - } - - MYSQL_ERROR* raised_condition() const; - - // Returns true if we found a handler in this context - inline bool - found_handler_here() - { - return (m_hfound >= 0); - } + MYSQL_ERROR * + raised_condition() const; - // Clears the handler find state - inline void - clear_handler() - { - m_hfound= -1; - } + void + push_hstack(uint h); - void push_hstack(uint h); + uint + pop_hstack(); - uint pop_hstack(); + bool + activate_handler(THD *thd, + uint *ip, + sp_instr *instr, + Query_arena *execute_arena, + Query_arena *backup_arena); - /** - Enter a SQL exception handler. - @param hip the handler instruction pointer - @param index the handler index - */ - void enter_handler(uint hip, uint index); - void exit_handler(); + void + exit_handler(); void push_cursor(sp_lex_keeper *lex_keeper, sp_instr_cpush *i); @@ -199,7 +172,7 @@ class sp_rcontext : public Sql_alloc void pop_cursors(uint count); - void + inline void pop_all_cursors() { pop_cursors(m_ccount); diff --git a/sql/spatial.cc b/sql/spatial.cc index f96196cb836..f1dd0e6cebd 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -142,11 +142,10 @@ Geometry *Geometry::construct(Geometry_buffer *buffer, { uint32 geom_type; Geometry *result; - char byte_order; if (data_len < SRID_SIZE + WKB_HEADER_SIZE) // < 4 + (1 + 4) return NULL; - byte_order= data[SRID_SIZE]; + /* + 1 to skip the byte order (stored in position SRID_SIZE). */ geom_type= uint4korr(data + SRID_SIZE + 1); if (!(result= create_by_typeid(buffer, (int) geom_type))) return NULL; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0008968de2a..19373507955 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3072,7 +3072,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, class LEX_COLUMN *column; List_iterator <LEX_COLUMN> column_iter(columns); - if (open_and_lock_tables(thd, table_list, TRUE, 0)) + if (open_normal_and_derived_tables(thd, table_list, 0)) DBUG_RETURN(TRUE); while ((column = column_iter++)) @@ -5826,7 +5826,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) { int result; String wrong_users; - ulong sql_mode; LEX_USER *user_name, *tmp_user_name; List_iterator <LEX_USER> user_list(list); TABLE_LIST tables[GRANT_TABLES]; @@ -5875,7 +5874,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) } some_users_created= TRUE; - sql_mode= thd->variables.sql_mode; if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0)) { append_user(&wrong_users, user_name); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 74f03d8d3c6..33d47c0659e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -124,6 +124,38 @@ bool Prelock_error_handler::safely_trapped_errors() */ /** + Protects table_def_hash, used and unused lists in the + TABLE_SHARE object, LRU lists of used TABLEs and used + TABLE_SHAREs, refresh_version and the table id counter. +*/ +mysql_mutex_t LOCK_open; + +#ifdef HAVE_PSI_INTERFACE +static PSI_mutex_key key_LOCK_open; +static PSI_mutex_info all_tdc_mutexes[]= { + { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL } +}; + +/** + Initialize performance schema instrumentation points + used by the table cache. +*/ + +static void init_tdc_psi_keys(void) +{ + const char *category= "sql"; + int count; + + if (PSI_server == NULL) + return; + + count= array_elements(all_tdc_mutexes); + PSI_server->register_mutex(category, all_tdc_mutexes, count); +} +#endif /* HAVE_PSI_INTERFACE */ + + +/** Total number of TABLE instances for tables in the table definition cache (both in use by threads and not in use). This value is accessible to user as "Open_tables" status variable. @@ -291,9 +323,14 @@ static void table_def_free_entry(TABLE_SHARE *share) bool table_def_init(void) { table_def_inited= 1; +#ifdef HAVE_PSI_INTERFACE + init_tdc_psi_keys(); +#endif + mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); oldest_unused_share= &end_of_unused_share; end_of_unused_share.prev= &oldest_unused_share; + return my_hash_init(&table_def_cache, &my_charset_bin, table_def_size, 0, 0, table_def_key, (my_hash_free_key) table_def_free_entry, 0) != 0; @@ -311,8 +348,6 @@ void table_def_start_shutdown(void) if (table_def_inited) { mysql_mutex_lock(&LOCK_open); - /* Free all cached but unused TABLEs and TABLE_SHAREs first. */ - close_cached_tables(NULL, NULL, TRUE, FALSE, LONG_TIMEOUT); /* Ensure that TABLE and TABLE_SHARE objects which are created for tables that are open during process of plugins' shutdown are @@ -321,6 +356,8 @@ void table_def_start_shutdown(void) */ table_def_shutdown_in_progress= TRUE; mysql_mutex_unlock(&LOCK_open); + /* Free all cached but unused TABLEs and TABLE_SHAREs. */ + close_cached_tables(NULL, NULL, FALSE, LONG_TIMEOUT); } } @@ -333,6 +370,7 @@ void table_def_free(void) table_def_inited= 0; /* Free table definitions. */ my_hash_free(&table_def_cache); + mysql_mutex_destroy(&LOCK_open); } DBUG_VOID_RETURN; } @@ -438,7 +476,7 @@ static void table_def_unuse_table(TABLE *table) DBUG_ASSERT(table->in_use); /* We shouldn't put the table to 'unused' list if the share is old. */ - DBUG_ASSERT(! table->s->needs_reopen()); + DBUG_ASSERT(! table->s->has_old_version()); table->in_use= 0; /* Remove table from the list of tables used in this share. */ @@ -513,10 +551,10 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, } /* - We assign a new table id under the protection of the LOCK_open and - the share's own mutex. We do this insted of creating a new mutex + We assign a new table id under the protection of LOCK_open. + We do this instead of creating a new mutex and using it for the sole purpose of serializing accesses to a - static variable, we assign the table id here. We assign it to the + static variable, we assign the table id here. We assign it to the share before inserting it into the table_def_cache to be really sure that it cannot be read from the cache without having a table id assigned. @@ -544,7 +582,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, DBUG_RETURN(share); found: - /* + /* We found an existing table definition. Return it if we didn't get an error when reading the table definition from file. */ @@ -586,21 +624,21 @@ found: } -/* +/** Get a table share. If it didn't exist, try creating it from engine - For arguments and return values, see get_table_from_share() + For arguments and return values, see get_table_share() */ -static TABLE_SHARE -*get_table_share_with_create(THD *thd, TABLE_LIST *table_list, - char *key, uint key_length, - uint db_flags, int *error, - my_hash_value_type hash_value) +static TABLE_SHARE * +get_table_share_with_discover(THD *thd, TABLE_LIST *table_list, + char *key, uint key_length, + uint db_flags, int *error, + my_hash_value_type hash_value) { TABLE_SHARE *share; - int tmp; + bool exists; DBUG_ENTER("get_table_share_with_create"); share= get_table_share(thd, table_list, key, key_length, db_flags, error, @@ -614,10 +652,15 @@ static TABLE_SHARE from the pre-locking list. In this case we still need to try auto-discover before returning a NULL share. + Or, we're inside SHOW CREATE VIEW, which + also installs a silencer for ER_NO_SUCH_TABLE error. + If share is NULL and the error is ER_NO_SUCH_TABLE, this is - the same as above, only that the error was not silenced by - pre-locking. Once again, we need to try to auto-discover - the share. + the same as above, only that the error was not silenced by + pre-locking or SHOW CREATE VIEW. + + In both these cases it won't harm to try to discover the + table. Finally, if share is still NULL, it's a real error and we need to abort. @@ -625,20 +668,25 @@ static TABLE_SHARE @todo Rework alternative ways to deal with ER_NO_SUCH TABLE. */ if (share || (thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE)) - DBUG_RETURN(share); + *error= 0; + /* Table didn't exist. Check if some engine can provide it */ - tmp= ha_create_table_from_engine(thd, table_list->db, - table_list->table_name); - if (tmp < 0) + if (ha_check_if_table_exists(thd, table_list->db, table_list->table_name, + &exists)) + { + thd->clear_error(); + /* Conventionally, the storage engine API does not report errors. */ + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + } + else if (! exists) { /* No such table in any engine. Hide "Table doesn't exist" errors if the table belongs to a view. The check for thd->is_error() is necessary to not push an - unwanted error in case of pre-locking, which silences - "no such table" errors. + unwanted error in case the error was already silenced. @todo Rework the alternative ways to deal with ER_NO_SUCH TABLE. */ if (thd->is_error()) @@ -656,27 +704,16 @@ static TABLE_SHARE view->view_db.str, view->view_name.str); } } - DBUG_RETURN(0); } - if (tmp) + else { - /* Give right error message */ thd->clear_error(); - DBUG_PRINT("error", ("Discovery of %s/%s failed", table_list->db, - table_list->table_name)); - my_printf_error(ER_UNKNOWN_ERROR, - "Failed to open '%-.64s', error while " - "unpacking from engine", - MYF(0), table_list->table_name); - DBUG_RETURN(0); + *error= 7; /* Run auto-discover. */ } - /* Table existed in engine. Let's open it */ - thd->warning_info->clear_warning_info(thd->query_id); - thd->clear_error(); // Clear error message - DBUG_RETURN(get_table_share(thd, table_list, key, key_length, - db_flags, error, hash_value)); + DBUG_RETURN(NULL); } + /** Mark that we are not using table share anymore. @@ -700,7 +737,7 @@ void release_table_share(TABLE_SHARE *share) DBUG_ASSERT(share->ref_count); if (!--share->ref_count) { - if (share->needs_reopen() || table_def_shutdown_in_progress) + if (share->has_old_version() || table_def_shutdown_in_progress) my_hash_delete(&table_def_cache, (uchar*) share); else { @@ -887,7 +924,7 @@ void free_io_cache(TABLE *table) @param share Table share. - @pre Caller should have LOCK_open mutex acquired. + @pre Caller should have LOCK_open mutex. */ static void kill_delayed_threads_for_table(TABLE_SHARE *share) @@ -923,7 +960,6 @@ static void kill_delayed_threads_for_table(TABLE_SHARE *share) @param thd Thread context @param tables List of tables to remove from the cache - @param have_lock If LOCK_open is locked @param wait_for_refresh Wait for a impending flush @param timeout Timeout for waiting for flush to be completed. @@ -938,7 +974,7 @@ static void kill_delayed_threads_for_table(TABLE_SHARE *share) lock taken by thread trying to obtain global read lock. */ -bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, +bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool wait_for_refresh, ulong timeout) { bool result= FALSE; @@ -947,14 +983,13 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, DBUG_ENTER("close_cached_tables"); DBUG_ASSERT(thd || (!wait_for_refresh && !tables)); - if (!have_lock) - mysql_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); if (!tables) { /* Force close of all open tables. - Note that code in TABLE_SHARE::wait_until_flushed() assumes that + Note that code in TABLE_SHARE::wait_for_old_version() assumes that incrementing of refresh_version and removal of unused tables and shares from TDC happens atomically under protection of LOCK_open, or putting it another way that TDC does not contain old shares @@ -986,7 +1021,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, kill_delayed_threads_for_table(share); /* tdc_remove_table() also sets TABLE_SHARE::version to 0. */ tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table->db, - table->table_name); + table->table_name, TRUE); found=1; } } @@ -994,15 +1029,11 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, wait_for_refresh=0; // Nothing to wait for } - if (!have_lock) - mysql_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); if (!wait_for_refresh) DBUG_RETURN(result); - /* Code below assume that LOCK_open is released. */ - DBUG_ASSERT(!have_lock); - set_timespec(abstime, timeout); if (thd->locked_tables_mode) @@ -1059,9 +1090,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, { for (uint idx=0 ; idx < table_def_cache.records ; idx++) { - share= (TABLE_SHARE*) my_hash_element(&table_def_cache, - idx); - if (share->needs_reopen()) + share= (TABLE_SHARE*) my_hash_element(&table_def_cache, idx); + if (share->has_old_version()) { found= TRUE; break; @@ -1073,7 +1103,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, for (TABLE_LIST *table= tables; table; table= table->next_local) { share= get_cached_table_share(table->db, table->table_name); - if (share && share->needs_reopen()) + if (share && share->has_old_version()) { found= TRUE; break; @@ -1083,9 +1113,12 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, if (found) { - /* The below method will unlock LOCK_open and frees share's memory. */ - if (share->wait_until_flushed(&thd->mdl_context, &abstime, - MDL_DEADLOCK_WEIGHT_DDL)) + /* + The method below temporarily unlocks LOCK_open and frees + share's memory. + */ + if (share->wait_for_old_version(thd, &abstime, + MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL)) { mysql_mutex_unlock(&LOCK_open); result= TRUE; @@ -1123,7 +1156,7 @@ err_with_reopen: */ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh, - LEX_STRING *connection, bool have_lock) + LEX_STRING *connection) { uint idx; TABLE_LIST tmp, *tables= NULL; @@ -1133,8 +1166,7 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh, bzero(&tmp, sizeof(TABLE_LIST)); - if (!have_lock) - mysql_mutex_lock(&LOCK_open); + mysql_mutex_lock(&LOCK_open); for (idx= 0; idx < table_def_cache.records; idx++) { @@ -1162,12 +1194,10 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh, tables= (TABLE_LIST *) memdup_root(thd->mem_root, (char*)&tmp, sizeof(TABLE_LIST)); } + mysql_mutex_unlock(&LOCK_open); if (tables) - result= close_cached_tables(thd, tables, TRUE, FALSE, LONG_TIMEOUT); - - if (!have_lock) - mysql_mutex_unlock(&LOCK_open); + result= close_cached_tables(thd, tables, FALSE, LONG_TIMEOUT); if (if_wait_for_refresh) { @@ -1370,9 +1400,8 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share, } } /* Remove the table share from the cache. */ - mysql_mutex_lock(&LOCK_open); - tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name); - mysql_mutex_unlock(&LOCK_open); + tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name, + FALSE); /* There could be a FLUSH thread waiting on the table to go away. Wake it up. @@ -1515,9 +1544,6 @@ void close_thread_tables(THD *thd) thd->lock=0; } /* - Note that we need to hold LOCK_open while changing the - open_tables list. Another thread may work on it. - (See: mysql_notify_thread_having_shared_lock()) Closing a MERGE child before the parent would be fatal if the other thread tries to abort the MERGE lock in between. */ @@ -1563,7 +1589,7 @@ bool close_thread_table(THD *thd, TABLE **table_ptr) mysql_mutex_lock(&LOCK_open); - if (table->s->needs_reopen() || table->needs_reopen() || + if (table->s->has_old_version() || table->needs_reopen() || table_def_shutdown_in_progress) { free_cache_entry(table); @@ -1597,7 +1623,7 @@ static inline uint tmpkeyval(THD *thd, TABLE *table) creates one DROP TEMPORARY TABLE binlog event for each pseudo-thread */ -void close_temporary_tables(THD *thd) +bool close_temporary_tables(THD *thd) { DBUG_ENTER("close_temporary_tables"); TABLE *table; @@ -1605,9 +1631,10 @@ void close_temporary_tables(THD *thd) TABLE *prev_table; /* Assume thd->variables.option_bits has OPTION_QUOTE_SHOW_CREATE */ bool was_quote_show= TRUE; + bool error= 0; if (!thd->temporary_tables) - DBUG_VOID_RETURN; + DBUG_RETURN(FALSE); if (!mysql_bin_log.is_open()) { @@ -1618,7 +1645,7 @@ void close_temporary_tables(THD *thd) close_temporary(table, 1, 1); } thd->temporary_tables= 0; - DBUG_VOID_RETURN; + DBUG_RETURN(FALSE); } /* Better add "if exists", in case a RESET MASTER has been done */ @@ -1717,11 +1744,27 @@ void close_temporary_tables(THD *thd) qinfo.db= db.ptr(); qinfo.db_len= db.length(); thd->variables.character_set_client= cs_save; - if (mysql_bin_log.write(&qinfo)) + + thd->stmt_da->can_overwrite_status= TRUE; + if ((error= (mysql_bin_log.write(&qinfo) || error))) { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, MYF(0), - "Failed to write the DROP statement for temporary tables to binary log"); + /* + If we're here following THD::cleanup, thence the connection + has been closed already. So lets print a message to the + error log instead of pushing yet another error into the + stmt_da. + + Also, we keep the error flag so that we propagate the error + up in the stack. This way, if we're the SQL thread we notice + that close_temporary_tables failed. (Actually, the SQL + thread only calls close_temporary_tables while applying old + Start_log_event_v3 events.) + */ + sql_print_error("Failed to write the DROP statement for " + "temporary tables to binary log"); } + thd->stmt_da->can_overwrite_status= FALSE; + thd->variables.pseudo_thread_id= save_pseudo_thread_id; thd->thread_specific_used= save_thread_specific_used; } @@ -1734,7 +1777,8 @@ void close_temporary_tables(THD *thd) if (!was_quote_show) thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE; /* restore option */ thd->temporary_tables=0; - DBUG_VOID_RETURN; + + DBUG_RETURN(error); } /* @@ -2198,10 +2242,9 @@ bool wait_while_table_is_used(THD *thd, TABLE *table, table->mdl_ticket, thd->variables.lock_wait_timeout)) DBUG_RETURN(TRUE); - mysql_mutex_lock(&LOCK_open); tdc_remove_table(thd, TDC_RT_REMOVE_NOT_OWN, - table->s->db.str, table->s->table_name.str); - mysql_mutex_unlock(&LOCK_open); + table->s->db.str, table->s->table_name.str, + FALSE); /* extra() call must come only after all instances above are closed */ (void) table->file->extra(function); DBUG_RETURN(FALSE); @@ -2242,9 +2285,8 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name, table->file->extra(HA_EXTRA_PREPARE_FOR_DROP); close_thread_table(thd, &thd->open_tables); /* Remove the table share from the table cache. */ - mysql_mutex_lock(&LOCK_open); - tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db_name, table_name); - mysql_mutex_unlock(&LOCK_open); + tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db_name, table_name, + FALSE); /* Remove the table from the storage engine and rm the .frm. */ quick_rm_table(table_type, db_name, table_name, 0); } @@ -2262,8 +2304,6 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name, exists and to FALSE otherwise. @note This function acquires LOCK_open internally. - It also assumes that the fact that there are no exclusive - metadata locks on the table was checked beforehand. @note If there is no .FRM file for the table but it exists in one of engines (e.g. it was created on another node of NDB cluster) @@ -2276,16 +2316,20 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name, bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists) { char path[FN_REFLEN + 1]; - int rc= 0; + TABLE_SHARE *share; DBUG_ENTER("check_if_table_exists"); - mysql_mutex_assert_not_owner(&LOCK_open); - *exists= TRUE; + DBUG_ASSERT(thd->mdl_context. + is_lock_owner(MDL_key::TABLE, table->db, + table->table_name, MDL_SHARED)); + mysql_mutex_lock(&LOCK_open); + share= get_cached_table_share(table->db, table->table_name); + mysql_mutex_unlock(&LOCK_open); - if (get_cached_table_share(table->db, table->table_name)) + if (share) goto end; build_table_filename(path, sizeof(path) - 1, table->db, table->table_name, @@ -2295,24 +2339,14 @@ bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists) goto end; /* .FRM file doesn't exist. Check if some engine can provide it. */ - - rc= ha_create_table_from_engine(thd, table->db, table->table_name); - - if (rc < 0) - { - /* Table does not exists in engines as well. */ - *exists= FALSE; - rc= 0; - } - else if (rc) + if (ha_check_if_table_exists(thd, table->db, table->table_name, exists)) { - my_printf_error(ER_UNKNOWN_ERROR, "Failed to open '%-.64s', error while " + my_printf_error(ER_OUT_OF_RESOURCES, "Failed to open '%-.64s', error while " "unpacking from engine", MYF(0), table->table_name); + DBUG_RETURN(TRUE); } - end: - mysql_mutex_unlock(&LOCK_open); - DBUG_RETURN(test(rc)); + DBUG_RETURN(FALSE); } @@ -2362,8 +2396,9 @@ bool MDL_deadlock_handler::handle_condition(THD *, { /* Disable the handler to avoid infinite recursion. */ m_is_active= TRUE; - (void) m_ot_ctx->request_backoff_action(Open_table_context::OT_CONFLICT, - NULL); + (void) m_ot_ctx->request_backoff_action( + Open_table_context::OT_BACKOFF_AND_RETRY, + NULL); m_is_active= FALSE; /* If the above back-off request failed, a new instance of @@ -2505,34 +2540,36 @@ open_table_get_mdl_lock(THD *thd, Open_table_context *ot_ctx, /** - Check if table's share requires flush and if yes wait until it - will be flushed. + Check if table's share is being removed from the table definition + cache and, if yes, wait until the flush is complete. @param thd Thread context. @param table_list Table which share should be checked. @param timeout Timeout for waiting. @param deadlock_weight Weight of this wait for deadlock detector. - @retval FALSE - Success. Share is up to date or has been flushed. - @retval TRUE - Error (OOM, thread was killed, wait resulted in - deadlock or timeout). + @retval FALSE Success. Share is up to date or has been flushed. + @retval TRUE Error (OOM, our was killed, the wait resulted + in a deadlock or timeout). Reported. */ -static bool tdc_wait_for_old_version(THD *thd, TABLE_LIST *table_list, - ulong timeout, uint deadlock_weight) +static bool +tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name, + ulong wait_timeout, uint deadlock_weight) { TABLE_SHARE *share; + bool res= FALSE; - if ((share= get_cached_table_share(table_list->db, - table_list->table_name)) && - share->needs_reopen()) + mysql_mutex_lock(&LOCK_open); + if ((share= get_cached_table_share(db, table_name)) && + share->has_old_version()) { struct timespec abstime; - set_timespec(abstime, timeout); - return share->wait_until_flushed(&thd->mdl_context, &abstime, - deadlock_weight); + set_timespec(abstime, wait_timeout); + res= share->wait_for_old_version(thd, &abstime, deadlock_weight); } - return FALSE; + mysql_mutex_unlock(&LOCK_open); + return res; } @@ -2837,15 +2874,29 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB) DBUG_RETURN(FALSE); - mysql_mutex_lock(&LOCK_open); - retry_share: - if (!(share= get_table_share_with_create(thd, table_list, key, - key_length, OPEN_VIEW, - &error, - hash_value))) - goto err_unlock2; + mysql_mutex_lock(&LOCK_open); + + if (!(share= get_table_share_with_discover(thd, table_list, key, + key_length, OPEN_VIEW, + &error, + hash_value))) + { + mysql_mutex_unlock(&LOCK_open); + /* + If thd->is_error() is not set, we either need discover + (error == 7), or the error was silenced by the prelocking + handler (error == 0), in which case we should skip this + table. + */ + if (error == 7 && !thd->is_error()) + { + (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER, + table_list); + } + DBUG_RETURN(TRUE); + } if (share->is_view) { @@ -2898,7 +2949,7 @@ retry_share: if (!(flags & MYSQL_OPEN_IGNORE_FLUSH)) { - if (share->needs_reopen()) + if (share->has_old_version()) { /* We already have an MDL lock. But we have encountered an old @@ -2913,18 +2964,18 @@ retry_share: bool wait_result; release_table_share(share); + mysql_mutex_unlock(&LOCK_open); thd->push_internal_handler(&mdl_deadlock_handler); - wait_result= tdc_wait_for_old_version(thd, table_list, + wait_result= tdc_wait_for_old_version(thd, table_list->db, + table_list->table_name, ot_ctx->get_timeout(), mdl_ticket->get_deadlock_weight()); thd->pop_internal_handler(); if (wait_result) - { - mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(TRUE); - } + goto retry_share; } @@ -3058,7 +3109,6 @@ err_lock: mysql_mutex_lock(&LOCK_open); err_unlock: release_table_share(share); -err_unlock2: mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(TRUE); @@ -3480,7 +3530,7 @@ Locked_tables_list::reopen_tables(THD *thd) PRE-CONDITION(S) share is non-NULL - The LOCK_open mutex is locked + The LOCK_open mutex is locked. POST-CONDITION(S) @@ -3681,10 +3731,10 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias, cache_key_length); mysql_mutex_lock(&LOCK_open); - if (!(share= get_table_share_with_create(thd, table_list, cache_key, - cache_key_length, - OPEN_VIEW, &error, - hash_value))) + if (!(share= get_table_share(thd, table_list, cache_key, + cache_key_length, + OPEN_VIEW, &error, + hash_value))) goto err; if (share->is_view && @@ -3786,10 +3836,10 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list) cache_key_length); mysql_mutex_lock(&LOCK_open); - if (!(share= get_table_share_with_create(thd, table_list, cache_key, - cache_key_length, - OPEN_VIEW, ¬_used, - hash_value))) + if (!(share= get_table_share(thd, table_list, cache_key, + cache_key_length, + OPEN_VIEW, ¬_used, + hash_value))) goto end_unlock; if (share->is_view) @@ -3834,7 +3884,8 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list) release_table_share(share); /* Remove the repaired share from the table cache. */ tdc_remove_table(thd, TDC_RT_REMOVE_ALL, - table_list->db, table_list->table_name); + table_list->db, table_list->table_name, + TRUE); end_unlock: mysql_mutex_unlock(&LOCK_open); return result; @@ -3868,7 +3919,7 @@ request_backoff_action(enum_open_table_action action_arg, TABLE_LIST *table) { /* - A back off action may be one of the three kinds: + A back off action may be one of three kinds: * We met a broken table that needs repair, or a table that is not present on this MySQL server and needs re-discovery. @@ -3877,25 +3928,45 @@ request_backoff_action(enum_open_table_action action_arg, locks is very deadlock-prone. If this is a multi- statement transaction that holds metadata locks for completed statements, we don't do it, and report an error instead. + The action type in this case is OT_DISCOVER or OT_REPAIR. * Our attempt to acquire an MDL lock lead to a deadlock, detected by the MDL deadlock detector. The current session was chosen a victim. If this is a multi-statement - transaction that holds metadata locks for completed statements, - restarting locking for the current statement may lead - to a livelock. Thus, again, if m_has_locks is set, + transaction that holds metadata locks taken by completed + statements, restarting locking for the current statement + may lead to a livelock. Releasing locks of completed + statements can not be done as will lead to violation + of ACID. Thus, again, if m_has_locks is set, we report an error. Otherwise, when there are no metadata locks other than which belong to this statement, we can try to recover from error by releasing all locks and restarting the pre-locking. - * Finally, we could have met a TABLE_SHARE with old version. - Again, if this is a first statement in a transaction we can - close all tables, release all metadata locks and wait for - the old version to go away. Otherwise, waiting with MDL locks - may lead to criss-cross wait between this connection and a - connection that has an open table and waits on a metadata lock, - i.e. to a deadlock. - Since there is no way to detect such a deadlock, we prevent - it by reporting an error. + Similarly, a deadlock error can occur when the + pre-locking process met a TABLE_SHARE that is being + flushed, and unsuccessfully waited for the flush to + complete. A deadlock in this case can happen, e.g., + when our session is holding a metadata lock that + is being waited on by a session which is using + the table which is being flushed. The only way + to recover from this error is, again, to close all + open tables, release all locks, and retry pre-locking. + Action type name is OT_REOPEN_TABLES. Re-trying + while holding some locks may lead to a livelock, + and thus we don't do it. + * Finally, this session has open TABLEs from different + "generations" of the table cache. This can happen, e.g., + when, after this session has successfully opened one + table used for a statement, FLUSH TABLES interfered and + expelled another table used in it. FLUSH TABLES then + blocks and waits on the table already opened by this + statement. + We detect this situation by ensuring that table cache + version of all tables used in a statement is the same. + If it isn't, all tables needs to be reopened. + Note, that we can always perform a reopen in this case, + even if we already have metadata locks, since we don't + keep tables open between statements and a livelock + is not possible. */ if (action_arg != OT_REOPEN_TABLES && m_has_locks) { @@ -3943,7 +4014,7 @@ recover_from_failed_open(THD *thd) /* Execute the action. */ switch (m_action) { - case OT_CONFLICT: + case OT_BACKOFF_AND_RETRY: break; case OT_REOPEN_TABLES: break; @@ -3954,12 +4025,10 @@ recover_from_failed_open(THD *thd) MYSQL_OPEN_SKIP_TEMPORARY))) break; - mysql_mutex_lock(&LOCK_open); tdc_remove_table(thd, TDC_RT_REMOVE_ALL, m_failed_table->db, - m_failed_table->table_name); + m_failed_table->table_name, FALSE); ha_create_table_from_engine(thd, m_failed_table->db, m_failed_table->table_name); - mysql_mutex_unlock(&LOCK_open); thd->warning_info->clear_warning_info(thd->query_id); thd->clear_error(); // Clear error message @@ -3973,10 +4042,8 @@ recover_from_failed_open(THD *thd) MYSQL_OPEN_SKIP_TEMPORARY))) break; - mysql_mutex_lock(&LOCK_open); tdc_remove_table(thd, TDC_RT_REMOVE_ALL, m_failed_table->db, - m_failed_table->table_name); - mysql_mutex_unlock(&LOCK_open); + m_failed_table->table_name, FALSE); result= auto_repair_table(thd, m_failed_table); thd->mdl_context.release_transactional_locks(); @@ -5808,7 +5875,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) DBUG_ENTER("update_field_dependencies"); if (thd->mark_used_columns != MARK_COLUMNS_NONE) { - MY_BITMAP *current_bitmap, *other_bitmap; + MY_BITMAP *bitmap; /* We always want to register the used keys, as the column bitmap may have @@ -5819,15 +5886,9 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) table->merge_keys.merge(field->part_of_key); if (thd->mark_used_columns == MARK_COLUMNS_READ) - { - current_bitmap= table->read_set; - other_bitmap= table->write_set; - } + bitmap= table->read_set; else - { - current_bitmap= table->write_set; - other_bitmap= table->read_set; - } + bitmap= table->write_set; /* The test-and-set mechanism in the bitmap is not reliable during @@ -5836,7 +5897,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) only those columns that are used in the SET clause. I.e they are being set here. See multi_update::prepare() */ - if (bitmap_fast_test_and_set(current_bitmap, field->field_index)) + if (bitmap_fast_test_and_set(bitmap, field->field_index)) { if (thd->mark_used_columns == MARK_COLUMNS_WRITE) { @@ -8591,7 +8652,7 @@ void tdc_flush_unused_tables() mysql_mutex_lock(&LOCK_open); while (unused_tables) free_cache_entry(unused_tables); - (void) mysql_mutex_unlock(&LOCK_open); + mysql_mutex_unlock(&LOCK_open); } @@ -8685,21 +8746,27 @@ bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use, remove TABLE_SHARE). @param db Name of database @param table_name Name of table + @param has_lock If TRUE, LOCK_open is already acquired - @note Unlike remove_table_from_cache() it assumes that table instances - are already not used by any (other) thread (this should be achieved - by using meta-data locks). + @note It assumes that table instances are already not used by any + (other) thread (this should be achieved by using meta-data locks). */ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, - const char *db, const char *table_name) + const char *db, const char *table_name, + bool has_lock) { char key[MAX_DBKEY_LENGTH]; uint key_length; TABLE *table; TABLE_SHARE *share; - mysql_mutex_assert_owner(&LOCK_open); + if (! has_lock) + mysql_mutex_lock(&LOCK_open); + else + { + mysql_mutex_assert_owner(&LOCK_open); + } DBUG_ASSERT(remove_type == TDC_RT_REMOVE_UNUSED || thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name, @@ -8732,7 +8799,7 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, Set share's version to zero in order to ensure that it gets automatically deleted once it is no longer referenced. - Note that code in TABLE_SHARE::wait_until_flushed() assumes + Note that code in TABLE_SHARE::wait_for_old_version() assumes that marking share as old and removal of its unused tables and of the share itself from TDC happens atomically under protection of LOCK_open, or, putting it another way, that @@ -8747,6 +8814,9 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, else (void) my_hash_delete(&table_def_cache, (uchar*) share); } + + if (! has_lock) + mysql_mutex_unlock(&LOCK_open); } @@ -8873,11 +8943,6 @@ static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt) TABLE *table; DBUG_ENTER("alter_close_tables"); /* - We must keep LOCK_open while manipulating with thd->open_tables. - Another thread may be working on it. - */ - mysql_mutex_lock(&LOCK_open); - /* We can safely remove locks for all tables with the same name: later they will all be closed anyway in alter_partition_lock_handling(). @@ -8887,9 +8952,20 @@ static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt) if (!strcmp(table->s->table_name.str, share->table_name.str) && !strcmp(table->s->db.str, share->db.str)) { + /* + No need to take LOCK_thd_data to protect mysql_lock_remove(), + since mysql_lock_abort_for_thread() only aborts waiting + locks, and our lock is already granted. + */ mysql_lock_remove(thd, thd->lock, table); + /* + Protect members of thd->open_tables concurrently used + in mysql_notify_thread_having_shared_lock(). + */ + mysql_mutex_lock(&thd->LOCK_thd_data); table->file->close(); table->db_stat= 0; // Mark file closed + mysql_mutex_unlock(&thd->LOCK_thd_data); /* Ensure that we won't end up with a crippled table instance in the table cache if an error occurs before we reach @@ -8898,10 +8974,10 @@ static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt) */ tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table->s->db.str, - table->s->table_name.str); + table->s->table_name.str, + FALSE); } } - mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(0); } diff --git a/sql/sql_base.h b/sql/sql_base.h index 7d13b69e063..e59b20957d2 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -70,6 +70,7 @@ enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN, #define RTFC_CHECK_KILLED_FLAG 0x0004 bool check_dup(const char *db, const char *name, TABLE_LIST *tables); +extern mysql_mutex_t LOCK_open; bool table_cache_init(void); void table_cache_free(void); bool table_def_init(void); @@ -90,28 +91,10 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update, uint lock_flags); bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, Open_table_context *ot_ctx); -bool name_lock_locked_table(THD *thd, TABLE_LIST *tables); -bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in); -TABLE *table_cache_insert_placeholder(THD *thd, const char *key, - uint key_length); -bool lock_table_name_if_not_cached(THD *thd, const char *db, - const char *table_name, TABLE **table); -void detach_merge_children(TABLE *table, bool clear_refs); -bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last, - TABLE_LIST *new_child_list, TABLE_LIST **new_last); -bool reopen_table(TABLE *table); -bool reopen_tables(THD *thd,bool get_locks,bool in_refresh); -void close_data_files_and_morph_locks(THD *thd, const char *db, - const char *table_name); -void close_handle_and_leave_table_as_lock(TABLE *table); bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias, uint db_stat, uint prgflag, uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc, MEM_ROOT *mem_root); -bool wait_for_tables(THD *thd); -bool table_is_used(TABLE *table, bool wait_for_name_lock); -TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name); -void abort_locked_tables(THD *thd,const char *db, const char *table_name); bool get_key_map_from_key_list(key_map *map, TABLE *table, List<String> *index_list); @@ -190,12 +173,9 @@ bool setup_tables_and_check_access(THD *thd, ulong want_access); bool wait_while_table_is_used(THD *thd, TABLE *table, enum ha_extra_function function); -void unlink_open_table(THD *thd, TABLE *find, bool unlock); void drop_open_table(THD *thd, TABLE *table, const char *db_name, const char *table_name); -void close_all_tables_for_name(THD *thd, TABLE_SHARE *share, - bool remove_from_locked_tables); void update_non_unique_table_error(TABLE_LIST *update, const char *operation, TABLE_LIST *duplicate); @@ -223,7 +203,7 @@ int decide_logging_format(THD *thd, TABLE_LIST *tables); void free_io_cache(TABLE *entry); void intern_close_table(TABLE *entry); bool close_thread_table(THD *thd, TABLE **table_ptr); -void close_temporary_tables(THD *thd); +bool close_temporary_tables(THD *thd); TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, bool check_alias); int drop_temporary_table(THD *thd, TABLE_LIST *table_list); @@ -232,8 +212,6 @@ void close_temporary_table(THD *thd, TABLE *table, bool free_share, void close_temporary(TABLE *table, bool free_share, bool delete_table); bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db, const char *table_name); -void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table); -void remove_db_from_cache(const char *db); bool is_equal(const LEX_STRING *a, const LEX_STRING *b); /* Functions to work with system tables. */ @@ -249,18 +227,16 @@ TABLE *open_performance_schema_table(THD *thd, TABLE_LIST *one_table, Open_tables_state *backup); void close_performance_schema_table(THD *thd, Open_tables_state *backup); -bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, +bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool wait_for_refresh, ulong timeout); bool close_cached_connection_tables(THD *thd, bool wait_for_refresh, - LEX_STRING *connect_string, - bool have_lock = FALSE); + LEX_STRING *connect_string); void close_all_tables_for_name(THD *thd, TABLE_SHARE *share, bool remove_from_locked_tables); OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild); -bool remove_table_from_cache(THD *thd, const char *db, const char *table, - uint flags); void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, - const char *db, const char *table_name); + const char *db, const char *table_name, + bool has_lock); bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias, char *cache_key, uint cache_key_length, MEM_ROOT *mem_root, uint flags); @@ -271,12 +247,10 @@ TABLE *find_table_for_mdl_upgrade(TABLE *list, const char *db, void mark_tmp_table_for_reuse(TABLE *table); bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists); -extern uint table_cache_count; extern TABLE *unused_tables; extern Item **not_found_item; extern Field *not_found_field; extern Field *view_ref_found; -extern HASH open_cache; extern HASH table_def_cache; /** @@ -454,7 +428,7 @@ public: enum enum_open_table_action { OT_NO_ACTION= 0, - OT_CONFLICT, + OT_BACKOFF_AND_RETRY, OT_REOPEN_TABLES, OT_DISCOVER, OT_REPAIR diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index b73de320ef5..d6dc9edc502 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1673,7 +1673,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", thd->limit_found_rows = query->found_rows(); thd->status_var.last_query_cost= 0.0; - thd->stmt_da->disable_status(); + if (!thd->stmt_da->is_set()) + thd->stmt_da->disable_status(); BLOCK_UNLOCK_RD(query_block); MYSQL_QUERY_CACHE_HIT(thd->query(), (ulong) thd->limit_found_rows); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f3ef440c2f0..60a871e9e88 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -490,7 +490,6 @@ THD::THD() :Statement(&main_lex, &main_mem_root, CONVENTIONAL_EXECUTION, /* statement id */ 0), rli_fake(0), - lock_id(&main_lock_id), user_time(0), in_sub_stmt(0), binlog_unsafe_warning_flags(0), stmt_accessed_table_flag(0), @@ -624,7 +623,6 @@ THD::THD() randominit(&rand, tmp + (ulong) &rand, tmp + (ulong) ::global_query_id); substitute_null_with_insert_id = FALSE; thr_lock_info_init(&lock_info); /* safety: will be reset after start */ - thr_lock_owner_init(&main_lock_id, &lock_info); m_internal_handler= NULL; current_user_used= FALSE; @@ -847,35 +845,6 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno, } } - /* - If a continue handler is found, the error message will be cleared - by the stored procedures code. - */ - if (!is_fatal_error && spcont && - spcont->handle_condition(this, sql_errno, sqlstate, level, msg, &cond)) - { - /* - Do not push any warnings, a handled error must be completely - silenced. - */ - DBUG_RETURN(cond); - } - - /* Un-handled conditions */ - - cond= raise_condition_no_handler(sql_errno, sqlstate, level, msg); - DBUG_RETURN(cond); -} - -MYSQL_ERROR* -THD::raise_condition_no_handler(uint sql_errno, - const char* sqlstate, - MYSQL_ERROR::enum_warning_level level, - const char* msg) -{ - MYSQL_ERROR *cond= NULL; - DBUG_ENTER("THD::raise_condition_no_handler"); - query_cache_abort(&query_cache_tls); /* FIXME: broken special case */ @@ -888,6 +857,7 @@ THD::raise_condition_no_handler(uint sql_errno, cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg); DBUG_RETURN(cond); } + extern "C" void *thd_alloc(MYSQL_THD thd, unsigned int size) { @@ -1113,7 +1083,6 @@ THD::~THD() } #endif stmt_map.reset(); /* close all prepared statements */ - DBUG_ASSERT(lock_info.n_cursors == 0); if (!cleanup_done) cleanup(); @@ -1740,9 +1709,9 @@ bool select_send::send_result_set_metadata(List<Item> &list, uint flags) return res; } -void select_send::abort() +void select_send::abort_result_set() { - DBUG_ENTER("select_send::abort"); + DBUG_ENTER("select_send::abort_result_set"); if (is_result_set_started && thd->spcont) { @@ -2589,7 +2558,6 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg, id(id_arg), mark_used_columns(MARK_COLUMNS_READ), lex(lex_arg), - cursor(0), db(NULL), db_length(0) { @@ -2611,7 +2579,6 @@ void Statement::set_statement(Statement *stmt) mark_used_columns= stmt->mark_used_columns; lex= stmt->lex; query_string= stmt->query_string; - cursor= stmt->cursor; } @@ -4164,71 +4131,6 @@ THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*, Update_rows_log_event *); #endif -#ifdef NOT_USED -static char const* -field_type_name(enum_field_types type) -{ - switch (type) { - case MYSQL_TYPE_DECIMAL: - return "MYSQL_TYPE_DECIMAL"; - case MYSQL_TYPE_TINY: - return "MYSQL_TYPE_TINY"; - case MYSQL_TYPE_SHORT: - return "MYSQL_TYPE_SHORT"; - case MYSQL_TYPE_LONG: - return "MYSQL_TYPE_LONG"; - case MYSQL_TYPE_FLOAT: - return "MYSQL_TYPE_FLOAT"; - case MYSQL_TYPE_DOUBLE: - return "MYSQL_TYPE_DOUBLE"; - case MYSQL_TYPE_NULL: - return "MYSQL_TYPE_NULL"; - case MYSQL_TYPE_TIMESTAMP: - return "MYSQL_TYPE_TIMESTAMP"; - case MYSQL_TYPE_LONGLONG: - return "MYSQL_TYPE_LONGLONG"; - case MYSQL_TYPE_INT24: - return "MYSQL_TYPE_INT24"; - case MYSQL_TYPE_DATE: - return "MYSQL_TYPE_DATE"; - case MYSQL_TYPE_TIME: - return "MYSQL_TYPE_TIME"; - case MYSQL_TYPE_DATETIME: - return "MYSQL_TYPE_DATETIME"; - case MYSQL_TYPE_YEAR: - return "MYSQL_TYPE_YEAR"; - case MYSQL_TYPE_NEWDATE: - return "MYSQL_TYPE_NEWDATE"; - case MYSQL_TYPE_VARCHAR: - return "MYSQL_TYPE_VARCHAR"; - case MYSQL_TYPE_BIT: - return "MYSQL_TYPE_BIT"; - case MYSQL_TYPE_NEWDECIMAL: - return "MYSQL_TYPE_NEWDECIMAL"; - case MYSQL_TYPE_ENUM: - return "MYSQL_TYPE_ENUM"; - case MYSQL_TYPE_SET: - return "MYSQL_TYPE_SET"; - case MYSQL_TYPE_TINY_BLOB: - return "MYSQL_TYPE_TINY_BLOB"; - case MYSQL_TYPE_MEDIUM_BLOB: - return "MYSQL_TYPE_MEDIUM_BLOB"; - case MYSQL_TYPE_LONG_BLOB: - return "MYSQL_TYPE_LONG_BLOB"; - case MYSQL_TYPE_BLOB: - return "MYSQL_TYPE_BLOB"; - case MYSQL_TYPE_VAR_STRING: - return "MYSQL_TYPE_VAR_STRING"; - case MYSQL_TYPE_STRING: - return "MYSQL_TYPE_STRING"; - case MYSQL_TYPE_GEOMETRY: - return "MYSQL_TYPE_GEOMETRY"; - } - return "Unknown"; -} -#endif - - /* Declare in unnamed namespace. */ CPP_UNNAMED_NS_START diff --git a/sql/sql_class.h b/sql/sql_class.h index e96c3f8dd26..b23b65dae2f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -38,7 +38,7 @@ #include "protocol.h" /* Protocol_text, Protocol_binary */ #include "violite.h" /* vio_is_connected */ #include "thr_lock.h" /* thr_lock_type, THR_LOCK_DATA, - THR_LOCK_INFO, THR_LOCK_OWNER */ + THR_LOCK_INFO */ class Reprepare_observer; @@ -723,7 +723,6 @@ public: ENGINE INNODB STATUS. */ LEX_STRING query_string; - Server_side_cursor *cursor; inline char *query() { return query_string.str; } inline uint32 query_length() { return query_string.length; } @@ -1416,9 +1415,6 @@ public: struct system_status_var status_var; // Per thread statistic vars struct system_status_var *initial_status_var; /* used by show status */ THR_LOCK_INFO lock_info; // Locking info of this thread - THR_LOCK_OWNER main_lock_id; // To use for conventional queries - THR_LOCK_OWNER *lock_id; // If not main_lock_id, points to - // the lock_id of a cursor. /** Protects THD data accessed from other threads: - thd->query and thd->query_length (used by SHOW ENGINE @@ -2302,12 +2298,6 @@ public: { const char* old_msg = proc_info; mysql_mutex_assert_owner(mutex); - /* - This method should not be called with LOCK_open mutex as an - argument. Otherwise deadlocks can arise in MDL deadlock detector. - @sa TABLE_SHARE::find_deadlock(). - */ - DBUG_ASSERT(mutex != &LOCK_open); mysys_var->current_mutex = mutex; mysys_var->current_cond = cond; proc_info = msg; @@ -2810,23 +2800,6 @@ private: MYSQL_ERROR::enum_warning_level level, const char* msg); - /** - Raise a generic SQL condition, without activation any SQL condition - handlers. - This method is necessary to support the RESIGNAL statement, - which is allowed to bypass SQL exception handlers. - @param sql_errno the condition error number - @param sqlstate the condition SQLSTATE - @param level the condition level - @param msg the condition message text - @return The condition raised, or NULL - */ - MYSQL_ERROR* - raise_condition_no_handler(uint sql_errno, - const char* sqlstate, - MYSQL_ERROR::enum_warning_level level, - const char* msg); - public: /** Overloaded to guard query/query_length fields */ virtual void set_statement(Statement *stmt); @@ -2997,7 +2970,7 @@ public: @retval TRUE error, an error message is set */ virtual bool check_simple_select() const; - virtual void abort() {} + virtual void abort_result_set() {} /* Cleanup instance of this class for next execution of a prepared statement/stored procedure. @@ -3040,7 +3013,7 @@ public: bool send_data(List<Item> &items); bool send_eof(); virtual bool check_simple_select() const { return FALSE; } - void abort(); + void abort_result_set(); virtual void cleanup(); }; @@ -3132,7 +3105,7 @@ class select_insert :public select_result_interceptor { virtual bool can_rollback_data() { return 0; } void send_error(uint errcode,const char *err); bool send_eof(); - void abort(); + virtual void abort_result_set(); /* not implemented: select_insert is never re-used in prepared statements */ void cleanup(); }; @@ -3168,7 +3141,7 @@ public: void store_values(List<Item> &values); void send_error(uint errcode,const char *err); bool send_eof(); - void abort(); + virtual void abort_result_set(); virtual bool can_rollback_data() { return 1; } // Needed for access from local class MY_HOOKS in prepare(), since thd is proteted. @@ -3502,7 +3475,7 @@ public: { return deleted; } - virtual void abort(); + virtual void abort_result_set(); }; @@ -3553,7 +3526,7 @@ public: { return updated; } - virtual void abort(); + virtual void abort_result_set(); }; class my_var : public Sql_alloc { diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index 28d2bd8b4de..7a9834b4cde 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -19,61 +19,14 @@ #include "sql_priv.h" #include "unireg.h" #include "sql_cursor.h" -#include "sql_select.h" #include "probes_mysql.h" #include "sql_parse.h" // mysql_execute_command -#include "sql_base.h" /**************************************************************************** Declarations. ****************************************************************************/ /** - Sensitive_cursor -- a sensitive non-materialized server side - cursor. An instance of this class cursor has its own runtime - state -- list of used items and memory root for runtime memory, - open and locked tables, change list for the changes of the - parsed tree. This state is freed when the cursor is closed. -*/ - -class Sensitive_cursor: public Server_side_cursor -{ - MEM_ROOT main_mem_root; - Query_arena *stmt_arena; - JOIN *join; - TABLE *open_tables; - MYSQL_LOCK *lock; - TABLE *derived_tables; - /* List of items created during execution */ - query_id_t query_id; - struct Engine_info - { - handlerton *ht; - void *read_view; - }; - Engine_info ht_info[MAX_HA]; - Item_change_list change_list; - my_bool close_at_commit; - THR_LOCK_OWNER lock_id; -private: - /* bzero cursor state in THD */ - void reset_thd(THD *thd); -public: - Sensitive_cursor(THD *thd, select_result *result_arg); - - THR_LOCK_OWNER *get_lock_id() { return &lock_id; } - /* Save THD state into cursor */ - void post_open(THD *thd); - - virtual bool is_open() const { return join != 0; } - virtual int open(JOIN *join); - virtual void fetch(ulong num_rows); - virtual void close(); - virtual ~Sensitive_cursor(); -}; - - -/** Materialized_cursor -- an insensitive materialized server-side cursor. The result set of this cursor is saved in a temporary table at open. The cursor itself is simply an interface for the @@ -125,10 +78,9 @@ public: /**************************************************************************/ /** - Attempt to open a materialized or non-materialized cursor. + Attempt to open a materialized cursor. @param thd thread handle - @param[in] flags create a materialized cursor or not @param[in] result result class of the caller used as a destination for the rows fetched from the cursor @param[out] pcursor a pointer to store a pointer to cursor in @@ -141,37 +93,21 @@ public: non-zero an error, 'pcursor' has been left intact. */ -int mysql_open_cursor(THD *thd, uint flags, select_result *result, +int mysql_open_cursor(THD *thd, select_result *result, Server_side_cursor **pcursor) { - Sensitive_cursor *sensitive_cursor; select_result *save_result; Select_materialize *result_materialize; LEX *lex= thd->lex; int rc; - /* - The lifetime of the sensitive cursor is the same or less as the - lifetime of the runtime memory of the statement it's opened for. - */ if (! (result_materialize= new (thd->mem_root) Select_materialize(result))) return 1; - if (! (sensitive_cursor= new (thd->mem_root) Sensitive_cursor(thd, result))) - { - delete result_materialize; - result_materialize= NULL; - return 1; - } - save_result= lex->result; lex->result= result_materialize; - if (! (flags & (uint) ALWAYS_MATERIALIZED_CURSOR)) - { - thd->lock_id= sensitive_cursor->get_lock_id(); - thd->cursor= sensitive_cursor; - } + MYSQL_QUERY_EXEC_START(thd->query(), thd->thread_id, (char *) (thd->db ? thd->db : ""), @@ -182,20 +118,14 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result, MYSQL_QUERY_EXEC_DONE(rc); lex->result= save_result; - thd->lock_id= &thd->main_lock_id; - thd->cursor= 0; - /* Possible options here: - - a sensitive cursor is open. In this case rc is 0 and - result_materialize->materialized_cursor is NULL, or - a materialized cursor is open. In this case rc is 0 and result_materialize->materialized is not NULL - an error occurred during materialization. result_materialize->materialized_cursor is not NULL, but rc != 0 - successful completion of mysql_execute_command without - a cursor: rc is 0, result_materialize->materialized_cursor is NULL, - sensitive_cursor is not open. + a cursor: rc is 0, result_materialize->materialized_cursor is NULL. This is possible if some command writes directly to the network, bypassing select_result mechanism. An example of such command is SHOW VARIABLES or SHOW STATUS. @@ -204,23 +134,10 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result, { if (result_materialize->materialized_cursor) delete result_materialize->materialized_cursor; - goto err_open; - } - - if (sensitive_cursor->is_open()) - { - DBUG_ASSERT(!result_materialize->materialized_cursor); - /* - It's safer if we grab THD state after mysql_execute_command - is finished and not in Sensitive_cursor::open(), because - currently the call to Sensitive_cursor::open is buried deep - in JOIN::exec of the top level join. - */ - sensitive_cursor->post_open(thd); - *pcursor= sensitive_cursor; goto end; } - else if (result_materialize->materialized_cursor) + + if (result_materialize->materialized_cursor) { Materialized_cursor *materialized_cursor= result_materialize->materialized_cursor; @@ -228,18 +145,13 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result, if ((rc= materialized_cursor->open(0))) { delete materialized_cursor; - materialized_cursor= NULL; - goto err_open; + goto end; } *pcursor= materialized_cursor; thd->stmt_arena->cleanup_stmt(); - goto end; } -err_open: - DBUG_ASSERT(! (sensitive_cursor && sensitive_cursor->is_open())); - delete sensitive_cursor; end: delete result_materialize; return rc; @@ -271,280 +183,6 @@ void Server_side_cursor::operator delete(void *ptr, size_t size) DBUG_VOID_RETURN; } -/**************************************************************************** - Sensitive_cursor -****************************************************************************/ - -Sensitive_cursor::Sensitive_cursor(THD *thd, select_result *result_arg) - :Server_side_cursor(&main_mem_root, result_arg), - stmt_arena(0), - join(0), - close_at_commit(FALSE) -{ - /* We will overwrite it at open anyway. */ - init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0); - thr_lock_owner_init(&lock_id, &thd->lock_info); - bzero((void*) ht_info, sizeof(ht_info)); -} - - -/** - Save THD state into cursor. - - @todo - - What problems can we have with it if cursor is open? - - TODO: must be fixed because of the prelocked mode. -*/ -void -Sensitive_cursor::post_open(THD *thd) -{ - Engine_info *info; - /* - We need to save and reset thd->mem_root, otherwise it'll be - freed later in mysql_parse. - - We can't just change thd->mem_root here as we want to keep the - things that are already allocated in thd->mem_root for - Sensitive_cursor::fetch() - */ - *mem_root= *thd->mem_root; - stmt_arena= thd->stmt_arena; - state= stmt_arena->state; - /* Allocate a new memory root for thd */ - init_sql_alloc(thd->mem_root, - thd->variables.query_alloc_block_size, - thd->variables.query_prealloc_size); - - /* - Save tables and zero THD pointers to prevent table close in - close_thread_tables. - */ - derived_tables= thd->derived_tables; - open_tables= thd->open_tables; - lock= thd->lock; - query_id= thd->query_id; - free_list= thd->free_list; - thd->change_list.move_elements_to(&change_list); - reset_thd(thd); - /* Now we have an active cursor and can cause a deadlock */ - thd->lock_info.n_cursors++; - - close_at_commit= FALSE; /* reset in case we're reusing the cursor */ - info= &ht_info[0]; - for (Ha_trx_info *ha_trx_info= thd->transaction.stmt.ha_list; - ha_trx_info; ha_trx_info= ha_trx_info->next()) - { - handlerton *ht= ha_trx_info->ht(); - close_at_commit|= test(ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT); - if (ht->create_cursor_read_view) - { - info->ht= ht; - info->read_view= (ht->create_cursor_read_view)(ht, thd); - ++info; - } - } - /* - What problems can we have with it if cursor is open? - TODO: must be fixed because of the prelocked mode. - */ -} - - -/** - bzero cursor state in THD. -*/ - -void -Sensitive_cursor::reset_thd(THD *thd) -{ - thd->derived_tables= 0; - thd->set_open_tables(NULL); - thd->lock= 0; - thd->free_list= 0; - thd->change_list.empty(); -} - - -int -Sensitive_cursor::open(JOIN *join_arg) -{ - join= join_arg; - THD *thd= join->thd; - /* First non-constant table */ - JOIN_TAB *join_tab= join->join_tab + join->const_tables; - DBUG_ENTER("Sensitive_cursor::open"); - - join->change_result(result); - /* - Send fields description to the client; server_status is sent - in 'EOF' packet, which follows send_result_set_metadata(). - We don't simply use SEND_EOF flag of send_result_set_metadata because we also - want to flush the network buffer, which is done only in a standalone - send_eof(). - */ - result->send_result_set_metadata(*join->fields, Protocol::SEND_NUM_ROWS); - thd->server_status|= SERVER_STATUS_CURSOR_EXISTS; - result->send_eof(); - thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS; - - /* Prepare JOIN for reading rows. */ - join->tmp_table= 0; - join->join_tab[join->tables-1].next_select= setup_end_select_func(join); - join->send_records= 0; - join->fetch_limit= join->unit->offset_limit_cnt; - - /* Disable JOIN CACHE as it is not working with cursors yet */ - for (JOIN_TAB *tab= join_tab; - tab != join->join_tab + join->tables - 1; - tab++) - { - if (tab->next_select == sub_select_cache) - tab->next_select= sub_select; - } - - DBUG_ASSERT(join_tab->table->reginfo.not_exists_optimize == 0); - DBUG_ASSERT(join_tab->not_used_in_distinct == 0); - /* - null_row is set only if row not found and it's outer join: should never - happen for the first table in join_tab list - */ - DBUG_ASSERT(join_tab->table->null_row == 0); - DBUG_RETURN(0); -} - - -/** - Fetch next num_rows rows from the cursor and send them to the client. - - Precondition: - - Sensitive_cursor is open - - @param num_rows fetch up to this number of rows (maybe less) -*/ - -void -Sensitive_cursor::fetch(ulong num_rows) -{ - THD *thd= join->thd; - JOIN_TAB *join_tab= join->join_tab + join->const_tables; - enum_nested_loop_state error= NESTED_LOOP_OK; - Query_arena backup_arena; - Engine_info *info; - DBUG_ENTER("Sensitive_cursor::fetch"); - DBUG_PRINT("enter",("rows: %lu", num_rows)); - - DBUG_ASSERT(thd->derived_tables == 0 && thd->open_tables == 0 && - thd->lock == 0); - - thd->derived_tables= derived_tables; - thd->set_open_tables(open_tables); - thd->lock= lock; - thd->set_query_id(query_id); - change_list.move_elements_to(&thd->change_list); - /* save references to memory allocated during fetch */ - thd->set_n_backup_active_arena(this, &backup_arena); - - for (info= ht_info; info->read_view ; info++) - (info->ht->set_cursor_read_view)(info->ht, thd, info->read_view); - - join->fetch_limit+= num_rows; - - error= sub_select(join, join_tab, 0); - if (error == NESTED_LOOP_OK || error == NESTED_LOOP_NO_MORE_ROWS) - error= sub_select(join,join_tab,1); - if (error == NESTED_LOOP_QUERY_LIMIT) - error= NESTED_LOOP_OK; /* select_limit used */ - if (error == NESTED_LOOP_CURSOR_LIMIT) - join->resume_nested_loop= TRUE; - - ha_release_temporary_latches(thd); - - /* Grab free_list here to correctly free it in close */ - thd->restore_active_arena(this, &backup_arena); - - thd->change_list.move_elements_to(&change_list); - reset_thd(thd); - - for (info= ht_info; info->read_view; info++) - (info->ht->set_cursor_read_view)(info->ht, thd, 0); - - if (error == NESTED_LOOP_CURSOR_LIMIT) - { - /* Fetch limit worked, possibly more rows are there */ - thd->server_status|= SERVER_STATUS_CURSOR_EXISTS; - result->send_eof(); - thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS; - } - else - { - close(); - if (error == NESTED_LOOP_OK) - { - thd->server_status|= SERVER_STATUS_LAST_ROW_SENT; - result->send_eof(); - thd->server_status&= ~SERVER_STATUS_LAST_ROW_SENT; - } - else if (error != NESTED_LOOP_KILLED) - my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); - } - DBUG_VOID_RETURN; -} - - -/** - @todo - Another hack: we need to set THD state as if in a fetch to be - able to call stmt close. -*/ -void -Sensitive_cursor::close() -{ - THD *thd= join->thd; - DBUG_ENTER("Sensitive_cursor::close"); - - for (Engine_info *info= ht_info; info->read_view; info++) - { - (info->ht->close_cursor_read_view)(info->ht, thd, info->read_view); - info->read_view= 0; - info->ht= 0; - } - - change_list.move_elements_to(&thd->change_list); - { - /* - XXX: Another hack: we need to set THD state as if in a fetch to be - able to call stmt close. - */ - DBUG_ASSERT(lock || open_tables || derived_tables); - - TABLE *tmp_derived_tables= thd->derived_tables; - MYSQL_LOCK *tmp_lock= thd->lock; - - thd->set_open_tables(open_tables); - thd->derived_tables= derived_tables; - thd->lock= lock; - - close_thread_tables(thd); - /* Is expected to at least close tables and empty thd->change_list */ - stmt_arena->cleanup_stmt(); - - thd->set_open_tables(tmp_derived_tables); - thd->derived_tables= tmp_derived_tables; - thd->lock= tmp_lock; - } - thd->lock_info.n_cursors--; /* Decrease the number of active cursors */ - join= 0; - stmt_arena= 0; - free_items(); - DBUG_VOID_RETURN; -} - - -Sensitive_cursor::~Sensitive_cursor() -{ - if (is_open()) - close(); -} /*************************************************************************** Materialized_cursor @@ -570,7 +208,8 @@ Materialized_cursor::Materialized_cursor(select_result *result_arg, @param send_result_set_metadata List of fields that would be sent. */ -int Materialized_cursor::fill_item_list(THD *thd, List<Item> &send_result_set_metadata) +int Materialized_cursor::fill_item_list(THD *thd, + List<Item> &send_result_set_metadata) { Query_arena backup_arena; int rc; @@ -608,6 +247,7 @@ end: return rc || thd->is_error(); } + int Materialized_cursor::open(JOIN *join __attribute__((unused))) { THD *thd= fake_unit.thd; @@ -666,7 +306,12 @@ void Materialized_cursor::fetch(ulong num_rows) if ((res= table->file->rnd_next(table->record[0]))) break; /* Send data only if the read was successful. */ - result->send_data(item_list); + /* + If network write failed (i.e. due to a closed socked), + the error has already been set. Just return. + */ + if (result->send_data(item_list)) + return; } switch (res) { diff --git a/sql/sql_cursor.h b/sql/sql_cursor.h index 2a394e281b4..ed7bfac821a 100644 --- a/sql/sql_cursor.h +++ b/sql/sql_cursor.h @@ -32,11 +32,11 @@ class JOIN; */ /** - Server_side_cursor -- an interface for materialized and - sensitive (non-materialized) implementation of cursors. All - cursors are self-contained (created in their own memory root). - For that reason they must be deleted only using a pointer to - Server_side_cursor, not to its base class. + Server_side_cursor -- an interface for materialized + implementation of cursors. All cursors are self-contained + (created in their own memory root). For that reason they must + be deleted only using a pointer to Server_side_cursor, not to + its base class. */ class Server_side_cursor: protected Query_arena, public Sql_alloc @@ -60,11 +60,7 @@ public: }; -int mysql_open_cursor(THD *thd, uint flags, - select_result *result, +int mysql_open_cursor(THD *thd, select_result *result, Server_side_cursor **res); -/** Possible values for flags */ -enum { ANY_CURSOR= 1, ALWAYS_MATERIALIZED_CURSOR= 2 }; - #endif /* _sql_cusor_h_ */ diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index c94ea1302c8..2f69bac917e 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -59,6 +59,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, bool const_cond_result; ha_rows deleted= 0; bool reverse= FALSE; + bool skip_record; ORDER *order= (ORDER *) ((order_list && order_list->elements) ? order_list->first : NULL); uint usable_index= MAX_KEY; @@ -298,7 +299,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { thd->examined_row_count++; // thd->is_error() is tested to disallow delete row on error - if (!(select && select->skip_record())&& ! thd->is_error() ) + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (table->triggers && @@ -769,9 +770,9 @@ void multi_delete::send_error(uint errcode,const char *err) } -void multi_delete::abort() +void multi_delete::abort_result_set() { - DBUG_ENTER("multi_delete::abort"); + DBUG_ENTER("multi_delete::abort_result_set"); /* the error was handled or nothing deleted and no side effects return */ if (error_handled || diff --git a/sql/sql_error.cc b/sql/sql_error.cc index cc6529f7b10..8c038e10a1f 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -494,14 +494,6 @@ void Warning_info::clear_warning_info(ulonglong warn_id_arg) m_current_row_for_warning= 1; /* Start counting from the first row */ } -void Warning_info::reserve_space(THD *thd, uint count) -{ - /* Make room for count conditions */ - while ((m_warn_list.elements > 0) && - ((m_warn_list.elements + count) > thd->variables.max_error_count)) - m_warn_list.pop(); -} - /** Append warnings only if the original contents of the routine warning info was replaced. @@ -588,16 +580,11 @@ void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg)); /* - Calling push_warning/push_warning_printf with a - level of WARN_LEVEL_ERROR *is* a bug. - Either use my_error(), or WARN_LEVEL_WARN. - Please fix the calling code, and do *NOT* - add more work around code in the assert below. + Calling push_warning/push_warning_printf with a level of + WARN_LEVEL_ERROR *is* a bug. Either use my_printf_error(), + my_error(), or WARN_LEVEL_WARN. */ - DBUG_ASSERT( (level != MYSQL_ERROR::WARN_LEVEL_ERROR) - || (code == ER_CANT_CREATE_TABLE) /* See Bug#47233 */ - || (code == ER_ILLEGAL_HA_CREATE_OPTION) /* See Bug#47233 */ - ); + DBUG_ASSERT(level != MYSQL_ERROR::WARN_LEVEL_ERROR); if (level == MYSQL_ERROR::WARN_LEVEL_ERROR) level= MYSQL_ERROR::WARN_LEVEL_WARN; diff --git a/sql/sql_error.h b/sql/sql_error.h index 9e649a004df..87e98e27673 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -153,8 +153,8 @@ private: Representation of a SQL condition. A SQL condition can be a completion condition (note, warning), or an exception condition (error, not found). - @note This class is named MYSQL_ERROR instead of SQL_condition for historical reasons, - to facilitate merging code with previous releases. + @note This class is named MYSQL_ERROR instead of SQL_condition for + historical reasons, to facilitate merging code with previous releases. */ class MYSQL_ERROR : public Sql_alloc { @@ -471,18 +471,6 @@ public: ulong statement_warn_count() const { return m_statement_warn_count; } - /** - Reserve some space in the condition area. - This is a privileged operation, reserved for the RESIGNAL implementation, - as only the RESIGNAL statement is allowed to remove conditions from - the condition area. - For other statements, new conditions are not added to the condition - area once the condition area is full. - @param thd The current thread - @param count The number of slots to reserve - */ - void reserve_space(THD *thd, uint count); - /** Add a new condition to the current list. */ MYSQL_ERROR *push_warning(THD *thd, uint sql_errno, const char* sqlstate, diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index f1dddbb2eb5..a5c126a8521 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -934,7 +934,7 @@ void mysql_ha_flush(THD *thd) ((hash_tables->table->mdl_ticket && hash_tables->table->mdl_ticket->has_pending_conflicting_lock()) || (!hash_tables->table->s->tmp_table && - hash_tables->table->s->needs_reopen()))) + hash_tables->table->s->has_old_version()))) mysql_ha_close_table(thd, hash_tables); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cc0b6ba3a2d..ce9de4d2edf 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2705,7 +2705,7 @@ bool Delayed_insert::handle_inserts(void) thd_proc_info(&thd, "insert"); max_rows= delayed_insert_limit; - if (thd.killed || table->s->needs_reopen()) + if (thd.killed || table->s->has_old_version()) { thd.killed= THD::KILL_CONNECTION; max_rows= ULONG_MAX; // Do as much as possible @@ -3399,9 +3399,9 @@ bool select_insert::send_eof() DBUG_RETURN(0); } -void select_insert::abort() { +void select_insert::abort_result_set() { - DBUG_ENTER("select_insert::abort"); + DBUG_ENTER("select_insert::abort_result_set"); /* If the creation of the table failed (due to a syntax error, for example), no table will have been opened and therefore 'table' @@ -3600,11 +3600,9 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, */ if (open_table(thd, create_table, thd->mem_root, &ot_ctx)) { - mysql_mutex_lock(&LOCK_open); quick_rm_table(create_info->db_type, create_table->db, table_case_name(create_info, create_table->table_name), 0); - mysql_mutex_unlock(&LOCK_open); } else table= create_table->table; @@ -3938,9 +3936,9 @@ bool select_create::send_eof() } -void select_create::abort() +void select_create::abort_result_set() { - DBUG_ENTER("select_create::abort"); + DBUG_ENTER("select_create::abort_result_set"); /* In select_insert::abort() we roll back the statement, including @@ -3958,7 +3956,7 @@ void select_create::abort() log state. */ tmp_disable_binlog(thd); - select_insert::abort(); + select_insert::abort_result_set(); thd->transaction.stmt.modified_non_trans_table= FALSE; reenable_binlog(thd); /* possible error of writing binary log is ignored deliberately */ diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index eef139d5698..6411b194a8a 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -41,7 +41,6 @@ sys_var *trg_new_row_fake_var= (sys_var*) 0x01; LEX_STRING constant for null-string to be used in parser and other places. */ const LEX_STRING null_lex_str= {NULL, 0}; -const LEX_STRING empty_lex_str= { (char*) "", 0 }; /** @note The order of the elements of this array must correspond to the order of elements in enum_binlog_stmt_unsafe. @@ -153,7 +152,7 @@ st_parsing_options::reset() */ bool Lex_input_stream::init(THD *thd, - const char* buff, + char* buff, unsigned int length) { DBUG_EXECUTE_IF("bug42064_simulate_oom", @@ -183,7 +182,7 @@ bool Lex_input_stream::init(THD *thd, */ void -Lex_input_stream::reset(const char *buffer, unsigned int length) +Lex_input_stream::reset(char *buffer, unsigned int length) { yylineno= 1; yytoklen= 0; @@ -1428,11 +1427,10 @@ int lex_one_token(void *arg, void *yythd) ulong version; version=strtol(version_str, NULL, 10); - /* Accept 'M' 'm' 'm' 'd' 'd' */ - lip->yySkipn(5); - if (version <= MYSQL_VERSION_ID) { + /* Accept 'M' 'm' 'm' 'd' 'd' */ + lip->yySkipn(5); /* Expand the content of the special comment as real code */ lip->set_echo(TRUE); state=MY_LEX_START; @@ -1440,7 +1438,19 @@ int lex_one_token(void *arg, void *yythd) } else { + const char* version_mark= lip->get_ptr() - 1; + DBUG_ASSERT(*version_mark == '!'); + /* + Patch and skip the conditional comment to avoid it + being propagated infinitely (eg. to a slave). + */ + char *pcom= lip->yyUnput(' '); comment_closed= ! consume_comment(lip, 1); + if (! comment_closed) + { + DBUG_ASSERT(pcom == version_mark); + *pcom= '!'; + } /* version allowed to have one level of comment inside. */ } } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index b8bf3b220c9..f1b558b8be4 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -589,11 +589,11 @@ public: st_select_lex* outer_select(); st_select_lex* first_select() { - return my_reinterpret_cast(st_select_lex*)(slave); + return reinterpret_cast<st_select_lex*>(slave); } st_select_lex_unit* next_unit() { - return my_reinterpret_cast(st_select_lex_unit*)(next); + return reinterpret_cast<st_select_lex_unit*>(next); } st_select_lex* return_after_parsing() { return return_to; } void exclude_level(); @@ -995,8 +995,6 @@ enum xa_option_words {XA_NONE, XA_JOIN, XA_RESUME, XA_ONE_PHASE, XA_SUSPEND, XA_FOR_MIGRATE}; extern const LEX_STRING null_lex_str; -extern const LEX_STRING empty_lex_str; - class Sroutine_hash_entry; @@ -1394,9 +1392,9 @@ public: @retval FALSE OK @retval TRUE Error */ - bool init(THD *thd, const char *buff, unsigned int length); + bool init(THD *thd, char *buff, unsigned int length); - void reset(const char *buff, unsigned int length); + void reset(char *buff, unsigned int length); /** Set the echo mode. @@ -1512,6 +1510,20 @@ public: } /** + Puts a character back into the stream, canceling + the effect of the last yyGet() or yySkip(). + Note that the echo mode should not change between calls + to unput, get, or skip from the stream. + */ + char *yyUnput(char ch) + { + *--m_ptr= ch; + if (m_echo) + m_cpp_ptr--; + return m_ptr; + } + + /** End of file indicator for the query text to parse. @return true if there are no more characters to parse */ @@ -1668,7 +1680,7 @@ public: private: /** Pointer to the current position in the raw input stream. */ - const char *m_ptr; + char *m_ptr; /** Starting position of the last token parsed, in the raw buffer. */ const char *m_tok_start; @@ -2350,7 +2362,7 @@ public: @retval FALSE OK @retval TRUE Error */ - bool init(THD *thd, const char *buff, unsigned int length) + bool init(THD *thd, char *buff, unsigned int length) { return m_lip.init(thd, buff, length); } @@ -2361,7 +2373,7 @@ public: Lex_input_stream m_lip; Yacc_state m_yacc; - void reset(const char *found_semicolon, unsigned int length) + void reset(char *found_semicolon, unsigned int length) { m_lip.reset(found_semicolon, length); m_yacc.reset(); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index b2a816a69dd..d367c1c4fde 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -175,6 +175,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool is_fifo=0; #ifndef EMBEDDED_LIBRARY LOAD_FILE_INFO lf_info; + THD::killed_state killed_status= THD::NOT_KILLED; #endif char *db = table_list->db; // This is never null /* @@ -186,7 +187,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ulong skip_lines= ex->skip_lines; bool transactional_table; bool is_concurrent; - THD::killed_state killed_status= THD::NOT_KILLED; DBUG_ENTER("mysql_load"); #ifdef EMBEDDED_LIBRARY @@ -510,7 +510,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, error=1; thd->killed= THD::KILL_QUERY; };); - killed_status= (error == 0)? THD::NOT_KILLED : thd->killed; + +#ifndef EMBEDDED_LIBRARY + killed_status= (error == 0) ? THD::NOT_KILLED : thd->killed; +#endif + /* We must invalidate the table in query cache before binlog writing and ha_autocommit_... @@ -553,7 +557,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (lf_info.wrote_create_file) { int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); - + /* since there is already an error, the possible error of writing binary log will be ignored */ if (thd->transaction.stmt.modified_non_trans_table) @@ -767,12 +771,9 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, List_iterator_fast<Item> it(fields_vars); Item_field *sql_field; TABLE *table= table_list->table; - ulonglong id; bool err; DBUG_ENTER("read_fixed_length"); - id= 0; - while (!read_info.read_fixed_length()) { if (thd->killed) @@ -901,12 +902,10 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, Item *item; TABLE *table= table_list->table; uint enclosed_length; - ulonglong id; bool err; DBUG_ENTER("read_sep_field"); enclosed_length=enclosed.length(); - id= 0; for (;;it.rewind()) { diff --git a/sql/sql_map.cc b/sql/sql_map.cc deleted file mode 100644 index ca8a88bcbf8..00000000000 --- a/sql/sql_map.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 2000-2001, 2004-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include "sql_priv.h" -#include "unireg.h" // REQUIRED: for other includes -#include "sql_map.h" // mapped_files -#include "sql_class.h" // THD - -#include <sys/stat.h> -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#endif - -mapped_files::mapped_files(const char * filename,uchar *magic,uint magic_length) -{ -#ifdef HAVE_MMAP - name=my_strdup(filename,MYF(0)); - use_count=1; - error=0; - map=0; - size=0; - if ((file= mysql_file_open(key_file_map, name, O_RDONLY, MYF(MY_WME))) >= 0) - { - struct stat stat_buf; - if (!fstat(file, &stat_buf)) - { - if (!(map=(uchar*) my_mmap(0,(size_t)(size= stat_buf.st_size),PROT_READ, - MAP_SHARED | MAP_NORESERVE,file, - 0L))) - { - error=errno; - my_error(ER_NO_FILE_MAPPING, MYF(0), (char *) name, error); - } - } - if (map && memcmp(map,magic,magic_length)) - { - my_error(ER_WRONG_MAGIC, MYF(0), name); - (void) my_munmap((char*) map,(size_t)size); - map=0; - } - if (!map) - { - (void) mysql_file_close(file, MYF(0)); - file= -1; - } - } -#endif -} - - -mapped_files::~mapped_files() -{ -#ifdef HAVE_MMAP - if (file >= 0) - { - (void) my_munmap((char*) map,(size_t)size); - (void) mysql_file_close(file, MYF(0)); - file= -1; map=0; - } - my_free(name); -#endif -} - - -static I_List<mapped_files> maps_in_use; - -/* -** Check if a file is mapped. If it is, then return pointer to old map, -** else alloc new object -*/ - -mapped_files *map_file(const char * name,uchar *magic,uint magic_length) -{ -#ifdef HAVE_MMAP - mysql_mutex_lock(&LOCK_mapped_file); - I_List_iterator<mapped_files> list(maps_in_use); - mapped_files *map; - char path[FN_REFLEN]; - sprintf(path,"%s/%s/%s.uniq",mysql_data_home,current_thd->db,name); - (void) unpack_filename(path,path); - - while ((map=list++)) - { - if (!strcmp(path,map->name)) - break; - } - if (!map) - { - map=new mapped_files(path,magic,magic_length); - maps_in_use.append(map); - } - else - { - map->use_count++; - if (!map->map) - my_error(ER_NO_FILE_MAPPING, MYF(0), path, map->error); - } - mysql_mutex_unlock(&LOCK_mapped_file); - return map; -#else - return NULL; -#endif -} - -/* -** free the map if there are no more users for it -*/ - -void unmap_file(mapped_files *map) -{ -#ifdef HAVE_MMAP - mysql_mutex_lock(&LOCK_mapped_file); - if (!map->use_count--) - delete map; - mysql_mutex_unlock(&LOCK_mapped_file); -#endif -} - -/***************************************************************************** -** Instansiate templates -*****************************************************************************/ - -#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION -/* Used templates */ -template class I_List<mapped_files>; -template class I_List_iterator<mapped_files>; -#endif diff --git a/sql/sql_map.h b/sql/sql_map.h deleted file mode 100644 index be1c145df3f..00000000000 --- a/sql/sql_map.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef SQL_MAP_INCLUDED -#define SQL_MAP_INCLUDED - -/* Copyright (C) 2000-2001, 2005 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - -/* interface for memory mapped files */ - -#ifdef USE_PRAGMA_INTERFACE -#pragma interface /* gcc class implementation */ -#endif - -#include "my_base.h" /* ha_rows */ -#include "sql_list.h" /* ilink */ - -class mapped_files; -mapped_files *map_file(const char * name,uchar *magic,uint magic_length); -void unmap_file(mapped_files *map); - -class mapped_files :public ilink { - uchar *map; - ha_rows size; - char *name; // name of mapped file - File file; // >= 0 if open - int error; // If not mapped - uint use_count; - -public: - mapped_files(const char * name,uchar *magic,uint magic_length); - ~mapped_files(); - - friend class mapped_file; - friend mapped_files *map_file(const char * name,uchar *magic, - uint magic_length); - friend void unmap_file(mapped_files *map); -}; - - -class mapped_file -{ - mapped_files *file; -public: - mapped_file(const char * name,uchar *magic,uint magic_length) - { - file=map_file(name,magic,magic_length); /* old or new map */ - } - ~mapped_file() - { - unmap_file(file); /* free map */ - } - uchar *map() - { - return file->map; - } -}; - -#endif /* SQL_MAP_INCLUDED */ diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc deleted file mode 100644 index b957d1e9be4..00000000000 --- a/sql/sql_olap.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2000-2006 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - -/* - OLAP implementation by Sinisa Milivojevic <sinisa@mysql.com> - Inspired by code submitted by Srilakshmi <lakshmi@gdit.iiit.net> - - The ROLLUP code in this file has to be complitely rewritten as it's - not good enough to satisfy the goals of MySQL. - - In 4.1 we will replace this with a working, superior implementation - of ROLLUP. -*/ - -#ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1 - -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include "sql_priv.h" -#include "unireg.h" -#include "sql_select.h" - - -/**************************************************************************** - Functions that recursively actually creates new SELECT's - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - - -static int make_new_olap_select(LEX *lex, SELECT_LEX *select_lex, List<Item> new_fields) -{ - THD *thd=current_thd; - Item *item, *new_item; - Item_null *constant= new Item_null("ALL"); - - SELECT_LEX *new_select = (SELECT_LEX *) thd->memdup((char*) select_lex, sizeof(*select_lex)); - if (!new_select) - return 1; - lex->last_selects->next=new_select; - new_select->linkage=OLAP_TYPE; - new_select->olap=NON_EXISTING_ONE; - new_select->group_list.elements=0; - new_select->group_list.first=(uchar *)0; - new_select->group_list.next=(uchar **)&new_select->group_list.first; - List<Item> privlist; - - List_iterator<Item> list_it(select_lex->item_list); - List_iterator<Item> new_it(new_fields); - - while ((item=list_it++)) - { - bool not_found= TRUE; - if (item->type()==Item::FIELD_ITEM) - { - Item_field *iif = (Item_field *)item; - new_it.rewind(); - while ((new_item=new_it++)) - { - if (new_item->type()==Item::FIELD_ITEM && - !strcmp(((Item_field*)new_item)->table_name,iif->table_name) && - !strcmp(((Item_field*)new_item)->field_name,iif->field_name)) - { - not_found= 0; - ((Item_field*)new_item)->db_name=iif->db_name; - Item_field *new_one=new Item_field(&select_lex->context, - iif->db_name, iif->table_name, iif->field_name); - privlist.push_back(new_one); - if (add_to_list(new_select->group_list,new_one,1)) - return 1; - break; - } - } - } - if (not_found) - { - if (item->type() == Item::FIELD_ITEM) - privlist.push_back(constant); - else - privlist.push_back((Item*)thd->memdup((char *)item,item->size_of())); - } - } - new_select->item_list=privlist; - - lex->last_selects = new_select; - return 0; -} - -/**************************************************************************** - Functions that recursively creates combinations of queries for OLAP - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - -static int olap_combos(List<Item> old_fields, List<Item> new_fields, Item *item, LEX *lex, - SELECT_LEX *select_lex, int position, int selection, int num_fields, - int num_new_fields) -{ - int sl_return = 0; - if (position == num_new_fields) - { - if (item) - new_fields.push_front(item); - sl_return = make_new_olap_select(lex, select_lex, new_fields); - } - else - { - if (item) - new_fields.push_front(item); - while ((num_fields - num_new_fields >= selection - position) && !sl_return) - { - item = old_fields.pop(); - sl_return = olap_combos(old_fields, new_fields, item, lex, select_lex, position+1, ++selection, num_fields, num_new_fields); - } - } - return sl_return; -} - - -/**************************************************************************** - Top level function for converting OLAP clauses to multiple selects - This is also a place where clauses treatment depends on OLAP type - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - -int handle_olaps(LEX *lex, SELECT_LEX *select_lex) -{ - List<Item> item_list_copy, new_item_list; - item_list_copy.empty(); - new_item_list.empty(); - int count=select_lex->group_list.elements; - int sl_return=0; - - - lex->last_selects=select_lex; - - for (ORDER *order= select_lex->group_list.first ; order ; order=order->next) - item_list_copy.push_back(*(order->item)); - - List<Item> all_fields(select_lex->item_list); - - - if (setup_tables(lex->thd, &select_lex->context, &select_lex->top_join_list, - select_lex->table_list.first - &select_lex->leaf_tables, FALSE) || - setup_fields(lex->thd, 0, select_lex->item_list, MARK_COLUMNS_READ, - &all_fields,1) || - setup_fields(lex->thd, 0, item_list_copy, MARK_COLUMNS_READ, - &all_fields, 1)) - return -1; - - if (select_lex->olap == CUBE_TYPE) - { - for ( int i=count-1; i>=0 && !sl_return; i--) - sl_return=olap_combos(item_list_copy, new_item_list, (Item *)0, lex, select_lex, 0, 0, count, i); - } - else if (select_lex->olap == ROLLUP_TYPE) - { - for ( int i=count-1; i>=0 && !sl_return; i--) - { - Item *item; - item_list_copy.pop(); - List_iterator<Item> it(item_list_copy); - new_item_list.empty(); - while ((item = it++)) - new_item_list.push_front(item); - sl_return=make_new_olap_select(lex, select_lex, new_item_list); - } - } - else - sl_return=1; // impossible - return sl_return; -} - -#endif /* DISABLED_UNTIL_REWRITTEN_IN_4_1 */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7cb27ff4916..6305d2b4140 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1393,7 +1393,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { STATUS_VAR current_global_status_var; ulong uptime; - uint length; + uint length __attribute__((unused)); ulonglong queries_per_second1000; char buff[250]; uint buff_len= sizeof(buff); @@ -1406,7 +1406,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, else queries_per_second1000= thd->query_id * LL(1000) / uptime; - length= my_snprintf((char*) buff, buff_len - 1, + length= my_snprintf(buff, buff_len - 1, "Uptime: %lu Threads: %d Questions: %lu " "Slow queries: %lu Opens: %lu Flush tables: %lu " "Open tables: %u Queries per second avg: %u.%u", @@ -1511,7 +1511,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #endif if (MYSQL_QUERY_DONE_ENABLED() || MYSQL_COMMAND_DONE_ENABLED()) { - int res; + int res __attribute__((unused)); res= (int) thd->is_error(); if (command == COM_QUERY) { @@ -1794,11 +1794,9 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) table_list= table_list->next_global) { /* Request removal of table from cache. */ - mysql_mutex_lock(&LOCK_open); tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table_list->db, - table_list->table_name); - mysql_mutex_unlock(&LOCK_open); + table_list->table_name, FALSE); /* Skip views and temporary tables. */ table_list->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */ @@ -1806,9 +1804,9 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) } /* - Before opening and locking tables the below call also waits for old - shares to go away, so the fact that we don't pass MYSQL_LOCK_IGNORE_FLUSH - flag to it is important. + Before opening and locking tables the below call also waits + for old shares to go away, so the fact that we don't pass + MYSQL_LOCK_IGNORE_FLUSH flag to it is important. */ if (open_and_lock_tables(thd, all_tables, FALSE, MYSQL_OPEN_HAS_MDL_LOCK, @@ -3395,7 +3393,7 @@ end_with_restore_list: res|= thd->is_error(); MYSQL_MULTI_DELETE_DONE(res, del_result->num_deleted()); if (res) - del_result->abort(); + del_result->abort_result_set(); delete del_result; } else @@ -3418,7 +3416,7 @@ end_with_restore_list: /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */ thd->variables.option_bits|= OPTION_KEEP_LOG; } - /* DDL and binlog write order protected by LOCK_open */ + /* DDL and binlog write order are protected by metadata locks. */ res= mysql_rm_table(thd, first_table, lex->drop_if_exists, lex->drop_temporary); } @@ -4865,7 +4863,7 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables) ER_YES, str.ptr()); } if (res) - result->abort(); + result->abort_result_set(); else result->send_eof(); delete result; @@ -5824,16 +5822,16 @@ void mysql_init_multi_delete(LEX *lex) Parse a query. @param thd Current thread - @param inBuf Begining of the query text + @param rawbuf Begining of the query text @param length Length of the query text @param[out] found_semicolon For multi queries, position of the character of the next query in the query text. */ -void mysql_parse(THD *thd, const char *inBuf, uint length, +void mysql_parse(THD *thd, char *rawbuf, uint length, Parser_state *parser_state) { - int error; + int error __attribute__((unused)); DBUG_ENTER("mysql_parse"); DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on();); @@ -5857,7 +5855,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, lex_start(thd); mysql_reset_thd_for_next_command(thd); - if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0) + if (query_cache_send_result_to_client(thd, rawbuf, length) <= 0) { LEX *lex= thd->lex; @@ -5939,14 +5937,14 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, 1 can be ignored */ -bool mysql_test_parse_for_slave(THD *thd, char *inBuf, uint length) +bool mysql_test_parse_for_slave(THD *thd, char *rawbuf, uint length) { LEX *lex= thd->lex; bool error= 0; DBUG_ENTER("mysql_test_parse_for_slave"); Parser_state parser_state; - if (!(error= parser_state.init(thd, inBuf, length))) + if (!(error= parser_state.init(thd, rawbuf, length))) { lex_start(thd); mysql_reset_thd_for_next_command(thd); @@ -6065,7 +6063,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type, void store_position_for_column(const char *name) { - current_thd->lex->last_field->after=my_const_cast(char*) (name); + current_thd->lex->last_field->after=(char*) (name); } bool @@ -6858,10 +6856,11 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, tmp_write_to_binlog= 0; if (thd->global_read_lock.lock_global_read_lock(thd)) return 1; // Killed - if (close_cached_tables(thd, tables, FALSE, ((options & REFRESH_FAST) ? - FALSE : TRUE), thd->variables.lock_wait_timeout)) - result= 1; - + if (close_cached_tables(thd, tables, + ((options & REFRESH_FAST) ? FALSE : TRUE), + thd->variables.lock_wait_timeout)) + result= 1; + if (thd->global_read_lock.make_global_read_lock_block_commit(thd)) // Killed { /* Don't leave things in a half-locked state */ @@ -6898,10 +6897,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, } } - if (close_cached_tables(thd, tables, FALSE, ((options & REFRESH_FAST) ? - FALSE : TRUE), + if (close_cached_tables(thd, tables, + ((options & REFRESH_FAST) ? FALSE : TRUE), (thd ? thd->variables.lock_wait_timeout : - LONG_TIMEOUT))) + LONG_TIMEOUT))) result= 1; } my_dbopt_cleanup(); @@ -7543,28 +7542,6 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, if (select_lex->item_list.elements) { /* Check permissions for used tables in CREATE TABLE ... SELECT */ - -#ifdef NOT_NECESSARY_TO_CHECK_CREATE_TABLE_EXIST_WHEN_PREPARING_STATEMENT - /* This code throws an ill error for CREATE TABLE t1 SELECT * FROM t1 */ - /* - Only do the check for PS, because we on execute we have to check that - against the opened tables to ensure we don't use a table that is part - of the view (which can only be done after the table has been opened). - */ - if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute()) - { - /* - For temporary tables we don't have to check if the created table exists - */ - if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && - find_table_in_global_list(tables, create_table->db, - create_table->table_name)) - { - error= FALSE; - goto err; - } - } -#endif if (tables && check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE)) goto err; diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 7304836ed0f..8b7fe8f7b83 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -83,7 +83,7 @@ bool is_update_query(enum enum_sql_command command); bool is_log_table_write_query(enum enum_sql_command command); bool alloc_query(THD *thd, const char *packet, uint packet_length); void mysql_init_select(LEX *lex); -void mysql_parse(THD *thd, const char *inBuf, uint length, +void mysql_parse(THD *thd, char *rawbuf, uint length, Parser_state *parser_state); void mysql_reset_thd_for_next_command(THD *thd); bool mysql_new_select(LEX *lex, bool move_down); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 2c8b5d67d04..fb880cce8d3 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1071,7 +1071,6 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, partition_info *part_info= table->part_info; bool result= TRUE; int error; - const char *save_where; LEX *old_lex= thd->lex; LEX lex; uint8 saved_full_group_by_flag; @@ -1083,7 +1082,6 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, func_expr->walk(&Item::change_context_processor, 0, (uchar*) &lex.select_lex.context); - save_where= thd->where; thd->where= "partition function"; /* In execution we must avoid the use of thd->change_item_tree since @@ -4185,7 +4183,7 @@ void get_partition_set(const TABLE *table, uchar *buf, const uint index, */ bool mysql_unpack_partition(THD *thd, - const char *part_buf, uint part_info_len, + char *part_buf, uint part_info_len, TABLE* table, bool is_create_table_ind, handlerton *default_db_type, bool *work_part_info_used) diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 2e0ea740555..c644e63794c 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -110,7 +110,7 @@ void get_full_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info, const key_range *key_spec, part_id_range *part_spec); -bool mysql_unpack_partition(THD *thd, const char *part_buf, +bool mysql_unpack_partition(THD *thd, char *part_buf, uint part_info_len, TABLE *table, bool is_create_table_ind, handlerton *default_db_type, diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 27cd03d8edd..7e8c1fed999 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -901,19 +901,6 @@ static void plugin_del(struct st_plugin_int *plugin) DBUG_VOID_RETURN; } -#ifdef NOT_USED - -static void plugin_del(const LEX_STRING *name) -{ - struct st_plugin_int *plugin; - DBUG_ENTER("plugin_del(name)"); - if ((plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) - plugin_del(plugin); - DBUG_VOID_RETURN; -} - -#endif - static void reap_plugins(void) { uint count, idx; @@ -1394,51 +1381,6 @@ static bool register_builtin(struct st_mysql_plugin *plugin, DBUG_RETURN(0); } -#ifdef NOT_USED_YET -/* - Register a plugin at run time. (note, this doesn't initialize a plugin) - Will be useful for embedded applications. - - SYNOPSIS - plugin_register_builtin() - thd current thread (used to store scratch data in mem_root) - plugin static plugin to install - - RETURN - false - plugin registered successfully -*/ -bool plugin_register_builtin(THD *thd, struct st_mysql_plugin *plugin) -{ - struct st_plugin_int tmp, *ptr; - bool result= true; - int dummy_argc= 0; - DBUG_ENTER("plugin_register_builtin"); - - bzero(&tmp, sizeof(tmp)); - tmp.plugin= plugin; - tmp.name.str= (char *)plugin->name; - tmp.name.length= strlen(plugin->name); - - mysql_mutex_lock(&LOCK_plugin); - mysql_rwlock_wrlock(&LOCK_system_variables_hash); - - if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL)) - goto end; - tmp.state= PLUGIN_IS_UNINITIALIZED; - if ((result= register_builtin(plugin, &tmp, &ptr))) - { - mysql_del_sys_var_chain(tmp.system_vars); - restore_pluginvar_names(tmp.system_vars); - } - -end: - mysql_rwlock_unlock(&LOCK_system_variables_hash); - mysql_mutex_unlock(&LOCK_plugin); - - DBUG_RETURN(result);; -} -#endif /* NOT_USED_YET */ - /* called only by plugin_init() diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 151a135125e..a77dbe2dab4 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -152,6 +152,7 @@ public: THD *thd; Select_fetch_protocol_binary result; Item_param **param_array; + Server_side_cursor *cursor; uint param_count; uint last_errno; uint flags; @@ -352,8 +353,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) &stmt->lex->param_list, Protocol::SEND_EOF); } - /* Flag that a response has already been sent */ - thd->stmt_da->disable_status(); + + if (!error) + /* Flag that a response has already been sent */ + thd->stmt_da->disable_status(); + DBUG_RETURN(error); } #else @@ -2672,7 +2676,6 @@ void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length) if (!cursor->is_open()) { stmt->close_cursor(); - thd->cursor= 0; reset_stmt_params(stmt); } @@ -3010,6 +3013,7 @@ Prepared_statement::Prepared_statement(THD *thd_arg) thd(thd_arg), result(thd_arg), param_array(0), + cursor(0), param_count(0), last_errno(0), flags((uint) IS_IN_USE) @@ -3751,8 +3755,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) /* Go! */ if (open_cursor) - error= mysql_open_cursor(thd, (uint) ALWAYS_MATERIALIZED_CURSOR, - &result, &cursor); + error= mysql_open_cursor(thd, &result, &cursor); else { /* diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 708608fc2f1..f0f6a1969f5 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -59,8 +59,6 @@ (Old), (New)); \ } while(0) -extern char err_shared_dir[]; - /*************************************************************************/ #endif diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 301b22bd70e..97f8e46d052 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -147,13 +147,15 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent) MYSQL_OPEN_SKIP_TEMPORARY)) goto err; - mysql_mutex_lock(&LOCK_open); - for (ren_table= table_list; ren_table; ren_table= ren_table->next_local) tdc_remove_table(thd, TDC_RT_REMOVE_ALL, ren_table->db, - ren_table->table_name); + ren_table->table_name, FALSE); error=0; + /* + An exclusive lock on table names is satisfactory to ensure + no other thread accesses this table. + */ if ((ren_table=rename_tables(thd,table_list,0))) { /* Rename didn't succeed; rename back the tables in reverse order */ @@ -175,17 +177,6 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent) error= 1; } - /* - An exclusive lock on table names is satisfactory to ensure - no other thread accesses this table. - However, NDB assumes that handler::rename_tables is called under - LOCK_open. And it indeed is, from ALTER TABLE. - TODO: remove this limitation. - We still should unlock LOCK_open as early as possible, to provide - higher concurrency - query_cache_invalidate can take minutes to - complete. - */ - mysql_mutex_unlock(&LOCK_open); if (!silent && !error) { @@ -197,8 +188,6 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent) if (!error) query_cache_invalidate3(thd, table_list, 0); - thd->mdl_context.release_transactional_locks(); - err: thd->global_read_lock.start_waiting_global_read_lock(thd); DBUG_RETURN(error || binlog_error); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 5f994c09d6d..ab6c6e738b2 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -452,6 +452,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, #ifndef DBUG_OFF int left_events = max_binlog_dump_events; #endif + int old_max_allowed_packet= thd->variables.max_allowed_packet; DBUG_ENTER("mysql_binlog_send"); DBUG_PRINT("enter",("log_ident: '%s' pos: %ld", log_ident, (long) pos)); @@ -975,6 +976,7 @@ end: mysql_mutex_lock(&LOCK_thread_count); thd->current_linfo = 0; mysql_mutex_unlock(&LOCK_thread_count); + thd->variables.max_allowed_packet= old_max_allowed_packet; DBUG_VOID_RETURN; err: @@ -993,6 +995,7 @@ err: mysql_mutex_unlock(&LOCK_thread_count); if (file >= 0) mysql_file_close(file, MYF(MY_WME)); + thd->variables.max_allowed_packet= old_max_allowed_packet; my_message(my_errno, errmsg, MYF(0)); DBUG_VOID_RETURN; @@ -1394,12 +1397,9 @@ bool change_master(THD* thd, Master_info* mi) /* Before processing the command, save the previous state. */ - char *pos; - pos= strmake(saved_host, mi->host, HOSTNAME_LENGTH); - pos= '\0'; + strmake(saved_host, mi->host, HOSTNAME_LENGTH); saved_port= mi->port; - pos= strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); - pos= '\0'; + strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); saved_log_pos= mi->master_log_pos; /* @@ -1690,6 +1690,7 @@ bool mysql_show_binlog_events(THD* thd) IO_CACHE log; File file = -1; MYSQL_BIN_LOG *binary_log= NULL; + int old_max_allowed_packet= thd->variables.max_allowed_packet; DBUG_ENTER("mysql_show_binlog_events"); Log_event::init_show_field_list(&field_list); @@ -1844,6 +1845,7 @@ err: mysql_mutex_lock(&LOCK_thread_count); thd->current_linfo = 0; mysql_mutex_unlock(&LOCK_thread_count); + thd->variables.max_allowed_packet= old_max_allowed_packet; DBUG_RETURN(ret); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 11378ac0d11..ccfd93a1bc8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -33,7 +33,6 @@ #include "sql_select.h" #include "sql_cache.h" // query_cache_* #include "sql_table.h" // primary_key_name -#include "sql_cursor.h" #include "probes_mysql.h" #include "key.h" // key_copy, key_cmp, key_cmp_if_same #include "lock.h" // mysql_unlock_some_tables, @@ -300,7 +299,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, thd->is_error())); res|= thd->is_error(); if (unlikely(res)) - result->abort(); + result->abort_result_set(); MYSQL_SELECT_DONE((int) res, (ulong) thd->limit_found_rows); DBUG_RETURN(res); @@ -2340,35 +2339,13 @@ JOIN::exec() curr_join->fields= curr_fields_list; curr_join->procedure= procedure; - if (is_top_level_join() && thd->cursor && tables != const_tables) - { - /* - We are here if this is JOIN::exec for the last select of the main unit - and the client requested to open a cursor. - We check that not all tables are constant because this case is not - handled by do_select() separately, and this case is not implemented - for cursors yet. - */ - DBUG_ASSERT(error == 0); - /* - curr_join is used only for reusable joins - that is, - to perform SELECT for each outer row (like in subselects). - This join is main, so we know for sure that curr_join == join. - */ - DBUG_ASSERT(curr_join == this); - /* Open cursor for the last join sweep */ - error= thd->cursor->open(this); - } - else - { - thd_proc_info(thd, "Sending data"); - DBUG_PRINT("info", ("%s", thd->proc_info)); - result->send_result_set_metadata((procedure ? curr_join->procedure_fields_list : - *curr_fields_list), - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); - error= do_select(curr_join, curr_fields_list, NULL, procedure); - thd->limit_found_rows= curr_join->send_records; - } + thd_proc_info(thd, "Sending data"); + DBUG_PRINT("info", ("%s", thd->proc_info)); + result->send_result_set_metadata((procedure ? curr_join->procedure_fields_list : + *curr_fields_list), + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); + error= do_select(curr_join, curr_fields_list, NULL, procedure); + thd->limit_found_rows= curr_join->send_records; /* Accumulate the counts from all join iterations of all join parts. */ thd->examined_row_count+= curr_join->examined_rows; @@ -2563,16 +2540,6 @@ mysql_select(THD *thd, Item ***rref_pointer_array, join->exec(); - if (thd->cursor && thd->cursor->is_open()) - { - /* - A cursor was opened for the last sweep in exec(). - We are here only if this is mysql_select for top-level SELECT_LEX_UNIT - and there were no error. - */ - free_join= 0; - } - if (thd->lex->describe & DESCRIBE_EXTENDED) { select_lex->where= join->conds_history; @@ -11642,37 +11609,23 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) enum_nested_loop_state rc; READ_RECORD *info= &join_tab->read_record; - if (join->resume_nested_loop) - { - /* If not the last table, plunge down the nested loop */ - if (join_tab < join->join_tab + join->tables - 1) - rc= (*join_tab->next_select)(join, join_tab + 1, 0); - else - { - join->resume_nested_loop= FALSE; - rc= NESTED_LOOP_OK; - } - } - else - { - join->return_tab= join_tab; + join->return_tab= join_tab; - if (join_tab->last_inner) - { - /* join_tab is the first inner table for an outer join operation. */ - - /* Set initial state of guard variables for this table.*/ - join_tab->found=0; - join_tab->not_null_compl= 1; + if (join_tab->last_inner) + { + /* join_tab is the first inner table for an outer join operation. */ - /* Set first_unmatched for the last inner table of this group */ - join_tab->last_inner->first_unmatched= join_tab; - } - join->thd->warning_info->reset_current_row_for_warning(); + /* Set initial state of guard variables for this table.*/ + join_tab->found=0; + join_tab->not_null_compl= 1; - error= (*join_tab->read_first_record)(join_tab); - rc= evaluate_join_record(join, join_tab, error); + /* Set first_unmatched for the last inner table of this group */ + join_tab->last_inner->first_unmatched= join_tab; } + join->thd->warning_info->reset_current_row_for_warning(); + + error= (*join_tab->read_first_record)(join_tab); + rc= evaluate_join_record(join, join_tab, error); while (rc == NESTED_LOOP_OK) { @@ -11941,38 +11894,30 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skip_last) SQL_SELECT *select=join_tab->select; if (rc == NESTED_LOOP_OK) { - bool consider_record= !join_tab->cache.select || - !join_tab->cache.select->skip_record(); - - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) + bool skip_record= FALSE; + if (join_tab->cache.select && + join_tab->cache.select->skip_record(join->thd, &skip_record)) { reset_cache_write(&join_tab->cache); return NESTED_LOOP_ERROR; } - if (consider_record) + if (!skip_record) { uint i; reset_cache_read(&join_tab->cache); for (i=(join_tab->cache.records- (skip_last ? 1 : 0)) ; i-- > 0 ;) { read_cached_record(join_tab); - if (!select || !select->skip_record()) + skip_record= FALSE; + if (select && select->skip_record(join->thd, &skip_record)) { - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) - rc= NESTED_LOOP_ERROR; - else - rc= (join_tab->next_select)(join,join_tab+1,0); + reset_cache_write(&join_tab->cache); + return NESTED_LOOP_ERROR; + } + if (!skip_record) + { + rc= (join_tab->next_select)(join,join_tab+1,0); if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) { reset_cache_write(&join_tab->cache); @@ -12488,11 +12433,6 @@ join_ft_read_first(JOIN_TAB *tab) if (!table->file->inited) table->file->ha_index_init(tab->ref.key, 1); -#if NOT_USED_YET - /* as ft-key doesn't use store_key's, see also FT_SELECT::init() */ - if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref)) - return -1; -#endif table->file->ft_init(); if ((error= table->file->ft_read(table->record[0]))) @@ -12782,22 +12722,6 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { copy_fields(&join->tmp_table_param); copy_funcs(join->tmp_table_param.items_to_copy); -#ifdef TO_BE_DELETED - if (!table->uniques) // If not unique handling - { - /* Copy null values from group to row */ - ORDER *group; - for (group=table->group ; group ; group=group->next) - { - Item *item= *group->item; - if (item->maybe_null) - { - Field *field=item->get_tmp_table_field(); - field->ptr[-1]= (uchar) (field->is_null() ? 1 : 0); - } - } - } -#endif if (!join->having || join->having->val_int()) { int error; @@ -13273,7 +13197,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, DBUG_RETURN(0); } - if (key_part->field != field) + if (key_part->field != field || !field->part_of_sortkey.is_set(idx)) DBUG_RETURN(0); /* set flag to 1 if we can use read-next on key, else to -1 */ @@ -14005,44 +13929,6 @@ err: DBUG_RETURN(-1); } -#ifdef NOT_YET -/** - Add the HAVING criteria to table->select. -*/ - -static bool fix_having(JOIN *join, Item **having) -{ - (*having)->update_used_tables(); // Some tables may have been const - JOIN_TAB *table=&join->join_tab[join->const_tables]; - table_map used_tables= join->const_table_map | table->table->map; - - DBUG_EXECUTE("where",print_where(*having,"having", QT_ORDINARY);); - Item* sort_table_cond=make_cond_for_table(*having,used_tables,used_tables); - if (sort_table_cond) - { - if (!table->select) - if (!(table->select=new SQL_SELECT)) - return 1; - if (!table->select->cond) - table->select->cond=sort_table_cond; - else // This should never happen - if (!(table->select->cond= new Item_cond_and(table->select->cond, - sort_table_cond)) || - table->select->cond->fix_fields(join->thd, &table->select->cond)) - return 1; - table->select_cond=table->select->cond; - table->select_cond->top_level_item(); - DBUG_EXECUTE("where",print_where(table->select_cond, - "select and having", - QT_ORDINARY);); - *having=make_cond_for_table(*having,~ (table_map) 0,~used_tables); - DBUG_EXECUTE("where", - print_where(*having,"having after make_cond", QT_ORDINARY);); - } - return 0; -} -#endif - /***************************************************************************** Remove duplicates from tmp table diff --git a/sql/sql_select.h b/sql/sql_select.h index 0496870bb3f..40f9e6d4054 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -309,11 +309,6 @@ public: bool sort_and_group; bool first_record,full_join,group, no_field_update; bool do_send_rows; - /** - TRUE when we want to resume nested loop iterations when - fetching data from a cursor - */ - bool resume_nested_loop; table_map const_table_map,found_const_table_map; /* Bitmap of all inner tables from outer joins @@ -479,7 +474,6 @@ public: sort_and_group= 0; first_record= 0; do_send_rows= 1; - resume_nested_loop= FALSE; send_records= 0; found_records= 0; fetch_limit= HA_POS_ERROR; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index dc3784eb538..3f0c0b9eaf9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -460,8 +460,19 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db, continue; file_name_len= filename_to_tablename(file->name, uname, sizeof(uname)); - if (wild && wild_compare(uname, wild, 0)) - continue; + if (wild) + { + if (lower_case_table_names) + { + if (my_wildcmp(files_charset_info, + uname, uname + file_name_len, + wild, wild + wild_length, + wild_prefix, wild_one,wild_many)) + continue; + } + else if (wild_compare(uname, wild, 0)) + continue; + } if (!(file_name= thd->make_lex_string(file_name, uname, file_name_len, TRUE))) { @@ -2936,7 +2947,7 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex, */ if (res == FIND_FILES_DIR) { - if (lex->sql_command != SQLCOM_SELECT) + if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) return 1; thd->clear_error(); return 2; @@ -3262,8 +3273,8 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables, /* TODO: investigate if in this particular situation we can get by - simply obtaining internal lock of data-dictionary (ATM it - is LOCK_open) instead of obtaning full-blown metadata lock. + simply obtaining internal lock of the data-dictionary + instead of obtaining full-blown metadata lock. */ if (try_acquire_high_prio_shared_mdl_lock(thd, &table_list, can_deadlock)) { @@ -4126,7 +4137,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, uchar *pos; char tmp[MAX_FIELD_WIDTH]; String type(tmp,sizeof(tmp), system_charset_info); - char *end; DEBUG_SYNC(thd, "get_schema_column"); @@ -4147,7 +4157,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, field->field_name) & COL_ACLS; if (!tables->schema_table && !col_access) continue; - end= tmp; + char *end= tmp; for (uint bitnr=0; col_access ; col_access>>=1,bitnr++) { if (col_access & 1) @@ -4183,7 +4193,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[15]->store((const char*) pos, strlen((const char*) pos), cs); - end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs); if (timestamp_field == field && @@ -5714,52 +5723,6 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables, } -#ifdef NOT_USED -static interval_type get_real_interval_type(interval_type i_type) -{ - switch (i_type) { - case INTERVAL_YEAR: - return INTERVAL_YEAR; - - case INTERVAL_QUARTER: - case INTERVAL_YEAR_MONTH: - case INTERVAL_MONTH: - return INTERVAL_MONTH; - - case INTERVAL_WEEK: - case INTERVAL_DAY: - return INTERVAL_DAY; - - case INTERVAL_DAY_HOUR: - case INTERVAL_HOUR: - return INTERVAL_HOUR; - - case INTERVAL_DAY_MINUTE: - case INTERVAL_HOUR_MINUTE: - case INTERVAL_MINUTE: - return INTERVAL_MINUTE; - - case INTERVAL_DAY_SECOND: - case INTERVAL_HOUR_SECOND: - case INTERVAL_MINUTE_SECOND: - case INTERVAL_SECOND: - return INTERVAL_SECOND; - - case INTERVAL_DAY_MICROSECOND: - case INTERVAL_HOUR_MICROSECOND: - case INTERVAL_MINUTE_MICROSECOND: - case INTERVAL_SECOND_MICROSECOND: - case INTERVAL_MICROSECOND: - return INTERVAL_MICROSECOND; - case INTERVAL_LAST: - DBUG_ASSERT(0); - } - DBUG_ASSERT(0); - return INTERVAL_SECOND; -} - -#endif - #ifdef HAVE_EVENT_SCHEDULER /* Loads an event from mysql.event and copies it's data to a row of @@ -7694,7 +7657,7 @@ static bool show_create_trigger_impl(THD *thd, */ static -TABLE_LIST *get_trigger_table_impl(THD *thd, const sp_name *trg_name) +TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name) { char trn_path_buff[FN_REFLEN]; LEX_STRING trn_path= { trn_path_buff, 0 }; @@ -7731,39 +7694,6 @@ TABLE_LIST *get_trigger_table_impl(THD *thd, const sp_name *trg_name) return table; } -/** - Read TRN and TRG files to obtain base table name for the specified - trigger name and construct TABE_LIST object for the base table. Acquire - LOCK_open when doing this. - - @param thd Thread context. - @param trg_name Trigger name. - - @return TABLE_LIST object corresponding to the base table. -*/ - -static -TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name) -{ - /* Acquire LOCK_open (stop the server). */ - - mysql_mutex_lock(&LOCK_open); - - /* - Load base table name from the TRN-file and create TABLE_LIST object. - */ - - TABLE_LIST *lst= get_trigger_table_impl(thd, trg_name); - - /* Release LOCK_open (continue the server). */ - - mysql_mutex_unlock(&LOCK_open); - - /* That's it. */ - - return lst; -} - /** SHOW CREATE TRIGGER high-level implementation. diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc index f340da373e8..09e9a828fa1 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -499,18 +499,6 @@ bool Resignal_statement::execute(THD *thd) } /* RESIGNAL with signal_value */ - - /* Make room for 2 conditions */ - thd->warning_info->reserve_space(thd, 2); - - MYSQL_ERROR *raised= NULL; - raised= thd->raise_condition_no_handler(signaled->get_sql_errno(), - signaled->get_sqlstate(), - signaled->get_level(), - signaled->get_message_text()); - if (raised) - raised->copy_opt_attributes(signaled); - result= raise_condition(thd, signaled); DBUG_RETURN(result); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 42b3dfaad83..5e1133fc6d8 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1723,7 +1723,6 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) completing this we write a new phase to the log entry that will deactivate it. */ - mysql_mutex_lock(&LOCK_open); if (mysql_file_delete(key_file_frm, frm_name, MYF(MY_WME)) || #ifdef WITH_PARTITION_STORAGE_ENGINE lpt->table->file->ha_create_handler_files(path, shadow_path, @@ -1779,12 +1778,12 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) #endif err: - mysql_mutex_unlock(&LOCK_open); #ifdef WITH_PARTITION_STORAGE_ENGINE deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos); part_info->frm_log_entry= NULL; (void) sync_ddl_log(); #endif + ; } end: @@ -1955,10 +1954,11 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (lock_table_names(thd, tables, NULL, thd->variables.lock_wait_timeout, MYSQL_OPEN_SKIP_TEMPORARY)) DBUG_RETURN(1); - mysql_mutex_lock(&LOCK_open); for (table= tables; table; table= table->next_local) - tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db, table->table_name); - mysql_mutex_unlock(&LOCK_open); + { + tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db, table->table_name, + FALSE); + } } else { @@ -2104,14 +2104,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, table->internal_tmp_table ? FN_IS_TMP : 0); } - /* - TODO: Investigate what should be done to remove this lock completely. - Is exclusive meta-data lock enough ? - */ DEBUG_SYNC(thd, "rm_table_part2_before_delete_table"); DBUG_EXECUTE_IF("sleep_before_part2_delete_table", my_sleep(100000);); - mysql_mutex_lock(&LOCK_open); if (drop_temporary || ((access(path, F_OK) && ha_create_table_from_engine(thd, db, alias)) || @@ -2131,8 +2126,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, char *end; /* Cannot use the db_type from the table, since that might have changed - while waiting for the exclusive name lock. We are under LOCK_open, - so reading from the frm-file is safe. + while waiting for the exclusive name lock. */ if (frm_db_type == DB_TYPE_UNKNOWN) { @@ -2173,7 +2167,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, error|= new_error; } } - mysql_mutex_unlock(&LOCK_open); if (error) { if (wrong_tables.length()) @@ -4053,7 +4046,6 @@ bool mysql_create_table_no_lock(THD *thd, goto err; } - mysql_mutex_lock(&LOCK_open); if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { if (!access(path,F_OK)) @@ -4061,7 +4053,7 @@ bool mysql_create_table_no_lock(THD *thd, if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) goto warn; my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); - goto unlock_and_end; + goto err; } /* We don't assert here, but check the result, because the table could be @@ -4071,11 +4063,14 @@ bool mysql_create_table_no_lock(THD *thd, Then she could create the table. This case is pretty obscure and therefore we don't introduce a new error message only for it. */ + mysql_mutex_lock(&LOCK_open); if (get_cached_table_share(db, table_name)) { + mysql_mutex_unlock(&LOCK_open); my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name); - goto unlock_and_end; + goto err; } + mysql_mutex_unlock(&LOCK_open); } /* @@ -4083,7 +4078,7 @@ bool mysql_create_table_no_lock(THD *thd, exist in any storage engine. In such a case it should be discovered and the error ER_TABLE_EXISTS_ERROR be returned unless user specified CREATE TABLE IF EXISTS - The LOCK_open mutex has been locked to make sure no + An exclusive metadata lock ensures that no one else is attempting to discover the table. Since it's not on disk as a frm file, no one could be using it! */ @@ -4104,12 +4099,12 @@ bool mysql_create_table_no_lock(THD *thd, if (create_if_not_exists) goto warn; my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); - goto unlock_and_end; + goto err; break; default: DBUG_PRINT("info", ("error: %u from storage engine", retcode)); my_error(retcode, MYF(0),table_name); - goto unlock_and_end; + goto err; } } @@ -4142,7 +4137,7 @@ bool mysql_create_table_no_lock(THD *thd, if (test_if_data_home_dir(dirpath)) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY"); - goto unlock_and_end; + goto err; } } if (create_info->index_file_name) @@ -4151,7 +4146,7 @@ bool mysql_create_table_no_lock(THD *thd, if (test_if_data_home_dir(dirpath)) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY"); - goto unlock_and_end; + goto err; } } } @@ -4159,7 +4154,7 @@ bool mysql_create_table_no_lock(THD *thd, #ifdef WITH_PARTITION_STORAGE_ENGINE if (check_partition_dirs(thd->lex->part_info)) { - goto unlock_and_end; + goto err; } #endif /* WITH_PARTITION_STORAGE_ENGINE */ @@ -4182,7 +4177,7 @@ bool mysql_create_table_no_lock(THD *thd, if (rea_create_table(thd, path, db, table_name, create_info, alter_info->create_list, key_count, key_info_buffer, file)) - goto unlock_and_end; + goto err; if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { @@ -4190,15 +4185,12 @@ bool mysql_create_table_no_lock(THD *thd, if (!(open_temporary_table(thd, path, db, table_name, 1))) { (void) rm_temporary_table(create_info->db_type, path); - goto unlock_and_end; + goto err; } thd->thread_specific_used= TRUE; } error= FALSE; -unlock_and_end: - mysql_mutex_unlock(&LOCK_open); - err: thd_proc_info(thd, "After create"); delete file; @@ -4210,7 +4202,7 @@ warn: ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), alias); create_info->table_existed= 1; // Mark that table existed - goto unlock_and_end; + goto err; } @@ -4459,20 +4451,19 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, hash_value= my_calc_hash(&table_def_cache, (uchar*) key, key_length); mysql_mutex_lock(&LOCK_open); - if (!(share= (get_table_share(thd, table_list, key, key_length, 0, - &error, hash_value)))) - { - mysql_mutex_unlock(&LOCK_open); + share= get_table_share(thd, table_list, key, key_length, 0, + &error, hash_value); + mysql_mutex_unlock(&LOCK_open); + if (share == NULL) DBUG_RETURN(0); // Can't open frm file - } if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, FALSE)) { + mysql_mutex_lock(&LOCK_open); release_table_share(share); mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(0); // Out of memory } - mysql_mutex_unlock(&LOCK_open); table= &tmp_table; } @@ -5136,15 +5127,14 @@ send_result_message: } else if (open_for_modify || fatal_error) { - mysql_mutex_lock(&LOCK_open); tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, - table->db, table->table_name); - mysql_mutex_unlock(&LOCK_open); + table->db, table->table_name, FALSE); /* May be something modified. Consequently, we have to invalidate the query cache. */ - query_cache_invalidate3(thd, table->table, 0); + table->table= 0; // For query cache + query_cache_invalidate3(thd, table, 0); } } /* Error path, a admin command failed. */ @@ -5152,7 +5142,6 @@ send_result_message: trans_commit_implicit(thd); close_thread_tables(thd); thd->mdl_context.release_transactional_locks(); - table->table=0; // For query cache /* If it is CHECK TABLE v1, v2, v3, and v1, v2, v3 are views, we will run @@ -6473,7 +6462,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, uint index_add_count= 0; uint *index_add_buffer= NULL; uint candidate_key_count= 0; - bool committed= 0; bool no_pk; DBUG_ENTER("mysql_alter_table"); @@ -6776,7 +6764,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, else { *fn_ext(new_name)=0; - mysql_mutex_lock(&LOCK_open); if (mysql_rename_table(old_db_type,db,table_name,new_db,new_alias, 0)) error= -1; else if (Table_triggers_list::change_table_name(thd, db, table_name, @@ -6786,7 +6773,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, table_name, 0); error= -1; } - mysql_mutex_unlock(&LOCK_open); } } @@ -7302,7 +7288,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, DBUG_PRINT("info", ("Committing before unlocking table")); if (trans_commit_stmt(thd) || trans_commit_implicit(thd)) goto err_new_table_cleanup; - committed= 1; } /*end of if (! new_table) for add/drop index*/ @@ -7312,12 +7297,22 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (table->s->tmp_table != NO_TMP_TABLE) { /* Close lock if this is a transactional table */ - if (thd->lock && - ! (thd->locked_tables_mode == LTM_LOCK_TABLES || - thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) + if (thd->lock) { - mysql_unlock_tables(thd, thd->lock); - thd->lock=0; + if (thd->locked_tables_mode != LTM_LOCK_TABLES && + thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + mysql_unlock_tables(thd, thd->lock); + thd->lock=0; + } + else + { + /* + If LOCK TABLES list is not empty and contains this table, + unlock the table and remove the table from this list. + */ + mysql_lock_remove(thd, thd->lock, table); + } } /* Remove link to old table and rename the new one */ close_temporary_table(thd, table, 1, 1); @@ -7396,7 +7391,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, /* This type cannot happen in regular ALTER. */ new_db_type= old_db_type= NULL; } - mysql_mutex_lock(&LOCK_open); if (mysql_rename_table(old_db_type, db, table_name, db, old_name, FN_TO_IS_TMP)) { @@ -7423,8 +7417,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (! error) (void) quick_rm_table(old_db_type, db, old_name, FN_IS_TMP); - mysql_mutex_unlock(&LOCK_open); - if (error) { /* This shouldn't happen. But let us play it safe. */ diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 501c4cf6a94..9d0614f8529 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -118,7 +118,7 @@ static void print_cached_tables(void) printf("unused_links isn't linked properly\n"); return; } - } while (count++ < table_cache_count && (lnk=lnk->next) != start_link); + } while (count++ < cached_open_tables() && (lnk=lnk->next) != start_link); if (lnk != start_link) { printf("Unused_links aren't connected\n"); @@ -416,7 +416,7 @@ static void display_table_locks(void) void *saved_base; DYNAMIC_ARRAY saved_table_locks; - (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO), table_cache_count + 20,50); + (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO), cached_open_tables() + 20,50); mysql_mutex_lock(&THR_LOCK_lock); for (list= thr_lock_thread_list; list; list= list_rest(list)) { diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index a5664b00287..b81461e8371 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -394,9 +394,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) /* We don't want perform our operations while global read lock is held so we have to wait until its end and then prevent it from occurring - again until we are done, unless we are under lock tables. (Acquiring - LOCK_open is not enough because global read lock is held without holding - LOCK_open). + again until we are done, unless we are under lock tables. */ if (!thd->locked_tables_mode && thd->global_read_lock.wait_if_global_read_lock(thd, FALSE, TRUE)) @@ -516,11 +514,9 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) goto end; } - mysql_mutex_lock(&LOCK_open); result= (create ? table->triggers->create_trigger(thd, tables, &stmt_query): table->triggers->drop_trigger(thd, tables, &stmt_query)); - mysql_mutex_unlock(&LOCK_open); if (result) goto end; @@ -1680,9 +1676,6 @@ bool add_table_for_trigger(THD *thd, @param db schema for table @param name name for table - @note - The calling thread should hold the LOCK_open mutex; - @retval False success @retval @@ -1912,14 +1905,10 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, /* This method interfaces the mysql server code protected by - either LOCK_open mutex or with an exclusive metadata lock. - In the future, only an exclusive metadata lock will be enough. + an exclusive metadata lock. */ -#ifndef DBUG_OFF - if (thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, old_table, - MDL_EXCLUSIVE)) - mysql_mutex_assert_owner(&LOCK_open); -#endif + DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, old_table, + MDL_EXCLUSIVE)); DBUG_ASSERT(my_strcasecmp(table_alias_charset, db, new_db) || my_strcasecmp(table_alias_charset, old_table, new_table)); diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index ee5c707cd69..38e32082388 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -310,10 +310,8 @@ static bool open_and_lock_table_for_truncate(THD *thd, TABLE_LIST *table_ref, upgrade_shared_lock_to_exclusive(table_ref->mdl_request.ticket, timeout)) DBUG_RETURN(TRUE); - mysql_mutex_lock(&LOCK_open); tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table_ref->db, - table_ref->table_name); - mysql_mutex_unlock(&LOCK_open); + table_ref->table_name, FALSE); } } else diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 9ca4556524f..acc0f704c44 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -36,8 +36,7 @@ bool mysql_union(THD *thd, LEX *lex, select_result *result, if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | setup_tables_done_option))) res= unit->exec(); - if (res || !thd->cursor || !thd->cursor->is_open()) - res|= unit->cleanup(); + res|= unit->cleanup(); DBUG_RETURN(res); } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 25c1fd6fa1e..35478e28520 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -477,7 +477,14 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record= FALSE; + if (select && select->skip_record(thd, &skip_record)) + { + error= 1; + table->file->unlock_row(); + break; + } + if (!skip_record) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ @@ -584,7 +591,8 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record; + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ @@ -1253,7 +1261,7 @@ bool mysql_multi_update(THD *thd, { /* If we had a another error reported earlier then this will be ignored */ (*result)->send_error(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR)); - (*result)->abort(); + (*result)->abort_result_set(); } thd->abort_on_warning= 0; DBUG_RETURN(res); @@ -1853,7 +1861,7 @@ void multi_update::send_error(uint errcode,const char *err) } -void multi_update::abort() +void multi_update::abort_result_set() { /* the error was handled or nothing deleted and no side effects return */ if (error_handled || diff --git a/sql/sql_view.cc b/sql/sql_view.cc index be13349b5a1..b6671d9096b 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -658,7 +658,6 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, goto err; } - mysql_mutex_lock(&LOCK_open); res= mysql_register_view(thd, view, mode); if (mysql_bin_log.is_open()) @@ -705,7 +704,6 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, res= TRUE; } - mysql_mutex_unlock(&LOCK_open); if (mode != VIEW_CREATE_NEW) query_cache_invalidate3(thd, view, 0); thd->global_read_lock.start_waiting_global_read_lock(thd); @@ -1656,10 +1654,8 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) MYSQL_OPEN_SKIP_TEMPORARY)) DBUG_RETURN(TRUE); - mysql_mutex_lock(&LOCK_open); for (view= views; view; view= view->next_local) { - TABLE_SHARE *share; frm_type_enum type= FRMTYPE_ERROR; build_table_filename(path, sizeof(path) - 1, view->db, view->table_name, reg_ext, 0); @@ -1698,16 +1694,12 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) some_views_deleted= TRUE; /* - For a view, there is only one table_share object which should never - be used outside of LOCK_open + For a view, there is a TABLE_SHARE object, but its + ref_count never goes above 1. Remove it from the table + definition cache, in case the view was cached. */ - if ((share= get_cached_table_share(view->db, view->table_name))) - { - DBUG_ASSERT(share->ref_count == 0); - share->ref_count++; - share->version= 0; - release_table_share(share); - } + tdc_remove_table(thd, TDC_RT_REMOVE_ALL, view->db, view->table_name, + FALSE); query_cache_invalidate3(thd, view, 0); sp_cache_invalidate(); } @@ -1732,8 +1724,6 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) something_wrong= 1; } - mysql_mutex_unlock(&LOCK_open); - if (something_wrong) { DBUG_RETURN(TRUE); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index cf185db0b7a..13d1e646f04 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -796,7 +796,11 @@ static Sys_var_lexstring Sys_init_connect( static Sys_var_charptr Sys_init_file( "init_file", "Read SQL commands from this file at startup", READ_ONLY GLOBAL_VAR(opt_init_file), - IF_DISABLE_GRANT_OPTIONS(NO_CMD_LINE, CMD_LINE(REQUIRED_ARG)), +#ifdef DISABLE_GRANT_OPTIONS + NO_CMD_LINE, +#else + CMD_LINE(REQUIRED_ARG), +#endif IN_FS_CHARSET, DEFAULT(0)); static PolyLock_rwlock PLock_sys_init_slave(&LOCK_sys_init_slave); @@ -1488,7 +1492,7 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type) can cause to wait on a read lock, it's required for the client application to unlock everything, and acceptable for the server to wait on all locks. */ - if ((result= close_cached_tables(thd, NULL, FALSE, TRUE, + if ((result= close_cached_tables(thd, NULL, TRUE, thd->variables.lock_wait_timeout))) goto end_with_read_lock; @@ -2874,6 +2878,8 @@ static bool fix_log_output(sys_var *self, THD *thd, enum_var_type type) return false; } +static const char *log_output_names[] = { "NONE", "FILE", "TABLE", NULL}; + static Sys_var_set Sys_log_output( "log_output", "Syntax: log-output=value[,value...], " "where \"value\" could be TABLE, FILE or NONE", diff --git a/sql/table.cc b/sql/table.cc index a8e1caa271a..f08a0aa84ca 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -34,7 +34,7 @@ #include <m_ctype.h> #include "my_md5.h" #include "sql_select.h" -#include "mdl.h" // Deadlock_detection_visitor +#include "mdl.h" // MDL_wait_for_graph_visitor /* INFORMATION_SCHEMA name */ LEX_STRING INFORMATION_SCHEMA_NAME= {C_STRING_WITH_LEN("information_schema")}; @@ -397,77 +397,85 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key, } -/* - Free table share and memory used by it - - SYNOPSIS - free_table_share() - share Table share - - NOTES - share->mutex must be locked when we come here if it's not a temp table +/** + Release resources (plugins) used by the share and free its memory. + TABLE_SHARE is self-contained -- it's stored in its own MEM_ROOT. + Free this MEM_ROOT. */ -void free_table_share(TABLE_SHARE *share) +void TABLE_SHARE::destroy() { - MEM_ROOT mem_root; uint idx; - KEY *key_info; - DBUG_ENTER("free_table_share"); - DBUG_PRINT("enter", ("table: %s.%s", share->db.str, share->table_name.str)); - DBUG_ASSERT(share->ref_count == 0); + KEY *info_it; /* The mutex is initialized only for shares that are part of the TDC */ - if (share->tmp_table == NO_TMP_TABLE) - mysql_mutex_destroy(&share->LOCK_ha_data); - my_hash_free(&share->name_hash); + if (tmp_table == NO_TMP_TABLE) + mysql_mutex_destroy(&LOCK_ha_data); + my_hash_free(&name_hash); - plugin_unlock(NULL, share->db_plugin); - share->db_plugin= NULL; + plugin_unlock(NULL, db_plugin); + db_plugin= NULL; /* Release fulltext parsers */ - key_info= share->key_info; - for (idx= share->keys; idx; idx--, key_info++) + info_it= key_info; + for (idx= keys; idx; idx--, info_it++) { - if (key_info->flags & HA_USES_PARSER) + if (info_it->flags & HA_USES_PARSER) { - plugin_unlock(NULL, key_info->parser); - key_info->flags= 0; + plugin_unlock(NULL, info_it->parser); + info_it->flags= 0; } } + /* + Make a copy since the share is allocated in its own root, + and free_root() updates its argument after freeing the memory. + */ + MEM_ROOT own_root= mem_root; + free_root(&own_root, MYF(0)); +} + +/* + Free table share and memory used by it + + SYNOPSIS + free_table_share() + share Table share +*/ + +void free_table_share(TABLE_SHARE *share) +{ + DBUG_ENTER("free_table_share"); + DBUG_PRINT("enter", ("table: %s.%s", share->db.str, share->table_name.str)); + DBUG_ASSERT(share->ref_count == 0); if (share->m_flush_tickets.is_empty()) { /* - There are no threads waiting for this share to be flushed. So - we can immediately release memory associated with it. We must - copy mem_root from share because share is allocated through it. + No threads are waiting for this share to be flushed (the + share is not old, is for a temporary table, or just nobody + happens to be waiting for it). Destroy it. */ - memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root)); - free_root(&mem_root, MYF(0)); // Free's share + share->destroy(); } else { + Wait_for_flush_list::Iterator it(share->m_flush_tickets); + Wait_for_flush *ticket; /* - If there are threads waiting for this share to be flushed we - don't free share memory here. Instead we notify waiting threads - and delegate freeing share's memory to them. - At this point a) all resources except memory associated with share - were already released b) share should have been already removed - from table definition cache. So it is OK to proceed without waiting - for these threads to finish their work. - */ - Flush_ticket_list::Iterator it(share->m_flush_tickets); - Flush_ticket *ticket; - - /* - To avoid problems due to threads being wake up concurrently modifying - flush ticket list we must hold LOCK_open here. + We're about to iterate over a list that is used + concurrently. Make sure this never happens without a lock. */ mysql_mutex_assert_owner(&LOCK_open); while ((ticket= it++)) (void) ticket->get_ctx()->m_wait.set_status(MDL_wait::GRANTED); + /* + If there are threads waiting for this share to be flushed, + the last one to receive the notification will destroy the + share. At this point the share is removed from the table + definition cache, so is OK to proceed here without waiting + for this thread to do the work. + */ } DBUG_VOID_RETURN; } @@ -575,7 +583,7 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) int error, table_type; bool error_given; File file; - uchar head[64], *disk_buff; + uchar head[64]; char path[FN_REFLEN]; MEM_ROOT **root_ptr, *old_root; DBUG_ENTER("open_table_def"); @@ -584,7 +592,6 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) error= 1; error_given= 0; - disk_buff= NULL; strxmov(path, share->normalized_path.str, reg_ext, NullS); if ((file= mysql_file_open(key_file_frm, @@ -831,7 +838,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, goto err; /* purecov: inspected */ bzero((char*) keyinfo,n_length); share->key_info= keyinfo; - key_part= my_reinterpret_cast(KEY_PART_INFO*) (keyinfo+keys); + key_part= reinterpret_cast<KEY_PART_INFO*>(keyinfo+keys); strpos=disk_buff+6; if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root, @@ -1856,8 +1863,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, if (!(key_info= (KEY*) alloc_root(&outparam->mem_root, n_length))) goto err; outparam->key_info= key_info; - key_part= (my_reinterpret_cast(KEY_PART_INFO*) (key_info+share->keys)); - + key_part= (reinterpret_cast<KEY_PART_INFO*>(key_info+share->keys)); + memcpy(key_info, share->key_info, sizeof(*key_info)*share->keys); memcpy(key_part, share->key_info[0].key_part, (sizeof(*key_part) * share->key_parts)); @@ -3036,16 +3043,16 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) @retval TRUE A deadlock is found. A victim is remembered by the visitor. - @retval FALSE + @retval FALSE Success, no deadlocks. */ -bool Flush_ticket::find_deadlock(Deadlock_detection_visitor *dvisitor) +bool Wait_for_flush::accept_visitor(MDL_wait_for_graph_visitor *gvisitor) { - return m_share->find_deadlock(this, dvisitor); + return m_share->visit_subgraph(this, gvisitor); } -uint Flush_ticket::get_deadlock_weight() const +uint Wait_for_flush::get_deadlock_weight() const { return m_deadlock_weight; } @@ -3060,71 +3067,45 @@ uint Flush_ticket::get_deadlock_weight() const @retval TRUE A deadlock is found. A victim is remembered by the visitor. - @retval FALSE + @retval FALSE No deadlocks, it's OK to begin wait. */ -bool TABLE_SHARE::find_deadlock(Flush_ticket *waiting_ticket, - Deadlock_detection_visitor *dvisitor) +bool TABLE_SHARE::visit_subgraph(Wait_for_flush *wait_for_flush, + MDL_wait_for_graph_visitor *gvisitor) { TABLE *table; - MDL_context *src_ctx= waiting_ticket->get_ctx(); + MDL_context *src_ctx= wait_for_flush->get_ctx(); bool result= TRUE; /* - To protect used_tables list from being concurrently modified while we - are iterating through it we acquire LOCK_open. This should not introduce - deadlocks in deadlock detector because we support recursive acquiring of - such mutex and also because we won't try to acquire LOCK_open mutex while - holding write-lock on MDL_lock::m_rwlock. - - Here is the more elaborate proof: - - 0) Let us assume that there is a deadlock. - 1) Wait graph (the one which reflects waits for system synchronization - primitives and not the one which inspected by MDL deadlock detector) - for this deadlock should contain loop including both LOCK_open and - some of MDL synchronization primitives. Otherwise deadlock would had - already exisited before we have introduced acquiring of LOCK_open in - MDL deadlock detector. - 2) Also in this graph edge going out of LOCK_open node should go to one - of MDL synchronization primitives. Different situation would mean that - we have some non-MDL synchronization primitive besides LOCK_open under - which we try to acquire MDL lock, which is not the case. - 3) Moreover edge coming from LOCK_open should go to MDL_lock::m_rwlock - object and correspond to request for read-lock. It can't be request - for rwlock in MDL_context or mutex in MDL_wait object because they - are terminal (i.e. thread having them locked in exclusive mode won't - wait for any other resource). It can't be request for write-lock on - MDL_lock::m_rwlock as this would mean that we try to acquire metadata - lock under LOCK_open (which is not the case). - 4) Since MDL_lock::m_rwlock is rwlock which prefers readers the only - situation when it can be waited for is when some thread has it - write-locked. - 5) TODO/FIXME: - - Either prove that thread having MDL_lock::m_rwlock write-locked won't - wait for LOCK_open directly or indirectly (see notify_shared_lock()). - - Or change code to hold only read-lock on MDL_lock::m_rwlock during - notify_shared_lock() and thus make MDL_lock::m_rwlock terminal when - write-locked. + To protect used_tables list from being concurrently modified + while we are iterating through it we acquire LOCK_open. + This does not introduce deadlocks in the deadlock detector + because we won't try to acquire LOCK_open while + holding a write-lock on MDL_lock::m_rwlock. */ - if (! (dvisitor->m_table_shares_visited++)) + if (gvisitor->m_lock_open_count++ == 0) mysql_mutex_lock(&LOCK_open); I_P_List_iterator <TABLE, TABLE_share> tables_it(used_tables); - /* Not strictly necessary ? */ + /* + In case of multiple searches running in parallel, avoid going + over the same loop twice and shortcut the search. + Do it after taking the lock to weed out unnecessary races. + */ if (src_ctx->m_wait.get_status() != MDL_wait::EMPTY) { result= FALSE; goto end; } - if (dvisitor->enter_node(src_ctx)) + if (gvisitor->enter_node(src_ctx)) goto end; while ((table= tables_it++)) { - if (dvisitor->inspect_edge(&table->in_use->mdl_context)) + if (gvisitor->inspect_edge(&table->in_use->mdl_context)) { goto end_leave_node; } @@ -3133,7 +3114,7 @@ bool TABLE_SHARE::find_deadlock(Flush_ticket *waiting_ticket, tables_it.rewind(); while ((table= tables_it++)) { - if (table->in_use->mdl_context.find_deadlock(dvisitor)) + if (table->in_use->mdl_context.visit_subgraph(gvisitor)) { goto end_leave_node; } @@ -3142,10 +3123,10 @@ bool TABLE_SHARE::find_deadlock(Flush_ticket *waiting_ticket, result= FALSE; end_leave_node: - dvisitor->leave_node(src_ctx); + gvisitor->leave_node(src_ctx); end: - if (! (--dvisitor->m_table_shares_visited)) + if (gvisitor->m_lock_open_count-- == 1) mysql_mutex_unlock(&LOCK_open); return result; @@ -3153,81 +3134,76 @@ end: /** - Wait until old version of table share is removed from TDC. + Wait until the subject share is removed from the table + definition cache and make sure it's destroyed. @param mdl_context MDL context for thread which is going to wait. @param abstime Timeout for waiting as absolute time value. @param deadlock_weight Weight of this wait for deadlock detector. - @note This method assumes that its caller owns LOCK_open mutex. - This mutex will be unlocked temporarily during its execution. + @pre LOCK_open is write locked, the share is used (has + non-zero reference count), is marked for flush and + this connection does not reference the share. + LOCK_open will be unlocked temporarily during execution. @retval FALSE - Success. @retval TRUE - Error (OOM, deadlock, timeout, etc...). */ -bool TABLE_SHARE::wait_until_flushed(MDL_context *mdl_context, - struct timespec *abstime, - uint deadlock_weight) +bool TABLE_SHARE::wait_for_old_version(THD *thd, struct timespec *abstime, + uint deadlock_weight) { - Flush_ticket *ticket; + MDL_context *mdl_context= &thd->mdl_context; + Wait_for_flush ticket(mdl_context, this, deadlock_weight); MDL_wait::enum_wait_status wait_status; mysql_mutex_assert_owner(&LOCK_open); - /* - We should enter this method only then share's version is not - up to date and the share is referenced. Otherwise there is - no guarantee that our thread will be waken-up from wait. + We should enter this method only when share's version is not + up to date and the share is referenced. Otherwise our + thread will never be woken up from wait. */ DBUG_ASSERT(version != refresh_version && ref_count != 0); - if (! (ticket= new Flush_ticket(mdl_context, this, deadlock_weight))) - { - mysql_mutex_unlock(&LOCK_open); - return TRUE; - } - - m_flush_tickets.push_front(ticket); + m_flush_tickets.push_front(&ticket); mdl_context->m_wait.reset_status(); mysql_mutex_unlock(&LOCK_open); - mdl_context->will_wait_for(ticket); + mdl_context->will_wait_for(&ticket); mdl_context->find_deadlock(); - wait_status= mdl_context->m_wait.timed_wait(mdl_context->get_thd(), - abstime, TRUE); + wait_status= mdl_context->m_wait.timed_wait(thd, abstime, TRUE, + "Waiting for table flush"); mdl_context->done_waiting_for(); mysql_mutex_lock(&LOCK_open); - m_flush_tickets.remove(ticket); + m_flush_tickets.remove(&ticket); - /* - If our thread was the last one waiting for table share to be flushed - we can finish destruction of share object by releasing its memory - (share object was allocated on share's own MEM_ROOT). - - In cases when our wait was aborted due KILL statement, deadlock or - timeout share still might be referenced, so we don't free its memory - in this case. Note that we can't rely on checking wait_status to - determine this condition as, for example, timeout can happen even - when there are no references to table share so memory should be - released. - */ - if (m_flush_tickets.is_empty() && ! ref_count) + if (m_flush_tickets.is_empty() && ref_count == 0) { - MEM_ROOT mem_root_copy; - memcpy((char*) &mem_root_copy, (char*) &mem_root, sizeof(mem_root)); - free_root(&mem_root_copy, MYF(0)); + /* + If our thread was the last one using the share, + we must destroy it here. + */ + destroy(); } - delete ticket; - + /* + In cases when our wait was aborted by KILL statement, + a deadlock or a timeout, the share might still be referenced, + so we don't delete it. Note, that we can't determine this + condition by checking wait_status alone, since, for example, + a timeout can happen after all references to the table share + were released, but before the share is removed from the + cache and we receive the notification. This is why + we first destroy the share, and then look at + wait_status. + */ switch (wait_status) { case MDL_wait::GRANTED: diff --git a/sql/table.h b/sql/table.h index 46015f4425a..390a26662d6 100644 --- a/sql/table.h +++ b/sql/table.h @@ -45,7 +45,6 @@ class ACL_internal_schema_access; class ACL_internal_table_access; struct TABLE_LIST; class Field; -class Deadlock_detection_visitor; /* Used to identify NESTED_JOIN structures within a join (applicable only to @@ -515,13 +514,13 @@ public: such waits in MDL deadlock detector. */ -class Flush_ticket : public Wait_for_edge +class Wait_for_flush : public MDL_wait_for_subgraph { MDL_context *m_ctx; TABLE_SHARE *m_share; uint m_deadlock_weight; public: - Flush_ticket(MDL_context *ctx_arg, TABLE_SHARE *share_arg, + Wait_for_flush(MDL_context *ctx_arg, TABLE_SHARE *share_arg, uint deadlock_weight_arg) : m_ctx(ctx_arg), m_share(share_arg), m_deadlock_weight(deadlock_weight_arg) @@ -529,26 +528,26 @@ public: MDL_context *get_ctx() const { return m_ctx; } - bool find_deadlock(Deadlock_detection_visitor *dvisitor); + virtual bool accept_visitor(MDL_wait_for_graph_visitor *dvisitor); - uint get_deadlock_weight() const; + virtual uint get_deadlock_weight() const; /** Pointers for participating in the list of waiters for table share. */ - Flush_ticket *next_in_share; - Flush_ticket **prev_in_share; + Wait_for_flush *next_in_share; + Wait_for_flush **prev_in_share; }; -typedef I_P_List <Flush_ticket, - I_P_List_adapter<Flush_ticket, - &Flush_ticket::next_in_share, - &Flush_ticket::prev_in_share> > - Flush_ticket_list; +typedef I_P_List <Wait_for_flush, + I_P_List_adapter<Wait_for_flush, + &Wait_for_flush::next_in_share, + &Wait_for_flush::prev_in_share> > + Wait_for_flush_list; -/* +/** This structure is shared between different table objects. There is one instance of table share per one table in the database. */ @@ -669,7 +668,7 @@ struct TABLE_SHARE #ifdef WITH_PARTITION_STORAGE_ENGINE /* filled in when reading from frm */ bool auto_partitioned; - const char *partition_info_str; + char *partition_info_str; uint partition_info_str_len; uint partition_info_buffer_size; handlerton *default_part_db_type; @@ -705,7 +704,7 @@ struct TABLE_SHARE /** List of tickets representing threads waiting for the share to be flushed. */ - Flush_ticket_list m_flush_tickets; + Wait_for_flush_list m_flush_tickets; /* Set share's table cache key and update its db and table name appropriately. @@ -776,10 +775,8 @@ struct TABLE_SHARE } - /* - Must all TABLEs be reopened? - */ - inline bool needs_reopen() const + /** Is this table share being expelled from the table definition cache? */ + inline bool has_old_version() const { return version != refresh_version; } @@ -882,12 +879,13 @@ struct TABLE_SHARE return (tmp_table == SYSTEM_TMP_TABLE || is_view) ? 0 : table_map_id; } - bool find_deadlock(Flush_ticket *waiting_ticket, - Deadlock_detection_visitor *dvisitor); + bool visit_subgraph(Wait_for_flush *waiting_ticket, + MDL_wait_for_graph_visitor *gvisitor); - bool wait_until_flushed(MDL_context *mdl_context, - struct timespec *abstime, - uint deadlock_weight); + bool wait_for_old_version(THD *thd, struct timespec *abstime, + uint deadlock_weight); + /** Release resources and free memory occupied by the table share. */ + void destroy(); }; @@ -1135,9 +1133,7 @@ public: read_set= &def_read_set; write_set= &def_write_set; } - /* - Is this instance of the table should be reopen? - */ + /** Should this instance of the table be reopened? */ inline bool needs_reopen() { return !db_stat || m_needs_reopen; } diff --git a/sql/udf_example.c b/sql/udf_example.c index 284689d329f..36828bdf94d 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -133,7 +133,6 @@ typedef long long longlong; #include <string.h> #define strmov(a,b) stpcpy(a,b) #define bzero(a,b) memset(a,0,b) -#define memcpy_fixed(a,b,c) memcpy(a,b,c) #endif #endif #include <mysql.h> @@ -778,7 +777,7 @@ char *lookup(UDF_INIT *initid __attribute__((unused)), UDF_ARGS *args, } pthread_mutex_unlock(&LOCK_hostname); #endif - memcpy_fixed((char*) &in,(char*) *hostent->h_addr_list, sizeof(in.s_addr)); + memcpy(&in, *hostent->h_addr_list, sizeof(in.s_addr)); *res_length= (ulong) (strmov(result, inet_ntoa(in)) - result); return result; } @@ -1072,7 +1071,7 @@ char *myfunc_argument_name(UDF_INIT *initid __attribute__((unused)), { if (!args->attributes[0]) { - null_value= 0; + *null_value= 1; return 0; } (*length)--; /* space for ending \0 (for debugging purposes) */ diff --git a/storage/archive/azio.c b/storage/archive/azio.c index c1dd6e6f38c..1e2753027dc 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -31,7 +31,7 @@ int az_open(azio_stream *s, const char *path, int Flags, File fd); int do_flush(azio_stream *file, int flush); int get_byte(azio_stream *s); void check_header(azio_stream *s); -void write_header(azio_stream *s); +int write_header(azio_stream *s); int destroy(azio_stream *s); void putLong(File file, uLong x); uLong getLong(azio_stream *s); @@ -155,7 +155,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) } -void write_header(azio_stream *s) +int write_header(azio_stream *s) { char buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE]; char *ptr= buffer; @@ -191,8 +191,8 @@ void write_header(azio_stream *s) *(ptr + AZ_DIRTY_POS)= (unsigned char)s->dirty; /* Start of Data Block Index Block */ /* Always begin at the begining, and end there as well */ - my_pwrite(s->file, (uchar*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0, - MYF(0)); + return my_pwrite(s->file, (uchar*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, + 0, MYF(MY_NABP)) ? 1 : 0; } /* =========================================================================== @@ -838,19 +838,19 @@ int azwrite_frm(azio_stream *s, char *blob, unsigned int length) s->frm_length= length; s->start+= length; - my_pwrite(s->file, (uchar*) blob, s->frm_length, s->frm_start_pos, MYF(0)); - - write_header(s); - my_seek(s->file, 0, MY_SEEK_END, MYF(0)); + if (my_pwrite(s->file, (uchar*) blob, s->frm_length, + s->frm_start_pos, MYF(MY_NABP)) || + write_header(s) || + (my_seek(s->file, 0, MY_SEEK_END, MYF(0)) == MY_FILEPOS_ERROR)) + return 1; return 0; } int azread_frm(azio_stream *s, char *blob) { - my_pread(s->file, (uchar*) blob, s->frm_length, s->frm_start_pos, MYF(0)); - - return 0; + return my_pread(s->file, (uchar*) blob, s->frm_length, + s->frm_start_pos, MYF(MY_NABP)) ? 1 : 0; } diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 63848370ff1..ef907b035b5 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -613,6 +613,34 @@ int ha_archive::close(void) } +/** + Copy a frm blob between streams. + + @param src The source stream. + @param dst The destination stream. + + @return Zero on success, non-zero otherwise. +*/ + +int ha_archive::frm_copy(azio_stream *src, azio_stream *dst) +{ + int rc= 0; + char *frm_ptr; + + if (!(frm_ptr= (char *) my_malloc(src->frm_length, MYF(0)))) + return HA_ERR_OUT_OF_MEM; + + /* Write file offset is set to the end of the file. */ + if (azread_frm(src, frm_ptr) || + azwrite_frm(dst, frm_ptr, src->frm_length)) + rc= my_errno ? my_errno : HA_ERR_INTERNAL_ERROR; + + my_free(frm_ptr); + + return rc; +} + + /* We create our data file here. The format is pretty simple. You can read about the format of the data file above. @@ -1345,10 +1373,10 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) */ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) { - DBUG_ENTER("ha_archive::optimize"); int rc= 0; azio_stream writer; char writer_filename[FN_REFLEN]; + DBUG_ENTER("ha_archive::optimize"); init_archive_reader(); @@ -1366,6 +1394,13 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY))) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + /* + Transfer the embedded FRM so that the file can be discoverable. + Write file offset is set to the end of the file. + */ + if ((rc= frm_copy(&archive, &writer))) + goto error; + /* An extended rebuild is a lot more effort. We open up each row and re-record it. Any dead rows are removed (aka rows that may have been partially recorded). diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index 94842203f16..b258b403c3c 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -75,6 +75,7 @@ class ha_archive: public handler archive_record_buffer *create_record_buffer(unsigned int length); void destroy_record_buffer(archive_record_buffer *r); + int frm_copy(azio_stream *src, azio_stream *dst); public: ha_archive(handlerton *hton, TABLE_SHARE *table_arg); diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 30c4c4d58ca..e8012a86ae6 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -519,7 +519,7 @@ int ha_tina::encode_quote(uchar *buf) const char *ptr; const char *end_ptr; const bool was_null= (*field)->is_null(); - + /* assistance for backwards compatibility in production builds. note: this will not work for ENUM columns. @@ -531,7 +531,7 @@ int ha_tina::encode_quote(uchar *buf) } (*field)->val_str(&attribute,&attribute); - + if (was_null) (*field)->set_null(); @@ -542,34 +542,30 @@ int ha_tina::encode_quote(uchar *buf) buffer.append('"'); - while (ptr < end_ptr) + for (; ptr < end_ptr; ptr++) { if (*ptr == '"') { buffer.append('\\'); buffer.append('"'); - *ptr++; } else if (*ptr == '\r') { buffer.append('\\'); buffer.append('r'); - *ptr++; } else if (*ptr == '\\') { buffer.append('\\'); buffer.append('\\'); - *ptr++; } else if (*ptr == '\n') { buffer.append('\\'); buffer.append('n'); - *ptr++; } else - buffer.append(*ptr++); + buffer.append(*ptr); } buffer.append('"'); } @@ -807,15 +803,15 @@ int ha_tina::find_current_row(uchar *buf) Field_blob *blob= *(Field_blob**) field; uchar *src, *tgt; uint length, packlength; - + packlength= blob->pack_length_no_ptr(); length= blob->get_length(blob->ptr); - memcpy_fixed(&src, blob->ptr + packlength, sizeof(char*)); + memcpy(&src, blob->ptr + packlength, sizeof(char*)); if (src) { tgt= (uchar*) alloc_root(&blobroot, length); bmove(tgt, src, length); - memcpy_fixed(blob->ptr + packlength, &tgt, sizeof(char*)); + memcpy(blob->ptr + packlength, &tgt, sizeof(char*)); } } } diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 899f55a33f7..306f8eaeccd 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -180,7 +180,7 @@ static int example_done_func(void *p) my_hash_free(&example_open_tables); mysql_mutex_destroy(&example_mutex); - DBUG_RETURN(0); + DBUG_RETURN(error); } diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index d17b56bd4b1..b1ae276dce8 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2752,9 +2752,9 @@ void ha_federated::position(const uchar *record __attribute__ ((unused))) position_called= TRUE; /* Store result set address. */ - memcpy_fixed(ref, &stored_result, sizeof(MYSQL_RES *)); + memcpy(ref, &stored_result, sizeof(MYSQL_RES *)); /* Store data cursor position. */ - memcpy_fixed(ref + sizeof(MYSQL_RES *), ¤t_position, + memcpy(ref + sizeof(MYSQL_RES *), ¤t_position, sizeof(MYSQL_ROW_OFFSET)); DBUG_VOID_RETURN; } @@ -2780,11 +2780,11 @@ int ha_federated::rnd_pos(uchar *buf, uchar *pos) ha_statistic_increment(&SSV::ha_read_rnd_count); /* Get stored result set. */ - memcpy_fixed(&result, pos, sizeof(MYSQL_RES *)); + memcpy(&result, pos, sizeof(MYSQL_RES *)); DBUG_ASSERT(result); /* Set data cursor position. */ - memcpy_fixed(&result->data_cursor, pos + sizeof(MYSQL_RES *), - sizeof(MYSQL_ROW_OFFSET)); + memcpy(&result->data_cursor, pos + sizeof(MYSQL_RES *), + sizeof(MYSQL_ROW_OFFSET)); /* Read a row. */ ret_val= read_next(buf, result); MYSQL_READ_ROW_DONE(ret_val); diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 350958f8230..481257def1d 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -390,7 +390,7 @@ int ha_heap::rnd_pos(uchar * buf, uchar *pos) MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str, FALSE); ha_statistic_increment(&SSV::ha_read_rnd_count); - memcpy_fixed((char*) &heap_position, pos, sizeof(HEAP_PTR)); + memcpy(&heap_position, pos, sizeof(HEAP_PTR)); error=heap_rrnd(file, buf, heap_position); table->status=error ? STATUS_NOT_FOUND: 0; MYSQL_READ_ROW_DONE(error); @@ -654,7 +654,7 @@ heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table, parts * sizeof(HA_KEYSEG), MYF(MY_WME)))) return my_errno; - seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + keys); + seg= reinterpret_cast<HA_KEYSEG*>(keydef + keys); for (key= 0; key < keys; key++) { KEY *pos= table_arg->key_info+key; diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index 1571fc98402..3ee903be7ed 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -179,11 +179,6 @@ int main(int argc, char *argv[]) printf("can't find key1: \"%s\"\n",(char*) key); goto err; } -#ifdef NOT_USED - if (file->current_ptr == hp_find_block(&file->s->block,0) || - file->current_ptr == hp_find_block(&file->s->block,1)) - continue; /* Don't remove 2 first records */ -#endif if (heap_delete(file,record)) { printf("error: %d; can't delete record: \"%s\"\n", my_errno,(char*) record); diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index b6399dcc478..2575580d646 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -40,6 +40,12 @@ IF(UNIX) ENDIF() ENDIF() +# Enable InnoDB's UNIV_DEBUG if MySQL's WITH_DEBUG[_FULL] is defined +# enable when this bug is resolved: +# Bug#54861 Additional connections not handled properly in mtr --embedded +#IF(WITH_DEBUG) +# ADD_DEFINITIONS("-DUNIV_DEBUG") +#ENDIF() IF(NOT MSVC) # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not @@ -182,11 +188,7 @@ IF(SIZEOF_PTHREAD_T) ENDIF() IF(MSVC) - # Windows atomics do not perform well. Disable Windows atomics by default. - # See bug#52102 for details. - - #ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS -DINNODB_RW_LOCKS_USE_ATOMICS -DHAVE_IB_PAUSE_INSTRUCTION) - ADD_DEFINITIONS(-DHAVE_IB_PAUSE_INSTRUCTION) + ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS -DHAVE_IB_PAUSE_INSTRUCTION) ENDIF() diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index 05dd094b6df..f8638af2e71 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -737,7 +737,7 @@ btr_create( ulint space, /*!< in: space where created */ ulint zip_size,/*!< in: compressed page size in bytes or 0 for uncompressed pages */ - dulint index_id,/*!< in: index id */ + index_id_t index_id,/*!< in: index id */ dict_index_t* index, /*!< in: index */ mtr_t* mtr) /*!< in: mini-transaction handle */ { @@ -1020,7 +1020,7 @@ btr_page_reorganize_low( /* In crash recovery, dict_index_is_sec_or_ibuf() always returns TRUE, even for clustered indexes. max_trx_id is unused in clustered index pages. */ - ut_ad(!ut_dulint_is_zero(max_trx_id) || recovery); + ut_ad(max_trx_id != 0 || recovery); } if (UNIV_LIKELY_NULL(page_zip) @@ -2883,7 +2883,7 @@ btr_discard_only_page_on_level( ibuf_reset_free_bits(block); if (page_is_leaf(buf_block_get_frame(block))) { - ut_a(!ut_dulint_is_zero(max_trx_id)); + ut_a(max_trx_id); page_set_max_trx_id(block, buf_block_get_page_zip(block), max_trx_id, mtr); diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c index 31e1a2d4b12..537d5f51184 100644 --- a/storage/innobase/btr/btr0cur.c +++ b/storage/innobase/btr/btr0cur.c @@ -660,7 +660,7 @@ retry_page_get: buf_block_dbg_add_level(block, SYNC_TREE_NODE); } - ut_ad(0 == ut_dulint_cmp(index->id, btr_page_get_index_id(page))); + ut_ad(index->id == btr_page_get_index_id(page)); if (UNIV_UNLIKELY(height == ULINT_UNDEFINED)) { /* We are in the root node */ @@ -854,8 +854,7 @@ btr_cur_open_at_index_side_func( RW_NO_LATCH, NULL, BUF_GET, file, line, mtr); page = buf_block_get_frame(block); - ut_ad(0 == ut_dulint_cmp(index->id, - btr_page_get_index_id(page))); + ut_ad(index->id == btr_page_get_index_id(page)); block->check_index_page_at_flush = TRUE; @@ -975,8 +974,7 @@ btr_cur_open_at_rnd_pos_func( RW_NO_LATCH, NULL, BUF_GET, file, line, mtr); page = buf_block_get_frame(block); - ut_ad(0 == ut_dulint_cmp(index->id, - btr_page_get_index_id(page))); + ut_ad(index->id == btr_page_get_index_id(page)); if (height == ULINT_UNDEFINED) { /* We are in the root node */ @@ -1135,7 +1133,7 @@ btr_cur_trx_report( const char* op) /*!< in: operation */ { fprintf(stderr, "Trx with id " TRX_ID_FMT " going to ", - TRX_ID_PREP_PRINTF(trx->id)); + (ullint) trx->id); fputs(op, stderr); dict_index_name_print(stderr, trx, index); putc('\n', stderr); @@ -1826,7 +1824,7 @@ btr_cur_update_in_place( page_zip_des_t* page_zip; ulint err; rec_t* rec; - roll_ptr_t roll_ptr = ut_dulint_zero; + roll_ptr_t roll_ptr = 0; trx_t* trx; ulint was_delete_marked; mem_heap_t* heap = NULL; @@ -4936,7 +4934,7 @@ btr_copy_externally_stored_field( /*******************************************************************//** Copies an externally stored field of a record to mem heap. -@return the field copied to heap */ +@return the field copied to heap, or NULL if the field is incomplete */ UNIV_INTERN byte* btr_rec_copy_externally_stored_field( @@ -4966,6 +4964,18 @@ btr_rec_copy_externally_stored_field( data = rec_get_nth_field(rec, offsets, no, &local_len); + ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); + + if (UNIV_UNLIKELY + (!memcmp(data + local_len - BTR_EXTERN_FIELD_REF_SIZE, + field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE))) { + /* The externally stored field was not written yet. + This record should only be seen by + recv_recovery_rollback_active() or any + TRX_ISO_READ_UNCOMMITTED transactions. */ + return(NULL); + } + return(btr_copy_externally_stored_field(len, data, zip_size, local_len, heap)); } diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 98a321bdb80..06cc48c7c60 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -46,6 +46,7 @@ Created 2/17/1996 Heikki Tuuri /** Flag: has the search system been enabled? Protected by btr_search_latch and btr_search_enabled_mutex. */ UNIV_INTERN char btr_search_enabled = TRUE; +UNIV_INTERN ibool btr_search_fully_disabled = FALSE; /** Mutex protecting btr_search_enabled */ static mutex_t btr_search_enabled_mutex; @@ -213,12 +214,19 @@ btr_search_disable(void) mutex_enter(&btr_search_enabled_mutex); rw_lock_x_lock(&btr_search_latch); + /* Disable access to hash index, also tell ha_insert_for_fold() + stop adding new nodes to hash index, but still allow updating + existing nodes */ btr_search_enabled = FALSE; /* Clear all block->is_hashed flags and remove all entries from btr_search_sys->hash_index. */ buf_pool_drop_hash_index(); + /* hash index has been cleaned up, disallow any operation to + the hash index */ + btr_search_fully_disabled = TRUE; + /* btr_search_enabled_mutex should guarantee this. */ ut_ad(!btr_search_enabled); @@ -237,6 +245,7 @@ btr_search_enable(void) rw_lock_x_lock(&btr_search_latch); btr_search_enabled = TRUE; + btr_search_fully_disabled = FALSE; rw_lock_x_unlock(&btr_search_latch); mutex_exit(&btr_search_enabled_mutex); @@ -523,9 +532,9 @@ btr_search_update_hash_ref( buf_block_t* block, /*!< in: buffer block where cursor positioned */ btr_cur_t* cursor) /*!< in: cursor */ { - ulint fold; - rec_t* rec; - dulint index_id; + ulint fold; + rec_t* rec; + index_id_t index_id; ut_ad(cursor->flag == BTR_CUR_HASH_FAIL); #ifdef UNIV_SYNC_DEBUG @@ -830,7 +839,7 @@ btr_search_guess_on_hash( buf_block_t* block; rec_t* rec; ulint fold; - dulint index_id; + index_id_t index_id; #ifdef notdefined btr_cur_t cursor2; btr_pcur_t pcur; @@ -922,8 +931,7 @@ btr_search_guess_on_hash( is positioned on. We cannot look at the next of the previous record to determine if our guess for the cursor position is right. */ - if (UNIV_EXPECT - (ut_dulint_cmp(index_id, btr_page_get_index_id(block->frame)), 0) + if (UNIV_UNLIKELY(index_id != btr_page_get_index_id(block->frame)) || !btr_search_check_guess(cursor, has_search_latch, tuple, mode, mtr)) { @@ -1028,7 +1036,7 @@ btr_search_drop_page_hash_index( const rec_t* rec; ulint fold; ulint prev_fold; - dulint index_id; + index_id_t index_id; ulint n_cached; ulint n_recs; ulint* folds; @@ -1088,7 +1096,7 @@ retry: index_id = btr_page_get_index_id(page); - ut_a(0 == ut_dulint_cmp(index_id, index->id)); + ut_a(index_id == index->id); prev_fold = 0; @@ -1245,7 +1253,7 @@ btr_search_build_page_hash_index( rec_t* next_rec; ulint fold; ulint next_fold; - dulint index_id; + index_id_t index_id; ulint n_cached; ulint n_recs; ulint* folds; @@ -1376,7 +1384,7 @@ btr_search_build_page_hash_index( rw_lock_x_lock(&btr_search_latch); - if (UNIV_UNLIKELY(!btr_search_enabled)) { + if (UNIV_UNLIKELY(btr_search_fully_disabled)) { goto exit_func; } @@ -1498,7 +1506,7 @@ btr_search_update_hash_on_delete( buf_block_t* block; rec_t* rec; ulint fold; - dulint index_id; + index_id_t index_id; ibool found; ulint offsets_[REC_OFFS_NORMAL_SIZE]; mem_heap_t* heap = NULL; @@ -1604,7 +1612,7 @@ btr_search_update_hash_on_insert( rec_t* rec; rec_t* ins_rec; rec_t* next_rec; - dulint index_id; + index_id_t index_id; ulint fold; ulint ins_fold; ulint next_fold = 0; /* remove warning (??? bug ???) */ @@ -1784,6 +1792,7 @@ btr_search_validate(void) = buf_block_align(node->data); const buf_block_t* hash_block; buf_pool_t* buf_pool; + index_id_t page_index_id; buf_pool = buf_pool_from_bpage((buf_page_t*) block); @@ -1828,12 +1837,15 @@ btr_search_validate(void) + (block->curr_n_bytes > 0), &heap); - if (!block->is_hashed || node->fold - != rec_fold((rec_t*)(node->data), - offsets, - block->curr_n_fields, - block->curr_n_bytes, - btr_page_get_index_id(block->frame))) { + page_index_id = btr_page_get_index_id(block->frame); + + if (UNIV_UNLIKELY + (!block->is_hashed || node->fold + != rec_fold((rec_t*)(node->data), + offsets, + block->curr_n_fields, + block->curr_n_bytes, + page_index_id))) { const page_t* page = block->frame; ok = FALSE; @@ -1843,21 +1855,17 @@ btr_search_validate(void) " InnoDB: Error in an adaptive hash" " index pointer to page %lu\n" "InnoDB: ptr mem address %p" - " index id %lu %lu," + " index id %llu," " node fold %lu, rec fold %lu\n", (ulong) page_get_page_no(page), node->data, - (ulong) ut_dulint_get_high( - btr_page_get_index_id(page)), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(page)), + (ullint) page_index_id, (ulong) node->fold, (ulong) rec_fold((rec_t*)(node->data), offsets, block->curr_n_fields, block->curr_n_bytes, - btr_page_get_index_id( - page))); + page_index_id)); fputs("InnoDB: Record ", stderr); rec_print_new(stderr, (rec_t*)node->data, diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 4b6b0a82486..ab3c1abf490 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -522,7 +522,9 @@ buf_page_is_corrupted( ib_uint64_t current_lsn; if (log_peek_lsn(¤t_lsn) - && current_lsn < mach_read_ull(read_buf + FIL_PAGE_LSN)) { + && UNIV_UNLIKELY + (current_lsn + < mach_read_from_8(read_buf + FIL_PAGE_LSN))) { ut_print_timestamp(stderr); fprintf(stderr, @@ -538,7 +540,7 @@ buf_page_is_corrupted( "InnoDB: for more information.\n", (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), - mach_read_ull(read_buf + FIL_PAGE_LSN), + mach_read_from_8(read_buf + FIL_PAGE_LSN), current_lsn); } } @@ -735,17 +737,15 @@ buf_page_print( #endif /* !UNIV_HOTBACKUP */ switch (fil_page_get_type(read_buf)) { + index_id_t index_id; case FIL_PAGE_INDEX: + index_id = btr_page_get_index_id(read_buf); fprintf(stderr, "InnoDB: Page may be an index page where" - " index id is %lu %lu\n", - (ulong) ut_dulint_get_high( - btr_page_get_index_id(read_buf)), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(read_buf))); + " index id is %llu\n", + (ullint) index_id); #ifndef UNIV_HOTBACKUP - index = dict_index_find_on_id_low( - btr_page_get_index_id(read_buf)); + index = dict_index_find_on_id_low(index_id); if (index) { fputs("InnoDB: (", stderr); dict_index_name_print(stderr, NULL, index); @@ -4461,12 +4461,12 @@ buf_print_instance( /*===============*/ buf_pool_t* buf_pool) { - dulint* index_ids; + index_id_t* index_ids; ulint* counts; ulint size; ulint i; ulint j; - dulint id; + index_id_t id; ulint n_found; buf_chunk_t* chunk; dict_index_t* index; @@ -4475,7 +4475,7 @@ buf_print_instance( size = buf_pool->curr_size; - index_ids = mem_alloc(sizeof(dulint) * size); + index_ids = mem_alloc(size * sizeof *index_ids); counts = mem_alloc(sizeof(ulint) * size); buf_pool_mutex_enter(buf_pool); @@ -4530,8 +4530,7 @@ buf_print_instance( while (j < n_found) { - if (ut_dulint_cmp(index_ids[j], - id) == 0) { + if (index_ids[j] == id) { counts[j]++; break; @@ -4554,8 +4553,8 @@ buf_print_instance( index = dict_index_get_if_in_cache(index_ids[i]); fprintf(stderr, - "Block count for index %lu in buffer is about %lu", - (ulong) ut_dulint_get_low(index_ids[i]), + "Block count for index %llu in buffer is about %lu", + (ullint) index_ids[i], (ulong) counts[i]); if (index) { diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c index 046f1ed51e8..3737627301f 100644 --- a/storage/innobase/buf/buf0flu.c +++ b/storage/innobase/buf/buf0flu.c @@ -114,7 +114,9 @@ buf_flush_insert_in_flush_rbt( p_node = rbt_prev(buf_pool->flush_rbt, c_node); if (p_node != NULL) { - prev = *rbt_value(buf_page_t*, p_node); + buf_page_t** value; + value = rbt_value(buf_page_t*, p_node); + prev = *value; ut_a(prev != NULL); } @@ -980,8 +982,8 @@ buf_flush_init_for_writing( case FIL_PAGE_TYPE_ZBLOB: case FIL_PAGE_TYPE_ZBLOB2: case FIL_PAGE_INDEX: - mach_write_ull(page_zip->data - + FIL_PAGE_LSN, newest_lsn); + mach_write_to_8(page_zip->data + + FIL_PAGE_LSN, newest_lsn); memset(page_zip->data + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); mach_write_to_4(page_zip->data + FIL_PAGE_SPACE_OR_CHKSUM, @@ -1003,10 +1005,10 @@ buf_flush_init_for_writing( } /* Write the newest modification lsn to the page header and trailer */ - mach_write_ull(page + FIL_PAGE_LSN, newest_lsn); + mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); - mach_write_ull(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, - newest_lsn); + mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, + newest_lsn); /* Store the new formula checksum */ @@ -1094,8 +1096,8 @@ buf_flush_write_block_low( ut_a(mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM) == page_zip_calc_checksum(frame, zip_size)); } - mach_write_ull(frame + FIL_PAGE_LSN, - bpage->newest_modification); + mach_write_to_8(frame + FIL_PAGE_LSN, + bpage->newest_modification); memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); break; case BUF_BLOCK_FILE_PAGE: @@ -2088,13 +2090,13 @@ buf_flush_validate_low( ut_a(om > 0); if (UNIV_LIKELY_NULL(buf_pool->flush_rbt)) { - buf_page_t* rpage; + buf_page_t** prpage; ut_a(rnode); - rpage = *rbt_value(buf_page_t*, rnode); + prpage = rbt_value(buf_page_t*, rnode); - ut_a(rpage); - ut_a(rpage == bpage); + ut_a(*prpage); + ut_a(*prpage == bpage); rnode = rbt_next(buf_pool->flush_rbt, rnode); } diff --git a/storage/innobase/buf/buf0lru.c b/storage/innobase/buf/buf0lru.c index a539c4e894b..e1d4b5081b8 100644 --- a/storage/innobase/buf/buf0lru.c +++ b/storage/innobase/buf/buf0lru.c @@ -2278,19 +2278,17 @@ buf_LRU_print_instance( case BUF_BLOCK_FILE_PAGE: frame = buf_block_get_frame((buf_block_t*) bpage); fprintf(stderr, "\ntype %lu" - " index id %lu\n", + " index id %llu\n", (ulong) fil_page_get_type(frame), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(frame))); + (ullint) btr_page_get_index_id(frame)); break; case BUF_BLOCK_ZIP_PAGE: frame = bpage->zip.data; fprintf(stderr, "\ntype %lu size %lu" - " index id %lu\n", + " index id %llu\n", (ulong) fil_page_get_type(frame), (ulong) buf_page_get_zip_size(bpage), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(frame))); + (ullint) btr_page_get_index_id(frame)); break; default: diff --git a/storage/innobase/data/data0data.c b/storage/innobase/data/data0data.c index 0715b49bf9c..0ef0cfa554a 100644 --- a/storage/innobase/data/data0data.c +++ b/storage/innobase/data/data0data.c @@ -367,7 +367,7 @@ dfield_print_also_hex( prtype = dtype_get_prtype(dfield_get_type(dfield)); switch (dtype_get_mtype(dfield_get_type(dfield))) { - dulint id; + ib_id_t id; case DATA_INT: switch (len) { ulint val; @@ -417,22 +417,16 @@ dfield_print_also_hex( case 6: id = mach_read_from_6(data); - fprintf(stderr, "{%lu %lu}", - ut_dulint_get_high(id), - ut_dulint_get_low(id)); + fprintf(stderr, "%llu", (ullint) id); break; case 7: id = mach_read_from_7(data); - fprintf(stderr, "{%lu %lu}", - ut_dulint_get_high(id), - ut_dulint_get_low(id)); + fprintf(stderr, "%llu", (ullint) id); break; case 8: id = mach_read_from_8(data); - fprintf(stderr, "{%lu %lu}", - ut_dulint_get_high(id), - ut_dulint_get_low(id)); + fprintf(stderr, "%llu", (ullint) id); break; default: goto print_hex; @@ -444,29 +438,25 @@ dfield_print_also_hex( case DATA_TRX_ID: id = mach_read_from_6(data); - fprintf(stderr, "trx_id " TRX_ID_FMT, - TRX_ID_PREP_PRINTF(id)); + fprintf(stderr, "trx_id " TRX_ID_FMT, (ullint) id); break; case DATA_ROLL_PTR: id = mach_read_from_7(data); - fprintf(stderr, "roll_ptr {%lu %lu}", - ut_dulint_get_high(id), ut_dulint_get_low(id)); + fprintf(stderr, "roll_ptr " TRX_ID_FMT, (ullint) id); break; case DATA_ROW_ID: id = mach_read_from_6(data); - fprintf(stderr, "row_id {%lu %lu}", - ut_dulint_get_high(id), ut_dulint_get_low(id)); + fprintf(stderr, "row_id " TRX_ID_FMT, (ullint) id); break; default: - id = mach_dulint_read_compressed(data); + id = mach_ull_read_compressed(data); - fprintf(stderr, "mix_id {%lu %lu}", - ut_dulint_get_high(id), ut_dulint_get_low(id)); + fprintf(stderr, "mix_id " TRX_ID_FMT, (ullint) id); } break; diff --git a/storage/innobase/data/data0type.c b/storage/innobase/data/data0type.c index e834fd2ec55..20d1f5db8d3 100644 --- a/storage/innobase/data/data0type.c +++ b/storage/innobase/data/data0type.c @@ -49,10 +49,8 @@ ulint dtype_get_at_most_n_mbchars( /*========================*/ ulint prtype, /*!< in: precise type */ - ulint mbminlen, /*!< in: minimum length of a - multi-byte character */ - ulint mbmaxlen, /*!< in: maximum length of a - multi-byte character */ + ulint mbminmaxlen, /*!< in: minimum and maximum length of + a multi-byte character */ ulint prefix_len, /*!< in: length of the requested prefix, in characters, multiplied by dtype_get_mbmaxlen(dtype) */ @@ -60,6 +58,9 @@ dtype_get_at_most_n_mbchars( const char* str) /*!< in: the string whose prefix length is being determined */ { + ulint mbminlen = DATA_MBMINLEN(mbminmaxlen); + ulint mbmaxlen = DATA_MBMAXLEN(mbminmaxlen); + ut_a(data_len != UNIV_SQL_NULL); ut_ad(!mbmaxlen || !(prefix_len % mbmaxlen)); @@ -180,7 +181,7 @@ dtype_validate( } #ifndef UNIV_HOTBACKUP - ut_a(type->mbminlen <= type->mbmaxlen); + ut_a(dtype_get_mbminlen(type) <= dtype_get_mbmaxlen(type)); #endif /* !UNIV_HOTBACKUP */ return(TRUE); diff --git a/storage/innobase/dict/dict0boot.c b/storage/innobase/dict/dict0boot.c index e63c1dc94b9..20d676e6129 100644 --- a/storage/innobase/dict/dict0boot.c +++ b/storage/innobase/dict/dict0boot.c @@ -67,12 +67,15 @@ UNIV_INTERN void dict_hdr_get_new_id( /*================*/ - dulint* table_id, /*!< out: table id (not assigned if NULL) */ - dulint* index_id, /*!< out: index id (not assigned if NULL) */ - ulint* space_id) /*!< out: space id (not assigned if NULL) */ + table_id_t* table_id, /*!< out: table id + (not assigned if NULL) */ + index_id_t* index_id, /*!< out: index id + (not assigned if NULL) */ + ulint* space_id) /*!< out: space id + (not assigned if NULL) */ { dict_hdr_t* dict_hdr; - dulint id; + ib_id_t id; mtr_t mtr; mtr_start(&mtr); @@ -80,16 +83,16 @@ dict_hdr_get_new_id( dict_hdr = dict_hdr_get(&mtr); if (table_id) { - id = mtr_read_dulint(dict_hdr + DICT_HDR_TABLE_ID, &mtr); - id = ut_dulint_add(id, 1); - mlog_write_dulint(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr); + id = mach_read_from_8(dict_hdr + DICT_HDR_TABLE_ID); + id++; + mlog_write_ull(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr); *table_id = id; } if (index_id) { - id = mtr_read_dulint(dict_hdr + DICT_HDR_INDEX_ID, &mtr); - id = ut_dulint_add(id, 1); - mlog_write_dulint(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr); + id = mach_read_from_8(dict_hdr + DICT_HDR_INDEX_ID); + id++; + mlog_write_ull(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr); *index_id = id; } @@ -114,7 +117,7 @@ dict_hdr_flush_row_id(void) /*=======================*/ { dict_hdr_t* dict_hdr; - dulint id; + row_id_t id; mtr_t mtr; ut_ad(mutex_own(&(dict_sys->mutex))); @@ -125,7 +128,7 @@ dict_hdr_flush_row_id(void) dict_hdr = dict_hdr_get(&mtr); - mlog_write_dulint(dict_hdr + DICT_HDR_ROW_ID, id, &mtr); + mlog_write_ull(dict_hdr + DICT_HDR_ROW_ID, id, &mtr); mtr_commit(&mtr); } @@ -157,14 +160,14 @@ dict_hdr_create( /* Start counting row, table, index, and tree ids from DICT_HDR_FIRST_ID */ - mlog_write_dulint(dict_header + DICT_HDR_ROW_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + mlog_write_ull(dict_header + DICT_HDR_ROW_ID, + DICT_HDR_FIRST_ID, mtr); - mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + mlog_write_ull(dict_header + DICT_HDR_TABLE_ID, + DICT_HDR_FIRST_ID, mtr); - mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + mlog_write_ull(dict_header + DICT_HDR_INDEX_ID, + DICT_HDR_FIRST_ID, mtr); mlog_write_ulint(dict_header + DICT_HDR_MAX_SPACE_ID, 0, MLOG_4BYTES, mtr); @@ -273,11 +276,9 @@ dict_boot(void) ..._MARGIN, it will immediately be updated to the disk-based header. */ - dict_sys->row_id = ut_dulint_add( - ut_dulint_align_up(mtr_read_dulint(dict_hdr + DICT_HDR_ROW_ID, - &mtr), - DICT_HDR_ROW_ID_WRITE_MARGIN), - DICT_HDR_ROW_ID_WRITE_MARGIN); + dict_sys->row_id = DICT_HDR_ROW_ID_WRITE_MARGIN + + ut_uint64_align_up(mach_read_from_8(dict_hdr + DICT_HDR_ROW_ID), + DICT_HDR_ROW_ID_WRITE_MARGIN); /* Insert into the dictionary cache the descriptions of the basic system tables */ diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c index f185371bfca..6824d0fa9f9 100644 --- a/storage/innobase/dict/dict0crea.c +++ b/storage/innobase/dict/dict0crea.c @@ -240,17 +240,29 @@ dict_build_table_def_step( ibool is_path; mtr_t mtr; ulint space = 0; + ibool file_per_table; ut_ad(mutex_own(&(dict_sys->mutex))); table = node->table; - dict_hdr_get_new_id(&table->id, NULL, - srv_file_per_table ? &space : NULL); + /* Cache the global variable "srv_file_per_table" to + a local variable before using it. Please note + "srv_file_per_table" is not under dict_sys mutex + protection, and could be changed while executing + this function. So better to cache the current value + to a local variable, and all future reference to + "srv_file_per_table" should use this local variable. */ + file_per_table = srv_file_per_table; + + dict_hdr_get_new_id(&table->id, NULL, NULL); thr_get_trx(thr)->table_id = table->id; - if (srv_file_per_table) { + if (file_per_table) { + /* Get a new space id if srv_file_per_table is set */ + dict_hdr_get_new_id(NULL, NULL, &space); + if (UNIV_UNLIKELY(space == ULINT_UNDEFINED)) { return(DB_ERROR); } @@ -578,7 +590,7 @@ dict_build_index_def_step( ins_node_set_new_row(node->ind_def, row); /* Note that the index was created by this transaction. */ - index->trx_id = (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id); + index->trx_id = trx->id; return(DB_SUCCESS); } @@ -749,7 +761,7 @@ dict_truncate_index_tree( ibool drop = !space; ulint zip_size; ulint type; - dulint index_id; + index_id_t index_id; rec_t* rec; const byte* ptr; ulint len; @@ -842,7 +854,7 @@ create: for (index = UT_LIST_GET_FIRST(table->indexes); index; index = UT_LIST_GET_NEXT(indexes, index)) { - if (!ut_dulint_cmp(index->id, index_id)) { + if (index->id == index_id) { root_page_no = btr_create(type, space, zip_size, index_id, index, mtr); index->page = (unsigned int) root_page_no; @@ -852,10 +864,9 @@ create: ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Index %lu %lu of table %s is missing\n" + " InnoDB: Index %llu of table %s is missing\n" "InnoDB: from the data dictionary during TRUNCATE!\n", - ut_dulint_get_high(index_id), - ut_dulint_get_low(index_id), + (ullint) index_id, table->name); return(FIL_NULL); @@ -1107,7 +1118,7 @@ dict_create_index_step( if (node->state == INDEX_ADD_TO_CACHE) { - dulint index_id = node->index->id; + index_id_t index_id = node->index->id; err = dict_index_add_to_cache( node->table, node->index, FIL_NULL, diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index a298d785449..802f0bd8b6f 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -256,8 +256,8 @@ dict_mutex_exit_for_mysql(void) /** Get the mutex that protects index->stat_n_diff_key_vals[] */ #define GET_INDEX_STAT_MUTEX(index) \ - (&dict_index_stat_mutex[ut_fold_dulint(index->id) \ - % DICT_INDEX_STAT_MUTEX_SIZE]) + (&dict_index_stat_mutex[ut_fold_ull(index->id) \ + % DICT_INDEX_STAT_MUTEX_SIZE]) /**********************************************************************//** Lock the appropriate mutex to protect index->stat_n_diff_key_vals[]. @@ -425,14 +425,14 @@ dict_index_t* dict_index_get_on_id_low( /*=====================*/ dict_table_t* table, /*!< in: table */ - dulint id) /*!< in: index id */ + index_id_t id) /*!< in: index id */ { dict_index_t* index; index = dict_table_get_first_index(table); while (index) { - if (0 == ut_dulint_cmp(id, index->id)) { + if (id == index->id) { /* Found */ return(index); @@ -574,20 +574,18 @@ UNIV_INTERN dict_table_t* dict_table_get_on_id( /*=================*/ - dulint table_id, /*!< in: table id */ - trx_t* trx) /*!< in: transaction handle */ + table_id_t table_id, /*!< in: table id */ + trx_t* trx) /*!< in: transaction handle */ { dict_table_t* table; - if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0 + if (table_id <= DICT_FIELDS_ID || trx->dict_operation_lock_mode == RW_X_LATCH) { - /* It is a system table which will always exist in the table - cache: we avoid acquiring the dictionary mutex, because - if we are doing a rollback to handle an error in TABLE - CREATE, for example, we already have the mutex! */ - ut_ad(mutex_own(&(dict_sys->mutex)) - || trx->dict_operation_lock_mode == RW_X_LATCH); + /* Note: An X latch implies that the transaction + already owns the dictionary mutex. */ + + ut_ad(mutex_own(&dict_sys->mutex)); return(dict_table_get_on_id_low(table_id)); } @@ -800,7 +798,7 @@ dict_table_add_to_cache( table->cached = TRUE; fold = ut_fold_string(table->name); - id_fold = ut_fold_dulint(table->id); + id_fold = ut_fold_ull(table->id); row_len = 0; for (i = 0; i < table->n_def; i++) { @@ -842,7 +840,7 @@ dict_table_add_to_cache( dict_table_t* table2; HASH_SEARCH(id_hash, dict_sys->table_id_hash, id_fold, dict_table_t*, table2, ut_ad(table2->cached), - ut_dulint_cmp(table2->id, table->id) == 0); + table2->id == table->id); ut_a(table2 == NULL); #ifdef UNIV_DEBUG @@ -864,7 +862,8 @@ dict_table_add_to_cache( /* Add table to LRU list of tables */ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table); - dict_sys->size += mem_heap_get_size(table->heap); + dict_sys->size += mem_heap_get_size(table->heap) + + strlen(table->name) + 1; } /**********************************************************************//** @@ -876,7 +875,7 @@ UNIV_INTERN dict_index_t* dict_index_find_on_id_low( /*======================*/ - dulint id) /*!< in: index id */ + index_id_t id) /*!< in: index id */ { dict_table_t* table; dict_index_t* index; @@ -887,7 +886,7 @@ dict_index_find_on_id_low( index = dict_table_get_first_index(table); while (index) { - if (0 == ut_dulint_cmp(id, index->id)) { + if (id == index->id) { /* Found */ return(index); @@ -918,14 +917,21 @@ dict_table_rename_in_cache( dict_foreign_t* foreign; dict_index_t* index; ulint fold; - ulint old_size; - const char* old_name; + char old_name[MAX_TABLE_NAME_LEN + 1]; ut_ad(table); ut_ad(mutex_own(&(dict_sys->mutex))); - old_size = mem_heap_get_size(table->heap); - old_name = table->name; + /* store the old/current name to an automatic variable */ + if (strlen(table->name) + 1 <= sizeof(old_name)) { + memcpy(old_name, table->name, strlen(table->name) + 1); + } else { + ut_print_timestamp(stderr); + fprintf(stderr, "InnoDB: too long table name: '%s', " + "max length is %d\n", table->name, + MAX_TABLE_NAME_LEN); + ut_error; + } fold = ut_fold_string(new_name); @@ -971,12 +977,22 @@ dict_table_rename_in_cache( /* Remove table from the hash tables of tables */ HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, ut_fold_string(old_name), table); - table->name = mem_heap_strdup(table->heap, new_name); + + if (strlen(new_name) > strlen(table->name)) { + /* We allocate MAX_TABLE_NAME_LEN+1 bytes here to avoid + memory fragmentation, we assume a repeated calls of + ut_realloc() with the same size do not cause fragmentation */ + ut_a(strlen(new_name) <= MAX_TABLE_NAME_LEN); + table->name = ut_realloc(table->name, MAX_TABLE_NAME_LEN + 1); + } + memcpy(table->name, new_name, strlen(new_name) + 1); /* Add table to hash table of tables */ HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold, table); - dict_sys->size += (mem_heap_get_size(table->heap) - old_size); + + dict_sys->size += strlen(new_name) - strlen(old_name); + ut_a(dict_sys->size > 0); /* Update the table_name field in indexes */ index = dict_table_get_first_index(table); @@ -1126,7 +1142,7 @@ void dict_table_change_id_in_cache( /*==========================*/ dict_table_t* table, /*!< in/out: table object already in cache */ - dulint new_id) /*!< in: new id to set */ + table_id_t new_id) /*!< in: new id to set */ { ut_ad(table); ut_ad(mutex_own(&(dict_sys->mutex))); @@ -1135,12 +1151,12 @@ dict_table_change_id_in_cache( /* Remove the table from the hash table of id's */ HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash, - ut_fold_dulint(table->id), table); + ut_fold_ull(table->id), table); table->id = new_id; /* Add the table back to the hash table */ HASH_INSERT(dict_table_t, id_hash, dict_sys->table_id_hash, - ut_fold_dulint(table->id), table); + ut_fold_ull(table->id), table); } /**********************************************************************//** @@ -1196,12 +1212,12 @@ dict_table_remove_from_cache( HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, ut_fold_string(table->name), table); HASH_DELETE(dict_table_t, id_hash, dict_sys->table_id_hash, - ut_fold_dulint(table->id), table); + ut_fold_ull(table->id), table); /* Remove table from LRU list of tables */ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table); - size = mem_heap_get_size(table->heap); + size = mem_heap_get_size(table->heap) + strlen(table->name) + 1; ut_ad(dict_sys->size >= size); @@ -2458,8 +2474,7 @@ dict_table_get_index_by_max_id( /* We found a matching index, select the index with the higher id*/ - if (!found - || ut_dulint_cmp(index->id, found->id) > 0) { + if (!found || index->id > found->id) { found = index; } @@ -3947,7 +3962,7 @@ UNIV_INTERN dict_index_t* dict_index_get_if_in_cache_low( /*===========================*/ - dulint index_id) /*!< in: index id */ + index_id_t index_id) /*!< in: index id */ { ut_ad(mutex_own(&(dict_sys->mutex))); @@ -3962,7 +3977,7 @@ UNIV_INTERN dict_index_t* dict_index_get_if_in_cache( /*=======================*/ - dulint index_id) /*!< in: index id */ + index_id_t index_id) /*!< in: index id */ { dict_index_t* index; @@ -4358,12 +4373,11 @@ dict_table_print_low( fprintf(stderr, "--------------------------------------\n" - "TABLE: name %s, id %lu %lu, flags %lx, columns %lu," + "TABLE: name %s, id %llu, flags %lx, columns %lu," " indexes %lu, appr.rows %lu\n" " COLUMNS: ", table->name, - (ulong) ut_dulint_get_high(table->id), - (ulong) ut_dulint_get_low(table->id), + (ullint) table->id, (ulong) table->flags, (ulong) table->n_cols, (ulong) UT_LIST_GET_LEN(table->indexes), @@ -4452,14 +4466,13 @@ dict_index_print_low( } fprintf(stderr, - " INDEX: name %s, id %lu %lu, fields %lu/%lu," + " INDEX: name %s, id %llu, fields %lu/%lu," " uniq %lu, type %lu\n" " root page %lu, appr.key vals %lu," " leaf pages %lu, size pages %lu\n" " FIELDS: ", index->name, - (ulong) ut_dulint_get_high(index->id), - (ulong) ut_dulint_get_low(index->id), + (ullint) index->id, (ulong) index->n_user_defined_cols, (ulong) index->n_fields, (ulong) index->n_uniq, @@ -4831,8 +4844,7 @@ dict_table_get_index_on_name_and_min_id( while (index != NULL) { if (ut_strcmp(index->name, name) == 0) { - if (!min_index - || ut_dulint_cmp(index->id, min_index->id) < 0) { + if (!min_index || index->id < min_index->id) { min_index = index; } diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index 6bf2c1d9d81..20a18c72a39 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -364,7 +364,7 @@ dict_process_sys_indexes_rec( mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current SYS_INDEXES rec */ dict_index_t* index, /*!< out: index to be filled */ - dulint* table_id) /*!< out: index table id */ + table_id_t* table_id) /*!< out: index table id */ { const char* err_msg; byte* buf; @@ -390,7 +390,7 @@ dict_process_sys_columns_rec( mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current SYS_COLUMNS rec */ dict_col_t* column, /*!< out: dict_col_t to be filled */ - dulint* table_id, /*!< out: table id */ + table_id_t* table_id, /*!< out: table id */ const char** col_name) /*!< out: column name */ { const char* err_msg; @@ -414,8 +414,8 @@ dict_process_sys_fields_rec( dict_field_t* sys_field, /*!< out: dict_field_t to be filled */ ulint* pos, /*!< out: Field position */ - dulint* index_id, /*!< out: current index id */ - dulint last_id) /*!< in: previous index id */ + index_id_t* index_id, /*!< out: current index id */ + index_id_t last_id) /*!< in: previous index id */ { byte* buf; byte* last_index_id; @@ -644,7 +644,7 @@ dict_check_tablespaces_and_store_max_id( dict_index_t* sys_index; btr_pcur_t pcur; const rec_t* rec; - ulint max_space_id = 0; + ulint max_space_id; mtr_t mtr; mutex_enter(&(dict_sys->mutex)); @@ -655,6 +655,11 @@ dict_check_tablespaces_and_store_max_id( sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); ut_a(!dict_table_is_comp(sys_tables)); + max_space_id = mtr_read_ulint(dict_hdr_get(&mtr) + + DICT_HDR_MAX_SPACE_ID, + MLOG_4BYTES, &mtr); + fil_set_max_space_id_if_bigger(max_space_id); + btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur, TRUE, &mtr); loop: @@ -777,13 +782,14 @@ const char* dict_load_column_low( /*=================*/ dict_table_t* table, /*!< in/out: table, could be NULL - if we just polulate a dict_column_t + if we just populate a dict_column_t struct with information from a SYS_COLUMNS record */ mem_heap_t* heap, /*!< in/out: memory heap for temporary storage */ - dict_col_t* column, /*!< out: dict_column_t to fill */ - dulint* table_id, /*!< out: table id */ + dict_col_t* column, /*!< out: dict_column_t to fill, + or NULL if table != NULL */ + table_id_t* table_id, /*!< out: table id */ const char** col_name, /*!< out: column name */ const rec_t* rec) /*!< in: SYS_COLUMNS record */ { @@ -795,6 +801,8 @@ dict_load_column_low( ulint col_len; ulint pos; + ut_ad(table || column); + if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) { return("delete-marked record in SYS_COLUMNS"); } @@ -811,8 +819,7 @@ err_len: if (table_id) { *table_id = mach_read_from_8(field); - } else if (UNIV_UNLIKELY(ut_dulint_cmp(table->id, - mach_read_from_8(field)))) { + } else if (UNIV_UNLIKELY(table->id != mach_read_from_8(field))) { return("SYS_COLUMNS.TABLE_ID mismatch"); } @@ -822,9 +829,9 @@ err_len: goto err_len; } - if (!table) { - pos = mach_read_from_4(field); - } else if (UNIV_UNLIKELY(table->n_def != mach_read_from_4(field))) { + pos = mach_read_from_4(field); + + if (UNIV_UNLIKELY(table && table->n_def != pos)) { return("SYS_COLUMNS.POS mismatch"); } @@ -1191,7 +1198,7 @@ dict_load_index_low( ulint len; ulint name_len; char* name_buf; - dulint id; + index_id_t id; ulint n_fields; ulint type; ulint space; @@ -1308,19 +1315,11 @@ dict_load_indexes( dfield_t* dfield; const rec_t* rec; byte* buf; - ibool is_sys_table; mtr_t mtr; ulint error = DB_SUCCESS; ut_ad(mutex_own(&(dict_sys->mutex))); - if ((ut_dulint_get_high(table->id) == 0) - && (ut_dulint_get_low(table->id) < DICT_HDR_FIRST_ID)) { - is_sys_table = TRUE; - } else { - is_sys_table = FALSE; - } - mtr_start(&mtr); sys_indexes = dict_table_get_low("SYS_INDEXES"); @@ -1406,7 +1405,7 @@ corrupted: " is not clustered!\n", stderr); goto corrupted; - } else if (is_sys_table + } else if (table->id < DICT_HDR_FIRST_ID && (dict_index_is_clust(index) || ((table == dict_sys->sys_tables) && !strcmp("ID_IND", index->name)))) { @@ -1766,7 +1765,7 @@ UNIV_INTERN dict_table_t* dict_load_table_on_id( /*==================*/ - dulint table_id) /*!< in: table id */ + table_id_t table_id) /*!< in: table id */ { byte id_buf[8]; btr_pcur_t pcur; @@ -1829,7 +1828,7 @@ dict_load_table_on_id( ut_ad(len == 8); /* Check if the table id in record is the one searched for */ - if (ut_dulint_cmp(table_id, mach_read_from_8(field)) != 0) { + if (table_id != mach_read_from_8(field)) { btr_pcur_close(&pcur); mtr_commit(&mtr); diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c index b6e516783c7..bbb8f810f44 100644 --- a/storage/innobase/dict/dict0mem.c +++ b/storage/innobase/dict/dict0mem.c @@ -73,7 +73,8 @@ dict_mem_table_create( table->heap = heap; table->flags = (unsigned int) flags; - table->name = mem_heap_strdup(heap, name); + table->name = ut_malloc(strlen(name) + 1); + memcpy(table->name, name, strlen(name) + 1); table->space = (unsigned int) space; table->n_cols = (unsigned int) (n_cols + DATA_N_SYS_COLS); @@ -112,6 +113,7 @@ dict_mem_table_free( #ifndef UNIV_HOTBACKUP mutex_free(&(table->autoinc_mutex)); #endif /* UNIV_HOTBACKUP */ + ut_free(table->name); mem_heap_free(table->heap); } @@ -204,6 +206,37 @@ dict_mem_table_add_col( dict_mem_fill_column_struct(col, i, mtype, prtype, len); } + +/**********************************************************************//** +This function populates a dict_col_t memory structure with +supplied information. */ +UNIV_INTERN +void +dict_mem_fill_column_struct( +/*========================*/ + dict_col_t* column, /*!< out: column struct to be + filled */ + ulint col_pos, /*!< in: column position */ + ulint mtype, /*!< in: main data type */ + ulint prtype, /*!< in: precise type */ + ulint col_len) /*!< in: column length */ +{ +#ifndef UNIV_HOTBACKUP + ulint mbminlen; + ulint mbmaxlen; +#endif /* !UNIV_HOTBACKUP */ + + column->ind = (unsigned int) col_pos; + column->ord_part = 0; + column->mtype = (unsigned int) mtype; + column->prtype = (unsigned int) prtype; + column->len = (unsigned int) col_len; +#ifndef UNIV_HOTBACKUP + dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen); + dict_col_set_mbminmaxlen(column, mbminlen, mbmaxlen); +#endif /* !UNIV_HOTBACKUP */ +} + /**********************************************************************//** Creates an index memory object. @return own: index object */ diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index 0d033c37879..710f0ac8603 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -1214,7 +1214,7 @@ try_again: space->tablespace_version = fil_system->tablespace_version; space->mark = FALSE; - if (UNIV_LIKELY(purpose == FIL_TABLESPACE) + if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on) && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) { if (!fil_system->space_id_reuse_warned) { fil_system->space_id_reuse_warned = TRUE; @@ -1705,7 +1705,7 @@ fil_write_lsn_and_arch_no_to_file( fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL); - mach_write_ull(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn); + mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn); fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL); @@ -1799,7 +1799,7 @@ fil_read_flushed_lsn_and_arch_log_no( os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE); - flushed_lsn = mach_read_ull(buf + FIL_PAGE_FILE_FLUSH_LSN); + flushed_lsn = mach_read_from_8(buf + FIL_PAGE_FILE_FLUSH_LSN); ut_free(buf2); @@ -2850,7 +2850,7 @@ fil_reset_too_high_lsns( /* We have to read the file flush lsn from the header of the file */ - flush_lsn = mach_read_ull(page + FIL_PAGE_FILE_FLUSH_LSN); + flush_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN); if (current_lsn >= flush_lsn) { /* Ok */ @@ -2898,7 +2898,7 @@ fil_reset_too_high_lsns( goto func_exit; } - if (mach_read_ull(page + FIL_PAGE_LSN) > current_lsn) { + if (mach_read_from_8(page + FIL_PAGE_LSN) > current_lsn) { /* We have to reset the lsn */ if (zip_size) { @@ -2940,7 +2940,7 @@ fil_reset_too_high_lsns( goto func_exit; } - mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn); + mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn); success = os_file_write(filepath, file, page, 0, 0, zip_size ? zip_size : UNIV_PAGE_SIZE); diff --git a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c index 2bae8481d20..3efe147b998 100644 --- a/storage/innobase/fsp/fsp0fsp.c +++ b/storage/innobase/fsp/fsp0fsp.c @@ -127,9 +127,8 @@ typedef byte fseg_inode_t; #define FSEG_ARR_OFFSET (FSEG_PAGE_DATA + FLST_NODE_SIZE) /*-------------------------------------*/ -#define FSEG_ID 0 /* 8 bytes of segment id: if this is - ut_dulint_zero, it means that the - header is unused */ +#define FSEG_ID 0 /* 8 bytes of segment id: if this is 0, + it means that the header is unused */ #define FSEG_NOT_FULL_N_USED 8 /* number of used segment pages in the FSEG_NOT_FULL list */ @@ -999,11 +998,11 @@ fsp_header_init( flst_init(header + FSP_SEG_INODES_FULL, mtr); flst_init(header + FSP_SEG_INODES_FREE, mtr); - mlog_write_dulint(header + FSP_SEG_ID, ut_dulint_create(0, 1), mtr); + mlog_write_ull(header + FSP_SEG_ID, 1, mtr); if (space == 0) { fsp_fill_free_list(FALSE, space, header, mtr); btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, - 0, 0, ut_dulint_add(DICT_IBUF_ID_MIN, space), + 0, 0, DICT_IBUF_ID_MIN + space, dict_ind_redundant, mtr); } else { fsp_fill_free_list(TRUE, space, header, mtr); @@ -1841,7 +1840,7 @@ fsp_seg_inode_page_find_used( inode = fsp_seg_inode_page_get_nth_inode( page, i, zip_size, mtr); - if (!ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) { + if (mach_read_from_8(inode + FSEG_ID)) { /* This is used */ ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) @@ -1872,7 +1871,7 @@ fsp_seg_inode_page_find_free( inode = fsp_seg_inode_page_get_nth_inode( page, i, zip_size, mtr); - if (ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) { + if (!mach_read_from_8(inode + FSEG_ID)) { /* This is unused */ return(i); @@ -1931,7 +1930,7 @@ fsp_alloc_seg_inode_page( inode = fsp_seg_inode_page_get_nth_inode(page, i, zip_size, mtr); - mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr); + mlog_write_ull(inode + FSEG_ID, 0, mtr); } flst_add_last(space_header + FSP_SEG_INODES_FREE, @@ -1998,7 +1997,7 @@ fsp_alloc_seg_inode( page + FSEG_INODE_PAGE_NODE, mtr); } - ut_ad(ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID)) + ut_ad(!mach_read_from_8(inode + FSEG_ID) || mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); return(inode); } @@ -2036,7 +2035,7 @@ fsp_free_seg_inode( page + FSEG_INODE_PAGE_NODE, mtr); } - mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr); + mlog_write_ull(inode + FSEG_ID, 0, mtr); mlog_write_ulint(inode + FSEG_MAGIC_N, 0xfa051ce3, MLOG_4BYTES, mtr); if (ULINT_UNDEFINED @@ -2073,8 +2072,7 @@ fseg_inode_try_get( inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr); - if (UNIV_UNLIKELY - (ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID)))) { + if (UNIV_UNLIKELY(!mach_read_from_8(inode + FSEG_ID))) { inode = NULL; } else { @@ -2249,7 +2247,7 @@ fseg_create_general( ulint zip_size; fsp_header_t* space_header; fseg_inode_t* inode; - dulint seg_id; + ib_id_t seg_id; buf_block_t* block = 0; /* remove warning */ fseg_header_t* header = 0; /* remove warning */ rw_lock_t* latch; @@ -2303,12 +2301,11 @@ fseg_create_general( /* Read the next segment id from space header and increment the value in space header */ - seg_id = mtr_read_dulint(space_header + FSP_SEG_ID, mtr); + seg_id = mach_read_from_8(space_header + FSP_SEG_ID); - mlog_write_dulint(space_header + FSP_SEG_ID, ut_dulint_add(seg_id, 1), - mtr); + mlog_write_ull(space_header + FSP_SEG_ID, seg_id + 1, mtr); - mlog_write_dulint(inode + FSEG_ID, seg_id, mtr); + mlog_write_ull(inode + FSEG_ID, seg_id, mtr); mlog_write_ulint(inode + FSEG_NOT_FULL_N_USED, 0, MLOG_4BYTES, mtr); flst_init(inode + FSEG_FREE, mtr); @@ -2460,7 +2457,7 @@ fseg_fill_free_list( { xdes_t* descr; ulint i; - dulint seg_id; + ib_id_t seg_id; ulint reserved; ulint used; @@ -2497,10 +2494,10 @@ fseg_fill_free_list( xdes_set_state(descr, XDES_FSEG, mtr); - seg_id = mtr_read_dulint(inode + FSEG_ID, mtr); + seg_id = mach_read_from_8(inode + FSEG_ID); ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); - mlog_write_dulint(descr + XDES_ID, seg_id, mtr); + mlog_write_ull(descr + XDES_ID, seg_id, mtr); flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr); hint += FSP_EXTENT_SIZE; @@ -2524,7 +2521,7 @@ fseg_alloc_free_extent( mtr_t* mtr) /*!< in: mtr */ { xdes_t* descr; - dulint seg_id; + ib_id_t seg_id; fil_addr_t first; ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE)); @@ -2545,10 +2542,10 @@ fseg_alloc_free_extent( return(NULL); } - seg_id = mtr_read_dulint(inode + FSEG_ID, mtr); + seg_id = mach_read_from_8(inode + FSEG_ID); xdes_set_state(descr, XDES_FSEG, mtr); - mlog_write_dulint(descr + XDES_ID, seg_id, mtr); + mlog_write_ull(descr + XDES_ID, seg_id, mtr); flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr); /* Try to fill the segment free list */ @@ -2583,7 +2580,7 @@ fseg_alloc_free_page_low( { fsp_header_t* space_header; ulint space_size; - dulint seg_id; + ib_id_t seg_id; ulint used; ulint reserved; xdes_t* descr; /*!< extent of the hinted page */ @@ -2599,9 +2596,9 @@ fseg_alloc_free_page_low( ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE)); - seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr); + seg_id = mach_read_from_8(seg_inode + FSEG_ID); - ut_ad(!ut_dulint_is_zero(seg_id)); + ut_ad(seg_id); reserved = fseg_n_reserved_pages_low(seg_inode, &used, mtr); @@ -2619,8 +2616,7 @@ fseg_alloc_free_page_low( /* In the big if-else below we look for ret_page and ret_descr */ /*-------------------------------------------------------------*/ if ((xdes_get_state(descr, mtr) == XDES_FSEG) - && (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, - mtr), seg_id)) + && mach_read_from_8(descr + XDES_ID) == seg_id && (xdes_get_bit(descr, XDES_FREE_BIT, hint % FSP_EXTENT_SIZE, mtr) == TRUE)) { @@ -2642,7 +2638,7 @@ fseg_alloc_free_page_low( ut_a(ret_descr == descr); xdes_set_state(ret_descr, XDES_FSEG, mtr); - mlog_write_dulint(ret_descr + XDES_ID, seg_id, mtr); + mlog_write_ull(ret_descr + XDES_ID, seg_id, mtr); flst_add_last(seg_inode + FSEG_FREE, ret_descr + XDES_FLST_NODE, mtr); @@ -2671,8 +2667,7 @@ fseg_alloc_free_page_low( } /*-----------------------------------------------------------*/ } else if ((xdes_get_state(descr, mtr) == XDES_FSEG) - && (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, - mtr), seg_id)) + && mach_read_from_8(descr + XDES_ID) == seg_id && (!xdes_is_full(descr, mtr))) { /* 4. We can take the page from the same extent as the @@ -3243,8 +3238,8 @@ fseg_free_page_low( xdes_t* descr; ulint not_full_n_used; ulint state; - dulint descr_id; - dulint seg_id; + ib_id_t descr_id; + ib_id_t seg_id; ulint i; ut_ad(seg_inode && mtr); @@ -3303,20 +3298,18 @@ crash: /* If we get here, the page is in some extent of the segment */ - descr_id = mtr_read_dulint(descr + XDES_ID, mtr); - seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr); + descr_id = mach_read_from_8(descr + XDES_ID); + seg_id = mach_read_from_8(seg_inode + FSEG_ID); #if 0 fprintf(stderr, "InnoDB: InnoDB is freeing space %lu page %lu,\n" - "InnoDB: which belongs to descr seg %lu %lu\n" - "InnoDB: segment %lu %lu.\n", + "InnoDB: which belongs to descr seg %llu\n" + "InnoDB: segment %llu.\n", (ulong) space, (ulong) page, - (ulong) ut_dulint_get_high(descr_id), - (ulong) ut_dulint_get_low(descr_id), - (ulong) ut_dulint_get_high(seg_id), - (ulong) ut_dulint_get_low(seg_id)); + (ullint) descr_id, + (ullint) seg_id); #endif /* 0 */ - if (0 != ut_dulint_cmp(descr_id, seg_id)) { + if (UNIV_UNLIKELY(descr_id != seg_id)) { fputs("InnoDB: Dump of the tablespace extent descriptor: ", stderr); ut_print_buf(stderr, descr, 40); @@ -3328,13 +3321,11 @@ crash: "InnoDB: Serious error: InnoDB is trying to" " free space %lu page %lu,\n" "InnoDB: which does not belong to" - " segment %lu %lu but belongs\n" - "InnoDB: to segment %lu %lu.\n", + " segment %llu but belongs\n" + "InnoDB: to segment %llu.\n", (ulong) space, (ulong) page, - (ulong) ut_dulint_get_high(descr_id), - (ulong) ut_dulint_get_low(descr_id), - (ulong) ut_dulint_get_high(seg_id), - (ulong) ut_dulint_get_low(seg_id)); + (ullint) descr_id, + (ullint) seg_id); goto crash; } @@ -3423,8 +3414,7 @@ fseg_free_extent( descr = xdes_get_descriptor(space, zip_size, page, mtr); ut_a(xdes_get_state(descr, mtr) == XDES_FSEG); - ut_a(0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, mtr), - mtr_read_dulint(seg_inode + FSEG_ID, mtr))); + ut_a(!memcmp(descr + XDES_ID, seg_inode + FSEG_ID, 8)); ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); @@ -3684,7 +3674,7 @@ fseg_validate_low( mtr_t* mtr2) /*!< in: mtr */ { ulint space; - dulint seg_id; + ib_id_t seg_id; mtr_t mtr; xdes_t* descr; fil_addr_t node_addr; @@ -3696,7 +3686,7 @@ fseg_validate_low( space = page_get_space_id(page_align(inode)); - seg_id = mtr_read_dulint(inode + FSEG_ID, mtr2); + seg_id = mach_read_from_8(inode + FSEG_ID); n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr2); flst_validate(inode + FSEG_FREE, mtr2); @@ -3719,8 +3709,7 @@ fseg_validate_low( ut_a(xdes_get_n_used(descr, &mtr) == 0); ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG); - ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr), - seg_id)); + ut_a(mach_read_from_8(descr + XDES_ID) == seg_id); node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr); mtr_commit(&mtr); @@ -3744,8 +3733,7 @@ fseg_validate_low( ut_a(xdes_get_n_used(descr, &mtr) > 0); ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE); ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG); - ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr), - seg_id)); + ut_a(mach_read_from_8(descr + XDES_ID) == seg_id); n_used2 += xdes_get_n_used(descr, &mtr); @@ -3770,8 +3758,7 @@ fseg_validate_low( ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE); ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG); - ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr), - seg_id)); + ut_a(mach_read_from_8(descr + XDES_ID) == seg_id); node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr); mtr_commit(&mtr); @@ -3822,8 +3809,6 @@ fseg_print_low( mtr_t* mtr) /*!< in: mtr */ { ulint space; - ulint seg_id_low; - ulint seg_id_high; ulint n_used; ulint n_frag; ulint n_free; @@ -3832,7 +3817,7 @@ fseg_print_low( ulint reserved; ulint used; ulint page_no; - dulint d_var; + ib_id_t seg_id; ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX)); space = page_get_space_id(page_align(inode)); @@ -3840,10 +3825,7 @@ fseg_print_low( reserved = fseg_n_reserved_pages_low(inode, &used, mtr); - d_var = mtr_read_dulint(inode + FSEG_ID, mtr); - - seg_id_low = ut_dulint_get_low(d_var); - seg_id_high = ut_dulint_get_high(d_var); + seg_id = mach_read_from_8(inode + FSEG_ID); n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr); @@ -3853,11 +3835,11 @@ fseg_print_low( n_full = flst_get_len(inode + FSEG_FULL, mtr); fprintf(stderr, - "SEGMENT id %lu %lu space %lu; page %lu;" + "SEGMENT id %llu space %lu; page %lu;" " res %lu used %lu; full ext %lu\n" "fragm pages %lu; free extents %lu;" " not full extents %lu: pages %lu\n", - (ulong) seg_id_high, (ulong) seg_id_low, + (ullint) seg_id, (ulong) space, (ulong) page_no, (ulong) reserved, (ulong) used, (ulong) n_full, (ulong) n_frag, (ulong) n_free, (ulong) n_not_full, @@ -4059,8 +4041,7 @@ fsp_validate( seg_inode = fsp_seg_inode_page_get_nth_inode( seg_inode_page, n, zip_size, &mtr); - ut_a(!ut_dulint_is_zero( - mach_read_from_8(seg_inode + FSEG_ID))); + ut_a(mach_read_from_8(seg_inode + FSEG_ID) != 0); fseg_validate_low(seg_inode, &mtr); descr_count += flst_get_len(seg_inode + FSEG_FREE, @@ -4105,8 +4086,7 @@ fsp_validate( seg_inode = fsp_seg_inode_page_get_nth_inode( seg_inode_page, n, zip_size, &mtr); - if (!ut_dulint_is_zero( - mach_read_from_8(seg_inode + FSEG_ID))) { + if (mach_read_from_8(seg_inode + FSEG_ID)) { fseg_validate_low(seg_inode, &mtr); descr_count += flst_get_len( @@ -4168,11 +4148,9 @@ fsp_print( ulint n_free; ulint n_free_frag; ulint n_full_frag; - ulint seg_id_low; - ulint seg_id_high; + ib_id_t seg_id; ulint n; ulint n_segs = 0; - dulint d_var; mtr_t mtr; mtr_t mtr2; @@ -4202,21 +4180,18 @@ fsp_print( n_free_frag = flst_get_len(header + FSP_FREE_FRAG, &mtr); n_full_frag = flst_get_len(header + FSP_FULL_FRAG, &mtr); - d_var = mtr_read_dulint(header + FSP_SEG_ID, &mtr); - - seg_id_low = ut_dulint_get_low(d_var); - seg_id_high = ut_dulint_get_high(d_var); + seg_id = mach_read_from_8(header + FSP_SEG_ID); fprintf(stderr, "FILE SPACE INFO: id %lu\n" "size %lu, free limit %lu, free extents %lu\n" "not full frag extents %lu: used pages %lu," " full frag extents %lu\n" - "first seg id not used %lu %lu\n", + "first seg id not used %llu\n", (ulong) space, (ulong) size, (ulong) free_limit, (ulong) n_free, (ulong) n_free_frag, (ulong) frag_n_used, (ulong) n_full_frag, - (ulong) seg_id_high, (ulong) seg_id_low); + (ullint) seg_id); mtr_commit(&mtr); @@ -4246,8 +4221,7 @@ fsp_print( seg_inode = fsp_seg_inode_page_get_nth_inode( seg_inode_page, n, zip_size, &mtr); - ut_a(!ut_dulint_is_zero( - mach_read_from_8(seg_inode + FSEG_ID))); + ut_a(mach_read_from_8(seg_inode + FSEG_ID) != 0); fseg_print_low(seg_inode, &mtr); n_segs++; @@ -4284,8 +4258,7 @@ fsp_print( seg_inode = fsp_seg_inode_page_get_nth_inode( seg_inode_page, n, zip_size, &mtr); - if (!ut_dulint_is_zero( - mach_read_from_8(seg_inode + FSEG_ID))) { + if (mach_read_from_8(seg_inode + FSEG_ID)) { fseg_print_low(seg_inode, &mtr); n_segs++; diff --git a/storage/innobase/ha/ha0ha.c b/storage/innobase/ha/ha0ha.c index 9d9d341ad39..f9e798012f8 100644 --- a/storage/innobase/ha/ha0ha.c +++ b/storage/innobase/ha/ha0ha.c @@ -31,9 +31,7 @@ Created 8/22/1994 Heikki Tuuri #ifdef UNIV_DEBUG # include "buf0buf.h" #endif /* UNIV_DEBUG */ -#ifdef UNIV_SYNC_DEBUG -# include "btr0sea.h" -#endif /* UNIV_SYNC_DEBUG */ +#include "btr0sea.h" #include "page0page.h" /*************************************************************//** @@ -127,7 +125,8 @@ ha_clear( /*************************************************************//** Inserts an entry into a hash table. If an entry with the same fold number is found, its node is updated to point to the new data, and no new node -is inserted. +is inserted. If btr_search_enabled is set to FALSE, we will only allow +updating existing nodes, but no new node is allowed to be added. @return TRUE if succeed, FALSE if no more memory could be allocated */ UNIV_INTERN ibool @@ -174,6 +173,7 @@ ha_insert_for_fold_func( prev_block->n_pointers--; block->n_pointers++; } + ut_ad(!btr_search_fully_disabled); # endif /* !UNIV_HOTBACKUP */ prev_node->block = block; @@ -186,6 +186,13 @@ ha_insert_for_fold_func( prev_node = prev_node->next; } + /* We are in the process of disabling hash index, do not add + new chain node */ + if (!btr_search_enabled) { + ut_ad(!btr_search_fully_disabled); + return(TRUE); + } + /* We have to allocate a new chain node */ node = mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t)); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index f5227add6f1..ab9df9a0272 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -571,7 +571,7 @@ innodb_show_status( THD* thd, /*!< in: the MySQL query thread of the caller */ stat_print_fn *stat_print); static -bool innobase_show_status(handlerton *hton, THD* thd, +bool innobase_show_status(handlerton *hton, THD* thd, stat_print_fn* stat_print, enum ha_stat_type stat_type); @@ -1032,6 +1032,8 @@ innobase_get_cset_width( if (cs) { *mbminlen = cs->mbminlen; *mbmaxlen = cs->mbmaxlen; + ut_ad(*mbminlen < DATA_MBMAX); + ut_ad(*mbmaxlen < DATA_MBMAX); } else { THD* thd = current_thd; @@ -1254,7 +1256,7 @@ innobase_mysql_tmpfile(void) my_close(). */ #ifdef _WIN32 - /* Note that on Windows, the integer returned by mysql_tmpfile + /* Note that on Windows, the integer returned by mysql_tmpfile has no relation to C runtime file descriptor. Here, we need to call my_get_osfhandle to get the HANDLE and then convert it to C runtime filedescriptor. */ @@ -2444,6 +2446,7 @@ innobase_change_buffering_inited_ok: /* Get the current high water mark format. */ innobase_file_format_max = (char*) trx_sys_file_format_max_get(); + btr_search_fully_disabled = (!btr_search_enabled); DBUG_RETURN(FALSE); error: DBUG_RETURN(TRUE); @@ -2956,9 +2959,9 @@ innobase_close_connection( global_system_variables.log_warnings) { sql_print_warning( "MySQL is closing a connection that has an active " - "InnoDB transaction. %lu row modifications will " + "InnoDB transaction. %llu row modifications will " "roll back.", - (ulong) trx->undo_no.low); + (ullint) trx->undo_no); } innobase_rollback_trx(trx); @@ -4128,6 +4131,11 @@ get_innobase_type_from_mysql_type( case MYSQL_TYPE_BLOB: case MYSQL_TYPE_LONG_BLOB: return(DATA_BLOB); + case MYSQL_TYPE_NULL: + /* MySQL currently accepts "NULL" datatype, but will + reject such datatype in the next release. We will cope + with it and not trigger assertion failure in 5.1 */ + break; default: ut_error; } @@ -4422,15 +4430,14 @@ ha_innobase::store_key_val_for_row( memcpy(buff, src_start, true_len); buff += true_len; - /* Pad the unused space with spaces. Note that no - padding is ever needed for UCS-2 because in MySQL, - all UCS2 characters are 2 bytes, as MySQL does not - support surrogate pairs, which are needed to represent - characters in the range U+10000 to U+10FFFF. */ + /* Pad the unused space with spaces. */ if (true_len < key_len) { - ulint pad_len = key_len - true_len; - memset(buff, ' ', pad_len); + ulint pad_len = key_len - true_len; + ut_a(!(pad_len % cs->mbminlen)); + + cs->cset->fill(cs, buff, pad_len, + 0x20 /* space */); buff += pad_len; } } @@ -4539,6 +4546,7 @@ build_template( /* Note that in InnoDB, i is the column number. MySQL calls columns 'fields'. */ for (i = 0; i < n_fields; i++) { + const dict_col_t* col = &index->table->cols[i]; templ = prebuilt->mysql_template + n_requested_fields; field = table->field[i]; @@ -4587,7 +4595,7 @@ include_field: if (index == clust_index) { templ->rec_field_no = dict_col_get_clust_pos( - &index->table->cols[i], index); + col, index); } else { templ->rec_field_no = dict_index_get_nth_col_pos( index, i); @@ -4616,7 +4624,7 @@ include_field: mysql_prefix_len = templ->mysql_col_offset + templ->mysql_col_len; } - templ->type = index->table->cols[i].mtype; + templ->type = col->mtype; templ->mysql_type = (ulint)field->type(); if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) { @@ -4624,12 +4632,10 @@ include_field: (((Field_varstring*)field)->length_bytes); } - templ->charset = dtype_get_charset_coll( - index->table->cols[i].prtype); - templ->mbminlen = index->table->cols[i].mbminlen; - templ->mbmaxlen = index->table->cols[i].mbmaxlen; - templ->is_unsigned = index->table->cols[i].prtype - & DATA_UNSIGNED; + templ->charset = dtype_get_charset_coll(col->prtype); + templ->mbminlen = dict_col_get_mbminlen(col); + templ->mbmaxlen = dict_col_get_mbmaxlen(col); + templ->is_unsigned = col->prtype & DATA_UNSIGNED; if (templ->type == DATA_BLOB) { prebuilt->templ_contains_blob = TRUE; } @@ -5557,6 +5563,9 @@ ha_innobase::index_read( prebuilt->index_usable = FALSE; DBUG_RETURN(HA_ERR_CRASHED); } + if (UNIV_UNLIKELY(!prebuilt->index_usable)) { + DBUG_RETURN(HA_ERR_TABLE_DEF_CHANGED); + } /* Note that if the index for which the search template is built is not necessarily prebuilt->index, but can also be the clustered index */ @@ -6175,7 +6184,22 @@ create_table_def( field = form->field[i]; col_type = get_innobase_type_from_mysql_type(&unsigned_type, - field); + field); + + if (!col_type) { + push_warning_printf( + (THD*) trx->mysql_thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_CANT_CREATE_TABLE, + "Error creating table '%s' with " + "column '%s'. Please check its " + "column type and try to re-create " + "the table with an appropriate " + "column type.", + table->name, (char*) field->field_name); + goto err_col; + } + if (field->null_ptr) { nulls_allowed = 0; } else { @@ -6233,7 +6257,7 @@ create_table_def( if (dict_col_name_is_reserved(field->field_name)){ my_error(ER_WRONG_COLUMN_NAME, MYF(0), field->field_name); - +err_col: dict_mem_table_free(table); trx_commit_for_mysql(trx); @@ -6635,6 +6659,7 @@ ha_innobase::create( const ulint file_format = srv_file_format; const char* stmt; size_t stmt_len; + enum row_type row_type; DBUG_ENTER("ha_innobase::create"); @@ -6755,94 +6780,94 @@ ha_innobase::create( } } - if (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) { - if (flags) { - /* KEY_BLOCK_SIZE was specified. */ - if (form->s->row_type != ROW_TYPE_COMPRESSED) { - /* ROW_FORMAT other than COMPRESSED - ignores KEY_BLOCK_SIZE. It does not - make sense to reject conflicting - KEY_BLOCK_SIZE and ROW_FORMAT, because - such combinations can be obtained - with ALTER TABLE anyway. */ - push_warning_printf( - thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ignoring KEY_BLOCK_SIZE=%lu" - " unless ROW_FORMAT=COMPRESSED.", - create_info->key_block_size); - flags = 0; - } - } else { - /* No KEY_BLOCK_SIZE */ - if (form->s->row_type == ROW_TYPE_COMPRESSED) { - /* ROW_FORMAT=COMPRESSED without - KEY_BLOCK_SIZE implies half the - maximum KEY_BLOCK_SIZE. */ - flags = (DICT_TF_ZSSIZE_MAX - 1) - << DICT_TF_ZSSIZE_SHIFT - | DICT_TF_COMPACT - | DICT_TF_FORMAT_ZIP - << DICT_TF_FORMAT_SHIFT; + row_type = form->s->row_type; + + if (flags) { + /* KEY_BLOCK_SIZE was specified. */ + if (!(create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) { + /* ROW_FORMAT was not specified; + default to ROW_FORMAT=COMPRESSED */ + row_type = ROW_TYPE_COMPRESSED; + } else if (row_type != ROW_TYPE_COMPRESSED) { + /* ROW_FORMAT other than COMPRESSED + ignores KEY_BLOCK_SIZE. It does not + make sense to reject conflicting + KEY_BLOCK_SIZE and ROW_FORMAT, because + such combinations can be obtained + with ALTER TABLE anyway. */ + push_warning_printf( + thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ignoring KEY_BLOCK_SIZE=%lu" + " unless ROW_FORMAT=COMPRESSED.", + create_info->key_block_size); + flags = 0; + } + } else { + /* No KEY_BLOCK_SIZE */ + if (row_type == ROW_TYPE_COMPRESSED) { + /* ROW_FORMAT=COMPRESSED without + KEY_BLOCK_SIZE implies half the + maximum KEY_BLOCK_SIZE. */ + flags = (DICT_TF_ZSSIZE_MAX - 1) + << DICT_TF_ZSSIZE_SHIFT + | DICT_TF_COMPACT + | DICT_TF_FORMAT_ZIP + << DICT_TF_FORMAT_SHIFT; #if DICT_TF_ZSSIZE_MAX < 1 # error "DICT_TF_ZSSIZE_MAX < 1" #endif - } } + } - switch (form->s->row_type) { - const char* row_format_name; - case ROW_TYPE_REDUNDANT: - break; - case ROW_TYPE_COMPRESSED: - case ROW_TYPE_DYNAMIC: - row_format_name - = form->s->row_type == ROW_TYPE_COMPRESSED - ? "COMPRESSED" - : "DYNAMIC"; - - if (!srv_file_per_table) { - push_warning_printf( - thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s" - " requires innodb_file_per_table.", - row_format_name); - } else if (file_format < DICT_TF_FORMAT_ZIP) { - push_warning_printf( - thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s" - " requires innodb_file_format >" - " Antelope.", - row_format_name); - } else { - flags |= DICT_TF_COMPACT - | (DICT_TF_FORMAT_ZIP - << DICT_TF_FORMAT_SHIFT); - break; - } + switch (row_type) { + const char* row_format_name; + case ROW_TYPE_REDUNDANT: + break; + case ROW_TYPE_COMPRESSED: + case ROW_TYPE_DYNAMIC: + row_format_name + = row_type == ROW_TYPE_COMPRESSED + ? "COMPRESSED" + : "DYNAMIC"; - /* fall through */ - case ROW_TYPE_NOT_USED: - case ROW_TYPE_FIXED: - default: - push_warning(thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: assuming ROW_FORMAT=COMPACT."); - case ROW_TYPE_DEFAULT: - case ROW_TYPE_COMPACT: - flags = DICT_TF_COMPACT; + if (!srv_file_per_table) { + push_warning_printf( + thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s" + " requires innodb_file_per_table.", + row_format_name); + } else if (file_format < DICT_TF_FORMAT_ZIP) { + push_warning_printf( + thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s" + " requires innodb_file_format >" + " Antelope.", + row_format_name); + } else { + flags |= DICT_TF_COMPACT + | (DICT_TF_FORMAT_ZIP + << DICT_TF_FORMAT_SHIFT); break; } - } else if (!flags) { - /* No KEY_BLOCK_SIZE or ROW_FORMAT specified: - use ROW_FORMAT=COMPACT by default. */ + + /* fall through */ + case ROW_TYPE_NOT_USED: + case ROW_TYPE_FIXED: + default: + push_warning(thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: assuming ROW_FORMAT=COMPACT."); + case ROW_TYPE_DEFAULT: + case ROW_TYPE_COMPACT: flags = DICT_TF_COMPACT; + break; } /* Look for a primary key */ @@ -7399,6 +7424,10 @@ ha_innobase::records_in_range( n_rows = HA_POS_ERROR; goto func_exit; } + if (UNIV_UNLIKELY(!row_merge_is_index_usable(prebuilt->trx, index))) { + n_rows = HA_ERR_TABLE_DEF_CHANGED; + goto func_exit; + } heap = mem_heap_create(2 * (key->key_parts * sizeof(dfield_t) + sizeof(dtuple_t))); @@ -10806,7 +10835,7 @@ by the server. Can be set during server startup at command line or configure file, and a read only variable after server startup */ static MYSQL_SYSVAR_BOOL(file_format_check, innobase_file_format_check, - PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY, + PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Whether to perform system file format check.", NULL, NULL, TRUE); diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index ec17882590c..3744d16570c 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -99,8 +99,10 @@ innobase_col_to_mysql( #ifdef UNIV_DEBUG case DATA_MYSQL: ut_ad(flen >= len); - ut_ad(col->mbmaxlen >= col->mbminlen); - ut_ad(col->mbmaxlen > col->mbminlen || flen == len); + ut_ad(DATA_MBMAXLEN(col->mbminmaxlen) + >= DATA_MBMINLEN(col->mbminmaxlen)); + ut_ad(DATA_MBMAXLEN(col->mbminmaxlen) + > DATA_MBMINLEN(col->mbminmaxlen) || flen == len); memcpy(dest, data, len); break; diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 2c15a3b87db..0733a558080 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -401,133 +401,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, #define IDX_TRX_ADAPTIVE_HASH_LATCHED 20 - {STRUCT_FLD(field_name, "trx_apative_hash_latched"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_ADAPTIVE_HASH_TIMEOUT 21 - {STRUCT_FLD(field_name, "trx_adaptive_hash_timeout"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_OPERATION_STATE 8 - {STRUCT_FLD(field_name, "trx_operation_state"), - STRUCT_FLD(field_length, TRX_I_S_TRX_OP_STATE_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_TABLES_IN_USE 9 - {STRUCT_FLD(field_name, "trx_tables_in_use"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_TABLES_LOCKED 10 - {STRUCT_FLD(field_name, "trx_tables_locked"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_LOCK_STRUCTS 11 - {STRUCT_FLD(field_name, "trx_lock_structs"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_LOCK_MEMORY_BYTES 12 - {STRUCT_FLD(field_name, "trx_lock_memory_bytes"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_ROWS_LOCKED 13 - {STRUCT_FLD(field_name, "trx_rows_locked"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_ROWS_MODIFIED 14 - {STRUCT_FLD(field_name, "trx_rows_modified"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_CONNCURRENCY_TICKETS 15 - {STRUCT_FLD(field_name, "trx_concurrency_tickets"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_ISOLATION_LEVEL 16 - {STRUCT_FLD(field_name, "trx_isolation_level"), - STRUCT_FLD(field_length, TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_UNIQUE_CHECKS 17 - {STRUCT_FLD(field_name, "trx_unique_checks"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 1), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_FOREIGN_KEY_CHECKS 18 - {STRUCT_FLD(field_name, "trx_foreign_key_checks"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 1), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_LAST_FOREIGN_KEY_ERROR 19 - {STRUCT_FLD(field_name, "trx_last_foreign_key_error"), - STRUCT_FLD(field_length, TRX_I_S_TRX_FK_ERROR_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_ADAPTIVE_HASH_LATCHED 20 - {STRUCT_FLD(field_name, "trx_apative_hash_latched"), + {STRUCT_FLD(field_name, "trx_adaptive_hash_latched"), STRUCT_FLD(field_length, 1), STRUCT_FLD(field_type, MYSQL_TYPE_LONG), STRUCT_FLD(value, 0), @@ -674,7 +548,7 @@ fill_innodb_trx_from_cache( OK(field_store_string(fields[IDX_TRX_LAST_FOREIGN_KEY_ERROR], row->trx_foreign_key_error)); - /* trx_apative_hash_latched */ + /* trx_adaptive_hash_latched */ OK(fields[IDX_TRX_ADAPTIVE_HASH_LATCHED]->store( row->trx_has_search_latch)); @@ -1973,16 +1847,13 @@ i_s_dict_fill_sys_tables( dict_table_t* table, /*!< in: table */ TABLE* table_to_fill) /*!< in/out: fill this table */ { - longlong table_id; Field** fields; DBUG_ENTER("i_s_dict_fill_sys_tables"); fields = table_to_fill->field; - table_id = ut_conv_dulint_to_longlong(table->id); - - OK(fields[SYS_TABLE_ID]->store(table_id, TRUE)); + OK(fields[SYS_TABLE_ID]->store(longlong(table->id), TRUE)); OK(field_store_string(fields[SYS_TABLE_NAME], table->name)); @@ -2238,16 +2109,13 @@ i_s_dict_fill_sys_tablestats( dict_table_t* table, /*!< in: table */ TABLE* table_to_fill) /*!< in/out: fill this table */ { - longlong table_id; Field** fields; DBUG_ENTER("i_s_dict_fill_sys_tablestats"); fields = table_to_fill->field; - table_id = ut_conv_dulint_to_longlong(table->id); - - OK(fields[SYS_TABLESTATS_ID]->store(table_id, TRUE)); + OK(fields[SYS_TABLESTATS_ID]->store(longlong(table->id), TRUE)); OK(field_store_string(fields[SYS_TABLESTATS_NAME], table->name)); @@ -2495,27 +2363,22 @@ int i_s_dict_fill_sys_indexes( /*======================*/ THD* thd, /*!< in: thread */ - dulint tableid, /*!< in: table id */ + table_id_t table_id, /*!< in: table id */ dict_index_t* index, /*!< in: populated dict_index_t struct with index info */ TABLE* table_to_fill) /*!< in/out: fill this table */ { - longlong table_id; - longlong index_id; Field** fields; DBUG_ENTER("i_s_dict_fill_sys_indexes"); fields = table_to_fill->field; - table_id = ut_conv_dulint_to_longlong(tableid); - index_id = ut_conv_dulint_to_longlong(index->id); - - OK(fields[SYS_INDEX_ID]->store(index_id, TRUE)); + OK(fields[SYS_INDEX_ID]->store(longlong(index->id), TRUE)); OK(field_store_string(fields[SYS_INDEX_NAME], index->name)); - OK(fields[SYS_INDEX_TABLE_ID]->store(table_id, TRUE)); + OK(fields[SYS_INDEX_TABLE_ID]->store(longlong(table_id), TRUE)); OK(fields[SYS_INDEX_TYPE]->store(index->type)); @@ -2564,7 +2427,7 @@ i_s_sys_indexes_fill_table( /* Process each record in the table */ while (rec) { const char* err_msg;; - dulint table_id; + table_id_t table_id; dict_index_t index_rec; /* Populate a dict_index_t structure with information from @@ -2737,22 +2600,19 @@ int i_s_dict_fill_sys_columns( /*======================*/ THD* thd, /*!< in: thread */ - dulint tableid, /*!< in: table ID */ + table_id_t table_id, /*!< in: table ID */ const char* col_name, /*!< in: column name */ dict_col_t* column, /*!< in: dict_col_t struct holding more column information */ TABLE* table_to_fill) /*!< in/out: fill this table */ { - longlong table_id; Field** fields; DBUG_ENTER("i_s_dict_fill_sys_columns"); fields = table_to_fill->field; - table_id = ut_conv_dulint_to_longlong(tableid); - - OK(fields[SYS_COLUMN_TABLE_ID]->store(table_id, TRUE)); + OK(fields[SYS_COLUMN_TABLE_ID]->store(longlong(table_id), TRUE)); OK(field_store_string(fields[SYS_COLUMN_NAME], col_name)); @@ -2803,7 +2663,7 @@ i_s_sys_columns_fill_table( while (rec) { const char* err_msg; dict_col_t column_rec; - dulint table_id; + table_id_t table_id; /* populate a dict_col_t structure with information from a SYS_COLUMNS row */ @@ -2948,21 +2808,18 @@ int i_s_dict_fill_sys_fields( /*=====================*/ THD* thd, /*!< in: thread */ - dulint indexid, /*!< in: index id for the field */ + index_id_t index_id, /*!< in: index id for the field */ dict_field_t* field, /*!< in: table */ ulint pos, /*!< in: Field position */ TABLE* table_to_fill) /*!< in/out: fill this table */ { - longlong index_id; Field** fields; DBUG_ENTER("i_s_dict_fill_sys_fields"); fields = table_to_fill->field; - index_id = ut_conv_dulint_to_longlong(indexid); - - OK(fields[SYS_FIELD_INDEX_ID]->store(index_id, TRUE)); + OK(fields[SYS_FIELD_INDEX_ID]->store(longlong(index_id), TRUE)); OK(field_store_string(fields[SYS_FIELD_NAME], field->name)); @@ -2988,7 +2845,7 @@ i_s_sys_fields_fill_table( btr_pcur_t pcur; const rec_t* rec; mem_heap_t* heap; - dulint last_id; + index_id_t last_id; mtr_t mtr; DBUG_ENTER("i_s_sys_fields_fill_table"); @@ -3005,14 +2862,14 @@ i_s_sys_fields_fill_table( /* will save last index id so that we know whether we move to the next index. This is used to calculate prefix length */ - last_id = ut_dulint_create(0, 0); + last_id = 0; rec = dict_startscan_system(&pcur, &mtr, SYS_FIELDS); while (rec) { ulint pos; const char* err_msg; - dulint index_id; + index_id_t index_id; dict_field_t field_rec; /* Populate a dict_field_t structure with information from diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index 0397af88ff4..dc8e61e5070 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -565,7 +565,7 @@ ibuf_init_at_db_start(void) dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0); - table->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID); + table->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID; dict_table_add_to_cache(table, heap); mem_heap_free(heap); @@ -576,7 +576,7 @@ ibuf_init_at_db_start(void) dict_mem_index_add_field(index, "DUMMY_COLUMN", 0); - index->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID); + index->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID; error = dict_index_add_to_cache(table, index, FSP_IBUF_TREE_ROOT_PAGE_NO, FALSE); diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index cc08cc620c5..3912f315f2a 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -130,7 +130,7 @@ btr_page_get( Gets the index id field of a page. @return index id */ UNIV_INLINE -dulint +index_id_t btr_page_get_index_id( /*==================*/ const page_t* page); /*!< in: index page */ @@ -226,7 +226,7 @@ btr_create( ulint space, /*!< in: space where created */ ulint zip_size,/*!< in: compressed page size in bytes or 0 for uncompressed pages */ - dulint index_id,/*!< in: index id */ + index_id_t index_id,/*!< in: index id */ dict_index_t* index, /*!< in: index */ mtr_t* mtr); /*!< in: mini-transaction handle */ /************************************************************//** diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index 97944cc2e26..6c580a0bd6e 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -86,7 +86,7 @@ btr_page_set_index_id( page_t* page, /*!< in: page to be created */ page_zip_des_t* page_zip,/*!< in: compressed page whose uncompressed part will be updated, or NULL */ - dulint id, /*!< in: index id */ + index_id_t id, /*!< in: index id */ mtr_t* mtr) /*!< in: mtr */ { if (UNIV_LIKELY_NULL(page_zip)) { @@ -95,8 +95,7 @@ btr_page_set_index_id( page + (PAGE_HEADER + PAGE_INDEX_ID), 8, mtr); } else { - mlog_write_dulint(page + (PAGE_HEADER + PAGE_INDEX_ID), - id, mtr); + mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr); } } #endif /* !UNIV_HOTBACKUP */ @@ -105,7 +104,7 @@ btr_page_set_index_id( Gets the index id field of a page. @return index id */ UNIV_INLINE -dulint +index_id_t btr_page_get_index_id( /*==================*/ const page_t* page) /*!< in: index page */ diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 136d2d068a1..757477838ee 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -558,7 +558,7 @@ btr_copy_externally_stored_field_prefix( ulint local_len);/*!< in: length of data, in bytes */ /*******************************************************************//** Copies an externally stored field of a record to mem heap. -@return the field copied to heap */ +@return the field copied to heap, or NULL if the field is incomplete */ UNIV_INTERN byte* btr_rec_copy_externally_stored_field( diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h index f98ba386f9c..20a2be7f877 100644 --- a/storage/innobase/include/btr0sea.h +++ b/storage/innobase/include/btr0sea.h @@ -190,7 +190,13 @@ btr_search_validate(void); /** Flag: has the search system been enabled? Protected by btr_search_latch and btr_search_enabled_mutex. */ -extern char btr_search_enabled; +extern char btr_search_enabled; + +/** Flag: whether the search system has completed its disabling process, +It is set to TRUE right after buf_pool_drop_hash_index() in +btr_search_disable(), indicating hash index entries are cleaned up. +Protected by btr_search_latch and btr_search_enabled_mutex. */ +extern ibool btr_search_fully_disabled; /** The search info struct in an index */ struct btr_search_struct{ diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 5326ca9c14f..f33ef65ddf2 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -869,7 +869,8 @@ buf_page_set_accessed( __attribute__((nonnull)); /*********************************************************************//** Gets the buf_block_t handle of a buffered file block if an uncompressed -page frame exists, or NULL. +page frame exists, or NULL. Note: even though bpage is not declared a +const we don't update its value. It is safe to make this pure. @return control block, or NULL */ UNIV_INLINE buf_block_t* diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index f9fce3f3657..11e4027777a 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -309,7 +309,7 @@ dtuple_fold( ulint n_fields,/*!< in: number of complete fields to fold */ ulint n_bytes,/*!< in: number of bytes to fold in an incomplete last field */ - dulint tree_id)/*!< in: index tree id */ + index_id_t tree_id)/*!< in: index tree id */ __attribute__((pure)); /*******************************************************************//** Sets types of fields binary in a tuple. */ diff --git a/storage/innobase/include/data0data.ic b/storage/innobase/include/data0data.ic index da79aa33702..2e3adf4b707 100644 --- a/storage/innobase/include/data0data.ic +++ b/storage/innobase/include/data0data.ic @@ -518,7 +518,7 @@ dtuple_fold( ulint n_fields,/*!< in: number of complete fields to fold */ ulint n_bytes,/*!< in: number of bytes to fold in an incomplete last field */ - dulint tree_id)/*!< in: index tree id */ + index_id_t tree_id)/*!< in: index tree id */ { const dfield_t* field; ulint i; @@ -530,7 +530,7 @@ dtuple_fold( ut_ad(tuple->magic_n == DATA_TUPLE_MAGIC_N); ut_ad(dtuple_check_typed(tuple)); - fold = ut_fold_dulint(tree_id); + fold = ut_fold_ull(tree_id); for (i = 0; i < n_fields; i++) { field = dtuple_get_nth_field(tuple, i); diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h index a73bed3a9f5..850cf2e2975 100644 --- a/storage/innobase/include/data0type.h +++ b/storage/innobase/include/data0type.h @@ -128,7 +128,7 @@ columns, and for them the precise type is usually not used at all. /* Precise data types for system columns and the length of those columns; NOTE: the values must run from 0 up in the order given! All codes must be less than 256 */ -#define DATA_ROW_ID 0 /* row id: a dulint */ +#define DATA_ROW_ID 0 /* row id: a 48-bit integer */ #define DATA_ROW_ID_LEN 6 /* stored length for row id */ #define DATA_TRX_ID 1 /* transaction id: 6 bytes */ @@ -168,6 +168,17 @@ SQL null*/ store the charset-collation number; one byte is left unused, though */ #define DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE 6 +/* Maximum multi-byte character length in bytes, plus 1 */ +#define DATA_MBMAX 5 + +/* Pack mbminlen, mbmaxlen to mbminmaxlen. */ +#define DATA_MBMINMAXLEN(mbminlen, mbmaxlen) \ + ((mbmaxlen) * DATA_MBMAX + (mbminlen)) +/* Get mbminlen from mbminmaxlen. */ +#define DATA_MBMINLEN(mbminmaxlen) UNIV_EXPECT(((mbminmaxlen) % DATA_MBMAX), 1) +/* Get mbmaxlen from mbminmaxlen. */ +#define DATA_MBMAXLEN(mbminmaxlen) ((mbminmaxlen) / DATA_MBMAX) + #ifndef UNIV_HOTBACKUP /*********************************************************************//** Gets the MySQL type code from a dtype. @@ -187,10 +198,8 @@ ulint dtype_get_at_most_n_mbchars( /*========================*/ ulint prtype, /*!< in: precise type */ - ulint mbminlen, /*!< in: minimum length of a - multi-byte character */ - ulint mbmaxlen, /*!< in: maximum length of a - multi-byte character */ + ulint mbminmaxlen, /*!< in: minimum and maximum length of + a multi-byte character */ ulint prefix_len, /*!< in: length of the requested prefix, in characters, multiplied by dtype_get_mbmaxlen(dtype) */ @@ -335,6 +344,19 @@ dtype_get_mbmaxlen( /*===============*/ const dtype_t* type); /*!< in: type */ /*********************************************************************//** +Sets the minimum and maximum length of a character, in bytes. */ +UNIV_INLINE +void +dtype_set_mbminmaxlen( +/*==================*/ + dtype_t* type, /*!< in/out: type */ + ulint mbminlen, /*!< in: minimum length of a char, + in bytes, or 0 if this is not + a character type */ + ulint mbmaxlen); /*!< in: maximum length of a char, + in bytes, or 0 if this is not + a character type */ +/*********************************************************************//** Gets the padding character code for the type. @return padding character code, or ULINT_UNDEFINED if no padding specified */ UNIV_INLINE @@ -354,8 +376,8 @@ dtype_get_fixed_size_low( ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ ulint len, /*!< in: length */ - ulint mbminlen, /*!< in: minimum length of a multibyte char */ - ulint mbmaxlen, /*!< in: maximum length of a multibyte char */ + ulint mbminmaxlen, /*!< in: minimum and maximum length of a + multibyte character, in bytes */ ulint comp); /*!< in: nonzero=ROW_FORMAT=COMPACT */ #ifndef UNIV_HOTBACKUP /***********************************************************************//** @@ -368,8 +390,8 @@ dtype_get_min_size_low( ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ ulint len, /*!< in: length */ - ulint mbminlen, /*!< in: minimum length of a multibyte char */ - ulint mbmaxlen); /*!< in: maximum length of a multibyte char */ + ulint mbminmaxlen); /*!< in: minimum and maximum length of a + multibyte character */ /***********************************************************************//** Returns the maximum size of a data type. Note: types in system tables may be incomplete and return incorrect information. @@ -472,10 +494,11 @@ struct dtype_struct{ the string, MySQL uses 1 or 2 bytes to store the string length) */ #ifndef UNIV_HOTBACKUP - unsigned mbminlen:2; /*!< minimum length of a - character, in bytes */ - unsigned mbmaxlen:3; /*!< maximum length of a - character, in bytes */ + unsigned mbminmaxlen:5; /*!< minimum and maximum length of a + character, in bytes; + DATA_MBMINMAXLEN(mbminlen,mbmaxlen); + mbminlen=DATA_MBMINLEN(mbminmaxlen); + mbmaxlen=DATA_MBMINLEN(mbminmaxlen) */ #endif /* !UNIV_HOTBACKUP */ }; diff --git a/storage/innobase/include/data0type.ic b/storage/innobase/include/data0type.ic index 2bf67a941bd..757dd815c5e 100644 --- a/storage/innobase/include/data0type.ic +++ b/storage/innobase/include/data0type.ic @@ -93,14 +93,35 @@ dtype_get_mblen( innobase_get_cset_width(dtype_get_charset_coll(prtype), mbminlen, mbmaxlen); ut_ad(*mbminlen <= *mbmaxlen); - ut_ad(*mbminlen <= 2); /* mbminlen in dtype_t is 0..3 */ - ut_ad(*mbmaxlen < 1 << 3); /* mbmaxlen in dtype_t is 0..7 */ + ut_ad(*mbminlen < DATA_MBMAX); + ut_ad(*mbmaxlen < DATA_MBMAX); } else { *mbminlen = *mbmaxlen = 0; } } /*********************************************************************//** +Sets the minimum and maximum length of a character, in bytes. */ +UNIV_INLINE +void +dtype_set_mbminmaxlen( +/*==================*/ + dtype_t* type, /*!< in/out: type */ + ulint mbminlen, /*!< in: minimum length of a char, + in bytes, or 0 if this is not + a character type */ + ulint mbmaxlen) /*!< in: maximum length of a char, + in bytes, or 0 if this is not + a character type */ +{ + ut_ad(mbminlen < DATA_MBMAX); + ut_ad(mbmaxlen < DATA_MBMAX); + ut_ad(mbminlen <= mbmaxlen); + + type->mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen); +} + +/*********************************************************************//** Compute the mbminlen and mbmaxlen members of a data type structure. */ UNIV_INLINE void @@ -112,8 +133,7 @@ dtype_set_mblen( ulint mbmaxlen; dtype_get_mblen(type->mtype, type->prtype, &mbminlen, &mbmaxlen); - type->mbminlen = mbminlen; - type->mbmaxlen = mbmaxlen; + dtype_set_mbminmaxlen(type, mbminlen, mbmaxlen); ut_ad(dtype_validate(type)); } @@ -210,7 +230,7 @@ dtype_get_mbminlen( const dtype_t* type) /*!< in: type */ { ut_ad(type); - return(type->mbminlen); + return(DATA_MBMINLEN(type->mbminmaxlen)); } /*********************************************************************//** Gets the maximum length of a character, in bytes. @@ -223,7 +243,7 @@ dtype_get_mbmaxlen( const dtype_t* type) /*!< in: type */ { ut_ad(type); - return(type->mbmaxlen); + return(DATA_MBMAXLEN(type->mbminmaxlen)); } /*********************************************************************//** @@ -404,8 +424,8 @@ dtype_get_fixed_size_low( ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ ulint len, /*!< in: length */ - ulint mbminlen, /*!< in: minimum length of a multibyte char */ - ulint mbmaxlen, /*!< in: maximum length of a multibyte char */ + ulint mbminmaxlen, /*!< in: minimum and maximum length of + a multibyte character, in bytes */ ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ { switch (mtype) { @@ -453,8 +473,9 @@ dtype_get_fixed_size_low( dtype_get_charset_coll(prtype), &i_mbminlen, &i_mbmaxlen); - if (UNIV_UNLIKELY(mbminlen != i_mbminlen) - || UNIV_UNLIKELY(mbmaxlen != i_mbmaxlen)) { + if (UNIV_UNLIKELY + (DATA_MBMINMAXLEN(i_mbminlen, i_mbmaxlen) + != mbminmaxlen)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: " @@ -464,10 +485,10 @@ dtype_get_fixed_size_low( "type->mbmaxlen=%lu\n", (ulong) i_mbminlen, (ulong) i_mbmaxlen, - (ulong) mbminlen, - (ulong) mbmaxlen); + (ulong) DATA_MBMINLEN(mbminmaxlen), + (ulong) DATA_MBMAXLEN(mbminmaxlen)); } - if (mbminlen == mbmaxlen) { + if (i_mbminlen == i_mbmaxlen) { return(len); } } @@ -499,8 +520,8 @@ dtype_get_min_size_low( ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ ulint len, /*!< in: length */ - ulint mbminlen, /*!< in: minimum length of a multibyte char */ - ulint mbmaxlen) /*!< in: maximum length of a multibyte char */ + ulint mbminmaxlen) /*!< in: minimum and maximum length of a + multi-byte character */ { switch (mtype) { case DATA_SYS: @@ -527,14 +548,22 @@ dtype_get_min_size_low( case DATA_DOUBLE: return(len); case DATA_MYSQL: - if ((prtype & DATA_BINARY_TYPE) || mbminlen == mbmaxlen) { + if (prtype & DATA_BINARY_TYPE) { return(len); + } else { + ulint mbminlen = DATA_MBMINLEN(mbminmaxlen); + ulint mbmaxlen = DATA_MBMAXLEN(mbminmaxlen); + + if (mbminlen == mbmaxlen) { + return(len); + } + + /* this is a variable-length character set */ + ut_a(mbminlen > 0); + ut_a(mbmaxlen > mbminlen); + ut_a(len % mbmaxlen == 0); + return(len * mbminlen / mbmaxlen); } - /* this is a variable-length character set */ - ut_a(mbminlen > 0); - ut_a(mbmaxlen > mbminlen); - ut_a(len % mbmaxlen == 0); - return(len * mbminlen / mbmaxlen); case DATA_VARCHAR: case DATA_BINARY: case DATA_DECIMAL: @@ -595,9 +624,9 @@ dtype_get_sql_null_size( { #ifndef UNIV_HOTBACKUP return(dtype_get_fixed_size_low(type->mtype, type->prtype, type->len, - type->mbminlen, type->mbmaxlen, comp)); + type->mbminmaxlen, comp)); #else /* !UNIV_HOTBACKUP */ return(dtype_get_fixed_size_low(type->mtype, type->prtype, type->len, - 0, 0, 0)); + 0, 0)); #endif /* !UNIV_HOTBACKUP */ } diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h index 148b5cbe250..22df826da65 100644 --- a/storage/innobase/include/dict0boot.h +++ b/storage/innobase/include/dict0boot.h @@ -51,32 +51,35 @@ UNIV_INTERN void dict_hdr_get_new_id( /*================*/ - dulint* table_id, /*!< out: table id (not assigned if NULL) */ - dulint* index_id, /*!< out: index id (not assigned if NULL) */ - ulint* space_id); /*!< out: space id (not assigned if NULL) */ + table_id_t* table_id, /*!< out: table id + (not assigned if NULL) */ + index_id_t* index_id, /*!< out: index id + (not assigned if NULL) */ + ulint* space_id); /*!< out: space id + (not assigned if NULL) */ /**********************************************************************//** Returns a new row id. @return the new id */ UNIV_INLINE -dulint +row_id_t dict_sys_get_new_row_id(void); /*=========================*/ /**********************************************************************//** Reads a row id from a record or other 6-byte stored form. @return row id */ UNIV_INLINE -dulint +row_id_t dict_sys_read_row_id( /*=================*/ - byte* field); /*!< in: record field */ + const byte* field); /*!< in: record field */ /**********************************************************************//** Writes a row id to a record or other 6-byte stored form. */ UNIV_INLINE void dict_sys_write_row_id( /*==================*/ - byte* field, /*!< in: record field */ - dulint row_id);/*!< in: row id */ + byte* field, /*!< in: record field */ + row_id_t row_id);/*!< in: row id */ /*****************************************************************//** Initializes the data dictionary memory structures when the database is started. This function is also called when the data dictionary is created. */ @@ -97,12 +100,12 @@ dict_create(void); #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO /* The ids for the basic system tables and their indexes */ -#define DICT_TABLES_ID ut_dulint_create(0, 1) -#define DICT_COLUMNS_ID ut_dulint_create(0, 2) -#define DICT_INDEXES_ID ut_dulint_create(0, 3) -#define DICT_FIELDS_ID ut_dulint_create(0, 4) +#define DICT_TABLES_ID 1 +#define DICT_COLUMNS_ID 2 +#define DICT_INDEXES_ID 3 +#define DICT_FIELDS_ID 4 /* The following is a secondary index on SYS_TABLES */ -#define DICT_TABLE_IDS_ID ut_dulint_create(0, 5) +#define DICT_TABLE_IDS_ID 5 #define DICT_HDR_FIRST_ID 10 /* the ids for tables etc. start from this number, except for basic @@ -110,7 +113,7 @@ dict_create(void); indexes; ibuf tables and indexes are assigned as the id the number DICT_IBUF_ID_MIN plus the space id */ -#define DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFFUL, 0) +#define DICT_IBUF_ID_MIN 0xFFFFFFFF00000000ULL /* The offset of the dictionary header on the page */ #define DICT_HDR FSEG_PAGE_DATA diff --git a/storage/innobase/include/dict0boot.ic b/storage/innobase/include/dict0boot.ic index d5f372e38c4..d3ba9eee78f 100644 --- a/storage/innobase/include/dict0boot.ic +++ b/storage/innobase/include/dict0boot.ic @@ -36,22 +36,22 @@ dict_hdr_flush_row_id(void); Returns a new row id. @return the new id */ UNIV_INLINE -dulint +row_id_t dict_sys_get_new_row_id(void) /*=========================*/ { - dulint id; + row_id_t id; mutex_enter(&(dict_sys->mutex)); id = dict_sys->row_id; - if (0 == (ut_dulint_get_low(id) % DICT_HDR_ROW_ID_WRITE_MARGIN)) { + if (0 == (id % DICT_HDR_ROW_ID_WRITE_MARGIN)) { dict_hdr_flush_row_id(); } - UT_DULINT_INC(dict_sys->row_id); + dict_sys->row_id++; mutex_exit(&(dict_sys->mutex)); @@ -62,10 +62,10 @@ dict_sys_get_new_row_id(void) Reads a row id from a record or other 6-byte stored form. @return row id */ UNIV_INLINE -dulint +row_id_t dict_sys_read_row_id( /*=================*/ - byte* field) /*!< in: record field */ + const byte* field) /*!< in: record field */ { #if DATA_ROW_ID_LEN != 6 # error "DATA_ROW_ID_LEN != 6" @@ -80,8 +80,8 @@ UNIV_INLINE void dict_sys_write_row_id( /*==================*/ - byte* field, /*!< in: record field */ - dulint row_id) /*!< in: row id */ + byte* field, /*!< in: record field */ + row_id_t row_id) /*!< in: row id */ { #if DATA_ROW_ID_LEN != 6 # error "DATA_ROW_ID_LEN != 6" diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 3a1bee4cd89..971173a65a5 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -75,8 +75,8 @@ UNIV_INTERN dict_table_t* dict_table_get_on_id( /*=================*/ - dulint table_id, /*!< in: table id */ - trx_t* trx); /*!< in: transaction handle */ + table_id_t table_id, /*!< in: table id */ + trx_t* trx); /*!< in: transaction handle */ /********************************************************************//** Decrements the count of open MySQL handles to a table. */ UNIV_INTERN @@ -102,6 +102,33 @@ void dict_load_space_id_list(void); /*=========================*/ /*********************************************************************//** +Gets the minimum number of bytes per character. +@return minimum multi-byte char size, in bytes */ +UNIV_INLINE +ulint +dict_col_get_mbminlen( +/*==================*/ + const dict_col_t* col); /*!< in: column */ +/*********************************************************************//** +Gets the maximum number of bytes per character. +@return maximum multi-byte char size, in bytes */ +UNIV_INLINE +ulint +dict_col_get_mbmaxlen( +/*==================*/ + const dict_col_t* col); /*!< in: column */ +/*********************************************************************//** +Sets the minimum and maximum number of bytes per character. */ +UNIV_INLINE +void +dict_col_set_mbminmaxlen( +/*=====================*/ + dict_col_t* col, /*!< in/out: column */ + ulint mbminlen, /*!< in: minimum multi-byte + character size, in bytes */ + ulint mbmaxlen); /*!< in: minimum multi-byte + character size, in bytes */ +/*********************************************************************//** Gets the column data type. */ UNIV_INLINE void @@ -277,7 +304,7 @@ void dict_table_change_id_in_cache( /*==========================*/ dict_table_t* table, /*!< in/out: table object already in cache */ - dulint new_id);/*!< in: new id to set */ + table_id_t new_id);/*!< in: new id to set */ /**********************************************************************//** Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. @@ -397,7 +424,7 @@ dict_index_t* dict_index_get_on_id_low( /*=====================*/ dict_table_t* table, /*!< in: table */ - dulint index_id); /*!< in: index id */ + index_id_t index_id); /*!< in: index id */ /**********************************************************************//** Checks if a table is in the dictionary cache. @return table, NULL if not found */ @@ -423,7 +450,7 @@ UNIV_INLINE dict_table_t* dict_table_get_on_id_low( /*=====================*/ - dulint table_id); /*!< in: table id */ + table_id_t table_id); /*!< in: table id */ /**********************************************************************//** Find an index that is equivalent to the one passed in and is not marked for deletion. @@ -710,7 +737,7 @@ UNIV_INTERN dict_index_t* dict_index_find_on_id_low( /*======================*/ - dulint id); /*!< in: index id */ + index_id_t id); /*!< in: index id */ /**********************************************************************//** Adds an index to the dictionary cache. @return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */ @@ -901,7 +928,7 @@ UNIV_INTERN dict_index_t* dict_index_get_if_in_cache_low( /*===========================*/ - dulint index_id); /*!< in: index id */ + index_id_t index_id); /*!< in: index id */ #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /**********************************************************************//** Returns an index object if it is found in the dictionary cache. @@ -910,7 +937,7 @@ UNIV_INTERN dict_index_t* dict_index_get_if_in_cache( /*=======================*/ - dulint index_id); /*!< in: index id */ + index_id_t index_id); /*!< in: index id */ #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #ifdef UNIV_DEBUG /**********************************************************************//** @@ -1135,7 +1162,7 @@ struct dict_sys_struct{ and DROP TABLE, as well as reading the dictionary data for a table from system tables */ - dulint row_id; /*!< the next row id to assign; + row_id_t row_id; /*!< the next row id to assign; NOTE that at a checkpoint this must be written to the dict system header and flushed to a file; in diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 93c3f8d4733..09f967aa74a 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -29,6 +29,46 @@ Created 1/8/1996 Heikki Tuuri #include "rem0types.h" /*********************************************************************//** +Gets the minimum number of bytes per character. +@return minimum multi-byte char size, in bytes */ +UNIV_INLINE +ulint +dict_col_get_mbminlen( +/*==================*/ + const dict_col_t* col) /*!< in: column */ +{ + return(DATA_MBMINLEN(col->mbminmaxlen)); +} +/*********************************************************************//** +Gets the maximum number of bytes per character. +@return maximum multi-byte char size, in bytes */ +UNIV_INLINE +ulint +dict_col_get_mbmaxlen( +/*==================*/ + const dict_col_t* col) /*!< in: column */ +{ + return(DATA_MBMAXLEN(col->mbminmaxlen)); +} +/*********************************************************************//** +Sets the minimum and maximum number of bytes per character. */ +UNIV_INLINE +void +dict_col_set_mbminmaxlen( +/*=====================*/ + dict_col_t* col, /*!< in/out: column */ + ulint mbminlen, /*!< in: minimum multi-byte + character size, in bytes */ + ulint mbmaxlen) /*!< in: minimum multi-byte + character size, in bytes */ +{ + ut_ad(mbminlen < DATA_MBMAX); + ut_ad(mbmaxlen < DATA_MBMAX); + ut_ad(mbminlen <= mbmaxlen); + + col->mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen); +} +/*********************************************************************//** Gets the column data type. */ UNIV_INLINE void @@ -42,8 +82,7 @@ dict_col_copy_type( type->mtype = col->mtype; type->prtype = col->prtype; type->len = col->len; - type->mbminlen = col->mbminlen; - type->mbmaxlen = col->mbmaxlen; + type->mbminmaxlen = col->mbminmaxlen; } #endif /* !UNIV_HOTBACKUP */ @@ -65,8 +104,7 @@ dict_col_type_assert_equal( ut_ad(col->prtype == type->prtype); ut_ad(col->len == type->len); # ifndef UNIV_HOTBACKUP - ut_ad(col->mbminlen == type->mbminlen); - ut_ad(col->mbmaxlen == type->mbmaxlen); + ut_ad(col->mbminmaxlen == type->mbminmaxlen); # endif /* !UNIV_HOTBACKUP */ return(TRUE); @@ -84,7 +122,7 @@ dict_col_get_min_size( const dict_col_t* col) /*!< in: column */ { return(dtype_get_min_size_low(col->mtype, col->prtype, col->len, - col->mbminlen, col->mbmaxlen)); + col->mbminmaxlen)); } /***********************************************************************//** Returns the maximum size of the column. @@ -109,7 +147,7 @@ dict_col_get_fixed_size( ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ { return(dtype_get_fixed_size_low(col->mtype, col->prtype, col->len, - col->mbminlen, col->mbmaxlen, comp)); + col->mbminmaxlen, comp)); } /***********************************************************************//** Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column. @@ -780,7 +818,7 @@ UNIV_INLINE dict_table_t* dict_table_get_on_id_low( /*=====================*/ - dulint table_id) /*!< in: table id */ + table_id_t table_id) /*!< in: table id */ { dict_table_t* table; ulint fold; @@ -788,11 +826,11 @@ dict_table_get_on_id_low( ut_ad(mutex_own(&(dict_sys->mutex))); /* Look for the table name in the hash table */ - fold = ut_fold_dulint(table_id); + fold = ut_fold_ull(table_id); HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold, dict_table_t*, table, ut_ad(table->cached), - !ut_dulint_cmp(table->id, table_id)); + table->id == table_id); if (table == NULL) { table = dict_load_table_on_id(table_id); } diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index d85f8f7fc3e..6a718a464ab 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -109,8 +109,9 @@ dict_load_column_low( a SYS_COLUMNS record */ mem_heap_t* heap, /*!< in/out: memory heap for temporary storage */ - dict_col_t* column, /*!< out: dict_column_t to fill */ - dulint* table_id, /*!< out: table id */ + dict_col_t* column, /*!< out: dict_column_t to fill, + or NULL if table != NULL */ + table_id_t* table_id, /*!< out: table id */ const char** col_name, /*!< out: column name */ const rec_t* rec); /*!< in: SYS_COLUMNS record */ /********************************************************************//** @@ -173,7 +174,7 @@ UNIV_INTERN dict_table_t* dict_load_table_on_id( /*==================*/ - dulint table_id); /*!< in: table id */ + table_id_t table_id); /*!< in: table id */ /********************************************************************//** This function is called when the database is booted. Loads system table index definitions except for the clustered index which @@ -255,7 +256,7 @@ dict_process_sys_indexes_rec( const rec_t* rec, /*!< in: current SYS_INDEXES rec */ dict_index_t* index, /*!< out: dict_index_t to be filled */ - dulint* table_id); /*!< out: table id */ + table_id_t* table_id); /*!< out: table id */ /********************************************************************//** This function parses a SYS_COLUMNS record and populate a dict_column_t structure with the information from the record. @@ -267,7 +268,7 @@ dict_process_sys_columns_rec( mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current SYS_COLUMNS rec */ dict_col_t* column, /*!< out: dict_col_t to be filled */ - dulint* table_id, /*!< out: table id */ + table_id_t* table_id, /*!< out: table id */ const char** col_name); /*!< out: column name */ /********************************************************************//** This function parses a SYS_FIELDS record and populate a dict_field_t @@ -282,8 +283,8 @@ dict_process_sys_fields_rec( dict_field_t* sys_field, /*!< out: dict_field_t to be filled */ ulint* pos, /*!< out: Field position */ - dulint* index_id, /*!< out: current index id */ - dulint last_id); /*!< in: previous index id */ + index_id_t* index_id, /*!< out: current index id */ + index_id_t last_id); /*!< in: previous index id */ /********************************************************************//** This function parses a SYS_FOREIGN record and populate a dict_foreign_t structure with the information from the record. For detail information diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 57e5b5394ee..75f9acd6b26 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -151,9 +151,9 @@ dict_mem_table_add_col( ulint prtype, /*!< in: precise type */ ulint len); /*!< in: precision */ /**********************************************************************//** -This function poplulates a dict_col_t memory structure with +This function populates a dict_col_t memory structure with supplied information. */ -UNIV_INLINE +UNIV_INTERN void dict_mem_fill_column_struct( /*========================*/ @@ -162,7 +162,7 @@ dict_mem_fill_column_struct( ulint col_pos, /*!< in: column position */ ulint mtype, /*!< in: main data type */ ulint prtype, /*!< in: precise type */ - ulint col_len); /*!< in: column lenght */ + ulint col_len); /*!< in: column length */ /**********************************************************************//** This function poplulates a dict_index_t index memory structure with supplied information. */ @@ -249,10 +249,11 @@ struct dict_col_struct{ the string, MySQL uses 1 or 2 bytes to store the string length) */ - unsigned mbminlen:2; /*!< minimum length of a - character, in bytes */ - unsigned mbmaxlen:3; /*!< maximum length of a - character, in bytes */ + unsigned mbminmaxlen:5; /*!< minimum and maximum length of a + character, in bytes; + DATA_MBMINMAXLEN(mbminlen,mbmaxlen); + mbminlen=DATA_MBMINLEN(mbminmaxlen); + mbmaxlen=DATA_MBMINLEN(mbminmaxlen) */ /*----------------------*/ /* End of definitions copied from dtype_t */ /* @} */ @@ -293,7 +294,7 @@ struct dict_field_struct{ /** Data structure for an index. Most fields will be initialized to 0, NULL or FALSE in dict_mem_index_create(). */ struct dict_index_struct{ - dulint id; /*!< id of the index */ + index_id_t id; /*!< id of the index */ mem_heap_t* heap; /*!< memory heap */ const char* name; /*!< index name */ const char* table_name;/*!< table name */ @@ -349,7 +350,7 @@ struct dict_index_struct{ /* @} */ rw_lock_t lock; /*!< read-write lock protecting the upper levels of the index tree */ - ib_uint64_t trx_id; /*!< id of the transaction that created this + trx_id_t trx_id; /*!< id of the transaction that created this index, or 0 if the index existed when InnoDB was started up */ #endif /* !UNIV_HOTBACKUP */ @@ -414,9 +415,9 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */ /** Data structure for a database table. Most fields will be initialized to 0, NULL or FALSE in dict_mem_table_create(). */ struct dict_table_struct{ - dulint id; /*!< id of the table */ + table_id_t id; /*!< id of the table */ mem_heap_t* heap; /*!< memory heap */ - const char* name; /*!< table name */ + char* name; /*!< table name */ const char* dir_path_of_temp_table;/*!< NULL or the directory path where a TEMPORARY table that was explicitly created by a user should be placed if diff --git a/storage/innobase/include/dict0mem.ic b/storage/innobase/include/dict0mem.ic index 5a851da5640..1d80ffc9b94 100644 --- a/storage/innobase/include/dict0mem.ic +++ b/storage/innobase/include/dict0mem.ic @@ -70,35 +70,3 @@ dict_mem_fill_index_struct( index->magic_n = DICT_INDEX_MAGIC_N; #endif /* UNIV_DEBUG */ } - -/**********************************************************************//** -This function poplulates a dict_col_t memory structure with -supplied information. */ -UNIV_INLINE -void -dict_mem_fill_column_struct( -/*========================*/ - dict_col_t* column, /*!< out: column struct to be - filled */ - ulint col_pos, /*!< in: column position */ - ulint mtype, /*!< in: main data type */ - ulint prtype, /*!< in: precise type */ - ulint col_len) /*!< in: column lenght */ -{ -#ifndef UNIV_HOTBACKUP - ulint mbminlen; - ulint mbmaxlen; -#endif /* !UNIV_HOTBACKUP */ - - column->ind = (unsigned int) col_pos; - column->ord_part = 0; - column->mtype = (unsigned int) mtype; - column->prtype = (unsigned int) prtype; - column->len = (unsigned int) col_len; -#ifndef UNIV_HOTBACKUP - dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen); - - column->mbminlen = (unsigned int) mbminlen; - column->mbmaxlen = (unsigned int) mbmaxlen; -#endif /* !UNIV_HOTBACKUP */ -} diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h index 7ad69193cc9..0a9edfbfe70 100644 --- a/storage/innobase/include/dict0types.h +++ b/storage/innobase/include/dict0types.h @@ -45,4 +45,7 @@ typedef struct tab_node_struct tab_node_t; #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */ #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO +typedef ib_id_t table_id_t; +typedef ib_id_t index_id_t; + #endif diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index c746915844b..d7d98787bcf 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -26,6 +26,7 @@ Created 10/25/1995 Heikki Tuuri #ifndef fil0fil_h #define fil0fil_h +#include "univ.i" #include "dict0types.h" #include "ut0byte.h" #include "os0file.h" diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 0319c0e9261..3eca80beda4 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -670,7 +670,7 @@ lock_get_type( Gets the id of the transaction owning a lock. @return transaction id */ UNIV_INTERN -ullint +trx_id_t lock_get_trx_id( /*============*/ const lock_t* lock); /*!< in: lock */ @@ -699,7 +699,7 @@ lock_get_type_str( Gets the id of the table on which the lock is. @return id of the table */ UNIV_INTERN -ullint +table_id_t lock_get_table_id( /*==============*/ const lock_t* lock); /*!< in: lock */ diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic index 139f4041a36..1ce00fd7313 100644 --- a/storage/innobase/include/log0log.ic +++ b/storage/innobase/include/log0log.ic @@ -433,7 +433,10 @@ void log_free_check(void) /*================*/ { - /* ut_ad(sync_thread_levels_empty()); */ + +#ifdef UNIV_SYNC_DEBUG + ut_ad(sync_thread_levels_empty_gen(TRUE)); +#endif /* UNIV_SYNC_DEBUG */ if (log_sys->check_flush_or_checkpoint) { diff --git a/storage/innobase/include/mach0data.h b/storage/innobase/include/mach0data.h index 44ee3df22ce..8434bc73586 100644 --- a/storage/innobase/include/mach0data.h +++ b/storage/innobase/include/mach0data.h @@ -166,14 +166,14 @@ UNIV_INLINE void mach_write_to_6( /*============*/ - byte* b, /*!< in: pointer to 6 bytes where to store */ - dulint n); /*!< in: dulint integer to be stored */ + byte* b, /*!< in: pointer to 6 bytes where to store */ + ib_uint64_t id); /*!< in: 48-bit integer */ /********************************************************//** The following function is used to fetch data from 6 consecutive bytes. The most significant byte is at the lowest address. -@return dulint integer */ +@return 48-bit integer */ UNIV_INLINE -dulint +ib_uint64_t mach_read_from_6( /*=============*/ const byte* b) /*!< in: pointer to 6 bytes */ @@ -185,14 +185,14 @@ UNIV_INLINE void mach_write_to_7( /*============*/ - byte* b, /*!< in: pointer to 7 bytes where to store */ - dulint n); /*!< in: dulint integer to be stored */ + byte* b, /*!< in: pointer to 7 bytes where to store */ + ib_uint64_t n); /*!< in: 56-bit integer */ /********************************************************//** The following function is used to fetch data from 7 consecutive bytes. The most significant byte is at the lowest address. -@return dulint integer */ +@return 56-bit integer */ UNIV_INLINE -dulint +ib_uint64_t mach_read_from_7( /*=============*/ const byte* b) /*!< in: pointer to 7 bytes */ @@ -204,88 +204,69 @@ UNIV_INLINE void mach_write_to_8( /*============*/ - byte* b, /*!< in: pointer to 8 bytes where to store */ - dulint n); /*!< in: dulint integer to be stored */ -/*******************************************************//** -The following function is used to store data in 8 consecutive -bytes. We store the most significant byte to the lowest address. */ -UNIV_INLINE -void -mach_write_ull( -/*===========*/ byte* b, /*!< in: pointer to 8 bytes where to store */ ib_uint64_t n); /*!< in: 64-bit integer to be stored */ /********************************************************//** The following function is used to fetch data from 8 consecutive bytes. The most significant byte is at the lowest address. -@return dulint integer */ -UNIV_INLINE -dulint -mach_read_from_8( -/*=============*/ - const byte* b) /*!< in: pointer to 8 bytes */ - __attribute__((nonnull, pure)); -/********************************************************//** -The following function is used to fetch data from 8 consecutive -bytes. The most significant byte is at the lowest address. @return 64-bit integer */ UNIV_INLINE ib_uint64_t -mach_read_ull( -/*==========*/ +mach_read_from_8( +/*=============*/ const byte* b) /*!< in: pointer to 8 bytes */ __attribute__((nonnull, pure)); /*********************************************************//** -Writes a dulint in a compressed form (5..9 bytes). +Writes a 64-bit integer in a compressed form (5..9 bytes). @return size in bytes */ UNIV_INLINE ulint -mach_dulint_write_compressed( -/*=========================*/ - byte* b, /*!< in: pointer to memory where to store */ - dulint n); /*!< in: dulint integer to be stored */ +mach_ull_write_compressed( +/*======================*/ + byte* b, /*!< in: pointer to memory where to store */ + ib_uint64_t n); /*!< in: 64-bit integer to be stored */ /*********************************************************//** -Returns the size of a dulint when written in the compressed form. +Returns the size of a 64-bit integer when written in the compressed form. @return compressed size in bytes */ UNIV_INLINE ulint -mach_dulint_get_compressed_size( -/*============================*/ - dulint n); /*!< in: dulint integer to be stored */ +mach_ull_get_compressed_size( +/*=========================*/ + ib_uint64_t n); /*!< in: 64-bit integer to be stored */ /*********************************************************//** -Reads a dulint in a compressed form. -@return read dulint */ +Reads a 64-bit integer in a compressed form. +@return the value read */ UNIV_INLINE -dulint -mach_dulint_read_compressed( -/*========================*/ +ib_uint64_t +mach_ull_read_compressed( +/*=====================*/ const byte* b) /*!< in: pointer to memory from where to read */ __attribute__((nonnull, pure)); /*********************************************************//** -Writes a dulint in a compressed form (1..11 bytes). +Writes a 64-bit integer in a compressed form (1..11 bytes). @return size in bytes */ UNIV_INLINE ulint -mach_dulint_write_much_compressed( -/*==============================*/ - byte* b, /*!< in: pointer to memory where to store */ - dulint n); /*!< in: dulint integer to be stored */ +mach_ull_write_much_compressed( +/*===========================*/ + byte* b, /*!< in: pointer to memory where to store */ + ib_uint64_t n); /*!< in: 64-bit integer to be stored */ /*********************************************************//** -Returns the size of a dulint when written in the compressed form. +Returns the size of a 64-bit integer when written in the compressed form. @return compressed size in bytes */ UNIV_INLINE ulint -mach_dulint_get_much_compressed_size( -/*=================================*/ - dulint n) /*!< in: dulint integer to be stored */ +mach_ull_get_much_compressed_size( +/*==============================*/ + ib_uint64_t n) /*!< in: 64-bit integer to be stored */ __attribute__((const)); /*********************************************************//** -Reads a dulint in a compressed form. -@return read dulint */ +Reads a 64-bit integer in a compressed form. +@return the value read */ UNIV_INLINE -dulint -mach_dulint_read_much_compressed( -/*=============================*/ +ib_uint64_t +mach_ull_read_much_compressed( +/*==========================*/ const byte* b) /*!< in: pointer to memory from where to read */ __attribute__((nonnull, pure)); /*********************************************************//** @@ -299,15 +280,16 @@ mach_parse_compressed( byte* end_ptr,/*!< in: pointer to end of the buffer */ ulint* val); /*!< out: read value */ /*********************************************************//** -Reads a dulint in a compressed form if the log record fully contains it. -@return pointer to end of the stored field, NULL if not complete */ -UNIV_INTERN +Reads a 64-bit integer in a compressed form +if the log record fully contains it. +@return pointer to end of the stored field, NULL if not complete */ +UNIV_INLINE byte* -mach_dulint_parse_compressed( -/*=========================*/ - byte* ptr, /*!< in: pointer to buffer from where to read */ - byte* end_ptr,/*!< in: pointer to end of the buffer */ - dulint* val); /*!< out: read value */ +mach_ull_parse_compressed( +/*======================*/ + byte* ptr, /*!< in: pointer to buffer from where to read */ + byte* end_ptr,/*!< in: pointer to end of the buffer */ + ib_uint64_t* val); /*!< out: read value */ #ifndef UNIV_HOTBACKUP /*********************************************************//** Reads a double. It is stored in a little-endian format. diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic index 96d2417ac81..b1e5991d39e 100644 --- a/storage/innobase/include/mach0data.ic +++ b/storage/innobase/include/mach0data.ic @@ -280,22 +280,6 @@ UNIV_INLINE void mach_write_to_8( /*============*/ - byte* b, /*!< in: pointer to 8 bytes where to store */ - dulint n) /*!< in: dulint integer to be stored */ -{ - ut_ad(b); - - mach_write_to_4(b, ut_dulint_get_high(n)); - mach_write_to_4(b + 4, ut_dulint_get_low(n)); -} - -/*******************************************************//** -The following function is used to store data in 8 consecutive -bytes. We store the most significant byte to the lowest address. */ -UNIV_INLINE -void -mach_write_ull( -/*===========*/ byte* b, /*!< in: pointer to 8 bytes where to store */ ib_uint64_t n) /*!< in: 64-bit integer to be stored */ { @@ -308,32 +292,11 @@ mach_write_ull( /********************************************************//** The following function is used to fetch data from 8 consecutive bytes. The most significant byte is at the lowest address. -@return dulint integer */ -UNIV_INLINE -dulint -mach_read_from_8( -/*=============*/ - const byte* b) /*!< in: pointer to 8 bytes */ -{ - ulint high; - ulint low; - - ut_ad(b); - - high = mach_read_from_4(b); - low = mach_read_from_4(b + 4); - - return(ut_dulint_create(high, low)); -} - -/********************************************************//** -The following function is used to fetch data from 8 consecutive -bytes. The most significant byte is at the lowest address. @return 64-bit integer */ UNIV_INLINE ib_uint64_t -mach_read_ull( -/*==========*/ +mach_read_from_8( +/*=============*/ const byte* b) /*!< in: pointer to 8 bytes */ { ib_uint64_t ull; @@ -351,34 +314,28 @@ UNIV_INLINE void mach_write_to_7( /*============*/ - byte* b, /*!< in: pointer to 7 bytes where to store */ - dulint n) /*!< in: dulint integer to be stored */ + byte* b, /*!< in: pointer to 7 bytes where to store */ + ib_uint64_t n) /*!< in: 56-bit integer */ { ut_ad(b); - mach_write_to_3(b, ut_dulint_get_high(n)); - mach_write_to_4(b + 3, ut_dulint_get_low(n)); + mach_write_to_3(b, (ulint) (n >> 32)); + mach_write_to_4(b + 3, (ulint) n); } /********************************************************//** The following function is used to fetch data from 7 consecutive bytes. The most significant byte is at the lowest address. -@return dulint integer */ +@return 56-bit integer */ UNIV_INLINE -dulint +ib_uint64_t mach_read_from_7( /*=============*/ const byte* b) /*!< in: pointer to 7 bytes */ { - ulint high; - ulint low; - ut_ad(b); - high = mach_read_from_3(b); - low = mach_read_from_4(b + 3); - - return(ut_dulint_create(high, low)); + return(ut_ull_create(mach_read_from_3(b), mach_read_from_4(b + 3))); } /*******************************************************//** @@ -388,162 +345,196 @@ UNIV_INLINE void mach_write_to_6( /*============*/ - byte* b, /*!< in: pointer to 6 bytes where to store */ - dulint n) /*!< in: dulint integer to be stored */ + byte* b, /*!< in: pointer to 6 bytes where to store */ + ib_uint64_t n) /*!< in: 48-bit integer */ { ut_ad(b); - mach_write_to_2(b, ut_dulint_get_high(n)); - mach_write_to_4(b + 2, ut_dulint_get_low(n)); + mach_write_to_2(b, (ulint) (n >> 32)); + mach_write_to_4(b + 2, (ulint) n); } /********************************************************//** The following function is used to fetch data from 6 consecutive bytes. The most significant byte is at the lowest address. -@return dulint integer */ +@return 48-bit integer */ UNIV_INLINE -dulint +ib_uint64_t mach_read_from_6( /*=============*/ const byte* b) /*!< in: pointer to 6 bytes */ { - ulint high; - ulint low; - ut_ad(b); - high = mach_read_from_2(b); - low = mach_read_from_4(b + 2); - - return(ut_dulint_create(high, low)); + return(ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2))); } /*********************************************************//** -Writes a dulint in a compressed form (5..9 bytes). +Writes a 64-bit integer in a compressed form (5..9 bytes). @return size in bytes */ UNIV_INLINE ulint -mach_dulint_write_compressed( -/*=========================*/ - byte* b, /*!< in: pointer to memory where to store */ - dulint n) /*!< in: dulint integer to be stored */ +mach_ull_write_compressed( +/*======================*/ + byte* b, /*!< in: pointer to memory where to store */ + ib_uint64_t n) /*!< in: 64-bit integer to be stored */ { ulint size; ut_ad(b); - size = mach_write_compressed(b, ut_dulint_get_high(n)); - mach_write_to_4(b + size, ut_dulint_get_low(n)); + size = mach_write_compressed(b, (ulint) (n >> 32)); + mach_write_to_4(b + size, (ulint) n); return(size + 4); } /*********************************************************//** -Returns the size of a dulint when written in the compressed form. +Returns the size of a 64-bit integer when written in the compressed form. @return compressed size in bytes */ UNIV_INLINE ulint -mach_dulint_get_compressed_size( -/*============================*/ - dulint n) /*!< in: dulint integer to be stored */ +mach_ull_get_compressed_size( +/*=========================*/ + ib_uint64_t n) /*!< in: 64-bit integer to be stored */ { - return(4 + mach_get_compressed_size(ut_dulint_get_high(n))); + return(4 + mach_get_compressed_size((ulint) (n >> 32))); } /*********************************************************//** -Reads a dulint in a compressed form. -@return read dulint */ +Reads a 64-bit integer in a compressed form. +@return the value read */ UNIV_INLINE -dulint -mach_dulint_read_compressed( -/*========================*/ +ib_uint64_t +mach_ull_read_compressed( +/*=====================*/ const byte* b) /*!< in: pointer to memory from where to read */ { - ulint high; - ulint low; - ulint size; + ib_uint64_t n; + ulint size; ut_ad(b); - high = mach_read_compressed(b); + n = (ib_uint64_t) mach_read_compressed(b); - size = mach_get_compressed_size(high); + size = mach_get_compressed_size((ulint) n); - low = mach_read_from_4(b + size); + n <<= 32; + n |= (ib_uint64_t) mach_read_from_4(b + size); - return(ut_dulint_create(high, low)); + return(n); } /*********************************************************//** -Writes a dulint in a compressed form (1..11 bytes). +Writes a 64-bit integer in a compressed form (1..11 bytes). @return size in bytes */ UNIV_INLINE ulint -mach_dulint_write_much_compressed( -/*==============================*/ - byte* b, /*!< in: pointer to memory where to store */ - dulint n) /*!< in: dulint integer to be stored */ +mach_ull_write_much_compressed( +/*===========================*/ + byte* b, /*!< in: pointer to memory where to store */ + ib_uint64_t n) /*!< in: 64-bit integer to be stored */ { ulint size; ut_ad(b); - if (ut_dulint_get_high(n) == 0) { - return(mach_write_compressed(b, ut_dulint_get_low(n))); + if (!(n >> 32)) { + return(mach_write_compressed(b, (ulint) n)); } *b = (byte)0xFF; - size = 1 + mach_write_compressed(b + 1, ut_dulint_get_high(n)); + size = 1 + mach_write_compressed(b + 1, (ulint) (n >> 32)); - size += mach_write_compressed(b + size, ut_dulint_get_low(n)); + size += mach_write_compressed(b + size, (ulint) n & 0xFFFFFFFF); return(size); } /*********************************************************//** -Returns the size of a dulint when written in the compressed form. +Returns the size of a 64-bit integer when written in the compressed form. @return compressed size in bytes */ UNIV_INLINE ulint -mach_dulint_get_much_compressed_size( -/*=================================*/ - dulint n) /*!< in: dulint integer to be stored */ +mach_ull_get_much_compressed_size( +/*==============================*/ + ib_uint64_t n) /*!< in: 64-bit integer to be stored */ { - if (0 == ut_dulint_get_high(n)) { - return(mach_get_compressed_size(ut_dulint_get_low(n))); + if (!(n >> 32)) { + return(mach_get_compressed_size((ulint) n)); } - return(1 + mach_get_compressed_size(ut_dulint_get_high(n)) - + mach_get_compressed_size(ut_dulint_get_low(n))); + return(1 + mach_get_compressed_size((ulint) (n >> 32)) + + mach_get_compressed_size((ulint) n & ULINT32_MASK)); } /*********************************************************//** -Reads a dulint in a compressed form. -@return read dulint */ +Reads a 64-bit integer in a compressed form. +@return the value read */ UNIV_INLINE -dulint -mach_dulint_read_much_compressed( -/*=============================*/ +ib_uint64_t +mach_ull_read_much_compressed( +/*==========================*/ const byte* b) /*!< in: pointer to memory from where to read */ { - ulint high; - ulint low; - ulint size; + ib_uint64_t n; + ulint size; ut_ad(b); if (*b != (byte)0xFF) { - high = 0; + n = 0; size = 0; } else { - high = mach_read_compressed(b + 1); + n = (ib_uint64_t) mach_read_compressed(b + 1); + + size = 1 + mach_get_compressed_size((ulint) n); + n <<= 32; + } + + n |= mach_read_compressed(b + size); + + return(n); +} + +/*********************************************************//** +Reads a 64-bit integer in a compressed form +if the log record fully contains it. +@return pointer to end of the stored field, NULL if not complete */ +UNIV_INLINE +byte* +mach_ull_parse_compressed( +/*======================*/ + byte* ptr, /* in: pointer to buffer from where to read */ + byte* end_ptr,/* in: pointer to end of the buffer */ + ib_uint64_t* val) /* out: read value */ +{ + ulint size; + + ut_ad(ptr); + ut_ad(end_ptr); + ut_ad(val); + + if (end_ptr < ptr + 5) { + + return(NULL); + } + + *val = mach_read_compressed(ptr); + + size = mach_get_compressed_size((ulint) *val); + + ptr += size; + + if (end_ptr < ptr + 4) { - size = 1 + mach_get_compressed_size(high); + return(NULL); } - low = mach_read_compressed(b + size); + *val <<= 32; + *val |= mach_read_from_4(ptr); - return(ut_dulint_create(high, low)); + return(ptr + 4); } #ifndef UNIV_HOTBACKUP /*********************************************************//** diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h index 6322af2a569..d271002a5fe 100644 --- a/storage/innobase/include/mtr0log.h +++ b/storage/innobase/include/mtr0log.h @@ -47,11 +47,11 @@ Writes 8 bytes to a file page buffered in the buffer pool. Writes the corresponding log record to the mini-transaction log. */ UNIV_INTERN void -mlog_write_dulint( -/*==============*/ - byte* ptr, /*!< in: pointer where to write */ - dulint val, /*!< in: value to write */ - mtr_t* mtr); /*!< in: mini-transaction handle */ +mlog_write_ull( +/*===========*/ + byte* ptr, /*!< in: pointer where to write */ + ib_uint64_t val, /*!< in: value to write */ + mtr_t* mtr); /*!< in: mini-transaction handle */ /********************************************************//** Writes a string to a file page buffered in the buffer pool. Writes the corresponding log record to the mini-transaction log. */ @@ -125,13 +125,13 @@ mlog_catenate_ulint_compressed( mtr_t* mtr, /*!< in: mtr */ ulint val); /*!< in: value to write */ /********************************************************//** -Catenates a compressed dulint to mlog. */ +Catenates a compressed 64-bit integer to mlog. */ UNIV_INLINE void -mlog_catenate_dulint_compressed( -/*============================*/ - mtr_t* mtr, /*!< in: mtr */ - dulint val); /*!< in: value to write */ +mlog_catenate_ull_compressed( +/*=========================*/ + mtr_t* mtr, /*!< in: mtr */ + ib_uint64_t val); /*!< in: value to write */ /********************************************************//** Opens a buffer to mlog. It must be closed with mlog_close. @return buffer, NULL if log mode MTR_LOG_NONE */ @@ -183,7 +183,7 @@ mlog_parse_initial_log_record( ulint* space, /*!< out: space id */ ulint* page_no);/*!< out: page number */ /********************************************************//** -Parses a log record written by mlog_write_ulint or mlog_write_dulint. +Parses a log record written by mlog_write_ulint or mlog_write_ull. @return parsed record end, NULL if not a complete record */ UNIV_INTERN byte* diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic index 5c24c38b337..c670a0a8c82 100644 --- a/storage/innobase/include/mtr0log.ic +++ b/storage/innobase/include/mtr0log.ic @@ -142,13 +142,13 @@ mlog_catenate_ulint_compressed( } /********************************************************//** -Catenates a compressed dulint to mlog. */ +Catenates a compressed 64-bit integer to mlog. */ UNIV_INLINE void -mlog_catenate_dulint_compressed( -/*============================*/ - mtr_t* mtr, /*!< in: mtr */ - dulint val) /*!< in: value to write */ +mlog_catenate_ull_compressed( +/*=========================*/ + mtr_t* mtr, /*!< in: mtr */ + ib_uint64_t val) /*!< in: value to write */ { byte* log_ptr; @@ -160,7 +160,7 @@ mlog_catenate_dulint_compressed( return; } - log_ptr += mach_dulint_write_compressed(log_ptr, val); + log_ptr += mach_ull_write_compressed(log_ptr, val); mlog_close(mtr, log_ptr); } diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index bc3f1951be9..8abca093548 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -264,15 +264,6 @@ mtr_read_ulint( const byte* ptr, /*!< in: pointer from where to read */ ulint type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ mtr_t* mtr); /*!< in: mini-transaction handle */ -/********************************************************//** -Reads 8 bytes from a file page buffered in the buffer pool. -@return value read */ -UNIV_INTERN -dulint -mtr_read_dulint( -/*============*/ - const byte* ptr, /*!< in: pointer from where to read */ - mtr_t* mtr); /*!< in: mini-transaction handle */ #ifndef UNIV_HOTBACKUP /*********************************************************************//** This macro locks an rw-lock in s-mode. */ diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index 197e361b2b1..6d95b280330 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -177,6 +177,13 @@ log. */ #define OS_WIN95 2 /*!< Microsoft Windows 95 */ #define OS_WINNT 3 /*!< Microsoft Windows NT 3.x */ #define OS_WIN2000 4 /*!< Microsoft Windows 2000 */ +#define OS_WINXP 5 /*!< Microsoft Windows XP + or Windows Server 2003 */ +#define OS_WINVISTA 6 /*!< Microsoft Windows Vista + or Windows Server 2008 */ +#define OS_WIN7 7 /*!< Microsoft Windows 7 + or Windows Server 2008 R2 */ + extern ulint os_n_file_reads; extern ulint os_n_file_writes; @@ -368,7 +375,8 @@ typedef DIR* os_file_dir_t; /*!< directory stream */ /***********************************************************************//** Gets the operating system version. Currently works only on Windows. -@return OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */ +@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000, OS_WINXP, OS_WINVISTA, +OS_WIN7. */ UNIV_INTERN ulint os_get_os_version(void); diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h index 0c22162b900..0b600c80ce3 100644 --- a/storage/innobase/include/os0sync.h +++ b/storage/innobase/include/os0sync.h @@ -38,28 +38,18 @@ Created 9/6/1995 Heikki Tuuri #include "ut0lst.h" #ifdef __WIN__ - +/** Native event (slow)*/ +typedef HANDLE os_native_event_t; /** Native mutex */ -#define os_fast_mutex_t CRITICAL_SECTION - -/** Native event */ -typedef HANDLE os_native_event_t; - -/** Operating system event */ -typedef struct os_event_struct os_event_struct_t; -/** Operating system event handle */ -typedef os_event_struct_t* os_event_t; - -/** An asynchronous signal sent between threads */ -struct os_event_struct { - os_native_event_t handle; - /*!< Windows event */ - UT_LIST_NODE_T(os_event_struct_t) os_event_list; - /*!< list of all created events */ -}; +typedef CRITICAL_SECTION os_fast_mutex_t; +/** Native condition variable. */ +typedef CONDITION_VARIABLE os_cond_t; #else /** Native mutex */ -typedef pthread_mutex_t os_fast_mutex_t; +typedef pthread_mutex_t os_fast_mutex_t; +/** Native condition variable */ +typedef pthread_cond_t os_cond_t; +#endif /** Operating system event */ typedef struct os_event_struct os_event_struct_t; @@ -68,6 +58,10 @@ typedef os_event_struct_t* os_event_t; /** An asynchronous signal sent between threads */ struct os_event_struct { +#ifdef __WIN__ + HANDLE handle; /*!< kernel event object, slow, + used on older Windows */ +#endif os_fast_mutex_t os_mutex; /*!< this mutex protects the next fields */ ibool is_set; /*!< this is TRUE when the event is @@ -76,24 +70,17 @@ struct os_event_struct { this event */ ib_int64_t signal_count; /*!< this is incremented each time the event becomes signaled */ - pthread_cond_t cond_var; /*!< condition variable is used in + os_cond_t cond_var; /*!< condition variable is used in waiting for the event */ UT_LIST_NODE_T(os_event_struct_t) os_event_list; /*!< list of all created events */ }; -#endif /** Operating system mutex */ typedef struct os_mutex_struct os_mutex_str_t; /** Operating system mutex handle */ typedef os_mutex_str_t* os_mutex_t; -/** Denotes an infinite delay for os_event_wait_time() */ -#define OS_SYNC_INFINITE_TIME ((ulint)(-1)) - -/** Return value of os_event_wait_time() when the time is exceeded */ -#define OS_SYNC_TIME_EXCEEDED 1 - /** Mutex protecting counts and the event and OS 'slow' mutex lists */ extern os_mutex_t os_sync_mutex; @@ -187,42 +174,14 @@ os_event_wait_low( #define os_event_wait(event) os_event_wait_low(event, 0) -/**********************************************************//** -Waits for an event object until it is in the signaled state or -a timeout is exceeded. In Unix the timeout is always infinite. -@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */ -UNIV_INTERN -ulint -os_event_wait_time( -/*===============*/ - os_event_t event, /*!< in: event to wait */ - ulint time); /*!< in: timeout in microseconds, or - OS_SYNC_INFINITE_TIME */ -#ifdef __WIN__ -/**********************************************************//** -Waits for any event in an OS native event array. Returns if even a single -one is signaled or becomes signaled. -@return index of the event which was signaled */ -UNIV_INTERN -ulint -os_event_wait_multiple( -/*===================*/ - ulint n, /*!< in: number of events in the - array */ - os_native_event_t* native_event_array); - /*!< in: pointer to an array of event - handles */ -#endif /*********************************************************//** Creates an operating system mutex semaphore. Because these are slow, the mutex semaphore of InnoDB itself (mutex_t) should be used where possible. @return the mutex handle */ UNIV_INTERN os_mutex_t -os_mutex_create( -/*============*/ - const char* name); /*!< in: the name of the mutex, if NULL - the mutex is created without a name */ +os_mutex_create(void); +/*=================*/ /**********************************************************//** Acquires ownership of a mutex semaphore. */ UNIV_INTERN diff --git a/storage/innobase/include/os0sync.ic b/storage/innobase/include/os0sync.ic index 1f3ce38fa65..c33f13aaad6 100644 --- a/storage/innobase/include/os0sync.ic +++ b/storage/innobase/include/os0sync.ic @@ -28,8 +28,7 @@ Created 9/6/1995 Heikki Tuuri #endif /**********************************************************//** -Acquires ownership of a fast mutex. Currently in Windows this is the same -as os_fast_mutex_lock! +Acquires ownership of a fast mutex. @return 0 if success, != 0 if was reserved by another thread */ UNIV_INLINE ulint @@ -38,9 +37,13 @@ os_fast_mutex_trylock( os_fast_mutex_t* fast_mutex) /*!< in: mutex to acquire */ { #ifdef __WIN__ - EnterCriticalSection(fast_mutex); + if (TryEnterCriticalSection(fast_mutex)) { - return(0); + return(0); + } else { + + return(1); + } #else /* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock so that it returns 0 on success. In the operating system diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index 3899499fb6a..826fd13125d 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -66,7 +66,7 @@ typedef byte page_header_t; direction */ #define PAGE_N_RECS 16 /* number of user records on the page */ #define PAGE_MAX_TRX_ID 18 /* highest id of a trx which may have modified - a record on the page; a dulint; defined only + a record on the page; trx_id_t; defined only in secondary indexes and in the insert buffer tree; NOTE: this may be modified only when the thread has an x-latch to the page, diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index 8f794410f20..e9624c2360f 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -94,11 +94,10 @@ page_update_max_trx_id( TRUE for the dummy indexes constructed during redo log application). In that case, PAGE_MAX_TRX_ID is unused, and trx_id is usually zero. */ - ut_ad(!ut_dulint_is_zero(trx_id) || recv_recovery_is_on()); + ut_ad(trx_id || recv_recovery_is_on()); ut_ad(page_is_leaf(buf_block_get_frame(block))); - if (ut_dulint_cmp(page_get_max_trx_id(buf_block_get_frame(block)), - trx_id) < 0) { + if (page_get_max_trx_id(buf_block_get_frame(block)) < trx_id) { page_set_max_trx_id(block, page_zip, trx_id, mtr); } diff --git a/storage/innobase/include/pars0pars.h b/storage/innobase/include/pars0pars.h index 524fe4ac3e7..141b2706d7d 100644 --- a/storage/innobase/include/pars0pars.h +++ b/storage/innobase/include/pars0pars.h @@ -520,35 +520,18 @@ pars_info_add_int4_literal( Equivalent to: char buf[8]; -mach_write_ull(buf, val); -pars_info_add_literal(info, name, buf, 8, DATA_INT, 0); - -except that the buffer is dynamically allocated from the info struct's -heap. */ -UNIV_INTERN -void -pars_info_add_uint64_literal( -/*=========================*/ - pars_info_t* info, /*!< in: info struct */ - const char* name, /*!< in: name */ - ib_uint64_t val); /*!< in: value */ - -/****************************************************************//** -Equivalent to: - -char buf[8]; mach_write_to_8(buf, val); -pars_info_add_literal(info, name, buf, 8, DATA_BINARY, 0); +pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0); except that the buffer is dynamically allocated from the info struct's heap. */ UNIV_INTERN void -pars_info_add_dulint_literal( -/*=========================*/ +pars_info_add_ull_literal( +/*======================*/ pars_info_t* info, /*!< in: info struct */ const char* name, /*!< in: name */ - dulint val); /*!< in: value */ + ib_uint64_t val); /*!< in: value */ /****************************************************************//** Add user function. */ UNIV_INTERN diff --git a/storage/innobase/include/que0que.h b/storage/innobase/include/que0que.h index 39f8d07af89..09734bbb197 100644 --- a/storage/innobase/include/que0que.h +++ b/storage/innobase/include/que0que.h @@ -421,9 +421,6 @@ struct que_fork_struct{ ibool cur_on_row; /*!< TRUE if cursor is on a row, i.e., it is not before the first row or after the last row */ - dulint n_inserts; /*!< number of rows inserted */ - dulint n_updates; /*!< number of rows updated */ - dulint n_deletes; /*!< number of rows deleted */ sel_node_t* last_sel_node; /*!< last executed select node, or NULL if none */ UT_LIST_NODE_T(que_fork_t) diff --git a/storage/innobase/include/read0read.h b/storage/innobase/include/read0read.h index 4d9a9fade36..73ea66f4da2 100644 --- a/storage/innobase/include/read0read.h +++ b/storage/innobase/include/read0read.h @@ -43,8 +43,7 @@ read_view_t* read_view_open_now( /*===============*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating - transaction, or ut_dulint_zero - used in purge */ + transaction, or 0 used in purge */ mem_heap_t* heap); /*!< in: memory heap from which allocated */ /*********************************************************************//** @@ -56,8 +55,7 @@ read_view_t* read_view_oldest_copy_or_open_new( /*==============================*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating - transaction, or ut_dulint_zero - used in purge */ + transaction, or 0 used in purge */ mem_heap_t* heap); /*!< in: memory heap from which allocated */ /*********************************************************************//** @@ -125,7 +123,7 @@ read should not see the modifications to the database. */ struct read_view_struct{ ulint type; /*!< VIEW_NORMAL, VIEW_HIGH_GRANULARITY */ - undo_no_t undo_no;/*!< ut_dulint_zero or if type is + undo_no_t undo_no;/*!< 0 or if type is VIEW_HIGH_GRANULARITY transaction undo_no when this high-granularity consistent read view was created */ @@ -156,7 +154,7 @@ struct read_view_struct{ that is, up_limit_id and low_limit_id. */ trx_id_t creator_trx_id; /*!< trx id of creating transaction, or - ut_dulint_zero used in purge */ + 0 used in purge */ UT_LIST_NODE_T(read_view_t) view_list; /*!< List of read views in trx_sys */ }; diff --git a/storage/innobase/include/read0read.ic b/storage/innobase/include/read0read.ic index 9924967cc2d..5bb5249b591 100644 --- a/storage/innobase/include/read0read.ic +++ b/storage/innobase/include/read0read.ic @@ -64,15 +64,14 @@ read_view_sees_trx_id( trx_id_t trx_id) /*!< in: trx id */ { ulint n_ids; - int cmp; ulint i; - if (ut_dulint_cmp(trx_id, view->up_limit_id) < 0) { + if (trx_id < view->up_limit_id) { return(TRUE); } - if (ut_dulint_cmp(trx_id, view->low_limit_id) >= 0) { + if (trx_id >= view->low_limit_id) { return(FALSE); } @@ -85,12 +84,11 @@ read_view_sees_trx_id( n_ids = view->n_trx_ids; for (i = 0; i < n_ids; i++) { + trx_id_t view_trx_id + = read_view_get_nth_trx_id(view, n_ids - i - 1); - cmp = ut_dulint_cmp( - trx_id, - read_view_get_nth_trx_id(view, n_ids - i - 1)); - if (cmp <= 0) { - return(cmp < 0); + if (trx_id <= view_trx_id) { + return(trx_id != view_trx_id); } } diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h index 17d08afabb9..53402e8d3a9 100644 --- a/storage/innobase/include/rem0rec.h +++ b/storage/innobase/include/rem0rec.h @@ -659,7 +659,7 @@ rec_fold( fields to fold */ ulint n_bytes, /*!< in: number of bytes to fold in an incomplete last field */ - dulint tree_id) /*!< in: index tree id */ + index_id_t tree_id) /*!< in: index tree id */ __attribute__((pure)); #endif /* !UNIV_HOTBACKUP */ /*********************************************************//** diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic index 8e5bd9a7fcd..ba306eaf27f 100644 --- a/storage/innobase/include/rem0rec.ic +++ b/storage/innobase/include/rem0rec.ic @@ -1594,7 +1594,7 @@ rec_fold( fields to fold */ ulint n_bytes, /*!< in: number of bytes to fold in an incomplete last field */ - dulint tree_id) /*!< in: index tree id */ + index_id_t tree_id) /*!< in: index tree id */ { ulint i; const byte* data; @@ -1618,7 +1618,7 @@ rec_fold( n_bytes = 0; } - fold = ut_fold_dulint(tree_id); + fold = ut_fold_ull(tree_id); for (i = 0; i < n_fields; i++) { data = rec_get_nth_field(rec, offsets, i, &len); diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 39ea240772c..d9c26a2ee3b 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -103,6 +103,17 @@ row_mysql_read_blob_ref( ulint col_len); /*!< in: BLOB reference length (not BLOB length) */ /**************************************************************//** +Pad a column with spaces. */ +UNIV_INTERN +void +row_mysql_pad_col( +/*==============*/ + ulint mbminlen, /*!< in: minimum size of a character, + in bytes */ + byte* pad, /*!< out: padded buffer */ + ulint len); /*!< in: number of bytes to pad */ + +/**************************************************************//** Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. The counterpart of this function is row_sel_field_store_in_mysql_format() in row0sel.c. @@ -622,7 +633,11 @@ struct row_prebuilt_struct { the secondary index, then this is set to TRUE */ unsigned templ_contains_blob:1;/*!< TRUE if the template contains - BLOB column(s) */ + a column with DATA_BLOB == + get_innobase_type_from_mysql_type(); + not to be confused with InnoDB + externally stored columns + (VARCHAR can be off-page too) */ mysql_row_templ_t* mysql_template;/*!< template used to transform rows fast between MySQL and Innobase formats; memory for this template diff --git a/storage/innobase/include/row0upd.h b/storage/innobase/include/row0upd.h index 635d746d5a1..f7bec6f7561 100644 --- a/storage/innobase/include/row0upd.h +++ b/storage/innobase/include/row0upd.h @@ -132,7 +132,7 @@ row_upd_index_entry_sys_field( them */ dict_index_t* index, /*!< in: clustered index */ ulint type, /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */ - dulint val); /*!< in: value to write */ + ib_uint64_t val); /*!< in: value to write */ /*********************************************************************//** Creates an update node for a query graph. @return own: update node */ diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 18f7c07c3c6..d78c8113aee 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -112,6 +112,9 @@ OS (provided we compiled Innobase with it in), otherwise we will use simulated aio we build below with threads. Currently we support native aio on windows and linux */ extern my_bool srv_use_native_aio; +#ifdef __WIN__ +extern ibool srv_use_native_conditions; +#endif extern ulint srv_n_data_files; extern char** srv_data_file_names; extern ulint* srv_data_file_sizes; @@ -161,9 +164,9 @@ is 5% of the max where max is srv_io_capacity. */ #define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0))) #ifdef UNIV_LOG_ARCHIVE -extern ibool srv_log_archive_on; -extern ibool srv_archive_recovery; -extern dulint srv_archive_recovery_limit_lsn; +extern ibool srv_log_archive_on; +extern ibool srv_archive_recovery; +extern ib_uint64_t srv_archive_recovery_limit_lsn; #endif /* UNIV_LOG_ARCHIVE */ extern char* srv_file_flush_method_str; diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index 4e73bee9108..940e583350a 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -621,7 +621,7 @@ or row lock! */ #define SYNC_FILE_FORMAT_TAG 1200 /* Used to serialize access to the file format tag */ #define SYNC_DICT_OPERATION 1001 /* table create, drop, etc. reserve - this in X-mode, implicit or backround + this in X-mode; implicit or backround operations purge, rollback, foreign key checks reserve this in S-mode */ #define SYNC_DICT 1000 diff --git a/storage/innobase/include/trx0i_s.h b/storage/innobase/include/trx0i_s.h index c610782c229..8f8b7367fb0 100644 --- a/storage/innobase/include/trx0i_s.h +++ b/storage/innobase/include/trx0i_s.h @@ -30,6 +30,7 @@ Created July 17, 2007 Vasil Dimov #include "univ.i" #include "trx0types.h" +#include "dict0types.h" #include "ut0ut.h" /** The maximum amount of memory that can be consumed by innodb_trx, @@ -95,7 +96,7 @@ struct i_s_hash_chain_struct { /** This structure represents INFORMATION_SCHEMA.innodb_locks row */ struct i_s_locks_row_struct { - ullint lock_trx_id; /*!< transaction identifier */ + trx_id_t lock_trx_id; /*!< transaction identifier */ const char* lock_mode; /*!< lock mode from lock_get_mode_str() */ const char* lock_type; /*!< lock type from @@ -116,7 +117,7 @@ struct i_s_locks_row_struct { /** The following are auxiliary and not included in the table */ /* @{ */ - ullint lock_table_id; + table_id_t lock_table_id; /*!< table identifier from lock_get_table_id */ i_s_hash_chain_t hash_chain; /*!< hash table chain node for @@ -126,10 +127,10 @@ struct i_s_locks_row_struct { /** This structure represents INFORMATION_SCHEMA.innodb_trx row */ struct i_s_trx_row_struct { - ullint trx_id; /*!< transaction identifier */ - const char* trx_state; /*!< transaction state from - trx_get_que_state_str() */ - ib_time_t trx_started; /*!< trx_struct::start_time */ + trx_id_t trx_id; /*!< transaction identifier */ + const char* trx_state; /*!< transaction state from + trx_get_que_state_str() */ + ib_time_t trx_started; /*!< trx_struct::start_time */ const i_s_locks_row_t* requested_lock_row; /*!< pointer to a row in innodb_locks if trx diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h index a6e56e963c6..477748f6f89 100644 --- a/storage/innobase/include/trx0rec.h +++ b/storage/innobase/include/trx0rec.h @@ -108,7 +108,7 @@ trx_undo_rec_get_pars( ibool* updated_extern, /*!< out: TRUE if we updated an externally stored fild */ undo_no_t* undo_no, /*!< out: undo log record number */ - dulint* table_id); /*!< out: table id */ + table_id_t* table_id); /*!< out: table id */ /*******************************************************************//** Builds a row reference from an undo log record. @return pointer to remaining part of undo record */ @@ -227,7 +227,7 @@ trx_undo_report_row_operation( index, otherwise NULL */ roll_ptr_t* roll_ptr); /*!< out: rollback pointer to the inserted undo log record, - ut_dulint_zero if BTR_NO_UNDO_LOG + 0 if BTR_NO_UNDO_LOG flag was specified */ /******************************************************************//** Copies an undo record to heap. This function can be called if we know that diff --git a/storage/innobase/include/trx0rec.ic b/storage/innobase/include/trx0rec.ic index e7e41d6d9f6..f0b3276ed44 100644 --- a/storage/innobase/include/trx0rec.ic +++ b/storage/innobase/include/trx0rec.ic @@ -78,7 +78,7 @@ trx_undo_rec_get_undo_no( ptr = undo_rec + 3; - return(mach_dulint_read_much_compressed(ptr)); + return(mach_ull_read_much_compressed(ptr)); } /**********************************************************************//** @@ -90,7 +90,7 @@ trx_undo_rec_get_offset( /*====================*/ undo_no_t undo_no) /*!< in: undo no read from node */ { - return (3 + mach_dulint_get_much_compressed_size(undo_no)); + return (3 + mach_ull_get_much_compressed_size(undo_no)); } /***********************************************************************//** diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index fc92b4317d5..63e3f6be934 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -568,11 +568,16 @@ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_NO. */ (TRX_SYS_PAGE_NO of TRX_SYS_SPACE) */ #define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16) -/** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format +/** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format identifier is added to this constant. */ #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL /** Contents of TRX_SYS_FILE_FORMAT_TAG+4 when valid */ #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH 2745987765UL +/** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format +identifier is added to this 64-bit constant. */ +#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N \ + ((ib_uint64_t) TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH << 32 \ + | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW) /* @} */ /** Doublewrite control struct */ diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index 820d31d0692..385c7f4f0cc 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -266,7 +266,7 @@ trx_get_on_id( trx = UT_LIST_GET_FIRST(trx_sys->trx_list); while (trx != NULL) { - if (0 == ut_dulint_cmp(trx_id, trx->id)) { + if (trx_id == trx->id) { return(trx); } @@ -315,12 +315,12 @@ trx_is_active( ut_ad(mutex_own(&(kernel_mutex))); - if (ut_dulint_cmp(trx_id, trx_list_get_min_trx_id()) < 0) { + if (trx_id < trx_list_get_min_trx_id()) { return(FALSE); } - if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) { + if (UNIV_UNLIKELY(trx_id >= trx_sys->max_trx_id)) { /* There must be corruption: we return TRUE because this function is only called by lock_clust_rec_some_has_impl() @@ -359,15 +359,12 @@ trx_sys_get_new_trx_id(void) Thus trx id values will not overlap when the database is repeatedly started! */ - if (ut_dulint_get_low(trx_sys->max_trx_id) - % TRX_SYS_TRX_ID_WRITE_MARGIN == 0) { + if ((ulint) trx_sys->max_trx_id % TRX_SYS_TRX_ID_WRITE_MARGIN == 0) { trx_sys_flush_max_trx_id(); } - id = trx_sys->max_trx_id; - - UT_DULINT_INC(trx_sys->max_trx_id); + id = trx_sys->max_trx_id++; return(id); } diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index abd175d365b..6a817ccdc8e 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -408,30 +408,20 @@ Calculates the "weight" of a transaction. The weight of one transaction is estimated as the number of altered rows + the number of locked rows. @param t transaction @return transaction weight */ -#define TRX_WEIGHT(t) \ - ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks)) +#define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->trx_locks)) /*******************************************************************//** Compares the "weight" (or size) of two transactions. Transactions that have edited non-transactional tables are considered heavier than ones that have not. -@return <0, 0 or >0; similar to strcmp(3) */ +@return TRUE if weight(a) >= weight(b) */ UNIV_INTERN -int -trx_weight_cmp( -/*===========*/ +ibool +trx_weight_ge( +/*==========*/ const trx_t* a, /*!< in: the first transaction to be compared */ const trx_t* b); /*!< in: the second transaction to be compared */ -/*******************************************************************//** -Retrieves transacion's id, represented as unsigned long long. -@return transaction's id */ -UNIV_INLINE -ullint -trx_get_id( -/*=======*/ - const trx_t* trx); /*!< in: transaction */ - /* Maximum length of a string that can be returned by trx_get_que_state_str(). */ #define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */ @@ -555,8 +545,8 @@ struct trx_struct{ max trx id when the transaction is moved to COMMITTED_IN_MEMORY state */ ib_uint64_t commit_lsn; /*!< lsn at the time of the commit */ - trx_id_t table_id; /*!< Table to drop iff dict_operation - is TRUE, or ut_dulint_zero. */ + table_id_t table_id; /*!< Table to drop iff dict_operation + is TRUE, or 0. */ /*------------------------------*/ void* mysql_thd; /*!< MySQL thread handle corresponding to this trx, or NULL */ diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic index 7332eeece85..4a1d3bcde0b 100644 --- a/storage/innobase/include/trx0trx.ic +++ b/storage/innobase/include/trx0trx.ic @@ -69,18 +69,6 @@ trx_get_error_info( } /*******************************************************************//** -Retrieves transacion's id, represented as unsigned long long. -@return transaction's id */ -UNIV_INLINE -ullint -trx_get_id( -/*=======*/ - const trx_t* trx) /*!< in: transaction */ -{ - return((ullint)ut_conv_dulint_to_longlong(trx->id)); -} - -/*******************************************************************//** Retrieves transaction's que state in a human readable string. The string should not be free()'d or modified. @return string in the data segment */ diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h index 40a7256cbfd..a4115b5aca7 100644 --- a/storage/innobase/include/trx0types.h +++ b/storage/innobase/include/trx0types.h @@ -28,10 +28,7 @@ Created 3/26/1996 Heikki Tuuri #include "ut0byte.h" -/** prepare trx_t::id for being printed via printf(3) */ -#define TRX_ID_PREP_PRINTF(id) (ullint) ut_conv_dulint_to_longlong(id) - -/** printf(3) format used for printing TRX_ID_PRINTF_PREP() */ +/** printf(3) format used for printing DB_TRX_ID and other system fields */ #define TRX_ID_FMT "%llX" /** maximum length that a formatted trx_t::id could take, not including @@ -81,12 +78,14 @@ enum trx_rb_ctx { in crash recovery */ }; +/** Row identifier (DB_ROW_ID, DATA_ROW_ID) */ +typedef ib_id_t row_id_t; /** Transaction identifier (DB_TRX_ID, DATA_TRX_ID) */ -typedef dulint trx_id_t; +typedef ib_id_t trx_id_t; /** Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR) */ -typedef dulint roll_ptr_t; +typedef ib_id_t roll_ptr_t; /** Undo number */ -typedef dulint undo_no_t; +typedef ib_id_t undo_no_t; /** Transaction savepoint */ typedef struct trx_savept_struct trx_savept_t; diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index a084f2394b5..54809f9c2d5 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -383,7 +383,7 @@ struct trx_undo_struct{ XID xid; /*!< X/Open XA transaction identification */ ibool dict_operation; /*!< TRUE if a dict operation trx */ - dulint table_id; /*!< if a dict operation, then the table + table_id_t table_id; /*!< if a dict operation, then the table id */ trx_rseg_t* rseg; /*!< rseg where the undo log belongs */ /*-----------------------------*/ diff --git a/storage/innobase/include/trx0undo.ic b/storage/innobase/include/trx0undo.ic index 6502ee826e5..b81330f7f8b 100644 --- a/storage/innobase/include/trx0undo.ic +++ b/storage/innobase/include/trx0undo.ic @@ -39,16 +39,19 @@ trx_undo_build_roll_ptr( ulint page_no, /*!< in: page number */ ulint offset) /*!< in: offset of the undo entry within page */ { + roll_ptr_t roll_ptr; #if DATA_ROLL_PTR_LEN != 7 # error "DATA_ROLL_PTR_LEN != 7" #endif + ut_ad(is_insert == 0 || is_insert == 1); ut_ad(rseg_id < TRX_SYS_N_RSEGS); + ut_ad(offset < 65536); - return(ut_dulint_create(is_insert * 128 * 256 * 256 - + rseg_id * 256 * 256 - + (page_no / 256) / 256, - (page_no % (256 * 256)) * 256 * 256 - + offset)); + roll_ptr = (roll_ptr_t) is_insert << 55 + | (roll_ptr_t) rseg_id << 48 + | (roll_ptr_t) page_no << 16 + | offset; + return(roll_ptr); } /***********************************************************************//** @@ -64,24 +67,20 @@ trx_undo_decode_roll_ptr( ulint* offset) /*!< out: offset of the undo entry within page */ { - ulint low; - ulint high; #if DATA_ROLL_PTR_LEN != 7 # error "DATA_ROLL_PTR_LEN != 7" #endif #if TRUE != 1 # error "TRUE != 1" #endif - high = ut_dulint_get_high(roll_ptr); - low = ut_dulint_get_low(roll_ptr); - - *offset = low % (256 * 256); - - *is_insert = high / (256 * 256 * 128); /* TRUE == 1 */ - *rseg_id = (high / (256 * 256)) % 128; - - *page_no = (high % (256 * 256)) * 256 * 256 - + (low / 256) / 256; + ut_ad(roll_ptr < (1ULL << 56)); + *offset = (ulint) roll_ptr & 0xFFFF; + roll_ptr >>= 16; + *page_no = (ulint) roll_ptr & 0xFFFFFFFF; + roll_ptr >>= 32; + *rseg_id = (ulint) roll_ptr & 0x7F; + roll_ptr >>= 7; + *is_insert = (ibool) roll_ptr; /* TRUE==1 */ } /***********************************************************************//** @@ -93,16 +92,14 @@ trx_undo_roll_ptr_is_insert( /*========================*/ roll_ptr_t roll_ptr) /*!< in: roll pointer */ { - ulint high; #if DATA_ROLL_PTR_LEN != 7 # error "DATA_ROLL_PTR_LEN != 7" #endif #if TRUE != 1 # error "TRUE != 1" #endif - high = ut_dulint_get_high(roll_ptr); - - return(high / (256 * 256 * 128)); + ut_ad(roll_ptr < (1ULL << 56)); + return((ibool) (roll_ptr >> 55)); } #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index ea213486445..ac87942f255 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -46,7 +46,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 1 #define INNODB_VERSION_MINOR 1 -#define INNODB_VERSION_BUGFIX 1 +#define INNODB_VERSION_BUGFIX 2 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; @@ -310,6 +310,12 @@ management to ensure correct alignment for doubles etc. */ /* Maximum number of parallel threads in a parallelized operation */ #define UNIV_MAX_PARALLELISM 32 +/* The maximum length of a table name. This is the MySQL limit and is +defined in mysql_com.h like NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN, the +number does not include a terminating '\0'. InnoDB probably can handle +longer names internally */ +#define MAX_TABLE_NAME_LEN 192 + /* UNIVERSAL TYPE DEFINITIONS ========================== @@ -365,8 +371,10 @@ typedef unsigned long long int ullint; /* The 'undefined' value for a ulint */ #define ULINT_UNDEFINED ((ulint)(-1)) +/** The bitmask of 32-bit unsigned integer */ +#define ULINT32_MASK 0xFFFFFFFF /* The undefined 32-bit unsigned integer */ -#define ULINT32_UNDEFINED 0xFFFFFFFF +#define ULINT32_UNDEFINED ULINT32_MASK /* Maximum value for a ulint */ #define ULINT_MAX ((ulint)(-2)) @@ -374,6 +382,9 @@ typedef unsigned long long int ullint; /* Maximum value for ib_uint64_t */ #define IB_ULONGLONG_MAX ((ib_uint64_t) (~0ULL)) +/** The generic InnoDB system object identifier data type */ +typedef ib_uint64_t ib_id_t; + /* This 'ibool' type is used within Innobase. Remember that different included headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */ #define ibool ulint diff --git a/storage/innobase/include/ut0byte.h b/storage/innobase/include/ut0byte.h index f55e2888c60..b99d7175b94 100644 --- a/storage/innobase/include/ut0byte.h +++ b/storage/innobase/include/ut0byte.h @@ -27,145 +27,22 @@ Created 1/20/1994 Heikki Tuuri #define ut0byte_h -#include "univ.i" - -/** Pair of ulint integers. */ -typedef struct dulint_struct dulint; -/** Type definition for a 64-bit unsigned integer, which works also -in 32-bit machines. NOTE! Access the fields only with the accessor -functions. This definition appears here only for the compiler to -know the size of a dulint. */ -struct dulint_struct{ - ulint high; /*!< most significant 32 bits */ - ulint low; /*!< least significant 32 bits */ -}; - -/** Zero value for a dulint */ -extern const dulint ut_dulint_zero; -/** Maximum value for a dulint */ -extern const dulint ut_dulint_max; +#include "univ.i" /*******************************************************//** -Creates a 64-bit dulint out of two ulints. +Creates a 64-bit integer out of two 32-bit integers. @return created dulint */ UNIV_INLINE -dulint -ut_dulint_create( -/*=============*/ - ulint high, /*!< in: high-order 32 bits */ - ulint low); /*!< in: low-order 32 bits */ -/*******************************************************//** -Gets the high-order 32 bits of a dulint. -@return 32 bits in ulint */ -UNIV_INLINE -ulint -ut_dulint_get_high( -/*===============*/ - dulint d); /*!< in: dulint */ -/*******************************************************//** -Gets the low-order 32 bits of a dulint. -@return 32 bits in ulint */ -UNIV_INLINE -ulint -ut_dulint_get_low( -/*==============*/ - dulint d); /*!< in: dulint */ -/*******************************************************//** -Converts a dulint (a struct of 2 ulints) to ib_int64_t, which is a 64-bit -integer type. -@return value in ib_int64_t type */ -UNIV_INLINE -ib_int64_t -ut_conv_dulint_to_longlong( -/*=======================*/ - dulint d); /*!< in: dulint */ -/*******************************************************//** -Tests if a dulint is zero. -@return TRUE if zero */ -UNIV_INLINE -ibool -ut_dulint_is_zero( -/*==============*/ - dulint a); /*!< in: dulint */ -/*******************************************************//** -Compares two dulints. -@return -1 if a < b, 0 if a == b, 1 if a > b */ -UNIV_INLINE -int -ut_dulint_cmp( -/*==========*/ - dulint a, /*!< in: dulint */ - dulint b); /*!< in: dulint */ -/*******************************************************//** -Calculates the max of two dulints. -@return max(a, b) */ -UNIV_INLINE -dulint -ut_dulint_get_max( -/*==============*/ - dulint a, /*!< in: dulint */ - dulint b); /*!< in: dulint */ -/*******************************************************//** -Calculates the min of two dulints. -@return min(a, b) */ -UNIV_INLINE -dulint -ut_dulint_get_min( -/*==============*/ - dulint a, /*!< in: dulint */ - dulint b); /*!< in: dulint */ -/*******************************************************//** -Adds a ulint to a dulint. -@return sum a + b */ -UNIV_INLINE -dulint -ut_dulint_add( +ib_uint64_t +ut_ull_create( /*==========*/ - dulint a, /*!< in: dulint */ - ulint b); /*!< in: ulint */ -/*******************************************************//** -Subtracts a ulint from a dulint. -@return a - b */ -UNIV_INLINE -dulint -ut_dulint_subtract( -/*===============*/ - dulint a, /*!< in: dulint */ - ulint b); /*!< in: ulint, b <= a */ -/*******************************************************//** -Subtracts a dulint from another. NOTE that the difference must be positive -and smaller that 4G. -@return a - b */ -UNIV_INLINE -ulint -ut_dulint_minus( -/*============*/ - dulint a, /*!< in: dulint; NOTE a must be >= b and at most - 2 to power 32 - 1 greater */ - dulint b); /*!< in: dulint */ -/********************************************************//** -Rounds a dulint downward to a multiple of a power of 2. -@return rounded value */ -UNIV_INLINE -dulint -ut_dulint_align_down( -/*=================*/ - dulint n, /*!< in: number to be rounded */ - ulint align_no); /*!< in: align by this number which must be a - power of 2 */ -/********************************************************//** -Rounds a dulint upward to a multiple of a power of 2. -@return rounded value */ -UNIV_INLINE -dulint -ut_dulint_align_up( -/*===============*/ - dulint n, /*!< in: number to be rounded */ - ulint align_no); /*!< in: align by this number which must be a - power of 2 */ + ulint high, /*!< in: high-order 32 bits */ + ulint low) /*!< in: low-order 32 bits */ + __attribute__((const)); + /********************************************************//** -Rounds a dulint downward to a multiple of a power of 2. +Rounds a 64-bit integer downward to a multiple of a power of 2. @return rounded value */ UNIV_INLINE ib_uint64_t @@ -184,34 +61,6 @@ ut_uint64_align_up( ib_uint64_t n, /*!< in: number to be rounded */ ulint align_no); /*!< in: align by this number which must be a power of 2 */ -/*******************************************************//** -Increments a dulint variable by 1. */ -#define UT_DULINT_INC(D)\ -{\ - if ((D).low == 0xFFFFFFFFUL) {\ - (D).high = (D).high + 1;\ - (D).low = 0;\ - } else {\ - (D).low = (D).low + 1;\ - }\ -} -/*******************************************************//** -Tests if two dulints are equal. */ -#define UT_DULINT_EQ(D1, D2) (((D1).low == (D2).low)\ - && ((D1).high == (D2).high)) -#ifdef notdefined -/************************************************************//** -Sort function for dulint arrays. */ -UNIV_INTERN -void -ut_dulint_sort( -/*===========*/ - dulint* arr, /*!< in/out: array to be sorted */ - dulint* aux_arr,/*!< in/out: auxiliary array (same size as arr) */ - ulint low, /*!< in: low bound of sort interval, inclusive */ - ulint high); /*!< in: high bound of sort interval, noninclusive */ -#endif /* notdefined */ - /*********************************************************//** The following function rounds up a pointer to the nearest aligned address. @return aligned pointer */ diff --git a/storage/innobase/include/ut0byte.ic b/storage/innobase/include/ut0byte.ic index 3dd51890cb4..e7908efa41a 100644 --- a/storage/innobase/include/ut0byte.ic +++ b/storage/innobase/include/ut0byte.ic @@ -24,260 +24,22 @@ Created 5/30/1994 Heikki Tuuri *******************************************************************/ /*******************************************************//** -Creates a 64-bit dulint out of two ulints. +Creates a 64-bit integer out of two 32-bit integers. @return created dulint */ UNIV_INLINE -dulint -ut_dulint_create( -/*=============*/ +ib_uint64_t +ut_ull_create( +/*==========*/ ulint high, /*!< in: high-order 32 bits */ ulint low) /*!< in: low-order 32 bits */ { - dulint res; - - ut_ad(high <= 0xFFFFFFFF); - ut_ad(low <= 0xFFFFFFFF); - - res.high = high; - res.low = low; - - return(res); -} - -/*******************************************************//** -Gets the high-order 32 bits of a dulint. -@return 32 bits in ulint */ -UNIV_INLINE -ulint -ut_dulint_get_high( -/*===============*/ - dulint d) /*!< in: dulint */ -{ - return(d.high); -} - -/*******************************************************//** -Gets the low-order 32 bits of a dulint. -@return 32 bits in ulint */ -UNIV_INLINE -ulint -ut_dulint_get_low( -/*==============*/ - dulint d) /*!< in: dulint */ -{ - return(d.low); -} - -/*******************************************************//** -Converts a dulint (a struct of 2 ulints) to ib_int64_t, which is a 64-bit -integer type. -@return value in ib_int64_t type */ -UNIV_INLINE -ib_int64_t -ut_conv_dulint_to_longlong( -/*=======================*/ - dulint d) /*!< in: dulint */ -{ - return((ib_int64_t)d.low - + (((ib_int64_t)d.high) << 32)); -} - -/*******************************************************//** -Tests if a dulint is zero. -@return TRUE if zero */ -UNIV_INLINE -ibool -ut_dulint_is_zero( -/*==============*/ - dulint a) /*!< in: dulint */ -{ - if ((a.low == 0) && (a.high == 0)) { - - return(TRUE); - } - - return(FALSE); -} - -/*******************************************************//** -Compares two dulints. -@return -1 if a < b, 0 if a == b, 1 if a > b */ -UNIV_INLINE -int -ut_dulint_cmp( -/*==========*/ - dulint a, /*!< in: dulint */ - dulint b) /*!< in: dulint */ -{ - if (a.high > b.high) { - return(1); - } else if (a.high < b.high) { - return(-1); - } else if (a.low > b.low) { - return(1); - } else if (a.low < b.low) { - return(-1); - } else { - return(0); - } -} - -/*******************************************************//** -Calculates the max of two dulints. -@return max(a, b) */ -UNIV_INLINE -dulint -ut_dulint_get_max( -/*==============*/ - dulint a, /*!< in: dulint */ - dulint b) /*!< in: dulint */ -{ - if (ut_dulint_cmp(a, b) > 0) { - - return(a); - } - - return(b); -} - -/*******************************************************//** -Calculates the min of two dulints. -@return min(a, b) */ -UNIV_INLINE -dulint -ut_dulint_get_min( -/*==============*/ - dulint a, /*!< in: dulint */ - dulint b) /*!< in: dulint */ -{ - if (ut_dulint_cmp(a, b) > 0) { - - return(b); - } - - return(a); -} - -/*******************************************************//** -Adds a ulint to a dulint. -@return sum a + b */ -UNIV_INLINE -dulint -ut_dulint_add( -/*==========*/ - dulint a, /*!< in: dulint */ - ulint b) /*!< in: ulint */ -{ - if (0xFFFFFFFFUL - b >= a.low) { - a.low += b; - - return(a); - } - - a.low = a.low - (0xFFFFFFFFUL - b) - 1; - - a.high++; - - return(a); -} - -/*******************************************************//** -Subtracts a ulint from a dulint. -@return a - b */ -UNIV_INLINE -dulint -ut_dulint_subtract( -/*===============*/ - dulint a, /*!< in: dulint */ - ulint b) /*!< in: ulint, b <= a */ -{ - if (a.low >= b) { - a.low -= b; - - return(a); - } - - b -= a.low + 1; - - a.low = 0xFFFFFFFFUL - b; - - ut_ad(a.high > 0); - - a.high--; - - return(a); -} - -/*******************************************************//** -Subtracts a dulint from another. NOTE that the difference must be positive -and smaller that 4G. -@return a - b */ -UNIV_INLINE -ulint -ut_dulint_minus( -/*============*/ - dulint a, /*!< in: dulint; NOTE a must be >= b and at most - 2 to power 32 - 1 greater */ - dulint b) /*!< in: dulint */ -{ - ulint diff; - - if (a.high == b.high) { - ut_ad(a.low >= b.low); - - return(a.low - b.low); - } - - ut_ad(a.high == b.high + 1); - - diff = (ulint)(0xFFFFFFFFUL - b.low); - diff += 1 + a.low; - - ut_ad(diff > a.low); - - return(diff); -} - -/********************************************************//** -Rounds a dulint downward to a multiple of a power of 2. -@return rounded value */ -UNIV_INLINE -dulint -ut_dulint_align_down( -/*=================*/ - dulint n, /*!< in: number to be rounded */ - ulint align_no) /*!< in: align by this number which must be a - power of 2 */ -{ - ulint low, high; - - ut_ad(align_no > 0); - ut_ad(((align_no - 1) & align_no) == 0); - - low = ut_dulint_get_low(n); - high = ut_dulint_get_high(n); - - low = low & ~(align_no - 1); - - return(ut_dulint_create(high, low)); -} - -/********************************************************//** -Rounds a dulint upward to a multiple of a power of 2. -@return rounded value */ -UNIV_INLINE -dulint -ut_dulint_align_up( -/*===============*/ - dulint n, /*!< in: number to be rounded */ - ulint align_no) /*!< in: align by this number which must be a - power of 2 */ -{ - return(ut_dulint_align_down(ut_dulint_add(n, align_no - 1), align_no)); + ut_ad(high <= ULINT32_MASK); + ut_ad(low <= ULINT32_MASK); + return(((ib_uint64_t) high) << 32 | low); } /********************************************************//** -Rounds ib_uint64_t downward to a multiple of a power of 2. +Rounds a 64-bit integer downward to a multiple of a power of 2. @return rounded value */ UNIV_INLINE ib_uint64_t diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h index ce5152e942f..946b1117af7 100644 --- a/storage/innobase/include/ut0rnd.h +++ b/storage/innobase/include/ut0rnd.h @@ -97,13 +97,13 @@ ut_fold_ulint_pair( ulint n2) /*!< in: ulint */ __attribute__((const)); /*************************************************************//** -Folds a dulint. +Folds a 64-bit integer. @return folded value */ UNIV_INLINE ulint -ut_fold_dulint( -/*===========*/ - dulint d) /*!< in: dulint */ +ut_fold_ull( +/*========*/ + ib_uint64_t d) /*!< in: 64-bit integer */ __attribute__((const)); /*************************************************************//** Folds a character string ending in the null character. diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index c3dbd86923c..a6ba4ec2ba2 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -173,16 +173,16 @@ ut_fold_ulint_pair( } /*************************************************************//** -Folds a dulint. +Folds a 64-bit integer. @return folded value */ UNIV_INLINE ulint -ut_fold_dulint( -/*===========*/ - dulint d) /*!< in: dulint */ +ut_fold_ull( +/*========*/ + ib_uint64_t d) /*!< in: 64-bit integer */ { - return(ut_fold_ulint_pair(ut_dulint_get_low(d), - ut_dulint_get_high(d))); + return(ut_fold_ulint_pair((ulint) d & ULINT32_MASK, + (ulint) (d >> 32))); } /*************************************************************//** diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index 0e57a52666e..dcfca1b6315 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -468,7 +468,7 @@ lock_check_trx_id_sanity( /* A sanity check: the trx_id in rec must be smaller than the global trx id counter */ - if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) { + if (UNIV_UNLIKELY(trx_id >= trx_sys->max_trx_id)) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: transaction id associated" " with record\n", @@ -481,8 +481,7 @@ lock_check_trx_id_sanity( " global trx id counter " TRX_ID_FMT "!\n" "InnoDB: The table is corrupt. You have to do" " dump + drop + reimport.\n", - TRX_ID_PREP_PRINTF(trx_id), - TRX_ID_PREP_PRINTF(trx_sys->max_trx_id)); + (ullint) trx_id, (ullint) trx_sys->max_trx_id); is_ok = FALSE; } @@ -556,9 +555,9 @@ lock_sec_rec_cons_read_sees( } max_trx_id = page_get_max_trx_id(page_align(rec)); - ut_ad(!ut_dulint_is_zero(max_trx_id)); + ut_ad(max_trx_id); - return(ut_dulint_cmp(max_trx_id, view->up_limit_id) < 0); + return(max_trx_id < view->up_limit_id); } /*********************************************************************//** @@ -1594,8 +1593,7 @@ lock_sec_rec_some_has_impl_off_kernel( max trx id to the log, and therefore during recovery, this value for a page may be incorrect. */ - if (!(ut_dulint_cmp(page_get_max_trx_id(page), - trx_list_get_min_trx_id()) >= 0) + if (page_get_max_trx_id(page) < trx_list_get_min_trx_id() && !recv_recovery_is_on()) { return(NULL); @@ -1820,8 +1818,8 @@ lock_rec_enqueue_waiting( #ifdef UNIV_DEBUG if (lock_print_waits) { - fprintf(stderr, "Lock wait for trx %lu in index ", - (ulong) ut_dulint_get_low(trx->id)); + fprintf(stderr, "Lock wait for trx " TRX_ID_FMT " in index ", + (ullint) trx->id); ut_print_name(stderr, trx, FALSE, index->name); } #endif /* UNIV_DEBUG */ @@ -2193,8 +2191,8 @@ lock_grant( #ifdef UNIV_DEBUG if (lock_print_waits) { - fprintf(stderr, "Lock wait for trx %lu ends\n", - (ulong) ut_dulint_get_low(lock->trx->id)); + fprintf(stderr, "Lock wait for trx " TRX_ID_FMT " ends\n", + (ullint) lock->trx->id); } #endif /* UNIV_DEBUG */ @@ -3486,8 +3484,7 @@ lock_deadlock_recursive( } #endif /* UNIV_DEBUG */ - if (trx_weight_cmp(wait_lock->trx, - start) >= 0) { + if (trx_weight_ge(wait_lock->trx, start)) { /* Our recursion starting point transaction is 'smaller', let us choose 'start' as the victim and roll @@ -4023,7 +4020,7 @@ lock_release_off_kernel( ut_ad(lock_get_type_low(lock) & LOCK_TABLE); if (lock_get_mode(lock) != LOCK_IS - && !ut_dulint_is_zero(trx->undo_no)) { + && trx->undo_no != 0) { /* The trx may have modified the table. We block the use of the MySQL query cache for @@ -4222,8 +4219,7 @@ lock_table_print( fputs("TABLE LOCK table ", file); ut_print_name(file, lock->trx, TRUE, lock->un_member.tab_lock.table->name); - fprintf(file, " trx id " TRX_ID_FMT, - TRX_ID_PREP_PRINTF(lock->trx->id)); + fprintf(file, " trx id " TRX_ID_FMT, (ullint) lock->trx->id); if (lock_get_mode(lock) == LOCK_S) { fputs(" lock mode S", file); @@ -4276,8 +4272,7 @@ lock_rec_print( (ulong) space, (ulong) page_no, (ulong) lock_rec_get_n_bits(lock)); dict_index_name_print(file, lock->trx, lock->index); - fprintf(file, " trx id " TRX_ID_FMT, - TRX_ID_PREP_PRINTF(lock->trx->id)); + fprintf(file, " trx id " TRX_ID_FMT, (ullint) lock->trx->id); if (lock_get_mode(lock) == LOCK_S) { fputs(" lock mode S", file); @@ -4412,13 +4407,13 @@ lock_print_info_summary( "------------\n", file); fprintf(file, "Trx id counter " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF(trx_sys->max_trx_id)); + (ullint) trx_sys->max_trx_id); fprintf(file, "Purge done for trx's n:o < " TRX_ID_FMT " undo n:o < " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF(purge_sys->purge_trx_no), - TRX_ID_PREP_PRINTF(purge_sys->purge_undo_no)); + (ullint) purge_sys->purge_trx_no, + (ullint) purge_sys->purge_undo_no); fprintf(file, "History list length %lu\n", @@ -4495,10 +4490,8 @@ loop: "Trx read view will not see trx with" " id >= " TRX_ID_FMT ", sees < " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF( - trx->read_view->low_limit_id), - TRX_ID_PREP_PRINTF( - trx->read_view->up_limit_id)); + (ullint) trx->read_view->low_limit_id, + (ullint) trx->read_view->up_limit_id); } if (trx->que_state == TRX_QUE_LOCK_WAIT) { @@ -4912,12 +4905,12 @@ ibool lock_validate(void) /*===============*/ { - lock_t* lock; - trx_t* trx; - dulint limit; - ulint space; - ulint page_no; - ulint i; + lock_t* lock; + trx_t* trx; + ib_uint64_t limit; + ulint space; + ulint page_no; + ulint i; lock_mutex_enter_kernel(); @@ -4941,20 +4934,21 @@ lock_validate(void) for (i = 0; i < hash_get_n_cells(lock_sys->rec_hash); i++) { - limit = ut_dulint_zero; + limit = 0; for (;;) { lock = HASH_GET_FIRST(lock_sys->rec_hash, i); while (lock) { + ib_uint64_t space_page; ut_a(trx_in_trx_list(lock->trx)); space = lock->un_member.rec_lock.space; page_no = lock->un_member.rec_lock.page_no; - if (ut_dulint_cmp( - ut_dulint_create(space, page_no), - limit) >= 0) { + space_page = ut_ull_create(space, page_no); + + if (space_page >= limit) { break; } @@ -4974,7 +4968,7 @@ lock_validate(void) lock_mutex_enter_kernel(); - limit = ut_dulint_create(space, page_no + 1); + limit = ut_ull_create(space, page_no + 1); } } @@ -5348,8 +5342,7 @@ lock_sec_rec_read_check_and_lock( if the max trx id for the page >= min trx id for the trx list or a database recovery is running. */ - if (((ut_dulint_cmp(page_get_max_trx_id(block->frame), - trx_list_get_min_trx_id()) >= 0) + if ((page_get_max_trx_id(block->frame) >= trx_list_get_min_trx_id() || recv_recovery_is_on()) && !page_rec_is_supremum(rec)) { @@ -5572,12 +5565,12 @@ lock_get_type( Gets the id of the transaction owning a lock. @return transaction id */ UNIV_INTERN -ullint +trx_id_t lock_get_trx_id( /*============*/ const lock_t* lock) /*!< in: lock */ { - return(trx_get_id(lock->trx)); + return(lock->trx->id); } /*******************************************************************//** @@ -5671,7 +5664,7 @@ lock_get_table( Gets the id of the table on which the lock is. @return id of the table */ UNIV_INTERN -ullint +table_id_t lock_get_table_id( /*==============*/ const lock_t* lock) /*!< in: lock */ @@ -5680,7 +5673,7 @@ lock_get_table_id( table = lock_get_table(lock); - return((ullint)ut_conv_dulint_to_longlong(table->id)); + return(table->id); } /*******************************************************************//** diff --git a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c index 386f9630baa..401cede1d8f 100644 --- a/storage/innobase/log/log0log.c +++ b/storage/innobase/log/log0log.c @@ -1166,7 +1166,7 @@ log_group_file_header_flush( buf = *(group->file_header_bufs + nth_file); mach_write_to_4(buf + LOG_GROUP_ID, group->id); - mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn); + mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn); /* Wipe over possible label of ibbackup --restore */ memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, " ", 4); @@ -1769,8 +1769,8 @@ log_group_checkpoint( buf = group->checkpoint_buf; - mach_write_ull(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no); - mach_write_ull(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn); + mach_write_to_8(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no); + mach_write_to_8(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn); mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET, log_group_calc_lsn_offset( @@ -1790,9 +1790,9 @@ log_group_checkpoint( } } - mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn); + mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn); #else /* UNIV_LOG_ARCHIVE */ - mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX); + mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX); #endif /* UNIV_LOG_ARCHIVE */ for (i = 0; i < LOG_MAX_N_GROUPS; i++) { @@ -1884,7 +1884,7 @@ log_reset_first_header_and_checkpoint( ib_uint64_t lsn; mach_write_to_4(hdr_buf + LOG_GROUP_ID, 0); - mach_write_ull(hdr_buf + LOG_FILE_START_LSN, start); + mach_write_to_8(hdr_buf + LOG_FILE_START_LSN, start); lsn = start + LOG_BLOCK_HDR_SIZE; @@ -1896,15 +1896,15 @@ log_reset_first_header_and_checkpoint( + (sizeof "ibbackup ") - 1)); buf = hdr_buf + LOG_CHECKPOINT_1; - mach_write_ull(buf + LOG_CHECKPOINT_NO, 0); - mach_write_ull(buf + LOG_CHECKPOINT_LSN, lsn); + mach_write_to_8(buf + LOG_CHECKPOINT_NO, 0); + mach_write_to_8(buf + LOG_CHECKPOINT_LSN, lsn); mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET, LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE); mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, 2 * 1024 * 1024); - mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX); + mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX); fold = ut_fold_binary(buf, LOG_CHECKPOINT_CHECKSUM_1); mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_1, fold); @@ -2272,7 +2272,7 @@ log_group_archive_file_header_write( buf = *(group->archive_file_header_bufs + nth_file); mach_write_to_4(buf + LOG_GROUP_ID, group->id); - mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn); + mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn); mach_write_to_4(buf + LOG_FILE_NO, file_no); mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, FALSE); @@ -2308,7 +2308,7 @@ log_group_archive_completed_header_write( buf = *(group->archive_file_header_bufs + nth_file); mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, TRUE); - mach_write_ull(buf + LOG_FILE_END_LSN, end_lsn); + mach_write_to_8(buf + LOG_FILE_END_LSN, end_lsn); dest_offset = nth_file * group->file_size + LOG_FILE_ARCH_COMPLETED; diff --git a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c index f47f47e6a68..f983c4fb974 100644 --- a/storage/innobase/log/log0recv.c +++ b/storage/innobase/log/log0recv.c @@ -704,11 +704,11 @@ recv_find_max_checkpoint( group->state = LOG_GROUP_OK; - group->lsn = mach_read_ull( + group->lsn = mach_read_from_8( buf + LOG_CHECKPOINT_LSN); group->lsn_offset = mach_read_from_4( buf + LOG_CHECKPOINT_OFFSET); - checkpoint_no = mach_read_ull( + checkpoint_no = mach_read_from_8( buf + LOG_CHECKPOINT_NO); #ifdef UNIV_DEBUG @@ -778,14 +778,14 @@ recv_read_cp_info_for_backup( cp_buf = hdr + LOG_CHECKPOINT_1; if (recv_check_cp_is_consistent(cp_buf)) { - max_cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO); + max_cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO); max_cp = LOG_CHECKPOINT_1; } cp_buf = hdr + LOG_CHECKPOINT_2; if (recv_check_cp_is_consistent(cp_buf)) { - if (mach_read_ull(cp_buf + LOG_CHECKPOINT_NO) > max_cp_no) { + if (mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO) > max_cp_no) { max_cp = LOG_CHECKPOINT_2; } } @@ -796,7 +796,7 @@ recv_read_cp_info_for_backup( cp_buf = hdr + max_cp; - *lsn = mach_read_ull(cp_buf + LOG_CHECKPOINT_LSN); + *lsn = mach_read_from_8(cp_buf + LOG_CHECKPOINT_LSN); *offset = mach_read_from_4(cp_buf + LOG_CHECKPOINT_OFFSET); /* If the user is running a pre-3.23.50 version of InnoDB, its @@ -816,9 +816,9 @@ recv_read_cp_info_for_backup( /* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */ - *cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO); + *cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO); - *first_header_lsn = mach_read_ull(hdr + LOG_FILE_START_LSN); + *first_header_lsn = mach_read_from_8(hdr + LOG_FILE_START_LSN); return(TRUE); } @@ -1541,7 +1541,7 @@ recv_recover_page_func( #endif /* !UNIV_HOTBACKUP */ /* Read the newest modification lsn from the page */ - page_lsn = mach_read_ull(page + FIL_PAGE_LSN); + page_lsn = mach_read_from_8(page + FIL_PAGE_LSN); #ifndef UNIV_HOTBACKUP /* It may be that the page has been modified in the buffer @@ -1616,14 +1616,14 @@ recv_recover_page_func( block, &mtr); end_lsn = recv->start_lsn + recv->len; - mach_write_ull(FIL_PAGE_LSN + page, end_lsn); - mach_write_ull(UNIV_PAGE_SIZE - - FIL_PAGE_END_LSN_OLD_CHKSUM - + page, end_lsn); + mach_write_to_8(FIL_PAGE_LSN + page, end_lsn); + mach_write_to_8(UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + + page, end_lsn); if (page_zip) { - mach_write_ull(FIL_PAGE_LSN - + page_zip->data, end_lsn); + mach_write_to_8(FIL_PAGE_LSN + + page_zip->data, end_lsn); } } @@ -1995,7 +1995,7 @@ recv_apply_log_recs_for_backup(void) buf_flush_init_for_writing( block->frame, buf_block_get_page_zip(block), - mach_read_ull(block->frame + FIL_PAGE_LSN)); + mach_read_from_8(block->frame + FIL_PAGE_LSN)); if (zip_size) { error = fil_io(OS_FILE_WRITE, TRUE, @@ -2961,9 +2961,9 @@ recv_recovery_from_checkpoint_start_func( buf = log_sys->checkpoint_buf; - checkpoint_lsn = mach_read_ull(buf + LOG_CHECKPOINT_LSN); - checkpoint_no = mach_read_ull(buf + LOG_CHECKPOINT_NO); - archived_lsn = mach_read_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN); + checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN); + checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO); + archived_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN); /* Read the first log file header to print a note if this is a recovery from a restored InnoDB Hot Backup */ @@ -3613,8 +3613,8 @@ ask_again: return(TRUE); } - start_lsn = mach_read_ull(buf + LOG_FILE_START_LSN); - file_end_lsn = mach_read_ull(buf + LOG_FILE_END_LSN); + start_lsn = mach_read_from_8(buf + LOG_FILE_START_LSN); + file_end_lsn = mach_read_from_8(buf + LOG_FILE_END_LSN); if (!recv_sys->scanned_lsn) { diff --git a/storage/innobase/mach/mach0data.c b/storage/innobase/mach/mach0data.c index e030ce9aadf..647d9e57384 100644 --- a/storage/innobase/mach/mach0data.c +++ b/storage/innobase/mach/mach0data.c @@ -92,43 +92,3 @@ mach_parse_compressed( return(ptr + 5); } } - -/*********************************************************//** -Reads a dulint in a compressed form if the log record fully contains it. -@return pointer to end of the stored field, NULL if not complete */ -UNIV_INTERN -byte* -mach_dulint_parse_compressed( -/*=========================*/ - byte* ptr, /*!< in: pointer to buffer from where to read */ - byte* end_ptr,/*!< in: pointer to end of the buffer */ - dulint* val) /*!< out: read value */ -{ - ulint high; - ulint low; - ulint size; - - ut_ad(ptr && end_ptr && val); - - if (end_ptr < ptr + 5) { - - return(NULL); - } - - high = mach_read_compressed(ptr); - - size = mach_get_compressed_size(high); - - ptr += size; - - if (end_ptr < ptr + 4) { - - return(NULL); - } - - low = mach_read_from_4(ptr); - - *val = ut_dulint_create(high, low); - - return(ptr + 4); -} diff --git a/storage/innobase/mtr/mtr0log.c b/storage/innobase/mtr/mtr0log.c index 3f3dab36b76..04eeb4391cd 100644 --- a/storage/innobase/mtr/mtr0log.c +++ b/storage/innobase/mtr/mtr0log.c @@ -133,7 +133,7 @@ mlog_parse_initial_log_record( } /********************************************************//** -Parses a log record written by mlog_write_ulint or mlog_write_dulint. +Parses a log record written by mlog_write_ulint or mlog_write_ull. @return parsed record end, NULL if not a complete record or a corrupt record */ UNIV_INTERN byte* @@ -145,9 +145,9 @@ mlog_parse_nbytes( byte* page, /*!< in: page where to apply the log record, or NULL */ void* page_zip)/*!< in/out: compressed page, or NULL */ { - ulint offset; - ulint val; - dulint dval; + ulint offset; + ulint val; + ib_uint64_t dval; ut_a(type <= MLOG_8BYTES); ut_a(!page || !page_zip || fil_page_get_type(page) != FIL_PAGE_INDEX); @@ -167,7 +167,7 @@ mlog_parse_nbytes( } if (type == MLOG_8BYTES) { - ptr = mach_dulint_parse_compressed(ptr, end_ptr, &dval); + ptr = mach_ull_parse_compressed(ptr, end_ptr, &dval); if (ptr == NULL) { @@ -290,11 +290,11 @@ Writes 8 bytes to a file page buffered in the buffer pool. Writes the corresponding log record to the mini-transaction log. */ UNIV_INTERN void -mlog_write_dulint( -/*==============*/ - byte* ptr, /*!< in: pointer where to write */ - dulint val, /*!< in: value to write */ - mtr_t* mtr) /*!< in: mini-transaction handle */ +mlog_write_ull( +/*===========*/ + byte* ptr, /*!< in: pointer where to write */ + ib_uint64_t val, /*!< in: value to write */ + mtr_t* mtr) /*!< in: mini-transaction handle */ { byte* log_ptr; @@ -316,7 +316,7 @@ mlog_write_dulint( mach_write_to_2(log_ptr, page_offset(ptr)); log_ptr += 2; - log_ptr += mach_dulint_write_compressed(log_ptr, val); + log_ptr += mach_ull_write_compressed(log_ptr, val); mlog_close(mtr, log_ptr); } diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c index b01462f6b9b..74d04a22b86 100644 --- a/storage/innobase/mtr/mtr0mtr.c +++ b/storage/innobase/mtr/mtr0mtr.c @@ -337,9 +337,12 @@ mtr_memo_release( slot = dyn_array_get_element(memo, offset); if (object == slot->object && type == slot->type) { - if (mtr->modifications) { - mtr_memo_slot_note_modification(mtr, slot); - } + + /* We cannot release a page that has been written + to in the middle of a mini-transaction. */ + + ut_ad(!(mtr->modifications + && slot->type == MTR_MEMO_PAGE_X_FIX)); mtr_memo_slot_release(mtr, slot); @@ -375,23 +378,6 @@ mtr_read_ulint( } } -/********************************************************//** -Reads 8 bytes from a file page buffered in the buffer pool. -@return value read */ -UNIV_INTERN -dulint -mtr_read_dulint( -/*============*/ - const byte* ptr, /*!< in: pointer from where to read */ - mtr_t* mtr __attribute__((unused))) - /*!< in: mini-transaction handle */ -{ - ut_ad(mtr->state == MTR_ACTIVE); - ut_ad(mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_S_FIX) - || mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_X_FIX)); - return(mach_read_from_8(ptr)); -} - #ifdef UNIV_DEBUG # ifndef UNIV_HOTBACKUP /**********************************************************//** diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 7c502d616d3..65c5d65f860 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -183,7 +183,7 @@ struct os_aio_slot_struct{ which pending aio operation was completed */ #ifdef WIN_ASYNC_IO - os_event_t event; /*!< event object we need in the + HANDLE handle; /*!< handle object we need in the OVERLAPPED struct */ OVERLAPPED control; /*!< Windows control block for the aio request */ @@ -225,7 +225,7 @@ struct os_aio_array_struct{ aio array outside the ibuf segment */ os_aio_slot_t* slots; /*!< Pointer to the slots in the array */ #ifdef __WIN__ - os_native_event_t* native_events; + HANDLE* handles; /*!< Pointer to an array of OS native event handles where we copied the handles from slots, in the same @@ -304,7 +304,8 @@ UNIV_INTERN ulint os_n_pending_reads = 0; /***********************************************************************//** Gets the operating system version. Currently works only on Windows. -@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000 */ +@return OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000, OS_WINXP, OS_WINVISTA, +OS_WIN7. */ UNIV_INTERN ulint os_get_os_version(void) @@ -322,10 +323,18 @@ os_get_os_version(void) } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { return(OS_WIN95); } else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) { - if (os_info.dwMajorVersion <= 4) { - return(OS_WINNT); - } else { - return(OS_WIN2000); + switch (os_info.dwMajorVersion) { + case 3: + case 4: + return OS_WINNT; + case 5: + return (os_info.dwMinorVersion == 0) ? OS_WIN2000 + : OS_WINXP; + case 6: + return (os_info.dwMinorVersion == 0) ? OS_WINVISTA + : OS_WIN7; + default: + return OS_WIN7; } } else { ut_error; @@ -673,10 +682,10 @@ os_io_init_simple(void) { ulint i; - os_file_count_mutex = os_mutex_create(NULL); + os_file_count_mutex = os_mutex_create(); for (i = 0; i < OS_FILE_N_SEEK_MUTEXES; i++) { - os_file_seek_mutexes[i] = os_mutex_create(NULL); + os_file_seek_mutexes[i] = os_mutex_create(); } } @@ -1445,7 +1454,11 @@ try_again: /* When srv_file_per_table is on, file creation failure may not be critical to the whole instance. Do not crash the server in - case of unknown errors. */ + case of unknown errors. + Please note "srv_file_per_table" is a global variable with + no explicit synchronization protection. It could be + changed during this execution path. It might not have the + same value as the one when building the table definition */ if (srv_file_per_table) { retry = os_file_handle_error_no_exit(name, create_mode == OS_FILE_CREATE ? @@ -1532,7 +1545,11 @@ try_again: /* When srv_file_per_table is on, file creation failure may not be critical to the whole instance. Do not crash the server in - case of unknown errors. */ + case of unknown errors. + Please note "srv_file_per_table" is a global variable with + no explicit synchronization protection. It could be + changed during this execution path. It might not have the + same value as the one when building the table definition */ if (srv_file_per_table) { retry = os_file_handle_error_no_exit(name, create_mode == OS_FILE_CREATE ? @@ -3209,7 +3226,7 @@ os_aio_array_create( array = ut_malloc(sizeof(os_aio_array_t)); - array->mutex = os_mutex_create(NULL); + array->mutex = os_mutex_create(); array->not_full = os_event_create(NULL); array->is_empty = os_event_create(NULL); @@ -3221,10 +3238,13 @@ os_aio_array_create( array->cur_seg = 0; array->slots = ut_malloc(n * sizeof(os_aio_slot_t)); #ifdef __WIN__ - array->native_events = ut_malloc(n * sizeof(os_native_event_t)); + array->handles = ut_malloc(n * sizeof(HANDLE)); #endif #if defined(LINUX_NATIVE_AIO) + array->aio_ctx = NULL; + array->aio_events = NULL; + /* If we are not using native aio interface then skip this part of initialization. */ if (!srv_use_native_aio) { @@ -3262,13 +3282,13 @@ skip_native_aio: slot->pos = i; slot->reserved = FALSE; #ifdef WIN_ASYNC_IO - slot->event = os_event_create(NULL); + slot->handle = CreateEvent(NULL,TRUE, FALSE, NULL); over = &(slot->control); - over->hEvent = slot->event->handle; + over->hEvent = slot->handle; - *((array->native_events) + i) = over->hEvent; + *((array->handles) + i) = over->hEvent; #elif defined(LINUX_NATIVE_AIO) @@ -3294,17 +3314,24 @@ os_aio_array_free( for (i = 0; i < array->n_slots; i++) { os_aio_slot_t* slot = os_aio_array_get_nth_slot(array, i); - os_event_free(slot->event); + CloseHandle(slot->handle); } #endif /* WIN_ASYNC_IO */ #ifdef __WIN__ - ut_free(array->native_events); + ut_free(array->handles); #endif /* __WIN__ */ os_mutex_free(array->mutex); os_event_free(array->not_full); os_event_free(array->is_empty); +#if defined(LINUX_NATIVE_AIO) + if (srv_use_native_aio) { + ut_free(array->aio_events); + ut_free(array->aio_ctx); + } +#endif /* LINUX_NATIVE_AIO */ + ut_free(array->slots); ut_free(array); } @@ -3445,7 +3472,7 @@ os_aio_array_wake_win_aio_at_shutdown( for (i = 0; i < array->n_slots; i++) { - os_event_set((array->slots + i)->event); + SetEvent((array->slots + i)->handle); } } #endif @@ -3684,7 +3711,7 @@ found: control = &(slot->control); control->Offset = (DWORD)offset; control->OffsetHigh = (DWORD)offset_high; - os_event_reset(slot->event); + ResetEvent(slot->handle); #elif defined(LINUX_NATIVE_AIO) @@ -3756,7 +3783,7 @@ os_aio_array_free_slot( #ifdef WIN_ASYNC_IO - os_event_reset(slot->event); + ResetEvent(slot->handle); #elif defined(LINUX_NATIVE_AIO) @@ -4190,13 +4217,20 @@ os_aio_windows_handle( n = array->n_slots / array->n_segments; if (array == os_aio_sync_array) { - os_event_wait(os_aio_array_get_nth_slot(array, pos)->event); + WaitForSingleObject( + os_aio_array_get_nth_slot(array, pos)->handle, + INFINITE); i = pos; } else { srv_set_io_thread_op_info(orig_seg, "wait Windows aio"); - i = os_event_wait_multiple(n, - (array->native_events) - + segment * n); + i = WaitForMultipleObjects((DWORD) n, + array->handles + segment * n, + FALSE, + INFINITE); + } + + if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { + os_thread_exit(NULL); } os_mutex_enter(array->mutex); diff --git a/storage/innobase/os/os0sync.c b/storage/innobase/os/os0sync.c index 60467242e14..3c70e93aae0 100644 --- a/storage/innobase/os/os0sync.c +++ b/storage/innobase/os/os0sync.c @@ -35,6 +35,7 @@ Created 9/6/1995 Heikki Tuuri #include "ut0mem.h" #include "srv0start.h" +#include "srv0srv.h" /* Type definition for an operating system mutex struct */ struct os_mutex_struct{ @@ -76,6 +77,155 @@ event embedded inside a mutex, on free, this generates a recursive call. This version of the free event function doesn't acquire the global lock */ static void os_event_free_internal(os_event_t event); +/* On Windows (Vista and later), load function pointers for condition +variable handling. Those functions are not available in prior versions, +so we have to use them via runtime loading, as long as we support XP. */ +static void os_cond_module_init(void); + +#ifdef __WIN__ +/* Prototypes and function pointers for condition variable functions */ +typedef VOID (WINAPI* InitializeConditionVariableProc) + (PCONDITION_VARIABLE ConditionVariable); +static InitializeConditionVariableProc initialize_condition_variable; + +typedef BOOL (WINAPI* SleepConditionVariableCSProc) + (PCONDITION_VARIABLE ConditionVariable, + PCRITICAL_SECTION CriticalSection, + DWORD dwMilliseconds); +static SleepConditionVariableCSProc sleep_condition_variable; + +typedef VOID (WINAPI* WakeAllConditionVariableProc) + (PCONDITION_VARIABLE ConditionVariable); +static WakeAllConditionVariableProc wake_all_condition_variable; + +typedef VOID (WINAPI* WakeConditionVariableProc) + (PCONDITION_VARIABLE ConditionVariable); +static WakeConditionVariableProc wake_condition_variable; +#endif + +/*********************************************************//** +Initialitze condition variable */ +UNIV_INLINE +void +os_cond_init( +/*=========*/ + os_cond_t* cond) /*!< in: condition variable. */ +{ + ut_a(cond); + +#ifdef __WIN__ + ut_a(initialize_condition_variable != NULL); + initialize_condition_variable(cond); +#else + ut_a(pthread_cond_init(cond, NULL) == 0); +#endif +} + +/*********************************************************//** +Wait on condition variable */ +UNIV_INLINE +void +os_cond_wait( +/*=========*/ + os_cond_t* cond, /*!< in: condition variable. */ + os_fast_mutex_t* mutex) /*!< in: fast mutex */ +{ + ut_a(cond); + ut_a(mutex); + +#ifdef __WIN__ + ut_a(sleep_condition_variable != NULL); + ut_a(sleep_condition_variable(cond, mutex, INFINITE)); +#else + ut_a(pthread_cond_wait(cond, mutex) == 0); +#endif +} + +/*********************************************************//** +Wakes all threads waiting for condition variable */ +UNIV_INLINE +void +os_cond_broadcast( +/*==============*/ + os_cond_t* cond) /*!< in: condition variable. */ +{ + ut_a(cond); + +#ifdef __WIN__ + ut_a(wake_all_condition_variable != NULL); + wake_all_condition_variable(cond); +#else + ut_a(pthread_cond_broadcast(cond) == 0); +#endif +} + +/*********************************************************//** +Wakes one thread waiting for condition variable */ +UNIV_INLINE +void +os_cond_signal( +/*==========*/ + os_cond_t* cond) /*!< in: condition variable. */ +{ + ut_a(cond); + +#ifdef __WIN__ + ut_a(wake_condition_variable != NULL); + wake_condition_variable(cond); +#else + ut_a(pthread_cond_signal(cond) == 0); +#endif +} + +/*********************************************************//** +Destroys condition variable */ +UNIV_INLINE +void +os_cond_destroy( +/*============*/ + os_cond_t* cond) /*!< in: condition variable. */ +{ +#ifdef __WIN__ + /* Do nothing */ +#else + ut_a(pthread_cond_destroy(cond) == 0); +#endif +} + +/*********************************************************//** +On Windows (Vista and later), load function pointers for condition variable +handling. Those functions are not available in prior versions, so we have to +use them via runtime loading, as long as we support XP. */ +static +void +os_cond_module_init(void) +/*=====================*/ +{ +#ifdef __WIN__ + HMODULE h_dll; + + if (!srv_use_native_conditions) + return; + + h_dll = GetModuleHandle("kernel32"); + + initialize_condition_variable = (InitializeConditionVariableProc) + GetProcAddress(h_dll, "InitializeConditionVariable"); + sleep_condition_variable = (SleepConditionVariableCSProc) + GetProcAddress(h_dll, "SleepConditionVariableCS"); + wake_all_condition_variable = (WakeAllConditionVariableProc) + GetProcAddress(h_dll, "WakeAllConditionVariable"); + wake_condition_variable = (WakeConditionVariableProc) + GetProcAddress(h_dll, "WakeConditionVariable"); + + /* When using native condition variables, check function pointers */ + ut_a(initialize_condition_variable); + ut_a(sleep_condition_variable); + ut_a(wake_all_condition_variable); + ut_a(wake_condition_variable); +#endif +} + /*********************************************************//** Initializes global event and OS 'slow' mutex lists. */ UNIV_INTERN @@ -89,7 +239,10 @@ os_sync_init(void) os_sync_mutex = NULL; os_sync_mutex_inited = FALSE; - os_sync_mutex = os_mutex_create(NULL); + /* Now for Windows only */ + os_cond_module_init(); + + os_sync_mutex = os_mutex_create(); os_sync_mutex_inited = TRUE; } @@ -143,42 +296,45 @@ os_event_create( const char* name) /*!< in: the name of the event, if NULL the event is created without a name */ { -#ifdef __WIN__ - os_event_t event; - - event = ut_malloc(sizeof(struct os_event_struct)); - - event->handle = CreateEvent(NULL, /* No security attributes */ - TRUE, /* Manual reset */ - FALSE, /* Initial state nonsignaled */ - (LPCTSTR) name); - if (!event->handle) { - fprintf(stderr, - "InnoDB: Could not create a Windows event semaphore;" - " Windows error %lu\n", - (ulong) GetLastError()); - } -#else /* Unix */ os_event_t event; - UT_NOT_USED(name); +#ifdef __WIN__ + if(!srv_use_native_conditions) { + + event = ut_malloc(sizeof(struct os_event_struct)); + + event->handle = CreateEvent(NULL, + TRUE, + FALSE, + (LPCTSTR) name); + if (!event->handle) { + fprintf(stderr, + "InnoDB: Could not create a Windows event" + " semaphore; Windows error %lu\n", + (ulong) GetLastError()); + } + } else /* Windows with condition variables */ +#endif - event = ut_malloc(sizeof(struct os_event_struct)); + { + UT_NOT_USED(name); - os_fast_mutex_init(&(event->os_mutex)); + event = ut_malloc(sizeof(struct os_event_struct)); - ut_a(0 == pthread_cond_init(&(event->cond_var), NULL)); + os_fast_mutex_init(&(event->os_mutex)); - event->is_set = FALSE; + os_cond_init(&(event->cond_var)); - /* We return this value in os_event_reset(), which can then be - be used to pass to the os_event_wait_low(). The value of zero - is reserved in os_event_wait_low() for the case when the - caller does not want to pass any signal_count value. To - distinguish between the two cases we initialize signal_count - to 1 here. */ - event->signal_count = 1; -#endif /* __WIN__ */ + event->is_set = FALSE; + + /* We return this value in os_event_reset(), which can then be + be used to pass to the os_event_wait_low(). The value of zero + is reserved in os_event_wait_low() for the case when the + caller does not want to pass any signal_count value. To + distinguish between the two cases we initialize signal_count + to 1 here. */ + event->signal_count = 1; + } /* The os_sync_mutex can be NULL because during startup an event can be created [ because it's embedded in the mutex/rwlock ] before @@ -208,10 +364,15 @@ os_event_set( /*=========*/ os_event_t event) /*!< in: event to set */ { -#ifdef __WIN__ ut_a(event); - ut_a(SetEvent(event->handle)); -#else + +#ifdef __WIN__ + if (!srv_use_native_conditions) { + ut_a(SetEvent(event->handle)); + return; + } +#endif + ut_a(event); os_fast_mutex_lock(&(event->os_mutex)); @@ -221,11 +382,10 @@ os_event_set( } else { event->is_set = TRUE; event->signal_count += 1; - ut_a(0 == pthread_cond_broadcast(&(event->cond_var))); + os_cond_broadcast(&(event->cond_var)); } os_fast_mutex_unlock(&(event->os_mutex)); -#endif } /**********************************************************//** @@ -244,12 +404,14 @@ os_event_reset( { ib_int64_t ret = 0; -#ifdef __WIN__ ut_a(event); - ut_a(ResetEvent(event->handle)); -#else - ut_a(event); +#ifdef __WIN__ + if(!srv_use_native_conditions) { + ut_a(ResetEvent(event->handle)); + return(0); + } +#endif os_fast_mutex_lock(&(event->os_mutex)); @@ -261,7 +423,6 @@ os_event_reset( ret = event->signal_count; os_fast_mutex_unlock(&(event->os_mutex)); -#endif return(ret); } @@ -274,19 +435,21 @@ os_event_free_internal( os_event_t event) /*!< in: event to free */ { #ifdef __WIN__ - ut_a(event); + if(!srv_use_native_conditions) { + ut_a(event); + ut_a(CloseHandle(event->handle)); + } else +#endif + { + ut_a(event); - ut_a(CloseHandle(event->handle)); -#else - ut_a(event); + /* This is to avoid freeing the mutex twice */ + os_fast_mutex_free(&(event->os_mutex)); - /* This is to avoid freeing the mutex twice */ - os_fast_mutex_free(&(event->os_mutex)); + os_cond_destroy(&(event->cond_var)); + } - ut_a(0 == pthread_cond_destroy(&(event->cond_var))); -#endif /* Remove from the list of events */ - UT_LIST_REMOVE(os_event_list, os_event_list, event); os_event_count--; @@ -303,18 +466,19 @@ os_event_free( os_event_t event) /*!< in: event to free */ { -#ifdef __WIN__ ut_a(event); +#ifdef __WIN__ + if(!srv_use_native_conditions){ + ut_a(CloseHandle(event->handle)); + } else /*Windows with condition variables */ +#endif + { + os_fast_mutex_free(&(event->os_mutex)); - ut_a(CloseHandle(event->handle)); -#else - ut_a(event); + os_cond_destroy(&(event->cond_var)); + } - os_fast_mutex_free(&(event->os_mutex)); - ut_a(0 == pthread_cond_destroy(&(event->cond_var))); -#endif /* Remove from the list of events */ - os_mutex_enter(os_sync_mutex); UT_LIST_REMOVE(os_event_list, os_event_list, event); @@ -355,23 +519,27 @@ os_event_wait_low( returned by previous call of os_event_reset(). */ { + ib_int64_t old_signal_count; + #ifdef __WIN__ - DWORD err; + if(!srv_use_native_conditions) { + DWORD err; - ut_a(event); + ut_a(event); - UT_NOT_USED(reset_sig_count); + UT_NOT_USED(reset_sig_count); - /* Specify an infinite time limit for waiting */ - err = WaitForSingleObject(event->handle, INFINITE); + /* Specify an infinite wait */ + err = WaitForSingleObject(event->handle, INFINITE); - ut_a(err == WAIT_OBJECT_0); + ut_a(err == WAIT_OBJECT_0); - if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - os_thread_exit(NULL); + if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { + os_thread_exit(NULL); + } + return; } -#else - ib_int64_t old_signal_count; +#endif os_fast_mutex_lock(&(event->os_mutex)); @@ -396,93 +564,13 @@ os_event_wait_low( return; } - pthread_cond_wait(&(event->cond_var), &(event->os_mutex)); + os_cond_wait(&(event->cond_var), &(event->os_mutex)); /* Solaris manual said that spurious wakeups may occur: we have to check if the event really has been signaled after we came here to wait */ } -#endif -} - -/**********************************************************//** -Waits for an event object until it is in the signaled state or -a timeout is exceeded. In Unix the timeout is always infinite. -@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */ -UNIV_INTERN -ulint -os_event_wait_time( -/*===============*/ - os_event_t event, /*!< in: event to wait */ - ulint time) /*!< in: timeout in microseconds, or - OS_SYNC_INFINITE_TIME */ -{ -#ifdef __WIN__ - DWORD err; - - ut_a(event); - - if (time != OS_SYNC_INFINITE_TIME) { - err = WaitForSingleObject(event->handle, (DWORD) time / 1000); - } else { - err = WaitForSingleObject(event->handle, INFINITE); - } - - if (err == WAIT_OBJECT_0) { - - return(0); - } else if (err == WAIT_TIMEOUT) { - - return(OS_SYNC_TIME_EXCEEDED); - } else { - ut_error; - return(1000000); /* dummy value to eliminate compiler warn. */ - } -#else - UT_NOT_USED(time); - - /* In Posix this is just an ordinary, infinite wait */ - - os_event_wait(event); - - return(0); -#endif -} - -#ifdef __WIN__ -/**********************************************************//** -Waits for any event in an OS native event array. Returns if even a single -one is signaled or becomes signaled. -@return index of the event which was signaled */ -UNIV_INTERN -ulint -os_event_wait_multiple( -/*===================*/ - ulint n, /*!< in: number of events in the - array */ - os_native_event_t* native_event_array) - /*!< in: pointer to an array of event - handles */ -{ - DWORD index; - - ut_a(native_event_array); - ut_a(n > 0); - - index = WaitForMultipleObjects((DWORD) n, native_event_array, - FALSE, /* Wait for any 1 event */ - INFINITE); /* Infinite wait time - limit */ - ut_a(index >= WAIT_OBJECT_0); /* NOTE: Pointless comparison */ - ut_a(index < WAIT_OBJECT_0 + n); - - if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - os_thread_exit(NULL); - } - - return(index - WAIT_OBJECT_0); } -#endif /*********************************************************//** Creates an operating system mutex semaphore. Because these are slow, the @@ -490,29 +578,15 @@ mutex semaphore of InnoDB itself (mutex_t) should be used where possible. @return the mutex handle */ UNIV_INTERN os_mutex_t -os_mutex_create( -/*============*/ - const char* name) /*!< in: the name of the mutex, if NULL - the mutex is created without a name */ +os_mutex_create(void) +/*=================*/ { -#ifdef __WIN__ - HANDLE mutex; - os_mutex_t mutex_str; - - mutex = CreateMutex(NULL, /* No security attributes */ - FALSE, /* Initial state: no owner */ - (LPCTSTR) name); - ut_a(mutex); -#else os_fast_mutex_t* mutex; os_mutex_t mutex_str; - UT_NOT_USED(name); - mutex = ut_malloc(sizeof(os_fast_mutex_t)); os_fast_mutex_init(mutex); -#endif mutex_str = ut_malloc(sizeof(os_mutex_str_t)); mutex_str->handle = mutex; @@ -543,25 +617,11 @@ os_mutex_enter( /*===========*/ os_mutex_t mutex) /*!< in: mutex to acquire */ { -#ifdef __WIN__ - DWORD err; - - ut_a(mutex); - - /* Specify infinite time limit for waiting */ - err = WaitForSingleObject(mutex->handle, INFINITE); - - ut_a(err == WAIT_OBJECT_0); - - (mutex->count)++; - ut_a(mutex->count == 1); -#else os_fast_mutex_lock(mutex->handle); (mutex->count)++; ut_a(mutex->count == 1); -#endif } /**********************************************************//** @@ -577,11 +637,7 @@ os_mutex_exit( ut_a(mutex->count == 1); (mutex->count)--; -#ifdef __WIN__ - ut_a(ReleaseMutex(mutex->handle)); -#else os_fast_mutex_unlock(mutex->handle); -#endif } /**********************************************************//** @@ -610,15 +666,9 @@ os_mutex_free( os_mutex_exit(os_sync_mutex); } -#ifdef __WIN__ - ut_a(CloseHandle(mutex->handle)); - - ut_free(mutex); -#else os_fast_mutex_free(mutex->handle); ut_free(mutex->handle); ut_free(mutex); -#endif } /*********************************************************//** diff --git a/storage/innobase/os/os0thread.c b/storage/innobase/os/os0thread.c index 632199b56bc..adc876be5d5 100644 --- a/storage/innobase/os/os0thread.c +++ b/storage/innobase/os/os0thread.c @@ -242,7 +242,7 @@ os_thread_yield(void) /*=================*/ { #if defined(__WIN__) - Sleep(0); + SwitchToThread(); #elif (defined(HAVE_SCHED_YIELD) && defined(HAVE_SCHED_H)) sched_yield(); #elif defined(HAVE_PTHREAD_YIELD_ZERO_ARG) diff --git a/storage/innobase/page/page0page.c b/storage/innobase/page/page0page.c index 10008f9ac25..2e785412ac9 100644 --- a/storage/innobase/page/page0page.c +++ b/storage/innobase/page/page0page.c @@ -235,8 +235,8 @@ page_set_max_trx_id( 8, mtr); #ifndef UNIV_HOTBACKUP } else if (mtr) { - mlog_write_dulint(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), - trx_id, mtr); + mlog_write_ull(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), + trx_id, mtr); #endif /* !UNIV_HOTBACKUP */ } else { mach_write_to_8(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), trx_id); @@ -457,7 +457,7 @@ page_create_low( page_header_set_field(page, NULL, PAGE_DIRECTION, PAGE_NO_DIRECTION); page_header_set_field(page, NULL, PAGE_N_DIRECTION, 0); page_header_set_field(page, NULL, PAGE_N_RECS, 0); - page_set_max_trx_id(block, NULL, ut_dulint_zero, NULL); + page_set_max_trx_id(block, NULL, 0, NULL); memset(heap_top, 0, UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START - page_offset(heap_top)); diff --git a/storage/innobase/page/page0zip.c b/storage/innobase/page/page0zip.c index 14ec3e7a94f..98640a8e6fb 100644 --- a/storage/innobase/page/page0zip.c +++ b/storage/innobase/page/page0zip.c @@ -1464,6 +1464,7 @@ page_zip_fields_free( dict_table_t* table = index->table; mem_heap_free(index->heap); mutex_free(&(table->autoinc_mutex)); + ut_free(table->name); mem_heap_free(table->heap); } } @@ -4467,7 +4468,7 @@ page_zip_reorganize( /* Copy max trx id to recreated page */ trx_id_t max_trx_id = page_get_max_trx_id(temp_page); page_set_max_trx_id(block, NULL, max_trx_id, NULL); - ut_ad(!ut_dulint_is_zero(max_trx_id)); + ut_ad(max_trx_id != 0); } /* Restore logging. */ @@ -4527,7 +4528,7 @@ page_zip_copy_recs( /* The PAGE_MAX_TRX_ID must be set on leaf pages of secondary indexes. It does not matter on other pages. */ ut_a(dict_index_is_clust(index) || !page_is_leaf(src) - || !ut_dulint_is_zero(page_get_max_trx_id(src))); + || page_get_max_trx_id(src)); UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_W(page_zip->data, page_zip_get_size(page_zip)); diff --git a/storage/innobase/pars/pars0pars.c b/storage/innobase/pars/pars0pars.c index 613e7962f0e..ef107f2896f 100644 --- a/storage/innobase/pars/pars0pars.c +++ b/storage/innobase/pars/pars0pars.c @@ -2031,29 +2031,6 @@ pars_info_add_int4_literal( Equivalent to: char buf[8]; -mach_write_ull(buf, val); -pars_info_add_literal(info, name, buf, 8, DATA_INT, 0); - -except that the buffer is dynamically allocated from the info struct's -heap. */ -UNIV_INTERN -void -pars_info_add_uint64_literal( -/*=========================*/ - pars_info_t* info, /*!< in: info struct */ - const char* name, /*!< in: name */ - ib_uint64_t val) /*!< in: value */ -{ - byte* buf = mem_heap_alloc(info->heap, 8); - - mach_write_ull(buf, val); - pars_info_add_literal(info, name, buf, 8, DATA_INT, 0); -} - -/****************************************************************//** -Equivalent to: - -char buf[8]; mach_write_to_8(buf, val); pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0); @@ -2061,11 +2038,11 @@ except that the buffer is dynamically allocated from the info struct's heap. */ UNIV_INTERN void -pars_info_add_dulint_literal( -/*=========================*/ +pars_info_add_ull_literal( +/*======================*/ pars_info_t* info, /*!< in: info struct */ const char* name, /*!< in: name */ - dulint val) /*!< in: value */ + ib_uint64_t val) /*!< in: value */ { byte* buf = mem_heap_alloc(info->heap, 8); diff --git a/storage/innobase/read/read0read.c b/storage/innobase/read/read0read.c index 85adae4ddff..9975b8c2c57 100644 --- a/storage/innobase/read/read0read.c +++ b/storage/innobase/read/read0read.c @@ -168,8 +168,7 @@ read_view_t* read_view_oldest_copy_or_open_new( /*==============================*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating - transaction, or ut_dulint_zero - used in purge */ + transaction, or 0 used in purge */ mem_heap_t* heap) /*!< in: memory heap from which allocated */ { @@ -191,7 +190,7 @@ read_view_oldest_copy_or_open_new( n = old_view->n_trx_ids; - if (!ut_dulint_is_zero(old_view->creator_trx_id)) { + if (old_view->creator_trx_id) { n++; } else { needs_insert = FALSE; @@ -206,9 +205,8 @@ read_view_oldest_copy_or_open_new( while (i < n) { if (needs_insert && (i >= old_view->n_trx_ids - || ut_dulint_cmp(old_view->creator_trx_id, - read_view_get_nth_trx_id(old_view, i)) - > 0)) { + || old_view->creator_trx_id + > read_view_get_nth_trx_id(old_view, i))) { read_view_set_nth_trx_id(view_copy, i, old_view->creator_trx_id); @@ -252,8 +250,7 @@ read_view_t* read_view_open_now( /*===============*/ trx_id_t cr_trx_id, /*!< in: trx_id of creating - transaction, or ut_dulint_zero - used in purge */ + transaction, or 0 used in purge */ mem_heap_t* heap) /*!< in: memory heap from which allocated */ { @@ -267,7 +264,7 @@ read_view_open_now( view->creator_trx_id = cr_trx_id; view->type = VIEW_NORMAL; - view->undo_no = ut_dulint_zero; + view->undo_no = 0; /* No future transactions should be visible in the view */ @@ -280,7 +277,7 @@ read_view_open_now( /* No active transaction should be visible, except cr_trx */ while (trx) { - if (ut_dulint_cmp(trx->id, cr_trx_id) != 0 + if (trx->id != cr_trx_id && (trx->conc_state == TRX_ACTIVE || trx->conc_state == TRX_PREPARED)) { @@ -292,9 +289,9 @@ read_view_open_now( trx_sys->max_trx_id can still be active, if it is in the middle of its commit! Note that when a transaction starts, we initialize trx->no to - ut_dulint_max. */ + IB_ULONGLONG_MAX. */ - if (ut_dulint_cmp(view->low_limit_no, trx->no) > 0) { + if (view->low_limit_no > trx->no) { view->low_limit_no = trx->no; } @@ -367,22 +364,20 @@ read_view_print( if (view->type == VIEW_HIGH_GRANULARITY) { fprintf(stderr, - "High-granularity read view undo_n:o %lu %lu\n", - (ulong) ut_dulint_get_high(view->undo_no), - (ulong) ut_dulint_get_low(view->undo_no)); + "High-granularity read view undo_n:o %llu\n", + (ullint) view->undo_no); } else { fprintf(stderr, "Normal read view\n"); } - fprintf(stderr, "Read view low limit trx n:o %lu %lu\n", - (ulong) ut_dulint_get_high(view->low_limit_no), - (ulong) ut_dulint_get_low(view->low_limit_no)); + fprintf(stderr, "Read view low limit trx n:o " TRX_ID_FMT "\n", + (ullint) view->low_limit_no); fprintf(stderr, "Read view up limit trx id " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF(view->up_limit_id)); + (ullint) view->up_limit_id); fprintf(stderr, "Read view low limit trx id " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF(view->low_limit_id)); + (ullint) view->low_limit_id); fprintf(stderr, "Read view individually stored trx ids:\n"); @@ -390,8 +385,7 @@ read_view_print( for (i = 0; i < n_ids; i++) { fprintf(stderr, "Read view trx id " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF( - read_view_get_nth_trx_id(view, i))); + (ullint) read_view_get_nth_trx_id(view, i)); } } @@ -460,9 +454,9 @@ read_cursor_view_create_for_mysql( trx_sys->max_trx_id can still be active, if it is in the middle of its commit! Note that when a transaction starts, we initialize trx->no to - ut_dulint_max. */ + IB_ULONGLONG_MAX. */ - if (ut_dulint_cmp(view->low_limit_no, trx->no) > 0) { + if (view->low_limit_no > trx->no) { view->low_limit_no = trx->no; } diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index c882a065cd1..8fd8c4f8532 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -51,6 +51,15 @@ Created 4/20/1996 Heikki Tuuri #define ROW_INS_PREV 1 #define ROW_INS_NEXT 2 +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ /*********************************************************************//** Creates an insert node struct. @@ -78,7 +87,7 @@ ins_node_create( node->select = NULL; - node->trx_id = ut_dulint_zero; + node->trx_id = 0; node->entry_sys_heap = mem_heap_create(128); @@ -198,7 +207,7 @@ ins_node_set_new_row( /* As we allocated a new trx id buf, the trx id should be written there again: */ - node->trx_id = ut_dulint_zero; + node->trx_id = 0; } /*******************************************************************//** @@ -506,8 +515,7 @@ row_ins_cascade_calc_update_vec( if (!dfield_is_null(&ufield->new_val) && dtype_get_at_most_n_mbchars( - col->prtype, - col->mbminlen, col->mbmaxlen, + col->prtype, col->mbminmaxlen, col->len, ufield_len, dfield_get_data(&ufield->new_val)) @@ -530,49 +538,37 @@ row_ins_cascade_calc_update_vec( if (min_size > ufield_len) { - char* pad_start; - const char* pad_end; - char* padded_data - = mem_heap_alloc( - heap, min_size); - pad_start = padded_data + ufield_len; - pad_end = padded_data + min_size; + byte* pad; + ulint pad_len; + byte* padded_data; + ulint mbminlen; + + padded_data = mem_heap_alloc( + heap, min_size); + + pad = padded_data + ufield_len; + pad_len = min_size - ufield_len; memcpy(padded_data, dfield_get_data(&ufield ->new_val), - dfield_get_len(&ufield - ->new_val)); + ufield_len); - switch (UNIV_EXPECT(col->mbminlen,1)) { - default: - ut_error; - return(ULINT_UNDEFINED); - case 1: - if (UNIV_UNLIKELY - (dtype_get_charset_coll( - col->prtype) - == DATA_MYSQL_BINARY_CHARSET_COLL)) { - /* Do not pad BINARY - columns. */ - return(ULINT_UNDEFINED); - } + mbminlen = dict_col_get_mbminlen(col); + + ut_ad(!(ufield_len % mbminlen)); + ut_ad(!(min_size % mbminlen)); - /* space=0x20 */ - memset(pad_start, 0x20, - pad_end - pad_start); - break; - case 2: - /* space=0x0020 */ - ut_a(!(ufield_len % 2)); - ut_a(!(min_size % 2)); - do { - *pad_start++ = 0x00; - *pad_start++ = 0x20; - } while (pad_start < pad_end); - break; + if (mbminlen == 1 + && dtype_get_charset_coll( + col->prtype) + == DATA_MYSQL_BINARY_CHARSET_COLL) { + /* Do not pad BINARY columns */ + return(ULINT_UNDEFINED); } + row_mysql_pad_col(mbminlen, + pad, pad_len); dfield_set_data(&ufield->new_val, padded_data, min_size); } @@ -2223,7 +2219,7 @@ row_ins_index_entry_set_vals( = dict_field_get_col(ind_field); len = dtype_get_at_most_n_mbchars( - col->prtype, col->mbminlen, col->mbmaxlen, + col->prtype, col->mbminmaxlen, ind_field->prefix_len, len, dfield_get_data(row_field)); @@ -2270,7 +2266,7 @@ row_ins_alloc_row_id_step( /*======================*/ ins_node_t* node) /*!< in: row insert node */ { - dulint row_id; + row_id_t row_id; ut_ad(node->state == INS_NODE_ALLOC_ROW_ID); @@ -2457,7 +2453,7 @@ row_ins_step( /* It may be that the current session has not yet started its transaction, or it has been committed: */ - if (UT_DULINT_EQ(trx->id, node->trx_id)) { + if (trx->id == node->trx_id) { /* No need to do IX-locking */ goto same_trx; diff --git a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c index eac2f9fb377..38ec4bff08f 100644 --- a/storage/innobase/row/row0merge.c +++ b/storage/innobase/row/row0merge.c @@ -338,7 +338,7 @@ row_merge_buf_add( if (ifield->prefix_len) { len = dtype_get_at_most_n_mbchars( col->prtype, - col->mbminlen, col->mbmaxlen, + col->mbminmaxlen, ifield->prefix_len, len, dfield_get_data(field)); dfield_set_len(field, len); @@ -1779,6 +1779,11 @@ row_merge_copy_blobs( (below). */ data = btr_rec_copy_externally_stored_field( mrec, offsets, zip_size, i, &len, heap); + /* Because we have locked the table, any records + written by incomplete transactions must have been + rolled back already. There must not be any incomplete + BLOB columns. */ + ut_a(data); dfield_set_data(field, data, len); } @@ -2023,7 +2028,7 @@ row_merge_drop_index( ut_ad(index && table && trx); - pars_info_add_dulint_literal(info, "indexid", index->id); + pars_info_add_ull_literal(info, "indexid", index->id); trx_start_if_not_started(trx); trx->op_info = "dropping index"; @@ -2093,7 +2098,7 @@ row_merge_drop_temp_indexes(void) const rec_t* rec; const byte* field; ulint len; - dulint table_id; + table_id_t table_id; dict_table_t* table; btr_pcur_move_to_next_user_rec(&pcur, &mtr); @@ -2322,7 +2327,7 @@ row_merge_rename_indexes( trx->op_info = "renaming indexes"; - pars_info_add_dulint_literal(info, "tableid", table->id); + pars_info_add_ull_literal(info, "tableid", table->id); err = que_eval_sql(info, rename_indexes, FALSE, trx); @@ -2359,7 +2364,7 @@ row_merge_rename_tables( { ulint err = DB_ERROR; pars_info_t* info; - const char* old_name= old_table->name; + char old_name[MAX_TABLE_NAME_LEN + 1]; ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(old_table != new_table); @@ -2367,6 +2372,17 @@ row_merge_rename_tables( ut_a(trx->dict_operation_lock_mode == RW_X_LATCH); + /* store the old/current name to an automatic variable */ + if (strlen(old_table->name) + 1 <= sizeof(old_name)) { + memcpy(old_name, old_table->name, strlen(old_table->name) + 1); + } else { + ut_print_timestamp(stderr); + fprintf(stderr, "InnoDB: too long table name: '%s', " + "max length is %d\n", old_table->name, + MAX_TABLE_NAME_LEN); + ut_error; + } + trx->op_info = "renaming tables"; /* We use the private SQL parser of Innobase to generate the query @@ -2499,8 +2515,7 @@ row_merge_create_index( /* Note the id of the transaction that created this index, we use it to restrict readers from accessing this index, to ensure read consistency. */ - index->trx_id = (ib_uint64_t) - ut_conv_dulint_to_longlong(trx->id); + index->trx_id = trx->id; } else { index = NULL; } @@ -2517,10 +2532,8 @@ row_merge_is_index_usable( const trx_t* trx, /*!< in: transaction */ const dict_index_t* index) /*!< in: index to check */ { - return(!trx->read_view || read_view_sees_trx_id( - trx->read_view, - ut_dulint_create((ulint) (index->trx_id >> 32), - (ulint) index->trx_id & 0xFFFFFFFF))); + return(!trx->read_view + || read_view_sees_trx_id(trx->read_view, index->trx_id)); } /*********************************************************************//** diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 1f7f98a59a2..1262ac71e98 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -266,6 +266,49 @@ row_mysql_read_blob_ref( } /**************************************************************//** +Pad a column with spaces. */ +UNIV_INTERN +void +row_mysql_pad_col( +/*==============*/ + ulint mbminlen, /*!< in: minimum size of a character, + in bytes */ + byte* pad, /*!< out: padded buffer */ + ulint len) /*!< in: number of bytes to pad */ +{ + const byte* pad_end; + + switch (UNIV_EXPECT(mbminlen, 1)) { + default: + ut_error; + case 1: + /* space=0x20 */ + memset(pad, 0x20, len); + break; + case 2: + /* space=0x0020 */ + pad_end = pad + len; + ut_a(!(len % 2)); + do { + *pad++ = 0x00; + *pad++ = 0x20; + } while (pad < pad_end); + break; + case 4: + /* space=0x00000020 */ + pad_end = pad + len; + ut_a(!(len % 4)); + do { + *pad++ = 0x00; + *pad++ = 0x00; + *pad++ = 0x00; + *pad++ = 0x20; + } while (pad < pad_end); + break; + } +} + +/**************************************************************//** Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. The counterpart of this function is row_sel_field_store_in_mysql_format() in row0sel.c. @@ -357,12 +400,28 @@ row_mysql_store_col_in_innobase_format( /* Remove trailing spaces from old style VARCHAR columns. */ - /* Handle UCS2 strings differently. */ + /* Handle Unicode strings differently. */ ulint mbminlen = dtype_get_mbminlen(dtype); ptr = mysql_data; - if (mbminlen == 2) { + switch (mbminlen) { + default: + ut_error; + case 4: + /* space=0x00000020 */ + /* Trim "half-chars", just in case. */ + col_len &= ~3; + + while (col_len >= 4 + && ptr[col_len - 4] == 0x00 + && ptr[col_len - 3] == 0x00 + && ptr[col_len - 2] == 0x00 + && ptr[col_len - 1] == 0x20) { + col_len -= 4; + } + break; + case 2: /* space=0x0020 */ /* Trim "half-chars", just in case. */ col_len &= ~1; @@ -371,8 +430,8 @@ row_mysql_store_col_in_innobase_format( && ptr[col_len - 1] == 0x20) { col_len -= 2; } - } else { - ut_a(mbminlen == 1); + break; + case 1: /* space=0x20 */ while (col_len > 0 && ptr[col_len - 1] == 0x20) { @@ -1532,7 +1591,7 @@ row_unlock_for_mysql( } } - if (ut_dulint_cmp(rec_trx_id, trx->id) != 0) { + if (rec_trx_id != trx->id) { /* We did not update the record: unlock it */ rec = btr_pcur_get_rec(pcur); @@ -2283,7 +2342,7 @@ row_discard_tablespace_for_mysql( trx_t* trx) /*!< in: transaction handle */ { dict_foreign_t* foreign; - dulint new_id; + table_id_t new_id; dict_table_t* table; ibool success; ulint err; @@ -2405,7 +2464,7 @@ row_discard_tablespace_for_mysql( info = pars_info_create(); pars_info_add_str_literal(info, "table_name", name); - pars_info_add_dulint_literal(info, "new_id", new_id); + pars_info_add_ull_literal(info, "new_id", new_id); err = que_eval_sql(info, "PROCEDURE DISCARD_TABLESPACE_PROC () IS\n" @@ -2619,7 +2678,7 @@ row_truncate_table_for_mysql( dict_index_t* sys_index; btr_pcur_t pcur; mtr_t mtr; - dulint new_id; + table_id_t new_id; ulint recreate_space = 0; pars_info_t* info = NULL; @@ -2873,8 +2932,8 @@ next_rec: info = pars_info_create(); pars_info_add_int4_literal(info, "space", (lint) table->space); - pars_info_add_dulint_literal(info, "old_id", table->id); - pars_info_add_dulint_literal(info, "new_id", new_id); + pars_info_add_ull_literal(info, "old_id", table->id); + pars_info_add_ull_literal(info, "new_id", new_id); err = que_eval_sql(info, "PROCEDURE RENUMBER_TABLESPACE_PROC () IS\n" diff --git a/storage/innobase/row/row0purge.c b/storage/innobase/row/row0purge.c index da9d31f333f..fe7a3e0236e 100644 --- a/storage/innobase/row/row0purge.c +++ b/storage/innobase/row/row0purge.c @@ -44,6 +44,16 @@ Created 3/14/1997 Heikki Tuuri #include "row0mysql.h" #include "log0log.h" +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /********************************************************************//** Creates a purge node to a query graph. @return own: purge node */ @@ -126,6 +136,7 @@ row_purge_remove_clust_if_poss_low( pcur = &(node->pcur); btr_cur = btr_pcur_get_btr_cur(pcur); + log_free_check(); mtr_start(&mtr); success = row_purge_reposition_pcur(mode, node, &mtr); @@ -140,10 +151,9 @@ row_purge_remove_clust_if_poss_low( rec = btr_pcur_get_rec(pcur); - if (0 != ut_dulint_cmp(node->roll_ptr, row_get_rec_roll_ptr( - rec, index, rec_get_offsets( - rec, index, offsets_, - ULINT_UNDEFINED, &heap)))) { + if (node->roll_ptr != row_get_rec_roll_ptr( + rec, index, rec_get_offsets(rec, index, offsets_, + ULINT_UNDEFINED, &heap))) { if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -606,7 +616,7 @@ row_purge_parse_undo_rec( byte* ptr; trx_t* trx; undo_no_t undo_no; - dulint table_id; + table_id_t table_id; trx_id_t trx_id; roll_ptr_t roll_ptr; ulint info_bits; diff --git a/storage/innobase/row/row0row.c b/storage/innobase/row/row0row.c index 6cdfa410c15..050b8522fa3 100644 --- a/storage/innobase/row/row0row.c +++ b/storage/innobase/row/row0row.c @@ -156,7 +156,7 @@ row_build_index_entry( } len = dtype_get_at_most_n_mbchars( - col->prtype, col->mbminlen, col->mbmaxlen, + col->prtype, col->mbminmaxlen, ind_field->prefix_len, len, dfield_get_data(dfield)); dfield_set_len(dfield, len); } @@ -294,7 +294,13 @@ row_build( ut_ad(dtuple_check_typed(row)); - if (j) { + if (!ext) { + /* REDUNDANT and COMPACT formats store a local + 768-byte prefix of each externally stored + column. No cache is needed. */ + ut_ad(dict_table_get_format(index->table) + < DICT_TF_FORMAT_ZIP); + } else if (j) { *ext = row_ext_create(j, ext_cols, row, dict_table_zip_size(index->table), heap); @@ -514,8 +520,7 @@ row_build_row_ref( dfield_set_len(dfield, dtype_get_at_most_n_mbchars( dtype->prtype, - dtype->mbminlen, - dtype->mbmaxlen, + dtype->mbminmaxlen, clust_col_prefix_len, len, (char*) field)); } @@ -629,8 +634,7 @@ notfound: dfield_set_len(dfield, dtype_get_at_most_n_mbchars( dtype->prtype, - dtype->mbminlen, - dtype->mbmaxlen, + dtype->mbminmaxlen, clust_col_prefix_len, len, (char*) field)); } diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 2861235a995..39ab2179740 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -88,10 +88,8 @@ row_sel_sec_rec_is_for_blob( /*========================*/ ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ - ulint mbminlen, /*!< in: minimum length of a - multi-byte character */ - ulint mbmaxlen, /*!< in: maximum length of a - multi-byte character */ + ulint mbminmaxlen, /*!< in: minimum and maximum length of + a multi-byte character */ const byte* clust_field, /*!< in: the locally stored part of the clustered index column, including the BLOB pointer; the clustered @@ -119,7 +117,7 @@ row_sel_sec_rec_is_for_blob( return(FALSE); } - len = dtype_get_at_most_n_mbchars(prtype, mbminlen, mbmaxlen, + len = dtype_get_at_most_n_mbchars(prtype, mbminmaxlen, sec_len, len, (const char*) buf); return(!cmp_data_data(mtype, prtype, buf, len, sec_field, sec_len)); @@ -202,14 +200,14 @@ row_sel_sec_rec_is_for_clust_rec( } len = dtype_get_at_most_n_mbchars( - col->prtype, col->mbminlen, col->mbmaxlen, + col->prtype, col->mbminmaxlen, ifield->prefix_len, len, (char*) clust_field); if (rec_offs_nth_extern(clust_offs, clust_pos) && len < sec_len) { if (!row_sel_sec_rec_is_for_blob( col->mtype, col->prtype, - col->mbminlen, col->mbmaxlen, + col->mbminmaxlen, clust_field, clust_len, sec_field, sec_len, dict_table_zip_size( @@ -416,7 +414,7 @@ row_sel_fetch_columns( field_no))) { /* Copy an externally stored field to the - temporary heap */ + temporary heap, if possible. */ heap = mem_heap_create(1); @@ -425,6 +423,17 @@ row_sel_fetch_columns( dict_table_zip_size(index->table), field_no, &len, heap); + /* data == NULL means that the + externally stored field was not + written yet. This record + should only be seen by + recv_recovery_rollback_active() or any + TRX_ISO_READ_UNCOMMITTED + transactions. The InnoDB SQL parser + (the sole caller of this function) + does not implement READ UNCOMMITTED, + and it is not involved during rollback. */ + ut_a(data); ut_a(len != UNIV_SQL_NULL); needs_copy = TRUE; @@ -926,6 +935,7 @@ row_sel_get_clust_rec( when plan->clust_pcur was positioned. The latch will not be released until mtr_commit(mtr). */ + ut_ad(!rec_get_deleted_flag(clust_rec, rec_offs_comp(offsets))); row_sel_fetch_columns(index, clust_rec, offsets, UT_LIST_GET_FIRST(plan->columns)); *out_rec = clust_rec; @@ -1628,6 +1638,13 @@ skip_lock: } if (old_vers == NULL) { + /* The record does not exist + in our read view. Skip it, but + first attempt to determine + whether the index segment we + are searching through has been + exhausted. */ + offsets = rec_get_offsets( rec, index, offsets, ULINT_UNDEFINED, &heap); @@ -2508,13 +2525,13 @@ row_sel_field_store_in_mysql_format( ulint len) /*!< in: length of the data */ { byte* ptr; - byte* field_end; - byte* pad_ptr; ut_ad(len != UNIV_SQL_NULL); UNIV_MEM_ASSERT_RW(data, len); switch (templ->type) { + const byte* field_end; + byte* pad; case DATA_INT: /* Convert integer data from Innobase to a little-endian format, sign bit restored to normal */ @@ -2558,38 +2575,32 @@ row_sel_field_store_in_mysql_format( unused end of a >= 5.0.3 true VARCHAR column, just in case MySQL expects its contents to be deterministic. */ - pad_ptr = dest + len; + pad = dest + len; ut_ad(templ->mbminlen <= templ->mbmaxlen); - /* We handle UCS2 charset strings differently. */ - if (templ->mbminlen == 2) { - /* A space char is two bytes, 0x0020 in UCS2 */ + /* We treat some Unicode charset strings specially. */ + switch (templ->mbminlen) { + case 4: + /* InnoDB should never have stripped partial + UTF-32 characters. */ + ut_a(!(len & 3)); + break; + case 2: + /* A space char is two bytes, + 0x0020 in UCS2 and UTF-16 */ - if (len & 1) { + if (UNIV_UNLIKELY(len & 1)) { /* A 0x20 has been stripped from the column. Pad it back. */ - if (pad_ptr < field_end) { - *pad_ptr = 0x20; - pad_ptr++; + if (pad < field_end) { + *pad++ = 0x20; } } - - /* Pad the rest of the string with 0x0020 */ - - while (pad_ptr < field_end) { - *pad_ptr = 0x00; - pad_ptr++; - *pad_ptr = 0x20; - pad_ptr++; - } - } else { - ut_ad(templ->mbminlen == 1); - /* space=0x20 */ - - memset(pad_ptr, 0x20, field_end - pad_ptr); } + + row_mysql_pad_col(templ->mbminlen, pad, field_end - pad); break; case DATA_BLOB: @@ -2614,9 +2625,9 @@ row_sel_field_store_in_mysql_format( || !(templ->mysql_col_len % templ->mbmaxlen)); ut_ad(len * templ->mbmaxlen >= templ->mysql_col_len); - if (templ->mbminlen != templ->mbmaxlen) { + if (templ->mbminlen == 1 && templ->mbmaxlen != 1) { /* Pad with spaces. This undoes the stripping - done in row0mysql.ic, function + done in row0mysql.c, function row_mysql_store_col_in_innobase_format(). */ memset(dest + len, 0x20, templ->mysql_col_len - len); @@ -2647,9 +2658,8 @@ Convert a row in the Innobase format to a row in the MySQL format. Note that the template in prebuilt may advise us to copy only a few columns to mysql_rec, other columns are left blank. All columns may not be needed in the query. -@return TRUE if success, FALSE if could not allocate memory for a BLOB -(though we may also assert in that case) */ -static +@return TRUE on success, FALSE if not all columns could be retrieved */ +static __attribute__((warn_unused_result)) ibool row_sel_store_mysql_rec( /*====================*/ @@ -2672,6 +2682,7 @@ row_sel_store_mysql_rec( ut_ad(prebuilt->mysql_template); ut_ad(prebuilt->default_rec); ut_ad(rec_offs_validate(rec, NULL, offsets)); + ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { mem_heap_free(prebuilt->blob_heap); @@ -2719,6 +2730,21 @@ row_sel_store_mysql_rec( dict_table_zip_size(prebuilt->table), templ->rec_field_no, &len, heap); + if (UNIV_UNLIKELY(!data)) { + /* The externally stored field + was not written yet. This + record should only be seen by + recv_recovery_rollback_active() + or any TRX_ISO_READ_UNCOMMITTED + transactions. */ + + if (extern_field_heap) { + mem_heap_free(extern_field_heap); + } + + return(FALSE); + } + ut_a(len != UNIV_SQL_NULL); } else { /* Field is stored in the row. */ @@ -3136,9 +3162,10 @@ row_sel_pop_cached_row_for_mysql( } /********************************************************************//** -Pushes a row for MySQL to the fetch cache. */ -UNIV_INLINE -void +Pushes a row for MySQL to the fetch cache. +@return TRUE on success, FALSE if the record contains incomplete BLOBs */ +UNIV_INLINE __attribute__((warn_unused_result)) +ibool row_sel_push_cache_row_for_mysql( /*=============================*/ row_prebuilt_t* prebuilt, /*!< in: prebuilt struct */ @@ -3180,10 +3207,11 @@ row_sel_push_cache_row_for_mysql( prebuilt->fetch_cache[ prebuilt->n_fetch_cached], prebuilt, rec, offsets))) { - ut_error; + return(FALSE); } prebuilt->n_fetch_cached++; + return(TRUE); } /*********************************************************************//** @@ -3578,11 +3606,21 @@ row_search_for_mysql( if (!row_sel_store_mysql_rec(buf, prebuilt, rec, offsets)) { - err = DB_TOO_BIG_RECORD; - - /* We let the main loop to do the - error handling */ - goto shortcut_fails_too_big_rec; + /* Only fresh inserts may contain + incomplete externally stored + columns. Pretend that such + records do not exist. Such + records may only be accessed + at the READ UNCOMMITTED + isolation level or when + rolling back a recovered + transaction. Rollback happens + at a lower level, not here. */ + ut_a(trx->isolation_level + == TRX_ISO_READ_UNCOMMITTED); + + /* Proceed as in case SEL_RETRY. */ + break; } mtr_commit(&mtr); @@ -3622,7 +3660,7 @@ release_search_latch_if_needed: default: ut_ad(0); } -shortcut_fails_too_big_rec: + mtr_commit(&mtr); mtr_start(&mtr); } @@ -4357,9 +4395,18 @@ requires_clust_rec: not cache rows because there the cursor is a scrollable cursor. */ - row_sel_push_cache_row_for_mysql(prebuilt, result_rec, - offsets); - if (prebuilt->n_fetch_cached == MYSQL_FETCH_CACHE_SIZE) { + if (!row_sel_push_cache_row_for_mysql(prebuilt, result_rec, + offsets)) { + /* Only fresh inserts may contain incomplete + externally stored columns. Pretend that such + records do not exist. Such records may only be + accessed at the READ UNCOMMITTED isolation + level or when rolling back a recovered + transaction. Rollback happens at a lower + level, not here. */ + ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED); + } else if (prebuilt->n_fetch_cached + == MYSQL_FETCH_CACHE_SIZE) { goto got_row; } @@ -4375,9 +4422,17 @@ requires_clust_rec: } else { if (!row_sel_store_mysql_rec(buf, prebuilt, result_rec, offsets)) { - err = DB_TOO_BIG_RECORD; - - goto lock_wait_or_error; + /* Only fresh inserts may contain + incomplete externally stored + columns. Pretend that such records do + not exist. Such records may only be + accessed at the READ UNCOMMITTED + isolation level or when rolling back a + recovered transaction. Rollback + happens at a lower level, not here. */ + ut_a(trx->isolation_level + == TRX_ISO_READ_UNCOMMITTED); + goto next_rec; } } @@ -4622,8 +4677,7 @@ row_search_check_if_query_cache_permitted( IX type locks actually would require ret = FALSE. */ if (UT_LIST_GET_LEN(table->locks) == 0 - && ut_dulint_cmp(trx->id, - table->query_cache_inv_trx_id) >= 0) { + && trx->id >= table->query_cache_inv_trx_id) { ret = TRUE; diff --git a/storage/innobase/row/row0uins.c b/storage/innobase/row/row0uins.c index c35f1ef7a44..d25afed3840 100644 --- a/storage/innobase/row/row0uins.c +++ b/storage/innobase/row/row0uins.c @@ -46,6 +46,16 @@ Created 2/25/1997 Heikki Tuuri #include "ibuf0ibuf.h" #include "log0log.h" +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /***************************************************************//** Removes a clustered index record. The pcur in node was positioned on the record, now it is detached. @@ -68,7 +78,7 @@ row_undo_ins_remove_clust_rec( &mtr); ut_a(success); - if (ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) { + if (node->table->id == DICT_INDEXES_ID) { ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH); /* Drop the index tree associated with the row in @@ -151,7 +161,6 @@ row_undo_ins_remove_sec_low( mtr_t mtr; enum row_search_result search_result; - log_free_check(); mtr_start(&mtr); btr_cur = btr_pcur_get_btr_cur(&pcur); @@ -251,7 +260,7 @@ row_undo_ins_parse_undo_rec( dict_index_t* clust_index; byte* ptr; undo_no_t undo_no; - dulint table_id; + table_id_t table_id; ulint type; ulint dummy; ibool dummy_extern; @@ -337,6 +346,7 @@ row_undo_ins( transactions. */ ut_a(trx_is_recv(node->trx)); } else { + log_free_check(); err = row_undo_ins_remove_sec(node->index, entry); if (err != DB_SUCCESS) { @@ -348,5 +358,6 @@ row_undo_ins( node->index = dict_table_get_next_index(node->index); } + log_free_check(); return(row_undo_ins_remove_clust_rec(node)); } diff --git a/storage/innobase/row/row0umod.c b/storage/innobase/row/row0umod.c index 75de18a0b7d..aebff0764c8 100644 --- a/storage/innobase/row/row0umod.c +++ b/storage/innobase/row/row0umod.c @@ -58,12 +58,22 @@ delete marked clustered index record was delete unmarked and possibly also some of its fields were changed. Now, it is possible that the delete marked version has become obsolete at the time the undo is started. */ +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /***********************************************************//** Checks if also the previous version of the clustered index record was modified or inserted by the same transaction, and its undo number is such that it should be undone in the same rollback. @return TRUE if also previous modify or insert of this row should be undone */ -UNIV_INLINE +static ibool row_undo_mod_undo_also_prev_vers( /*=============================*/ @@ -75,9 +85,9 @@ row_undo_mod_undo_also_prev_vers( trx = node->trx; - if (0 != ut_dulint_cmp(node->new_trx_id, trx->id)) { + if (node->new_trx_id != trx->id) { - *undo_no = ut_dulint_zero; + *undo_no = 0; return(FALSE); } @@ -85,7 +95,7 @@ row_undo_mod_undo_also_prev_vers( *undo_no = trx_undo_rec_get_undo_no(undo_rec); - return(ut_dulint_cmp(trx->roll_limit, *undo_no) <= 0); + return(trx->roll_limit <= *undo_no); } /***********************************************************//** @@ -231,6 +241,8 @@ row_undo_mod_clust( ut_ad(node && thr); + log_free_check(); + /* Check if also the previous version of the clustered index record should be undone in this same rollback operation */ @@ -778,7 +790,7 @@ row_undo_mod_parse_undo_rec( dict_index_t* clust_index; byte* ptr; undo_no_t undo_no; - dulint table_id; + table_id_t table_id; trx_id_t trx_id; roll_ptr_t roll_ptr; ulint info_bits; diff --git a/storage/innobase/row/row0undo.c b/storage/innobase/row/row0undo.c index 3d739c9689a..09970b7fe21 100644 --- a/storage/innobase/row/row0undo.c +++ b/storage/innobase/row/row0undo.c @@ -185,9 +185,8 @@ row_undo_search_clust_to_pcur( offsets = rec_get_offsets(rec, clust_index, offsets, ULINT_UNDEFINED, &heap); - if (!found || 0 != ut_dulint_cmp(node->roll_ptr, - row_get_rec_roll_ptr(rec, clust_index, - offsets))) { + if (!found || node->roll_ptr + != row_get_rec_roll_ptr(rec, clust_index, offsets)) { /* We must remove the reservation on the undo log record BEFORE releasing the latch on the clustered index page: this @@ -199,8 +198,24 @@ row_undo_search_clust_to_pcur( ret = FALSE; } else { + row_ext_t** ext; + + if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) { + /* In DYNAMIC or COMPRESSED format, there is + no prefix of externally stored columns in the + clustered index record. Build a cache of + column prefixes. */ + ext = &node->ext; + } else { + /* REDUNDANT and COMPACT formats store a local + 768-byte prefix of each externally stored + column. No cache is needed. */ + ext = NULL; + node->ext = NULL; + } + node->row = row_build(ROW_COPY_DATA, clust_index, rec, - offsets, NULL, &node->ext, node->heap); + offsets, NULL, ext, node->heap); if (node->update) { node->undo_row = dtuple_copy(node->row, node->heap); row_upd_replace(node->undo_row, &node->undo_ext, @@ -297,7 +312,7 @@ row_undo( if (locked_data_dict) { - row_mysql_lock_data_dictionary(trx); + row_mysql_freeze_data_dictionary(trx); } if (node->state == UNDO_NODE_INSERT) { @@ -312,7 +327,7 @@ row_undo( if (locked_data_dict) { - row_mysql_unlock_data_dictionary(trx); + row_mysql_unfreeze_data_dictionary(trx); } /* Do some cleanup */ diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c index f1a90a3bf1c..588ee352ba0 100644 --- a/storage/innobase/row/row0upd.c +++ b/storage/innobase/row/row0upd.c @@ -92,6 +92,16 @@ the x-latch freed? The most efficient way for performing a searched delete is obviously to keep the x-latch for several steps of query graph execution. */ +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /***********************************************************//** Checks if an update vector changes some of the first ordering fields of an index record. This is only used in foreign key checks and we can assume @@ -367,7 +377,7 @@ row_upd_index_entry_sys_field( them */ dict_index_t* index, /*!< in: clustered index */ ulint type, /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */ - dulint val) /*!< in: value to write */ + ib_uint64_t val) /*!< in: value to write */ { dfield_t* dfield; byte* field; @@ -526,7 +536,7 @@ row_upd_write_sys_vals_to_log( trx_write_roll_ptr(log_ptr, roll_ptr); log_ptr += DATA_ROLL_PTR_LEN; - log_ptr += mach_dulint_write_compressed(log_ptr, trx->id); + log_ptr += mach_ull_write_compressed(log_ptr, trx->id); return(log_ptr); } @@ -560,7 +570,7 @@ row_upd_parse_sys_vals( *roll_ptr = trx_read_roll_ptr(ptr); ptr += DATA_ROLL_PTR_LEN; - ptr = mach_dulint_parse_compressed(ptr, end_ptr, trx_id); + ptr = mach_ull_parse_compressed(ptr, end_ptr, trx_id); return(ptr); } @@ -939,7 +949,7 @@ row_upd_index_replace_new_col_val( } len = dtype_get_at_most_n_mbchars(col->prtype, - col->mbminlen, col->mbmaxlen, + col->mbminmaxlen, field->prefix_len, len, (const char*) data); @@ -1388,6 +1398,7 @@ row_upd_store_row( dict_index_t* clust_index; rec_t* rec; mem_heap_t* heap = NULL; + row_ext_t** ext; ulint offsets_[REC_OFFS_NORMAL_SIZE]; const ulint* offsets; rec_offs_init(offsets_); @@ -1404,8 +1415,22 @@ row_upd_store_row( offsets = rec_get_offsets(rec, clust_index, offsets_, ULINT_UNDEFINED, &heap); + + if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) { + /* In DYNAMIC or COMPRESSED format, there is no prefix + of externally stored columns in the clustered index + record. Build a cache of column prefixes. */ + ext = &node->ext; + } else { + /* REDUNDANT and COMPACT formats store a local + 768-byte prefix of each externally stored column. + No cache is needed. */ + ext = NULL; + node->ext = NULL; + } + node->row = row_build(ROW_COPY_DATA, clust_index, rec, offsets, - NULL, &node->ext, node->heap); + NULL, ext, node->heap); if (node->is_delete) { node->upd_row = NULL; node->upd_ext = NULL; @@ -1454,7 +1479,6 @@ row_upd_sec_index_entry( entry = row_build_index_entry(node->row, node->ext, index, heap); ut_a(entry); - log_free_check(); mtr_start(&mtr); /* Set the query thread, so that ibuf_insert_low() will be @@ -1557,7 +1581,7 @@ Updates the secondary index record if it is changed in the row update or deletes it if this is a delete. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -UNIV_INLINE +static ulint row_upd_sec_step( /*=============*/ @@ -1903,8 +1927,7 @@ row_upd_clust_step( then we have to free the file segments of the index tree associated with the index */ - if (node->is_delete - && ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) { + if (node->is_delete && node->table->id == DICT_INDEXES_ID) { dict_drop_index_tree(btr_pcur_get_rec(pcur), mtr); @@ -2049,6 +2072,7 @@ row_upd( if (node->state == UPD_NODE_UPDATE_CLUSTERED || node->state == UPD_NODE_INSERT_CLUSTERED) { + log_free_check(); err = row_upd_clust_step(node, thr); if (err != DB_SUCCESS) { @@ -2063,6 +2087,8 @@ row_upd( } while (node->index != NULL) { + + log_free_check(); err = row_upd_sec_step(node, thr); if (err != DB_SUCCESS) { diff --git a/storage/innobase/row/row0vers.c b/storage/innobase/row/row0vers.c index a4fbb5289aa..3e6fc3f18b6 100644 --- a/storage/innobase/row/row0vers.c +++ b/storage/innobase/row/row0vers.c @@ -209,7 +209,7 @@ row_vers_impl_x_locked_off_kernel( prev_trx_id must have already committed for the trx_id to be able to modify the row. Therefore, prev_trx_id cannot hold any implicit lock. */ - if (vers_del && 0 != ut_dulint_cmp(trx_id, prev_trx_id)) { + if (vers_del && trx_id != prev_trx_id) { mutex_enter(&kernel_mutex); break; @@ -280,7 +280,7 @@ row_vers_impl_x_locked_off_kernel( break; } - if (0 != ut_dulint_cmp(trx_id, prev_trx_id)) { + if (trx_id != prev_trx_id) { /* The versions modified by the trx_id transaction end to prev_version: no implicit x-lock */ @@ -533,7 +533,7 @@ row_vers_build_for_consistent_read( undo_no of the record is < undo_no in the view. */ if (view->type == VIEW_HIGH_GRANULARITY - && ut_dulint_cmp(view->creator_trx_id, trx_id) == 0) { + && view->creator_trx_id == trx_id) { roll_ptr = row_get_rec_roll_ptr(version, index, *offsets); @@ -541,7 +541,7 @@ row_vers_build_for_consistent_read( undo_no = trx_undo_rec_get_undo_no(undo_rec); mem_heap_empty(heap); - if (ut_dulint_cmp(view->undo_no, undo_no) > 0) { + if (view->undo_no > undo_no) { /* The view already sees this version: we can copy it to in_heap and return */ @@ -632,7 +632,7 @@ row_vers_build_for_semi_consistent_read( mem_heap_t* heap = NULL; byte* buf; ulint err; - trx_id_t rec_trx_id = ut_dulint_zero; + trx_id_t rec_trx_id = 0; ut_ad(dict_index_is_clust(index)); ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX) @@ -684,7 +684,7 @@ row_vers_build_for_semi_consistent_read( rolled back and the transaction is removed from the global list of transactions. */ - if (!ut_dulint_cmp(rec_trx_id, version_trx_id)) { + if (rec_trx_id == version_trx_id) { /* The transaction was committed while we searched for earlier versions. Return the current version as a diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 6354689105a..97d699dde99 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -142,6 +142,21 @@ use simulated aio we build below with threads. Currently we support native aio on windows and linux */ UNIV_INTERN my_bool srv_use_native_aio = TRUE; +#ifdef __WIN__ +/* Windows native condition variables. We use runtime loading / function +pointers, because they are not available on Windows Server 2003 and +Windows XP/2000. + +We use condition for events on Windows if possible, even if os_event +resembles Windows kernel event object well API-wise. The reason is +performance, kernel objects are heavyweights and WaitForSingleObject() is a +performance killer causing calling thread to context switch. Besides, Innodb +is preallocating large number (often millions) of os_events. With kernel event +objects it takes a big chunk out of non-paged pool, which is better suited +for tasks like IO than for storing idle event objects. */ +UNIV_INTERN ibool srv_use_native_conditions = FALSE; +#endif /* __WIN__ */ + UNIV_INTERN ulint srv_n_data_files = 0; UNIV_INTERN char** srv_data_file_names = NULL; /* size in database pages */ @@ -3007,6 +3022,8 @@ srv_purge_thread( slot_no = srv_table_reserve_slot(SRV_WORKER); + slot = srv_table_get_nth_slot(slot_no); + ++srv_n_threads_active[SRV_WORKER]; mutex_exit(&kernel_mutex); @@ -3058,20 +3075,16 @@ srv_purge_thread( mutex_enter(&kernel_mutex); + ut_ad(srv_table_get_nth_slot(slot_no) == slot); + /* Decrement the active count. */ srv_suspend_thread(); - mutex_exit(&kernel_mutex); + slot->in_use = FALSE; /* Free the thread local memory. */ thr_local_free(os_thread_get_curr_id()); - mutex_enter(&kernel_mutex); - - /* Free the slot for reuse. */ - slot = srv_table_get_nth_slot(slot_no); - slot->in_use = FALSE; - mutex_exit(&kernel_mutex); #ifdef UNIV_DEBUG_THREAD_CREATION diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 686ee6a4198..4da836672ec 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -1160,9 +1160,17 @@ innobase_start_or_create_for_mysql(void) srv_use_native_aio = FALSE; break; + + case OS_WIN2000: + case OS_WINXP: + /* On 2000 and XP, async IO is available. */ + srv_use_native_aio = TRUE; + break; + default: - /* On Win 2000 and XP use async i/o */ + /* Vista and later have both async IO and condition variables */ srv_use_native_aio = TRUE; + srv_use_native_conditions = TRUE; break; } @@ -1695,20 +1703,6 @@ innobase_start_or_create_for_mysql(void) /* fprintf(stderr, "Max allowed record size %lu\n", page_get_free_space_of_empty() / 2); */ - /* Create the thread which watches the timeouts for lock waits */ - os_thread_create(&srv_lock_timeout_thread, NULL, - thread_ids + 2 + SRV_MAX_N_IO_THREADS); - - /* Create the thread which warns of long semaphore waits */ - os_thread_create(&srv_error_monitor_thread, NULL, - thread_ids + 3 + SRV_MAX_N_IO_THREADS); - - /* Create the thread which prints InnoDB monitor info */ - os_thread_create(&srv_monitor_thread, NULL, - thread_ids + 4 + SRV_MAX_N_IO_THREADS); - - srv_is_being_started = FALSE; - if (trx_doublewrite == NULL) { /* Create the doublewrite buffer to a new tablespace */ @@ -1721,8 +1715,29 @@ innobase_start_or_create_for_mysql(void) We create the new segments only if it's a new database or the database was shutdown cleanly. */ + /* Note: When creating the extra rollback segments during an upgrade + we violate the latching order, even if the change buffer is empty. + We make an exception in sync0sync.c and check srv_is_being_started + for that violation. It cannot create a deadlock because we are still + running in single threaded mode essentially. Only the IO threads + should be running at this stage. */ + trx_sys_create_rsegs(TRX_SYS_N_RSEGS - 1); + /* Create the thread which watches the timeouts for lock waits */ + os_thread_create(&srv_lock_timeout_thread, NULL, + thread_ids + 2 + SRV_MAX_N_IO_THREADS); + + /* Create the thread which warns of long semaphore waits */ + os_thread_create(&srv_error_monitor_thread, NULL, + thread_ids + 3 + SRV_MAX_N_IO_THREADS); + + /* Create the thread which prints InnoDB monitor info */ + os_thread_create(&srv_monitor_thread, NULL, + thread_ids + 4 + SRV_MAX_N_IO_THREADS); + + srv_is_being_started = FALSE; + err = dict_create_or_check_foreign_constraint_tables(); if (err != DB_SUCCESS) { diff --git a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c index 248bd2cd25d..753ebd958ac 100644 --- a/storage/innobase/sync/sync0arr.c +++ b/storage/innobase/sync/sync0arr.c @@ -250,7 +250,7 @@ sync_array_create( /* Then create the mutex to protect the wait array complex */ if (protection == SYNC_ARRAY_OS_MUTEX) { - arr->os_mutex = os_mutex_create(NULL); + arr->os_mutex = os_mutex_create(); } else if (protection == SYNC_ARRAY_MUTEX) { mutex_create(syn_arr_mutex_key, &arr->mutex, SYNC_NO_ORDER_CHECK); diff --git a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c index 235f733382d..8062d9e902e 100644 --- a/storage/innobase/sync/sync0sync.c +++ b/storage/innobase/sync/sync0sync.c @@ -40,6 +40,9 @@ Created 9/5/1995 Heikki Tuuri #include "srv0srv.h" #include "buf0types.h" #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */ +#ifdef UNIV_SYNC_DEBUG +# include "srv0start.h" /* srv_is_being_started */ +#endif /* UNIV_SYNC_DEBUG */ /* REASONS FOR IMPLEMENTING THE SPIN LOCK MUTEX @@ -1152,6 +1155,13 @@ sync_thread_add_level( case SYNC_TREE_NODE_FROM_HASH: /* Do no order checking */ break; + case SYNC_TRX_SYS_HEADER: + if (srv_is_being_started) { + /* This is violated during trx_sys_create_rsegs() + when creating additional rollback segments when + upgrading in innobase_start_or_create_for_mysql(). */ + break; + } case SYNC_MEM_POOL: case SYNC_MEM_HASH: case SYNC_RECV: @@ -1160,7 +1170,6 @@ sync_thread_add_level( case SYNC_LOG_FLUSH_ORDER: case SYNC_THR_LOCAL: case SYNC_ANY_LATCH: - case SYNC_TRX_SYS_HEADER: case SYNC_FILE_FORMAT_TAG: case SYNC_DOUBLEWRITE: case SYNC_SEARCH_SYS: @@ -1222,8 +1231,12 @@ sync_thread_add_level( ut_a(sync_thread_levels_g(array, SYNC_IBUF_BITMAP - 1, TRUE)); } else { - ut_a(sync_thread_levels_g(array, SYNC_IBUF_BITMAP, - TRUE)); + /* This is violated during trx_sys_create_rsegs() + when creating additional rollback segments when + upgrading in innobase_start_or_create_for_mysql(). */ + ut_a(srv_is_being_started + || sync_thread_levels_g(array, SYNC_IBUF_BITMAP, + TRUE)); } break; case SYNC_FSP_PAGE: @@ -1492,14 +1505,16 @@ sync_print_wait_info( fprintf(file, "Mutex spin waits %llu, rounds %llu, OS waits %llu\n" - "RW-shared spins %llu, OS waits %llu;" - " RW-excl spins %llu, OS waits %llu\n", + "RW-shared spins %llu, rounds %llu, OS waits %llu\n" + "RW-excl spins %llu, rounds %llu, OS waits %llu\n", mutex_spin_wait_count, mutex_spin_round_count, mutex_os_wait_count, rw_s_spin_wait_count, + rw_s_spin_round_count, rw_s_os_wait_count, rw_x_spin_wait_count, + rw_x_spin_round_count, rw_x_os_wait_count); fprintf(file, diff --git a/storage/innobase/trx/trx0i_s.c b/storage/innobase/trx/trx0i_s.c index 8b719646023..1ad074769c7 100644 --- a/storage/innobase/trx/trx0i_s.c +++ b/storage/innobase/trx/trx0i_s.c @@ -444,7 +444,7 @@ fill_trx_row( ut_ad(mutex_own(&kernel_mutex)); - row->trx_id = trx_get_id(trx); + row->trx_id = trx->id; row->trx_started = (ib_time_t) trx->start_time; row->trx_state = trx_get_que_state_str(trx); @@ -462,7 +462,7 @@ fill_trx_row( row->trx_wait_started = 0; } - row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx)); + row->trx_weight = (ullint) TRX_WEIGHT(trx); if (trx->mysql_thd == NULL) { /* For internal transactions e.g., purge and transactions @@ -527,7 +527,7 @@ thd_done: row->trx_rows_locked = lock_number_of_rows_locked(trx); - row->trx_rows_modified = ut_conv_dulint_to_longlong(trx->undo_no); + row->trx_rows_modified = trx->undo_no; row->trx_concurrency_tickets = trx->n_tickets_to_enter_innodb; diff --git a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c index 550a8c9c4b3..e17ed547050 100644 --- a/storage/innobase/trx/trx0purge.c +++ b/storage/innobase/trx/trx0purge.c @@ -145,47 +145,44 @@ void trx_purge_arr_get_biggest( /*======================*/ trx_undo_arr_t* arr, /*!< in: purge array */ - trx_id_t* trx_no, /*!< out: transaction number: ut_dulint_zero + trx_id_t* trx_no, /*!< out: transaction number: 0 if array is empty */ undo_no_t* undo_no)/*!< out: undo number */ { trx_undo_inf_t* cell; trx_id_t pair_trx_no; undo_no_t pair_undo_no; - int trx_cmp; - ulint n_used; ulint i; ulint n; - n = 0; - n_used = arr->n_used; - pair_trx_no = ut_dulint_zero; - pair_undo_no = ut_dulint_zero; + n = arr->n_used; + pair_trx_no = 0; + pair_undo_no = 0; - for (i = 0;; i++) { - cell = trx_undo_arr_get_nth_info(arr, i); + if (n) { + for (i = 0;; i++) { + cell = trx_undo_arr_get_nth_info(arr, i); - if (cell->in_use) { - n++; - trx_cmp = ut_dulint_cmp(cell->trx_no, pair_trx_no); + if (!cell->in_use) { + continue; + } - if ((trx_cmp > 0) - || ((trx_cmp == 0) - && (ut_dulint_cmp(cell->undo_no, - pair_undo_no) >= 0))) { + if ((cell->trx_no > pair_trx_no) + || ((cell->trx_no == pair_trx_no) + && cell->undo_no >= pair_undo_no)) { pair_trx_no = cell->trx_no; pair_undo_no = cell->undo_no; } - } - - if (n == n_used) { - *trx_no = pair_trx_no; - *undo_no = pair_undo_no; - return; + if (!--n) { + break; + } } } + + *trx_no = pair_trx_no; + *undo_no = pair_undo_no; } /****************************************************************//** @@ -233,8 +230,8 @@ trx_purge_sys_create(void) purge_sys->n_pages_handled = 0; - purge_sys->purge_trx_no = ut_dulint_zero; - purge_sys->purge_undo_no = ut_dulint_zero; + purge_sys->purge_trx_no = 0; + purge_sys->purge_undo_no = 0; purge_sys->next_stored = FALSE; rw_lock_create(trx_purge_latch_key, @@ -257,7 +254,7 @@ trx_purge_sys_create(void) purge_sys->query = trx_purge_graph_build(); - purge_sys->view = read_view_oldest_copy_or_open_new(ut_dulint_zero, + purge_sys->view = read_view_oldest_copy_or_open_new(0, purge_sys->heap); } @@ -370,7 +367,7 @@ trx_purge_add_update_undo_to_history( } /* Write the trx number to the undo log header */ - mlog_write_dulint(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr); + mlog_write_ull(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr); /* Write information about delete markings to the undo log header */ if (!undo->del_marks) { @@ -512,9 +509,9 @@ trx_purge_truncate_rseg_history( page_t* undo_page; trx_ulogf_t* log_hdr; trx_usegf_t* seg_hdr; - int cmp; ulint n_removed_logs = 0; mtr_t mtr; + trx_id_t undo_trx_no; ut_ad(mutex_own(&(purge_sys->mutex))); @@ -540,15 +537,16 @@ loop: hdr_addr.page, &mtr); log_hdr = undo_page + hdr_addr.boffset; + undo_trx_no = mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO); - cmp = ut_dulint_cmp(mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO), - limit_trx_no); - if (cmp == 0) { - trx_undo_truncate_start(rseg, rseg->space, hdr_addr.page, - hdr_addr.boffset, limit_undo_no); - } + if (undo_trx_no >= limit_trx_no) { + if (undo_trx_no == limit_trx_no) { + trx_undo_truncate_start(rseg, rseg->space, + hdr_addr.page, + hdr_addr.boffset, + limit_undo_no); + } - if (cmp >= 0) { mutex_enter(&kernel_mutex); ut_a(trx_sys->rseg_history_len >= n_removed_logs); trx_sys->rseg_history_len -= n_removed_logs; @@ -614,7 +612,7 @@ trx_purge_truncate_history(void) trx_purge_arr_get_biggest(purge_sys->arr, &limit_trx_no, &limit_undo_no); - if (ut_dulint_is_zero(limit_trx_no)) { + if (limit_trx_no == 0) { limit_trx_no = purge_sys->purge_trx_no; limit_undo_no = purge_sys->purge_undo_no; @@ -623,13 +621,12 @@ trx_purge_truncate_history(void) /* We play safe and set the truncate limit at most to the purge view low_limit number, though this is not necessary */ - if (ut_dulint_cmp(limit_trx_no, purge_sys->view->low_limit_no) >= 0) { + if (limit_trx_no >= purge_sys->view->low_limit_no) { limit_trx_no = purge_sys->view->low_limit_no; - limit_undo_no = ut_dulint_zero; + limit_undo_no = 0; } - ut_ad((ut_dulint_cmp(limit_trx_no, - purge_sys->view->low_limit_no) <= 0)); + ut_ad(limit_trx_no <= purge_sys->view->low_limit_no); rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list); @@ -684,8 +681,8 @@ trx_purge_rseg_get_next_history_log( ut_a(rseg->last_page_no != FIL_NULL); - purge_sys->purge_trx_no = ut_dulint_add(rseg->last_trx_no, 1); - purge_sys->purge_undo_no = ut_dulint_zero; + purge_sys->purge_trx_no = rseg->last_trx_no + 1; + purge_sys->purge_undo_no = 0; purge_sys->next_stored = FALSE; mtr_start(&mtr); @@ -787,7 +784,7 @@ trx_purge_choose_next_log(void) rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list); - min_trx_no = ut_dulint_max; + min_trx_no = IB_ULONGLONG_MAX; min_rseg = NULL; @@ -796,9 +793,8 @@ trx_purge_choose_next_log(void) if (rseg->last_page_no != FIL_NULL) { - if ((min_rseg == NULL) - || (ut_dulint_cmp(min_trx_no, - rseg->last_trx_no) > 0)) { + if (min_rseg == NULL + || min_trx_no > rseg->last_trx_no) { min_rseg = rseg; min_trx_no = rseg->last_trx_no; @@ -848,7 +844,7 @@ trx_purge_choose_next_log(void) if (rec == &trx_purge_dummy_rec) { - purge_sys->purge_undo_no = ut_dulint_zero; + purge_sys->purge_undo_no = 0; purge_sys->page_no = page_no; purge_sys->offset = 0; } else { @@ -1041,8 +1037,7 @@ trx_purge_fetch_next_rec( return(NULL); } - if (ut_dulint_cmp(purge_sys->purge_trx_no, - purge_sys->view->low_limit_no) >= 0) { + if (purge_sys->purge_trx_no >= purge_sys->view->low_limit_no) { purge_sys->state = TRX_STOP_PURGE; trx_purge_truncate_if_arr_empty(); @@ -1052,10 +1047,10 @@ trx_purge_fetch_next_rec( return(NULL); } - /* fprintf(stderr, "Thread %lu purging trx %lu undo record %lu\n", + /* fprintf(stderr, "Thread %lu purging trx %llu undo record %llu\n", os_thread_get_curr_id(), - ut_dulint_get_low(purge_sys->purge_trx_no), - ut_dulint_get_low(purge_sys->purge_undo_no)); */ + (ullint) purge_sys->purge_trx_no, + (ullint) purge_sys->purge_undo_no); */ *roll_ptr = trx_undo_build_roll_ptr(FALSE, (purge_sys->rseg)->id, purge_sys->page_no, @@ -1064,8 +1059,7 @@ trx_purge_fetch_next_rec( *cell = trx_purge_arr_store_info(purge_sys->purge_trx_no, purge_sys->purge_undo_no); - ut_ad(ut_dulint_cmp(purge_sys->purge_trx_no, - (purge_sys->view)->low_limit_no) < 0); + ut_ad(purge_sys->purge_trx_no < purge_sys->view->low_limit_no); /* The following call will advance the stored values of purge_trx_no and purge_undo_no, therefore we had to store them first */ @@ -1157,7 +1151,7 @@ trx_purge( } } - purge_sys->view = read_view_oldest_copy_or_open_new(ut_dulint_zero, + purge_sys->view = read_view_oldest_copy_or_open_new(0, purge_sys->heap); mutex_exit(&kernel_mutex); @@ -1215,8 +1209,8 @@ trx_purge_sys_print(void) fprintf(stderr, "InnoDB: Purge trx n:o " TRX_ID_FMT ", undo n:o " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF(purge_sys->purge_trx_no), - TRX_ID_PREP_PRINTF(purge_sys->purge_undo_no)); + (ullint) purge_sys->purge_trx_no, + (ullint) purge_sys->purge_undo_no); fprintf(stderr, "InnoDB: Purge next stored %lu, page_no %lu, offset %lu,\n" "InnoDB: Purge hdr_page_no %lu, hdr_offset %lu\n", diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c index f50e10ed756..e7e9a008db4 100644 --- a/storage/innobase/trx/trx0rec.c +++ b/storage/innobase/trx/trx0rec.c @@ -242,8 +242,8 @@ trx_undo_page_report_insert( /* Store first some general parameters to the undo log */ *ptr++ = TRX_UNDO_INSERT_REC; - ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no); - ptr += mach_dulint_write_much_compressed(ptr, index->table->id); + ptr += mach_ull_write_much_compressed(ptr, trx->undo_no); + ptr += mach_ull_write_much_compressed(ptr, index->table->id); /*----------------------------------------*/ /* Store then the fields required to uniquely determine the record to be inserted in the clustered index */ @@ -289,7 +289,7 @@ trx_undo_rec_get_pars( ibool* updated_extern, /*!< out: TRUE if we updated an externally stored fild */ undo_no_t* undo_no, /*!< out: undo log record number */ - dulint* table_id) /*!< out: table id */ + table_id_t* table_id) /*!< out: table id */ { byte* ptr; ulint type_cmpl; @@ -309,11 +309,11 @@ trx_undo_rec_get_pars( *type = type_cmpl & (TRX_UNDO_CMPL_INFO_MULT - 1); *cmpl_info = type_cmpl / TRX_UNDO_CMPL_INFO_MULT; - *undo_no = mach_dulint_read_much_compressed(ptr); - ptr += mach_dulint_get_much_compressed_size(*undo_no); + *undo_no = mach_ull_read_much_compressed(ptr); + ptr += mach_ull_get_much_compressed_size(*undo_no); - *table_id = mach_dulint_read_much_compressed(ptr); - ptr += mach_dulint_get_much_compressed_size(*table_id); + *table_id = mach_ull_read_much_compressed(ptr); + ptr += mach_ull_get_much_compressed_size(*table_id); return(ptr); } @@ -598,9 +598,9 @@ trx_undo_page_report_modify( type_cmpl_ptr = ptr; *ptr++ = (byte) type_cmpl; - ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no); + ptr += mach_ull_write_much_compressed(ptr, trx->undo_no); - ptr += mach_dulint_write_much_compressed(ptr, table->id); + ptr += mach_ull_write_much_compressed(ptr, table->id); /*----------------------------------------*/ /* Store the state of the info bits */ @@ -620,16 +620,16 @@ trx_undo_page_report_modify( by some other trx as it must have committed by now for us to allow an over-write. */ if (ignore_prefix) { - ignore_prefix = ut_dulint_cmp(trx_id, trx->id) != 0; + ignore_prefix = (trx_id != trx->id); } - ptr += mach_dulint_write_compressed(ptr, trx_id); + ptr += mach_ull_write_compressed(ptr, trx_id); field = rec_get_nth_field(rec, offsets, dict_index_get_sys_col_pos( index, DATA_ROLL_PTR), &flen); ut_ad(flen == DATA_ROLL_PTR_LEN); - ptr += mach_dulint_write_compressed(ptr, trx_read_roll_ptr(field)); + ptr += mach_ull_write_compressed(ptr, trx_read_roll_ptr(field)); /*----------------------------------------*/ /* Store then the fields required to uniquely determine the @@ -848,11 +848,11 @@ trx_undo_update_rec_get_sys_cols( /* Read the values of the system columns */ - *trx_id = mach_dulint_read_compressed(ptr); - ptr += mach_dulint_get_compressed_size(*trx_id); + *trx_id = mach_ull_read_compressed(ptr); + ptr += mach_ull_get_compressed_size(*trx_id); - *roll_ptr = mach_dulint_read_compressed(ptr); - ptr += mach_dulint_get_compressed_size(*roll_ptr); + *roll_ptr = mach_ull_read_compressed(ptr); + ptr += mach_ull_get_compressed_size(*roll_ptr); return(ptr); } @@ -1168,7 +1168,7 @@ trx_undo_report_row_operation( index, otherwise NULL */ roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the inserted undo log record, - ut_dulint_zero if BTR_NO_UNDO_LOG + 0 if BTR_NO_UNDO_LOG flag was specified */ { trx_t* trx; @@ -1186,7 +1186,7 @@ trx_undo_report_row_operation( if (flags & BTR_NO_UNDO_LOG_FLAG) { - *roll_ptr = ut_dulint_zero; + *roll_ptr = 0; return(DB_SUCCESS); } @@ -1284,7 +1284,7 @@ trx_undo_report_row_operation( undo->top_undo_no = trx->undo_no; undo->guess_block = undo_block; - UT_DULINT_INC(trx->undo_no); + trx->undo_no++; mutex_exit(&trx->undo_mutex); @@ -1433,7 +1433,7 @@ trx_undo_prev_version_build( trx_id_t rec_trx_id; ulint type; undo_no_t undo_no; - dulint table_id; + table_id_t table_id; trx_id_t trx_id; roll_ptr_t roll_ptr; roll_ptr_t old_roll_ptr; @@ -1523,7 +1523,7 @@ trx_undo_prev_version_build( roll_ptr, info_bits, NULL, heap, &update); - if (ut_dulint_cmp(table_id, index->table->id) != 0) { + if (UNIV_UNLIKELY(table_id != index->table->id)) { ptr = NULL; fprintf(stderr, @@ -1544,16 +1544,14 @@ trx_undo_prev_version_build( fprintf(stderr, "InnoDB: table %s, index %s, n_uniq %lu\n" "InnoDB: undo rec address %p, type %lu cmpl_info %lu\n" - "InnoDB: undo rec table id %lu %lu," - " index table id %lu %lu\n" + "InnoDB: undo rec table id %llu," + " index table id %llu\n" "InnoDB: dump of 150 bytes in undo rec: ", index->table_name, index->name, (ulong) dict_index_get_n_unique(index), undo_rec, (ulong) type, (ulong) cmpl_info, - (ulong) ut_dulint_get_high(table_id), - (ulong) ut_dulint_get_low(table_id), - (ulong) ut_dulint_get_high(index->table->id), - (ulong) ut_dulint_get_low(index->table->id)); + (ullint) table_id, + (ullint) index->table->id); ut_print_buf(stderr, undo_rec, 150); fputs("\n" "InnoDB: index record ", stderr); @@ -1564,14 +1562,10 @@ trx_undo_prev_version_build( fprintf(stderr, "\n" "InnoDB: Record trx id " TRX_ID_FMT ", update rec trx id " TRX_ID_FMT "\n" - "InnoDB: Roll ptr in rec %lu %lu, in update rec" - " %lu %lu\n", - TRX_ID_PREP_PRINTF(rec_trx_id), - TRX_ID_PREP_PRINTF(trx_id), - (ulong) ut_dulint_get_high(old_roll_ptr), - (ulong) ut_dulint_get_low(old_roll_ptr), - (ulong) ut_dulint_get_high(roll_ptr), - (ulong) ut_dulint_get_low(roll_ptr)); + "InnoDB: Roll ptr in rec " TRX_ID_FMT + ", in update rec" TRX_ID_FMT "\n", + (ullint) rec_trx_id, (ullint) trx_id, + (ullint) old_roll_ptr, (ullint) roll_ptr); trx_purge_sys_print(); return(DB_ERROR); diff --git a/storage/innobase/trx/trx0roll.c b/storage/innobase/trx/trx0roll.c index 4f1a71a5531..42b8a8685ad 100644 --- a/storage/innobase/trx/trx0roll.c +++ b/storage/innobase/trx/trx0roll.c @@ -52,7 +52,7 @@ static trx_t* trx_roll_crash_recv_trx = NULL; /** In crash recovery we set this to the undo n:o of the current trx to be rolled back. Then we can print how many % the rollback has progressed. */ -static ib_int64_t trx_roll_max_undo_no; +static undo_no_t trx_roll_max_undo_no; /** Auxiliary variable which tells the previous progress % we printed */ static ulint trx_roll_progress_printed_pct; @@ -443,7 +443,7 @@ trx_rollback_active( ut_a(thr == que_fork_start_command(fork)); trx_roll_crash_recv_trx = trx; - trx_roll_max_undo_no = ut_conv_dulint_to_longlong(trx->undo_no); + trx_roll_max_undo_no = trx->undo_no; trx_roll_progress_printed_pct = 0; rows_to_undo = trx_roll_max_undo_no; @@ -456,7 +456,7 @@ trx_rollback_active( fprintf(stderr, " InnoDB: Rolling back trx with id " TRX_ID_FMT ", %lu%s" " rows to undo\n", - TRX_ID_PREP_PRINTF(trx->id), + (ullint) trx->id, (ulong) rows_to_undo, unit); mutex_exit(&kernel_mutex); @@ -478,8 +478,9 @@ trx_rollback_active( mutex_exit(&kernel_mutex); fprintf(stderr, - "InnoDB: Waiting for rollback of trx id %lu to end\n", - (ulong) ut_dulint_get_low(trx->id)); + "InnoDB: Waiting for rollback of trx id " + TRX_ID_FMT " to end\n", + (ullint) trx->id); os_thread_sleep(100000); mutex_enter(&kernel_mutex); @@ -488,16 +489,15 @@ trx_rollback_active( mutex_exit(&kernel_mutex); if (trx_get_dict_operation(trx) != TRX_DICT_OP_NONE - && !ut_dulint_is_zero(trx->table_id)) { + && trx->table_id != 0) { /* If the transaction was for a dictionary operation, we drop the relevant table, if it still exists */ fprintf(stderr, - "InnoDB: Dropping table with id %lu %lu" + "InnoDB: Dropping table with id %llu" " in recovery if it exists\n", - (ulong) ut_dulint_get_high(trx->table_id), - (ulong) ut_dulint_get_low(trx->table_id)); + (ullint) trx->table_id); table = dict_table_get_on_id_low(trx->table_id); @@ -521,7 +521,7 @@ trx_rollback_active( fprintf(stderr, "\nInnoDB: Rolling back of trx id " TRX_ID_FMT " completed\n", - TRX_ID_PREP_PRINTF(trx->id)); + (ullint) trx->id); mem_heap_free(heap); trx_roll_crash_recv_trx = NULL; @@ -574,7 +574,7 @@ loop: fprintf(stderr, "InnoDB: Cleaning up trx with id " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF(trx->id)); + (ullint) trx->id); trx_cleanup_at_db_startup(trx); goto loop; @@ -710,7 +710,7 @@ trx_undo_arr_store_info( } else { n++; - if (0 == ut_dulint_cmp(cell->undo_no, undo_no)) { + if (cell->undo_no == undo_no) { if (stored_here) { stored_here->in_use = FALSE; @@ -754,7 +754,7 @@ trx_undo_arr_remove_info( cell = trx_undo_arr_get_nth_info(arr, i); if (cell->in_use - && 0 == ut_dulint_cmp(cell->undo_no, undo_no)) { + && cell->undo_no == undo_no) { cell->in_use = FALSE; @@ -769,7 +769,7 @@ trx_undo_arr_remove_info( /*******************************************************************//** Gets the biggest undo number in an array. -@return biggest value, ut_dulint_zero if the array is empty */ +@return biggest value, 0 if the array is empty */ static undo_no_t trx_undo_arr_get_biggest( @@ -784,14 +784,14 @@ trx_undo_arr_get_biggest( n = 0; n_used = arr->n_used; - biggest = ut_dulint_zero; + biggest = 0; for (i = 0;; i++) { cell = trx_undo_arr_get_nth_info(arr, i); if (cell->in_use) { n++; - if (ut_dulint_cmp(cell->undo_no, biggest) > 0) { + if (cell->undo_no > biggest) { biggest = cell->undo_no; } @@ -827,9 +827,9 @@ trx_roll_try_truncate( if (arr->n_used > 0) { biggest = trx_undo_arr_get_biggest(arr); - if (ut_dulint_cmp(biggest, limit) >= 0) { + if (biggest >= limit) { - limit = ut_dulint_add(biggest, 1); + limit = biggest + 1; } } @@ -865,9 +865,9 @@ trx_roll_pop_top_rec( undo->top_page_no, mtr); offset = undo->top_offset; - /* fprintf(stderr, "Thread %lu undoing trx %lu undo record %lu\n", - os_thread_get_curr_id(), ut_dulint_get_low(trx->id), - ut_dulint_get_low(undo->top_undo_no)); */ + /* fprintf(stderr, "Thread %lu undoing trx " TRX_ID_FMT + " undo record " TRX_ID_FMT "\n", + os_thread_get_curr_id(), trx->id, undo->top_undo_no); */ prev_rec = trx_undo_get_prev_rec(undo_page + offset, undo->hdr_page_no, undo->hdr_offset, @@ -938,15 +938,14 @@ try_again: undo = upd_undo; } else if (!upd_undo || upd_undo->empty) { undo = ins_undo; - } else if (ut_dulint_cmp(upd_undo->top_undo_no, - ins_undo->top_undo_no) > 0) { + } else if (upd_undo->top_undo_no > ins_undo->top_undo_no) { undo = upd_undo; } else { undo = ins_undo; } if (!undo || undo->empty - || (ut_dulint_cmp(limit, undo->top_undo_no) > 0)) { + || limit > undo->top_undo_no) { if ((trx->undo_no_arr)->n_used == 0) { /* Rollback is ending */ @@ -978,7 +977,7 @@ try_again: undo_no = trx_undo_rec_get_undo_no(undo_rec); - ut_ad(ut_dulint_cmp(ut_dulint_add(undo_no, 1), trx->undo_no) == 0); + ut_ad(undo_no + 1 == trx->undo_no); /* We print rollback progress info if we are in a crash recovery and the transaction has at least 1000 row operations to undo. */ @@ -986,8 +985,7 @@ try_again: if (trx == trx_roll_crash_recv_trx && trx_roll_max_undo_no > 1000) { progress_pct = 100 - (ulint) - ((ut_conv_dulint_to_longlong(undo_no) * 100) - / trx_roll_max_undo_no); + ((undo_no * 100) / trx_roll_max_undo_no); if (progress_pct != trx_roll_progress_printed_pct) { if (trx_roll_progress_printed_pct == 0) { fprintf(stderr, @@ -1090,22 +1088,21 @@ trx_rollback( /* Initialize the rollback field in the transaction */ - if (sig->type == TRX_SIG_TOTAL_ROLLBACK) { - - trx->roll_limit = ut_dulint_zero; - - } else if (sig->type == TRX_SIG_ROLLBACK_TO_SAVEPT) { - + switch (sig->type) { + case TRX_SIG_TOTAL_ROLLBACK: + trx->roll_limit = 0; + break; + case TRX_SIG_ROLLBACK_TO_SAVEPT: trx->roll_limit = (sig->savept).least_undo_no; - - } else if (sig->type == TRX_SIG_ERROR_OCCURRED) { - + break; + case TRX_SIG_ERROR_OCCURRED: trx->roll_limit = trx->last_sql_stat_start.least_undo_no; - } else { + break; + default: ut_error; } - ut_a(ut_dulint_cmp(trx->roll_limit, trx->undo_no) <= 0); + ut_a(trx->roll_limit <= trx->undo_no); trx->pages_undone = 0; @@ -1269,8 +1266,8 @@ trx_finish_rollback_off_kernel( #ifdef UNIV_DEBUG if (lock_print_waits) { - fprintf(stderr, "Trx %lu rollback finished\n", - (ulong) ut_dulint_get_low(trx->id)); + fprintf(stderr, "Trx " TRX_ID_FMT " rollback finished\n", + (ullint) trx->id); } #endif /* UNIV_DEBUG */ diff --git a/storage/innobase/trx/trx0rseg.c b/storage/innobase/trx/trx0rseg.c index b458364b05d..740320f68c1 100644 --- a/storage/innobase/trx/trx0rseg.c +++ b/storage/innobase/trx/trx0rseg.c @@ -236,8 +236,8 @@ trx_rseg_mem_create( node_addr.page, mtr) + node_addr.boffset; - rseg->last_trx_no = mtr_read_dulint( - undo_log_hdr + TRX_UNDO_TRX_NO, mtr); + rseg->last_trx_no = mach_read_from_8( + undo_log_hdr + TRX_UNDO_TRX_NO); rseg->last_del_marks = mtr_read_ulint( undo_log_hdr + TRX_UNDO_DEL_MARKS, MLOG_2BYTES, mtr); } else { diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c index e2f0ff6d532..640412c4572 100644 --- a/storage/innobase/trx/trx0sys.c +++ b/storage/innobase/trx/trx0sys.c @@ -664,8 +664,8 @@ trx_sys_flush_max_trx_id(void) sys_header = trx_sysf_get(&mtr); - mlog_write_dulint(sys_header + TRX_SYS_TRX_ID_STORE, - trx_sys->max_trx_id, &mtr); + mlog_write_ull(sys_header + TRX_SYS_TRX_ID_STORE, + trx_sys->max_trx_id, &mtr); mtr_commit(&mtr); } @@ -912,8 +912,7 @@ trx_sysf_create( sys_header = trx_sysf_get(mtr); /* Start counting transaction ids from number 1 up */ - mach_write_to_8(sys_header + TRX_SYS_TRX_ID_STORE, - ut_dulint_create(0, 1)); + mach_write_to_8(sys_header + TRX_SYS_TRX_ID_STORE, 1); /* Reset the rollback segment slots. Old versions of InnoDB define TRX_SYS_N_RSEGS as 256 (TRX_SYS_OLD_N_RSEGS) and expect @@ -950,7 +949,7 @@ trx_sys_init_at_db_start(void) /*==========================*/ { trx_sysf_t* sys_header; - ib_int64_t rows_to_undo = 0; + ib_uint64_t rows_to_undo = 0; const char* unit = ""; trx_t* trx; mtr_t mtr; @@ -976,12 +975,10 @@ trx_sys_init_at_db_start(void) to the disk-based header! Thus trx id values will not overlap when the database is repeatedly started! */ - trx_sys->max_trx_id = ut_dulint_add( - ut_dulint_align_up(mtr_read_dulint( - sys_header - + TRX_SYS_TRX_ID_STORE, &mtr), - TRX_SYS_TRX_ID_WRITE_MARGIN), - 2 * TRX_SYS_TRX_ID_WRITE_MARGIN); + trx_sys->max_trx_id = 2 * TRX_SYS_TRX_ID_WRITE_MARGIN + + ut_uint64_align_up(mach_read_from_8(sys_header + + TRX_SYS_TRX_ID_STORE), + TRX_SYS_TRX_ID_WRITE_MARGIN); UT_LIST_INIT(trx_sys->mysql_trx_list); trx_dummy_sess = sess_open(); @@ -992,9 +989,8 @@ trx_sys_init_at_db_start(void) for (;;) { - if ( trx->conc_state != TRX_PREPARED) { - rows_to_undo += ut_conv_dulint_to_longlong( - trx->undo_no); + if (trx->conc_state != TRX_PREPARED) { + rows_to_undo += trx->undo_no; } trx = UT_LIST_GET_NEXT(trx_list, trx); @@ -1017,7 +1013,7 @@ trx_sys_init_at_db_start(void) (ulong) rows_to_undo, unit); fprintf(stderr, "InnoDB: Trx id counter is " TRX_ID_FMT "\n", - TRX_ID_PREP_PRINTF(trx_sys->max_trx_id)); + (ullint) trx_sys->max_trx_id); } UT_LIST_INIT(trx_sys->view_list); @@ -1061,7 +1057,7 @@ trx_sys_file_format_max_write( mtr_t mtr; byte* ptr; buf_block_t* block; - ulint tag_value_low; + ib_uint64_t tag_value; mtr_start(&mtr); @@ -1072,17 +1068,13 @@ trx_sys_file_format_max_write( file_format_max.name = trx_sys_file_format_id_to_name(format_id); ptr = buf_block_get_frame(block) + TRX_SYS_FILE_FORMAT_TAG; - tag_value_low = format_id + TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW; + tag_value = format_id + TRX_SYS_FILE_FORMAT_TAG_MAGIC_N; if (name) { *name = file_format_max.name; } - mlog_write_dulint( - ptr, - ut_dulint_create(TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH, - tag_value_low), - &mtr); + mlog_write_ull(ptr, tag_value, &mtr); mtr_commit(&mtr); @@ -1100,8 +1092,7 @@ trx_sys_file_format_max_read(void) mtr_t mtr; const byte* ptr; const buf_block_t* block; - ulint format_id; - dulint file_format_id; + ib_id_t file_format_id; /* Since this is called during the startup phase it's safe to read the value without a covering mutex. */ @@ -1115,16 +1106,15 @@ trx_sys_file_format_max_read(void) mtr_commit(&mtr); - format_id = file_format_id.low - TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW; + file_format_id -= TRX_SYS_FILE_FORMAT_TAG_MAGIC_N; - if (file_format_id.high != TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH - || format_id >= FILE_FORMAT_NAME_N) { + if (file_format_id >= FILE_FORMAT_NAME_N) { /* Either it has never been tagged, or garbage in it. */ return(ULINT_UNDEFINED); } - return(format_id); + return((ulint) file_format_id); } /*****************************************************************//** @@ -1416,7 +1406,7 @@ trx_sys_read_file_format_id( byte buf[UNIV_PAGE_SIZE * 2]; page_t* page = ut_align(buf, UNIV_PAGE_SIZE); const byte* ptr; - dulint file_format_id; + ib_id_t file_format_id; *format_id = ULINT_UNDEFINED; @@ -1430,9 +1420,9 @@ trx_sys_read_file_format_id( if (!success) { /* The following call prints an error message */ os_file_get_last_error(TRUE); - + ut_print_timestamp(stderr); - + fprintf(stderr, " ibbackup: Error: trying to read system tablespace file format,\n" " ibbackup: but could not open the tablespace file %s!\n", @@ -1449,9 +1439,9 @@ trx_sys_read_file_format_id( if (!success) { /* The following call prints an error message */ os_file_get_last_error(TRUE); - + ut_print_timestamp(stderr); - + fprintf(stderr, " ibbackup: Error: trying to read system table space file format,\n" " ibbackup: but failed to read the tablespace file %s!\n", @@ -1465,17 +1455,16 @@ trx_sys_read_file_format_id( /* get the file format from the page */ ptr = page + TRX_SYS_FILE_FORMAT_TAG; file_format_id = mach_read_from_8(ptr); + file_format_id -= TRX_SYS_FILE_FORMAT_TAG_MAGIC_N; - *format_id = file_format_id.low - TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW; - - if (file_format_id.high != TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH - || *format_id >= FILE_FORMAT_NAME_N) { + if (file_format_id >= FILE_FORMAT_NAME_N) { /* Either it has never been tagged, or garbage in it. */ - *format_id = ULINT_UNDEFINED; return(TRUE); } - + + *format_id = (ulint) file_format_id; + return(TRUE); } diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c index c794671f7be..19e3eb26421 100644 --- a/storage/innobase/trx/trx0trx.c +++ b/storage/innobase/trx/trx0trx.c @@ -109,8 +109,8 @@ trx_create( trx->isolation_level = TRX_ISO_REPEATABLE_READ; - trx->id = ut_dulint_zero; - trx->no = ut_dulint_max; + trx->id = 0; + trx->no = IB_ULONGLONG_MAX; trx->support_xa = TRUE; @@ -121,7 +121,7 @@ trx_create( trx->must_flush_log_later = FALSE; trx->dict_operation = TRX_DICT_OP_NONE; - trx->table_id = ut_dulint_zero; + trx->table_id = 0; trx->mysql_thd = NULL; trx->active_trans = 0; @@ -137,8 +137,8 @@ trx_create( trx->rseg = NULL; - trx->undo_no = ut_dulint_zero; - trx->last_sql_stat_start.least_undo_no = ut_dulint_zero; + trx->undo_no = 0; + trx->last_sql_stat_start.least_undo_no = 0; trx->insert_undo = NULL; trx->update_undo = NULL; trx->undo_no_arr = NULL; @@ -392,9 +392,9 @@ trx_list_insert_ordered( trx2 = UT_LIST_GET_FIRST(trx_sys->trx_list); while (trx2 != NULL) { - if (ut_dulint_cmp(trx->id, trx2->id) >= 0) { + if (trx->id >= trx2->id) { - ut_ad(ut_dulint_cmp(trx->id, trx2->id) == 1); + ut_ad(trx->id > trx2->id); break; } trx2 = UT_LIST_GET_NEXT(trx_list, trx2); @@ -463,7 +463,7 @@ trx_lists_init_at_db_start(void) TRX_ID_FMT " was in the" " XA prepared state.\n", - TRX_ID_PREP_PRINTF(trx->id)); + (ullint) trx->id); if (srv_force_recovery == 0) { @@ -495,9 +495,9 @@ trx_lists_init_at_db_start(void) trx->conc_state = TRX_ACTIVE; /* A running transaction always has the number - field inited to ut_dulint_max */ + field inited to IB_ULONGLONG_MAX */ - trx->no = ut_dulint_max; + trx->no = IB_ULONGLONG_MAX; } if (undo->dict_operation) { @@ -507,8 +507,7 @@ trx_lists_init_at_db_start(void) } if (!undo->empty) { - trx->undo_no = ut_dulint_add(undo->top_undo_no, - 1); + trx->undo_no = undo->top_undo_no + 1; } trx_list_insert_ordered(trx); @@ -539,8 +538,7 @@ trx_lists_init_at_db_start(void) "InnoDB: Transaction " TRX_ID_FMT " was in the" " XA prepared state.\n", - TRX_ID_PREP_PRINTF( - trx->id)); + (ullint) trx->id); if (srv_force_recovery == 0) { @@ -571,9 +569,9 @@ trx_lists_init_at_db_start(void) /* A running transaction always has the number field inited to - ut_dulint_max */ + IB_ULONGLONG_MAX */ - trx->no = ut_dulint_max; + trx->no = IB_ULONGLONG_MAX; } trx->rseg = rseg; @@ -589,11 +587,9 @@ trx_lists_init_at_db_start(void) trx->update_undo = undo; if ((!undo->empty) - && (ut_dulint_cmp(undo->top_undo_no, - trx->undo_no) >= 0)) { + && undo->top_undo_no >= trx->undo_no) { - trx->undo_no = ut_dulint_add(undo->top_undo_no, - 1); + trx->undo_no = undo->top_undo_no + 1; } undo = UT_LIST_GET_NEXT(undo_list, undo); @@ -655,7 +651,7 @@ trx_start_low( ut_ad(trx->rseg == NULL); if (trx->is_purge) { - trx->id = ut_dulint_zero; + trx->id = 0; trx->conc_state = TRX_ACTIVE; trx->start_time = time(NULL); @@ -673,10 +669,10 @@ trx_start_low( trx->id = trx_sys_get_new_trx_id(); - /* The initial value for trx->no: ut_dulint_max is used in + /* The initial value for trx->no: IB_ULONGLONG_MAX is used in read_view_open_now: */ - trx->no = ut_dulint_max; + trx->no = IB_ULONGLONG_MAX; trx->rseg = rseg; @@ -941,8 +937,8 @@ trx_commit_off_kernel( trx->conc_state = TRX_NOT_STARTED; trx->rseg = NULL; - trx->undo_no = ut_dulint_zero; - trx->last_sql_stat_start.least_undo_no = ut_dulint_zero; + trx->undo_no = 0; + trx->last_sql_stat_start.least_undo_no = 0; ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0); ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0); @@ -967,8 +963,8 @@ trx_cleanup_at_db_startup( trx->conc_state = TRX_NOT_STARTED; trx->rseg = NULL; - trx->undo_no = ut_dulint_zero; - trx->last_sql_stat_start.least_undo_no = ut_dulint_zero; + trx->undo_no = 0; + trx->last_sql_stat_start.least_undo_no = 0; UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx); } @@ -1631,7 +1627,7 @@ trx_mark_sql_stat_end( ut_a(trx); if (trx->conc_state == TRX_NOT_STARTED) { - trx->undo_no = ut_dulint_zero; + trx->undo_no = 0; } trx->last_sql_stat_start.least_undo_no = trx->undo_no; @@ -1651,7 +1647,7 @@ trx_print( { ibool newline; - fprintf(f, "TRANSACTION " TRX_ID_FMT, TRX_ID_PREP_PRINTF(trx->id)); + fprintf(f, "TRANSACTION " TRX_ID_FMT, (ullint) trx->id); switch (trx->conc_state) { case TRX_NOT_STARTED: @@ -1735,10 +1731,10 @@ trx_print( fputs(", holds adaptive hash latch", f); } - if (!ut_dulint_is_zero(trx->undo_no)) { + if (trx->undo_no != 0) { newline = TRUE; - fprintf(f, ", undo log entries %lu", - (ulong) ut_dulint_get_low(trx->undo_no)); + fprintf(f, ", undo log entries %llu", + (ullint) trx->undo_no); } if (newline) { @@ -1754,11 +1750,11 @@ trx_print( Compares the "weight" (or size) of two transactions. Transactions that have edited non-transactional tables are considered heavier than ones that have not. -@return <0, 0 or >0; similar to strcmp(3) */ +@return TRUE if weight(a) >= weight(b) */ UNIV_INTERN -int -trx_weight_cmp( -/*===========*/ +ibool +trx_weight_ge( +/*==========*/ const trx_t* a, /*!< in: the first transaction to be compared */ const trx_t* b) /*!< in: the second transaction to be compared */ { @@ -1769,19 +1765,14 @@ trx_weight_cmp( not edited non-transactional tables. */ a_notrans_edit = a->mysql_thd != NULL - && thd_has_edited_nontrans_tables(a->mysql_thd); + && thd_has_edited_nontrans_tables(a->mysql_thd); b_notrans_edit = b->mysql_thd != NULL - && thd_has_edited_nontrans_tables(b->mysql_thd); - - if (a_notrans_edit && !b_notrans_edit) { - - return(1); - } + && thd_has_edited_nontrans_tables(b->mysql_thd); - if (!a_notrans_edit && b_notrans_edit) { + if (a_notrans_edit != b_notrans_edit) { - return(-1); + return(a_notrans_edit); } /* Either both had edited non-transactional tables or both had @@ -1792,13 +1783,11 @@ trx_weight_cmp( fprintf(stderr, "%s TRX_WEIGHT(a): %lld+%lu, TRX_WEIGHT(b): %lld+%lu\n", __func__, - ut_conv_dulint_to_longlong(a->undo_no), - UT_LIST_GET_LEN(a->trx_locks), - ut_conv_dulint_to_longlong(b->undo_no), - UT_LIST_GET_LEN(b->trx_locks)); + a->undo_no, UT_LIST_GET_LEN(a->trx_locks), + b->undo_no, UT_LIST_GET_LEN(b->trx_locks)); #endif - return(ut_dulint_cmp(TRX_WEIGHT(a), TRX_WEIGHT(b))); + return(TRX_WEIGHT(a) >= TRX_WEIGHT(b)); } /****************************************************************//** @@ -1980,14 +1969,13 @@ trx_recover_for_mysql( fprintf(stderr, " InnoDB: Transaction " TRX_ID_FMT " in" " prepared state after recovery\n", - TRX_ID_PREP_PRINTF(trx->id)); + (ullint) trx->id); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Transaction contains changes" - " to %lu rows\n", - (ulong) ut_conv_dulint_to_longlong( - trx->undo_no)); + " to %llu rows\n", + (ullint) trx->undo_no); count++; @@ -2036,7 +2024,7 @@ trx_get_trx_by_xid( while (trx) { /* Compare two X/Open XA transaction id's: their length should be the same and binary comparison - of gtrid_lenght+bqual_length bytes should be + of gtrid_length+bqual_length bytes should be the same */ if (xid->gtrid_length == trx->xid.gtrid_length diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index eb5112c4d31..90fc98f419d 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -515,7 +515,7 @@ trx_undo_header_create_log( { mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_CREATE, mtr); - mlog_catenate_dulint_compressed(mtr, trx_id); + mlog_catenate_ull_compressed(mtr, trx_id); } #else /* !UNIV_HOTBACKUP */ # define trx_undo_header_create_log(undo_page,trx_id,mtr) ((void) 0) @@ -687,7 +687,7 @@ trx_undo_insert_header_reuse_log( { mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_REUSE, mtr); - mlog_catenate_dulint_compressed(mtr, trx_id); + mlog_catenate_ull_compressed(mtr, trx_id); } #else /* !UNIV_HOTBACKUP */ # define trx_undo_insert_header_reuse_log(undo_page,trx_id,mtr) ((void) 0) @@ -707,8 +707,14 @@ trx_undo_parse_page_header( mtr_t* mtr) /*!< in: mtr or NULL */ { trx_id_t trx_id; + /* Silence a GCC warning about possibly uninitialized variable + when mach_ull_parse_compressed() is not inlined. */ + ut_d(trx_id = 0); + /* Declare the variable uninitialized in Valgrind, so that the + above initialization will not mask any bugs. */ + UNIV_MEM_INVALID(&trx_id, sizeof trx_id); - ptr = mach_dulint_parse_compressed(ptr, end_ptr, &trx_id); + ptr = mach_ull_parse_compressed(ptr, end_ptr, &trx_id); if (ptr == NULL) { @@ -1098,8 +1104,7 @@ trx_undo_truncate_end( break; } - if (ut_dulint_cmp(trx_undo_rec_get_undo_no(rec), limit) - >= 0) { + if (trx_undo_rec_get_undo_no(rec) >= limit) { /* Truncate at least this record off, maybe more */ trunc_here = rec; @@ -1152,7 +1157,7 @@ trx_undo_truncate_start( ut_ad(mutex_own(&(rseg->mutex))); - if (ut_dulint_is_zero(limit)) { + if (!limit) { return; } @@ -1174,7 +1179,7 @@ loop: last_rec = trx_undo_page_get_last_rec(undo_page, hdr_page_no, hdr_offset); - if (ut_dulint_cmp(trx_undo_rec_get_undo_no(last_rec), limit) >= 0) { + if (trx_undo_rec_get_undo_no(last_rec) >= limit) { mtr_commit(&mtr); @@ -1296,7 +1301,7 @@ trx_undo_mem_create_at_db_start( undo_header = undo_page + offset; - trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr); + trx_id = mach_read_from_8(undo_header + TRX_UNDO_TRX_ID); xid_exists = mtr_read_ulint(undo_header + TRX_UNDO_XID_EXISTS, MLOG_1BYTE, mtr); @@ -1320,7 +1325,7 @@ trx_undo_mem_create_at_db_start( undo->dict_operation = mtr_read_ulint( undo_header + TRX_UNDO_DICT_TRANS, MLOG_1BYTE, mtr); - undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr); + undo->table_id = mach_read_from_8(undo_header + TRX_UNDO_TABLE_ID); undo->state = state; undo->size = flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr); @@ -1709,7 +1714,7 @@ trx_undo_mark_as_dict_operation( ut_error; case TRX_DICT_OP_INDEX: /* Do not discard the table on recovery. */ - undo->table_id = ut_dulint_zero; + undo->table_id = 0; break; case TRX_DICT_OP_TABLE: undo->table_id = trx->table_id; @@ -1720,8 +1725,8 @@ trx_undo_mark_as_dict_operation( + TRX_UNDO_DICT_TRANS, TRUE, MLOG_1BYTE, mtr); - mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID, - undo->table_id, mtr); + mlog_write_ull(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID, + undo->table_id, mtr); undo->dict_operation = TRUE; } diff --git a/storage/innobase/ut/ut0byte.c b/storage/innobase/ut/ut0byte.c index 4e093f72ce2..535f74b8907 100644 --- a/storage/innobase/ut/ut0byte.c +++ b/storage/innobase/ut/ut0byte.c @@ -28,28 +28,3 @@ Created 5/11/1994 Heikki Tuuri #ifdef UNIV_NONINL #include "ut0byte.ic" #endif - -/** Zero value for a dulint */ -UNIV_INTERN const dulint ut_dulint_zero = {0, 0}; - -/** Maximum value for a dulint */ -UNIV_INTERN const dulint ut_dulint_max = {0xFFFFFFFFUL, 0xFFFFFFFFUL}; - -#ifdef notdefined /* unused code */ -#include "ut0sort.h" - -/************************************************************//** -Sort function for dulint arrays. */ -UNIV_INTERN -void -ut_dulint_sort( -/*===========*/ - dulint* arr, /*!< in/out: array to be sorted */ - dulint* aux_arr,/*!< in/out: auxiliary array (same size as arr) */ - ulint low, /*!< in: low bound of sort interval, inclusive */ - ulint high) /*!< in: high bound of sort interval, noninclusive */ -{ - UT_SORT_FUNCTION_BODY(ut_dulint_sort, arr, aux_arr, low, high, - ut_dulint_cmp); -} -#endif /* notdefined */ diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 33c1e092a00..b54b4c6ce49 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -92,6 +92,8 @@ static double *nwghts=_nwghts+5; /* nwghts[i] = -0.5*1.5**i */ #define FTB_FLAG_NO 4 #define FTB_FLAG_WONLY 8 +#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) + typedef struct st_ftb_expr FTB_EXPR; struct st_ftb_expr { diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index 7d9b13b7714..937bb6ffe19 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -197,7 +197,8 @@ static int walk_and_push(FT_SUPERDOC *from, static int FT_DOC_cmp(void *unused __attribute__((unused)), FT_DOC *a, FT_DOC *b) { - return sgn(b->weight - a->weight); + double c= b->weight - a->weight; + return ((c < 0) ? -1 : (c > 0) ? 1 : 0); } diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index 8f5779b04ee..663d7869f71 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -39,7 +39,7 @@ static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat) { word->weight=LWS_IN_USE; docstat->sum+=word->weight; - memcpy_fixed((docstat->list)++,word,sizeof(FT_WORD)); + memcpy((docstat->list)++, word, sizeof(FT_WORD)); return 0; } diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c index d1548e32870..a2ddb49ecf0 100644 --- a/storage/myisam/ft_update.c +++ b/storage/myisam/ft_update.c @@ -83,8 +83,7 @@ uint _mi_ft_segiterator(register FT_SEG_ITERATOR *ftsi) if (ftsi->seg->flag & HA_BLOB_PART) { ftsi->len=_mi_calc_blob_length(ftsi->seg->bit_start,ftsi->pos); - memcpy_fixed((char*) &ftsi->pos, ftsi->pos+ftsi->seg->bit_start, - sizeof(char*)); + memcpy(&ftsi->pos, ftsi->pos+ftsi->seg->bit_start, sizeof(char*)); DBUG_RETURN(1); } ftsi->len=ftsi->seg->length; diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 13427130069..6bf01cd63c7 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -52,11 +52,6 @@ #endif #include "rt_index.h" -#ifndef USE_RAID -#define my_raid_create(K, A, B, C, D, E, F, G) mysql_file_create(K, A, B, C, G) -#define my_raid_delete(K, A, B, C) mysql_file_delete(K, A, B) -#endif - /* Functions defined in this file */ static int check_k_link(MI_CHECK *param, MI_INFO *info,uint nr); @@ -1577,15 +1572,12 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, if (!rep_quick) { /* Get real path for data file */ - if ((new_file= my_raid_create(mi_key_file_datatmp, - fn_format(param->temp_filename, - share->data_file_name, "", - DATA_TMP_EXT, 2+4), - 0, param->tmpfile_createflag, - share->base.raid_type, - share->base.raid_chunks, - share->base.raid_chunksize, - MYF(0))) < 0) + if ((new_file= mysql_file_create(mi_key_file_datatmp, + fn_format(param->temp_filename, + share->data_file_name, "", + DATA_TMP_EXT, 2+4), + 0, param->tmpfile_createflag, + MYF(0))) < 0) { mi_check_print_error(param,"Can't create new tempfile: '%s'", param->temp_filename); @@ -1751,8 +1743,7 @@ err: (size_t) info->s->mmaped_length); info->s->file_map= NULL; } - if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, - DATA_TMP_EXT, share->base.raid_chunks, + if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || mi_open_datafile(info,share,name,-1)) @@ -1767,9 +1758,8 @@ err: if (new_file >= 0) { (void) mysql_file_close(new_file, MYF(0)); - (void) my_raid_delete(mi_key_file_datatmp, - param->temp_filename, info->s->base.raid_chunks, - MYF(MY_WME)); + (void) mysql_file_delete(mi_key_file_datatmp, + param->temp_filename, MYF(MY_WME)); info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */ } mi_mark_crashed_on_repair(info); @@ -2011,7 +2001,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name) (void) mysql_file_close(share->kfile, MYF(MY_WME)); share->kfile = -1; (void) mysql_file_close(new_file, MYF(MY_WME)); - if (change_to_newfile(share->index_file_name,MI_NAME_IEXT,INDEX_TMP_EXT,0, + if (change_to_newfile(share->index_file_name, MI_NAME_IEXT, INDEX_TMP_EXT, MYF(0)) || mi_open_keyfile(share)) goto err2; @@ -2141,18 +2131,9 @@ err: */ int change_to_newfile(const char * filename, const char * old_ext, - const char * new_ext, - uint raid_chunks __attribute__((unused)), - myf MyFlags) + const char * new_ext, myf MyFlags) { char old_filename[FN_REFLEN],new_filename[FN_REFLEN]; -#ifdef USE_RAID - if (raid_chunks) - return my_raid_redel(fn_format(old_filename,filename,"",old_ext,2+4), - fn_format(new_filename,filename,"",new_ext,2+4), - raid_chunks, - MYF(MY_WME | MY_LINK_WARNING | MyFlags)); -#endif /* Get real path to filename */ (void) fn_format(old_filename,filename,"",old_ext,2+4+32); return my_redel(old_filename, @@ -2293,15 +2274,12 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, if (!rep_quick) { /* Get real path for data file */ - if ((new_file= my_raid_create(mi_key_file_datatmp, - fn_format(param->temp_filename, - share->data_file_name, "", - DATA_TMP_EXT, 2+4), - 0, param->tmpfile_createflag, - share->base.raid_type, - share->base.raid_chunks, - share->base.raid_chunksize, - MYF(0))) < 0) + if ((new_file= mysql_file_create(mi_key_file_datatmp, + fn_format(param->temp_filename, + share->data_file_name, "", + DATA_TMP_EXT, 2+4), + 0, param->tmpfile_createflag, + MYF(0))) < 0) { mi_check_print_error(param,"Can't create new tempfile: '%s'", param->temp_filename); @@ -2527,7 +2505,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, skr < share->base.reloc*share->base.min_pack_length) skr=share->base.reloc*share->base.min_pack_length; #endif - if (skr != sort_info.filelength && !info->s->base.raid_type) + if (skr != sort_info.filelength) if (mysql_file_chsize(info->dfile, skr, 0, MYF(0))) mi_check_print_warning(param, "Can't change size of datafile, error: %d", @@ -2565,8 +2543,7 @@ err: { mysql_file_close(new_file, MYF(0)); info->dfile=new_file= -1; - if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, - DATA_TMP_EXT, share->base.raid_chunks, + if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, DATA_TMP_EXT, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || mi_open_datafile(info,share,name,-1)) @@ -2580,9 +2557,8 @@ err: if (new_file >= 0) { (void) mysql_file_close(new_file, MYF(0)); - (void) my_raid_delete(mi_key_file_datatmp, - param->temp_filename, share->base.raid_chunks, - MYF(MY_WME)); + (void) mysql_file_delete(mi_key_file_datatmp, + param->temp_filename, MYF(MY_WME)); if (info->dfile == new_file) /* Retry with key cache */ if (unlikely(mi_open_datafile(info, share, name, -1))) param->retry_repair= 0; /* Safety */ @@ -2751,16 +2727,12 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, if (!rep_quick) { /* Get real path for data file */ - if ((new_file= my_raid_create(mi_key_file_datatmp, - fn_format(param->temp_filename, - share->data_file_name, "", - DATA_TMP_EXT, - 2+4), - 0, param->tmpfile_createflag, - share->base.raid_type, - share->base.raid_chunks, - share->base.raid_chunksize, - MYF(0))) < 0) + if ((new_file= mysql_file_create(mi_key_file_datatmp, + fn_format(param->temp_filename, + share->data_file_name, "", + DATA_TMP_EXT, 2+4), + 0, param->tmpfile_createflag, + MYF(0))) < 0) { mi_check_print_error(param,"Can't create new tempfile: '%s'", param->temp_filename); @@ -3055,7 +3027,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, skr < share->base.reloc*share->base.min_pack_length) skr=share->base.reloc*share->base.min_pack_length; #endif - if (skr != sort_info.filelength && !info->s->base.raid_type) + if (skr != sort_info.filelength) if (mysql_file_chsize(info->dfile, skr, 0, MYF(0))) mi_check_print_warning(param, "Can't change size of datafile, error: %d", @@ -3105,8 +3077,7 @@ err: { mysql_file_close(new_file, MYF(0)); info->dfile=new_file= -1; - if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, - DATA_TMP_EXT, share->base.raid_chunks, + if (change_to_newfile(share->data_file_name, MI_NAME_DEXT, DATA_TMP_EXT, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || mi_open_datafile(info,share,name,-1)) @@ -3120,9 +3091,8 @@ err: if (new_file >= 0) { (void) mysql_file_close(new_file, MYF(0)); - (void) my_raid_delete(mi_key_file_datatmp, - param->temp_filename, share->base.raid_chunks, - MYF(MY_WME)); + (void) mysql_file_delete(mi_key_file_datatmp, + param->temp_filename, MYF(MY_WME)); if (info->dfile == new_file) /* Retry with key cache */ if (unlikely(mi_open_datafile(info, share, name, -1))) param->retry_repair= 0; /* Safety */ diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 4a91c2d939b..46c61eb4709 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -549,11 +549,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, share.base.pack_bits=packed; share.base.fields=fields; share.base.pack_fields=packed; -#ifdef USE_RAID - share.base.raid_type=ci->raid_type; - share.base.raid_chunks=ci->raid_chunks; - share.base.raid_chunksize=ci->raid_chunksize; -#endif /* max_data_file_length and max_key_file_length are recalculated on open */ if (options & HA_OPTION_TMP_TABLE) @@ -642,20 +637,6 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (!(flags & HA_DONT_TOUCH_DATA)) { -#ifdef USE_RAID - if (share.base.raid_type) - { - (void) fn_format(filename, name, "", MI_NAME_DEXT, - MY_UNPACK_FILENAME | MY_APPEND_EXT); - if ((dfile=my_raid_create(filename, 0, create_mode, - share.base.raid_type, - share.base.raid_chunks, - share.base.raid_chunksize, - MYF(MY_WME | MY_RAID))) < 0) - goto err; - } - else -#endif { if (ci->data_file_name) { @@ -841,7 +822,6 @@ err: (void) mysql_file_close(dfile, MYF(0)); /* fall through */ case 2: - /* QQ: Tõnu should add a call to my_raid_delete() here */ if (! (flags & HA_DONT_TOUCH_DATA)) mysql_file_delete_with_symlink(mi_key_file_dfile, fn_format(filename, name, "", MI_NAME_DEXT, diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c index 58a60a760aa..a05a2ad6237 100644 --- a/storage/myisam/mi_delete_table.c +++ b/storage/myisam/mi_delete_table.c @@ -22,40 +22,11 @@ int mi_delete_table(const char *name) { char from[FN_REFLEN]; -#ifdef USE_RAID - uint raid_type=0,raid_chunks=0; -#endif DBUG_ENTER("mi_delete_table"); #ifdef EXTRA_DEBUG check_table_is_closed(name,"delete"); #endif -#ifdef USE_RAID - { - MI_INFO *info; - /* - When built with RAID support, we need to determine if this table - makes use of the raid feature. If yes, we need to remove all raid - chunks. This is done with my_raid_delete(). Unfortunately it is - necessary to open the table just to check this. We use - 'open_for_repair' to be able to open even a crashed table. If even - this open fails, we assume no raid configuration for this table - and try to remove the normal data file only. This may however - leave the raid chunks behind. - */ - if (!(info= mi_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR))) - raid_type= 0; - else - { - raid_type= info->s->base.raid_type; - raid_chunks= info->s->base.raid_chunks; - mi_close(info); - } - } -#ifdef EXTRA_DEBUG - check_table_is_closed(name,"delete"); -#endif -#endif /* USE_RAID */ fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from)) @@ -73,10 +44,6 @@ int mi_delete_table(const char *name) DBUG_RETURN(my_errno); } fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); -#ifdef USE_RAID - if (raid_type) - DBUG_RETURN(my_raid_delete(from, raid_chunks, MYF(MY_WME)) ? my_errno : 0); -#endif if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from)) { /* diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 59b895b5e64..f429edd2759 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -283,13 +283,6 @@ int _mi_write_blob_record(MI_INFO *info, const uchar *record) MI_DYN_DELETE_BLOCK_HEADER+1); reclength= (info->s->base.pack_reclength + _my_calc_total_blob_length(info,record)+ extra); -#ifdef NOT_USED /* We now support big rows */ - if (reclength > MI_DYN_MAX_ROW_LENGTH) - { - my_errno=HA_ERR_TO_BIG_ROW; - return -1; - } -#endif if (!(rec_buff=(uchar*) my_alloca(reclength))) { my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */ @@ -317,13 +310,6 @@ int _mi_update_blob_record(MI_INFO *info, my_off_t pos, const uchar *record) MI_DYN_DELETE_BLOCK_HEADER); reclength= (info->s->base.pack_reclength+ _my_calc_total_blob_length(info,record)+ extra); -#ifdef NOT_USED /* We now support big rows */ - if (reclength > MI_DYN_MAX_ROW_LENGTH) - { - my_errno=HA_ERR_TO_BIG_ROW; - return -1; - } -#endif if (!(rec_buff=(uchar*) my_alloca(reclength))) { my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */ @@ -1009,7 +995,7 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to, char *temp_pos; size_t tmp_length=length-portable_sizeof_char_ptr; memcpy((uchar*) to,from,tmp_length); - memcpy_fixed(&temp_pos,from+tmp_length,sizeof(char*)); + memcpy(&temp_pos,from+tmp_length,sizeof(char*)); memcpy(to+tmp_length,temp_pos,(size_t) blob->length); to+=tmp_length+blob->length; } @@ -1324,9 +1310,9 @@ ulong _mi_rec_unpack(register MI_INFO *info, register uchar *to, uchar *from, from_left - size_length < blob_length || from_left - size_length - blob_length < min_pack_length) goto err; - memcpy((uchar*) to,(uchar*) from,(size_t) size_length); + memcpy(to, from, (size_t) size_length); from+=size_length; - memcpy_fixed((uchar*) to+size_length,(uchar*) &from,sizeof(char*)); + memcpy(to+size_length, &from, sizeof(char*)); from+=blob_length; } else diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 3f445ebf44d..bce42b64e99 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -139,7 +139,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, else if (keyseg->flag & HA_BLOB_PART) { uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos); - memcpy_fixed((uchar*) &pos,pos+keyseg->bit_start,sizeof(char*)); + memcpy(&pos,pos+keyseg->bit_start,sizeof(char*)); set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 065f18965d1..6134b4f46df 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -29,7 +29,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) int error; uint count; MYISAM_SHARE *share=info->s; - uint flag; DBUG_ENTER("mi_lock_database"); DBUG_PRINT("enter",("lock_type: %d old lock %d r_locks: %u w_locks: %u " "global_changed: %d open_count: %u name: '%s'", @@ -49,7 +48,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) DBUG_RETURN(0); } - flag=error=0; + error= 0; mysql_mutex_lock(&share->intern_lock); if (share->kfile >= 0) /* May only be false on windows */ { @@ -121,14 +120,12 @@ int mi_lock_database(MI_INFO *info, int lock_type) { if (share->r_locks) { /* Only read locks left */ - flag=1; if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF, MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) error=my_errno; } else if (!share->w_locks) { /* No more locks */ - flag=1; if (my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF, MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) error=my_errno; @@ -150,7 +147,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) */ if (share->w_locks == 1) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, MYF(MY_SEEK_NOT_DONE))) { @@ -165,7 +161,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) } if (!share->r_locks && !share->w_locks) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, info->lock_wait | MY_SEEK_NOT_DONE)) { @@ -191,7 +186,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) { /* Change READONLY to RW */ if (share->r_locks == 1) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, MYF(info->lock_wait | MY_SEEK_NOT_DONE))) { @@ -208,7 +202,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) { if (!share->w_locks) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, info->lock_wait | MY_SEEK_NOT_DONE)) { @@ -256,11 +249,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) } #endif mysql_mutex_unlock(&share->intern_lock); -#if defined(FULL_LOG) || defined(_lint) - lock_type|=(int) (flag << 8); /* Set bit to set if real lock */ - myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type), - error); -#endif DBUG_RETURN(error); } /* mi_lock_database */ diff --git a/storage/myisam/mi_log.c b/storage/myisam/mi_log.c index f6bbaab1f87..5af4a057a95 100644 --- a/storage/myisam/mi_log.c +++ b/storage/myisam/mi_log.c @@ -149,7 +149,7 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, blob != end ; blob++) { - memcpy_fixed((uchar*) &pos, record+blob->offset+blob->pack_length, + memcpy(&pos, record+blob->offset+blob->pack_length, sizeof(char*)); (void) mysql_file_write(myisam_log_file, pos, blob->length, MYF(0)); } diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 5b3da9841b8..e3c29909067 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -260,25 +260,6 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) set_if_smaller(max_data_file_length, INT_MAX32); set_if_smaller(max_key_file_length, INT_MAX32); #endif -#if USE_RAID && SYSTEM_SIZEOF_OFF_T == 4 - set_if_smaller(max_key_file_length, INT_MAX32); - if (!share->base.raid_type) - { - set_if_smaller(max_data_file_length, INT_MAX32); - } - else - { - set_if_smaller(max_data_file_length, - (ulonglong) share->base.raid_chunks << 31); - } -#elif !defined(USE_RAID) - if (share->base.raid_type) - { - DBUG_PRINT("error",("Table uses RAID but we don't have RAID support")); - my_errno=HA_ERR_UNSUPPORTED; - goto err; - } -#endif share->base.max_data_file_length=(my_off_t) max_data_file_length; share->base.max_key_file_length=(my_off_t) max_key_file_length; @@ -877,7 +858,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite) key_blocks=state->header.max_block_size_index; DBUG_ENTER("mi_state_info_write"); - memcpy_fixed(ptr,&state->header,sizeof(state->header)); + memcpy(ptr, &state->header, sizeof(state->header)); ptr+=sizeof(state->header); /* open_count must be first because of _mi_mark_file_changed ! */ @@ -936,7 +917,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite) uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state) { uint i,keys,key_parts,key_blocks; - memcpy_fixed(&state->header,ptr, sizeof(state->header)); + memcpy(&state->header, ptr, sizeof(state->header)); ptr +=sizeof(state->header); keys=(uint) state->header.keys; key_parts=mi_uint2korr(state->header.key_parts); @@ -1036,10 +1017,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base) mi_int2store(ptr,base->max_key_length); ptr +=2; mi_int2store(ptr,base->extra_alloc_bytes); ptr +=2; *ptr++= base->extra_alloc_procent; - *ptr++= base->raid_type; - mi_int2store(ptr,base->raid_chunks); ptr +=2; - mi_int4store(ptr,base->raid_chunksize); ptr +=4; - bzero(ptr,6); ptr +=6; /* extra */ + bzero(ptr,13); ptr +=13; /* extra */ return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; } @@ -1070,17 +1048,8 @@ uchar *my_n_base_info_read(uchar *ptr, MI_BASE_INFO *base) base->max_key_length = mi_uint2korr(ptr); ptr +=2; base->extra_alloc_bytes = mi_uint2korr(ptr); ptr +=2; base->extra_alloc_procent = *ptr++; - base->raid_type= *ptr++; - base->raid_chunks= mi_uint2korr(ptr); ptr +=2; - base->raid_chunksize= mi_uint4korr(ptr); ptr +=4; - /* TO BE REMOVED: Fix for old RAID files */ - if (base->raid_type == 0) - { - base->raid_chunks=0; - base->raid_chunksize=0; - } - ptr+=6; + ptr+=13; return ptr; } @@ -1223,7 +1192,7 @@ uchar *mi_recinfo_read(uchar *ptr, MI_COLUMNDEF *recinfo) } /************************************************************************** -Open data file with or without RAID +Open data file. We can't use dup() here as the data file descriptors need to have different active seek-positions. @@ -1251,20 +1220,8 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name, data_name= real_data_name; } } -#ifdef USE_RAID - if (share->base.raid_type) - { - info->dfile=my_raid_open(data_name, - share->mode | O_SHARE, - share->base.raid_type, - share->base.raid_chunks, - share->base.raid_chunksize, - MYF(MY_WME | MY_RAID)); - } - else -#endif - info->dfile= mysql_file_open(mi_key_file_dfile, - data_name, share->mode | O_SHARE, MYF(MY_WME)); + info->dfile= mysql_file_open(mi_key_file_dfile, + data_name, share->mode | O_SHARE, MYF(MY_WME)); return info->dfile >= 0 ? 0 : 1; } diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index 0ba495fdd68..d8d892a5bc9 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -1051,8 +1051,7 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, } decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length); _my_store_blob_length((uchar*) to,pack_length,length); - memcpy_fixed((char*) to+pack_length,(char*) &bit_buff->blob_pos, - sizeof(char*)); + memcpy((char*) to+pack_length, &bit_buff->blob_pos, sizeof(char*)); bit_buff->blob_pos+=length; } } diff --git a/storage/myisam/mi_rename.c b/storage/myisam/mi_rename.c index 56ccb333d03..455d45cecfe 100644 --- a/storage/myisam/mi_rename.c +++ b/storage/myisam/mi_rename.c @@ -22,28 +22,12 @@ int mi_rename(const char *old_name, const char *new_name) { char from[FN_REFLEN],to[FN_REFLEN]; -#ifdef USE_RAID - uint raid_type=0,raid_chunks=0; -#endif DBUG_ENTER("mi_rename"); #ifdef EXTRA_DEBUG check_table_is_closed(old_name,"rename old_table"); check_table_is_closed(new_name,"rename new table2"); #endif -#ifdef USE_RAID - { - MI_INFO *info; - if (!(info=mi_open(old_name, O_RDONLY, 0))) - DBUG_RETURN(my_errno); - raid_type = info->s->base.raid_type; - raid_chunks = info->s->base.raid_chunks; - mi_close(info); - } -#ifdef EXTRA_DEBUG - check_table_is_closed(old_name,"rename raidcheck"); -#endif -#endif /* USE_RAID */ fn_format(from,old_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(to,new_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); @@ -51,11 +35,6 @@ int mi_rename(const char *old_name, const char *new_name) DBUG_RETURN(my_errno); fn_format(from,old_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(to,new_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); -#ifdef USE_RAID - if (raid_type) - DBUG_RETURN(my_raid_rename(from, to, raid_chunks, MYF(MY_WME)) ? my_errno : - 0); -#endif DBUG_RETURN(mysql_file_rename_with_symlink(mi_key_file_dfile, from, to, MYF(MY_WME)) ? my_errno : 0); diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c index baa01a507eb..073b127f1a3 100644 --- a/storage/myisam/mi_static.c +++ b/storage/myisam/mi_static.c @@ -38,7 +38,6 @@ uint myisam_concurrent_insert= 2; uint myisam_concurrent_insert= 0; #endif ulonglong myisam_max_temp_length= MAX_FILE_SIZE; -ulong myisam_bulk_insert_tree_size=8192*1024; ulong myisam_data_pointer_size=4; ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0; diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index 742864fe241..f89f2a8d21d 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -411,7 +411,7 @@ static void create_record(uchar *record,uint rownr) tmp=strlen((char*) blob_key); int4store(pos,tmp); ptr=blob_key; - memcpy_fixed(pos+4,&ptr,sizeof(char*)); + memcpy(pos+4, &ptr, sizeof(char*)); pos+=recinfo[1].length; } else if (recinfo[1].type == FIELD_VARCHAR) @@ -439,7 +439,7 @@ static void create_record(uchar *record,uint rownr) tmp=strlen((char*) blob_record); int4store(pos,tmp); ptr=blob_record; - memcpy_fixed(pos+4,&ptr,sizeof(char*)); + memcpy(pos+4, &ptr, sizeof(char*)); } else if (recinfo[2].type == FIELD_VARCHAR) { @@ -468,10 +468,10 @@ static void update_record(uchar *record) uchar *column,*ptr; int length; length=uint4korr(pos); /* Long blob */ - memcpy_fixed(&column,pos+4,sizeof(char*)); + memcpy(&column, pos+4, sizeof(char*)); memcpy(blob_key,column,length); /* Move old key */ ptr=blob_key; - memcpy_fixed(pos+4,&ptr,sizeof(char*)); /* Store pointer to new key */ + memcpy(pos+4, &ptr, sizeof(char*)); /* Store pointer to new key */ if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM) default_charset_info->cset->casedn(default_charset_info, (char*) blob_key, length, @@ -501,13 +501,13 @@ static void update_record(uchar *record) uchar *column; int length; length=uint4korr(pos); - memcpy_fixed(&column,pos+4,sizeof(char*)); + memcpy(&column, pos+4, sizeof(char*)); memcpy(blob_record,column,length); bfill(blob_record+length,20,'.'); /* Make it larger */ length+=20; int4store(pos,length); column= blob_record; - memcpy_fixed(pos+4,&column,sizeof(char*)); + memcpy(pos+4, &column, sizeof(char*)); } else if (recinfo[2].type == FIELD_VARCHAR) { diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 513b390ee68..127d93b5433 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -1030,7 +1030,7 @@ static void put_blob_in_record(uchar *blob_pos, char **blob_buffer) for (i=0 ; i < length ; i++) (*blob_buffer)[i]=(char) (length+i); int4store(blob_pos,length); - memcpy_fixed(blob_pos+4,(char*) blob_buffer,sizeof(char*)); + memcpy(blob_pos+4, blob_buffer, sizeof(char*)); } else { diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index bf36d8df7f4..c03a34df227 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -458,7 +458,7 @@ int test_update(MI_INFO *file,int id,int lock_type) } } } - memcpy_fixed(new_record.id,record.id,sizeof(record.id)); + memcpy(new_record.id, record.id, sizeof(record.id)); tmp=rnd(20000)+40000; int4store(new_record.nr,tmp); if (!mi_update(file,record.id,new_record.id)) diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c index fdba84a2e67..cee159951de 100644 --- a/storage/myisam/mi_unique.c +++ b/storage/myisam/mi_unique.c @@ -111,7 +111,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const uchar *record) else if (keyseg->flag & HA_BLOB_PART) { uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos); - memcpy_fixed((uchar*) &pos,pos+keyseg->bit_start,sizeof(char*)); + memcpy(&pos, pos+keyseg->bit_start, sizeof(char*)); if (!length || length > tmp_length) length=tmp_length; /* The whole blob */ } @@ -206,8 +206,8 @@ int mi_unique_comp(MI_UNIQUEDEF *def, const uchar *a, const uchar *b, set_if_smaller(a_length, keyseg->length); set_if_smaller(b_length, keyseg->length); } - memcpy_fixed((uchar*) &pos_a,pos_a+keyseg->bit_start,sizeof(char*)); - memcpy_fixed((uchar*) &pos_b,pos_b+keyseg->bit_start,sizeof(char*)); + memcpy(&pos_a, pos_a+keyseg->bit_start, sizeof(char*)); + memcpy(&pos_b, pos_b+keyseg->bit_start, sizeof(char*)); } if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 || type == HA_KEYTYPE_VARTEXT2) diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index f2d43585eef..bd56bb04f65 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -61,11 +61,6 @@ int mi_write(MI_INFO *info, uchar *record) if (_mi_readinfo(info,F_WRLCK,1)) DBUG_RETURN(my_errno); dont_break(); /* Dont allow SIGHUP or SIGINT */ -#if !defined(NO_LOCKING) && defined(USE_RECORD_LOCK) - if (!info->locked && my_lock(info->dfile,F_WRLCK,0L,F_TO_EOF, - MYF(MY_SEEK_NOT_DONE) | info->lock_wait)) - goto err; -#endif filepos= ((share->state.dellink != HA_OFFSET_ERROR && !info->append_insert_at_end) ? share->state.dellink : diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index 4718abc3481..1c534fe8d02 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -46,7 +46,7 @@ static struct my_option my_long_options[] = {"stats", 's', "Report global stats.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Be verbose.", - (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + &verbose, &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index e1cedf6bc31..4df76e31872 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -27,12 +27,6 @@ #ifdef HAVE_SYS_MMAN_H #include <sys/mman.h> #endif -SET_STACK_SIZE(9000) /* Minimum stack size for program */ - -#ifndef USE_RAID -#define my_raid_create(A,B,C,D,E,F,G) my_create(A,B,C,G) -#define my_raid_delete(A,B,C) my_delete(A,B) -#endif static uint decode_bits; static char **default_argv; @@ -782,7 +776,6 @@ static int myisamchk(MI_CHECK *param, char * filename) { int error,lock_type,recreate; int rep_quick= param->testflag & (T_QUICK | T_FORCE_UNIQUENESS); - uint raid_chunks; MI_INFO *info; File datafile; char llbuff[22],llbuff2[22]; @@ -844,7 +837,6 @@ static int myisamchk(MI_CHECK *param, char * filename) share->options&= ~HA_OPTION_READ_ONLY_DATA; /* We are modifing it */ share->tot_locks-= share->r_locks; share->r_locks=0; - raid_chunks=share->base.raid_chunks; /* Skip the checking of the file if: @@ -1013,9 +1005,7 @@ static int myisamchk(MI_CHECK *param, char * filename) if (param->out_flag & O_NEW_DATA) { /* Change temp file to org file */ (void) my_close(info->dfile,MYF(MY_WME)); /* Close new file */ - error|=change_to_newfile(filename,MI_NAME_DEXT,DATA_TMP_EXT, - raid_chunks, - MYF(0)); + error|=change_to_newfile(filename, MI_NAME_DEXT, DATA_TMP_EXT, MYF(0)); if (mi_open_datafile(info,info->s, NULL, -1)) error=1; param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */ @@ -1146,12 +1136,10 @@ end2: { if (param->out_flag & O_NEW_DATA) error|=change_to_newfile(filename,MI_NAME_DEXT,DATA_TMP_EXT, - raid_chunks, ((param->testflag & T_BACKUP_DATA) ? MYF(MY_REDEL_MAKE_BACKUP) : MYF(0))); if (param->out_flag & O_NEW_INDEX) - error|=change_to_newfile(filename,MI_NAME_IEXT,INDEX_TMP_EXT,0, - MYF(0)); + error|=change_to_newfile(filename, MI_NAME_IEXT, INDEX_TMP_EXT, MYF(0)); } (void) fflush(stdout); (void) fflush(stderr); if (param->error_printed) @@ -1247,16 +1235,9 @@ static void descript(MI_CHECK *param, register MI_INFO *info, char * name) share->base.auto_key, llstr(share->state.auto_increment,llbuff)); } - if (share->base.raid_type) - { - printf("RAID: Type: %u Chunks: %u Chunksize: %lu\n", - share->base.raid_type, - share->base.raid_chunks, - share->base.raid_chunksize); - } if (share->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) printf("Checksum: %23s\n",llstr(info->state->checksum,llbuff)); -; + if (share->options & HA_OPTION_DELAY_KEY_WRITE) printf("Keys are only flushed at close\n"); @@ -1527,14 +1508,11 @@ static int mi_sort_records(MI_CHECK *param, goto err; } fn_format(param->temp_filename,name,"", MI_NAME_DEXT,2+4+32); - new_file=my_raid_create(fn_format(param->temp_filename, - param->temp_filename,"", - DATA_TMP_EXT,2+4), - 0,param->tmpfile_createflag, - share->base.raid_type, - share->base.raid_chunks, - share->base.raid_chunksize, - MYF(0)); + new_file= my_create(fn_format(param->temp_filename, + param->temp_filename, "", + DATA_TMP_EXT, 2+4), + 0, param->tmpfile_createflag, + MYF(0)); if (new_file < 0) { mi_check_print_error(param,"Can't create new tempfile: '%s'", @@ -1609,8 +1587,7 @@ err: { (void) end_io_cache(&info->rec_cache); (void) my_close(new_file,MYF(MY_WME)); - (void) my_raid_delete(param->temp_filename, share->base.raid_chunks, - MYF(MY_WME)); + (void) my_delete(param->temp_filename, MYF(MY_WME)); } if (temp_buff) { diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 130a96bc9e0..c7f0cb27a40 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -26,8 +26,9 @@ #endif #include <mysql/psi/mysql_file.h> -#if defined(my_write) && !defined(MAP_TO_USE_RAID) -#undef my_write /* undef map from my_nosys; We need test-if-disk full */ +/* undef map from my_nosys; We need test-if-disk full */ +#if defined(my_write) +#undef my_write #endif typedef struct st_mi_status_info @@ -130,9 +131,6 @@ typedef struct st_mi_base_info /* Extra allocation when using dynamic record format */ uint extra_alloc_bytes; uint extra_alloc_procent; - /* Info about raid */ - uint raid_type,raid_chunks; - ulong raid_chunksize; /* The following are from the header */ uint key_parts,all_key_parts; } MI_BASE_INFO; @@ -544,10 +542,6 @@ void _mi_store_static_key(MI_KEYDEF *keyinfo, uchar *key_pos, MI_KEY_PARAM *s_temp); void _mi_store_var_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, MI_KEY_PARAM *s_temp); -#ifdef NOT_USED -void _mi_store_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, - MI_KEY_PARAM *s_temp); -#endif void _mi_store_bin_pack_key(MI_KEYDEF *keyinfo, uchar *key_pos, MI_KEY_PARAM *s_temp); diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index d3da0eab22c..84743b8da51 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -619,7 +619,7 @@ static int examine_log(char * file_name, char **table_names) case MI_LOG_LOCK: if (my_b_read(&cache,(uchar*) head,sizeof(lock_command))) goto err; - memcpy_fixed(&lock_command,head,sizeof(lock_command)); + memcpy(&lock_command, head, sizeof(lock_command)); if (verbose && !record_pos_file && (!table_names[0] || (curr_file_info && curr_file_info->used))) printf_log("%s: %s(%d) -> %d\n",FILENAME(curr_file_info), @@ -728,7 +728,7 @@ static void fix_blob_pointers(MI_INFO *info, uchar *record) blob != end ; blob++) { - memcpy_fixed(record+blob->offset+blob->pack_length,&pos,sizeof(char*)); + memcpy(record+blob->offset+blob->pack_length, &pos, sizeof(char*)); pos+=_mi_calc_blob_length(blob->pack_length,record+blob->offset); } } diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 4cd305fdc69..84a7f2a1ba9 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -1040,7 +1040,7 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) { uint field_length=count->field_length -portable_sizeof_char_ptr; ulong blob_length= _mi_calc_blob_length(field_length, start_pos); - memcpy_fixed((char*) &pos, start_pos+field_length,sizeof(char*)); + memcpy(&pos, start_pos+field_length, sizeof(char*)); end_pos=pos+blob_length; tot_blob_length+=blob_length; set_if_bigger(count->max_length,blob_length); @@ -1889,7 +1889,7 @@ static uint join_same_trees(HUFF_COUNTS *huff_counts, uint trees) i->tree->tree_pack_length+j->tree->tree_pack_length+ ALLOWED_JOIN_DIFF) { - memcpy_fixed((uchar*) i->counts,(uchar*) count.counts, + memcpy(i->counts, count.counts, sizeof(count.counts[0])*256); my_free(j->tree->element_buffer); j->tree->element_buffer=0; @@ -2040,7 +2040,7 @@ static int write_header(PACK_MRG_INFO *mrg,uint head_length,uint trees, uchar *buff= (uchar*) file_buffer.pos; bzero(buff,HEAD_LENGTH); - memcpy_fixed(buff,myisam_pack_file_magic,4); + memcpy(buff,myisam_pack_file_magic,4); int4store(buff+4,head_length); int4store(buff+8, mrg->min_pack_length); int4store(buff+12,mrg->max_pack_length); @@ -2697,8 +2697,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) DBUG_PRINT("fields", ("FIELD_BLOB %lu bytes, bits: %2u", blob_length, count->length_bits)); write_bits(blob_length,count->length_bits); - memcpy_fixed(&blob,end_pos-portable_sizeof_char_ptr, - sizeof(char*)); + memcpy(&blob, end_pos-portable_sizeof_char_ptr, sizeof(char*)); blob_end=blob+blob_length; /* Encode the blob bytes. */ for ( ; blob < blob_end ; blob++) diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c index 88cf643faf9..03d22de68fa 100644 --- a/storage/myisam/rt_split.c +++ b/storage/myisam/rt_split.c @@ -255,7 +255,6 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key, SplitStruct *stop; double *coord_buf; double *next_coord; - double *old_coord; int n_dim; uchar *source_cur, *cur1, *cur2; uchar *new_page= info->buff; @@ -293,8 +292,6 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key, rtree_d_mbr(keyinfo->seg, key, key_length, cur->coords); cur->key = key; - old_coord = next_coord; - if (split_rtree_node(task, max_keys + 1, mi_getint(page) + full_length + 2, full_length, rt_PAGE_MIN_SIZE(keyinfo->block_length), diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 4a9b61605d9..7233300c539 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -366,25 +366,6 @@ static int read_with_pos (MI_INFO * file,int silent) } -#ifdef NOT_USED -static void bprint_record(char * record, - my_off_t offs __attribute__((unused)), - const char * tail) -{ - int i; - char * pos; - i=(unsigned char)record[0]; - printf("%02X ",i); - - for( pos=record+1, i=0; i<32; i++,pos++){ - int b=(unsigned char)*pos; - printf("%02X",b); - } - printf("%s",tail); -} -#endif - - static void print_record(uchar * record, my_off_t offs __attribute__((unused)), const char * tail) @@ -424,30 +405,6 @@ static void create_record1(uchar *record,uint rownr) } } -#ifdef NOT_USED - -static void create_record0(uchar *record,uint rownr) -{ - int i; - char * pos; - double c=rownr+10; - double c0=0; - - bzero((char*) record,MAX_REC_LENGTH); - record[0]=0x01; /* DEL marker */ - - for ( pos=record+1, i=0; i<ndims; i++) - { - memcpy(pos,&c0,sizeof(c0)); - float8store(pos,c0); - pos+=sizeof(c0); - memcpy(pos,&c,sizeof(c)); - float8store(pos,c); - pos+=sizeof(c); - } -} - -#endif static void create_record(uchar *record,uint rownr) { diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c index 3748a38ff81..bde0e1cb388 100644 --- a/storage/myisam/sp_key.c +++ b/storage/myisam/sp_key.c @@ -47,7 +47,7 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, pos = (uchar*)record + keyseg->start; dlen = _mi_calc_blob_length(keyseg->bit_start, pos); - memcpy_fixed(&dptr, pos + keyseg->bit_start, sizeof(char*)); + memcpy(&dptr, pos + keyseg->bit_start, sizeof(char*)); if (!dptr) { my_errno= HA_ERR_NULL_IN_SPATIAL; diff --git a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c index 069f43c320d..d86fdc03908 100644 --- a/storage/myisam/sp_test.c +++ b/storage/myisam/sp_test.c @@ -299,26 +299,6 @@ static int read_with_pos (MI_INFO * file,int silent) } -#ifdef NOT_USED -static void bprint_record(uchar * record, - my_off_t offs __attribute__((unused)), - const char * tail) -{ - int i; - char * pos; - i=(unsigned char)record[0]; - printf("%02X ",i); - - for( pos=record+1, i=0; i<32; i++,pos++) - { - int b=(unsigned char)*pos; - printf("%02X",b); - } - printf("%s",tail); -} -#endif - - static void print_record(uchar * record, my_off_t offs,const char * tail) { uchar *pos; @@ -330,7 +310,7 @@ static void print_record(uchar * record, my_off_t offs,const char * tail) len=sint4korr(pos); pos+=4; printf(" len=%d ",len); - memcpy_fixed(&ptr,pos,sizeof(char*)); + memcpy(&ptr, pos, sizeof(char*)); if (ptr) rtree_PrintWKB((uchar*) ptr,SPDIMS); else @@ -340,34 +320,6 @@ static void print_record(uchar * record, my_off_t offs,const char * tail) } -#ifdef NOT_USED -static void create_point(uchar *record,uint rownr) -{ - uint tmp; - char *ptr; - char *pos=record; - double x[200]; - int i; - - for(i=0;i<SPDIMS;i++) - x[i]=rownr; - - bzero((char*) record,MAX_REC_LENGTH); - *pos=0x01; /* DEL marker */ - pos++; - - memset(blob_key,0,sizeof(blob_key)); - tmp=rtree_CreatePointWKB(x,SPDIMS,blob_key); - - int4store(pos,tmp); - pos+=4; - - ptr=blob_key; - memcpy_fixed(pos,&ptr,sizeof(char*)); -} -#endif - - static void create_linestring(uchar *record,uint rownr) { uint tmp; @@ -376,23 +328,23 @@ static void create_linestring(uchar *record,uint rownr) double x[200]; int i,j; int npoints=2; - + for(j=0;j<npoints;j++) for(i=0;i<SPDIMS;i++) x[i+j*SPDIMS]=rownr*j; - + bzero((char*) record,MAX_REC_LENGTH); *pos=0x01; /* DEL marker */ pos++; - + memset(blob_key,0,sizeof(blob_key)); tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints, (uchar*) blob_key); - + int4store(pos,tmp); pos+=4; - + ptr=blob_key; - memcpy_fixed(pos,&ptr,sizeof(char*)); + memcpy(pos, &ptr, sizeof(char*)); } @@ -401,7 +353,7 @@ static void create_key(uchar *key,uint rownr) double c=rownr; uchar *pos; uint i; - + bzero(key,MAX_REC_LENGTH); for (pos=key, i=0; i<2*SPDIMS; i++) { @@ -426,27 +378,6 @@ static void print_key(const uchar *key,const char * tail) } -#ifdef NOT_USED - -static int rtree_CreatePointWKB(double *ords, uint n_dims, uchar *wkb) -{ - uint i; - - *wkb = wkbXDR; - ++wkb; - int4store(wkb, wkbPoint); - wkb += 4; - - for (i=0; i < n_dims; ++i) - { - float8store(wkb, ords[i]); - wkb += 8; - } - return 5 + n_dims * 8; -} -#endif - - static int rtree_CreateLineStringWKB(double *ords, uint n_dims, uint n_points, uchar *wkb) { diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index f41629ff882..f62aff4e383 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -642,7 +642,7 @@ extern "C" MI_INFO *myisammrg_attach_children_callback(void *callback_param) my_errno= HA_ERR_WRONG_MRG_TABLE_DEF; } DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx my_errno: %d", - my_errno ? NULL : (long) myisam, my_errno)); + my_errno ? 0L : (long) myisam, my_errno)); end: DBUG_RETURN(myisam); diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index c9e19d32e96..b8e86b89181 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -226,9 +226,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, int save_errno; int insert_method; uint length; - uint dir_length; uint child_count; - size_t name_buff_length; File fd; IO_CACHE file_cache; char parent_name_buff[FN_REFLEN * 2]; @@ -300,7 +298,6 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, } /* Call callback for each child. */ - dir_length= dirname_part(parent_name_buff, parent_name, &name_buff_length); my_b_seek(&file_cache, 0); while ((length= my_b_gets(&file_cache, child_name_buff, FN_REFLEN - 1))) { @@ -381,7 +378,6 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, { ulonglong file_offset; MI_INFO *myisam; - int rc; int errpos; int save_errno; uint idx; @@ -400,7 +396,6 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, here and in ha_myisammrg::store_lock() forces consistent data. */ mysql_mutex_lock(&m_info->mutex); - rc= 1; errpos= 0; file_offset= 0; min_keys= 0; diff --git a/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp b/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp index 8126267f946..95dbf5204f1 100644 --- a/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp +++ b/storage/ndb/include/kernel/signaldata/FsOpenReq.hpp @@ -203,7 +203,7 @@ Uint32 FsOpenReq::getVersion(const Uint32 fileNumber[]){ inline void FsOpenReq::setVersion(Uint32 fileNumber[], Uint8 val){ const Uint32 t = fileNumber[3]; - fileNumber[3] = t & 0x00FFFFFF | (((Uint32)val) << 24); + fileNumber[3] = (t & 0x00FFFFFF) | (((Uint32)val) << 24); } inline @@ -214,7 +214,7 @@ Uint32 FsOpenReq::getSuffix(const Uint32 fileNumber[]){ inline void FsOpenReq::setSuffix(Uint32 fileNumber[], Uint8 val){ const Uint32 t = fileNumber[3]; - fileNumber[3] = t & 0xFF00FFFF | (((Uint32)val) << 16); + fileNumber[3] = (t & 0xFF00FFFF) | (((Uint32)val) << 16); } inline @@ -225,7 +225,7 @@ Uint32 FsOpenReq::v1_getDisk(const Uint32 fileNumber[]){ inline void FsOpenReq::v1_setDisk(Uint32 fileNumber[], Uint8 val){ const Uint32 t = fileNumber[3]; - fileNumber[3] = t & 0xFFFF00FF | (((Uint32)val) << 8); + fileNumber[3] = (t & 0xFFFF00FF) | (((Uint32)val) << 8); } inline @@ -266,7 +266,7 @@ Uint32 FsOpenReq::v1_getP(const Uint32 fileNumber[]){ inline void FsOpenReq::v1_setP(Uint32 fileNumber[], Uint8 val){ const Uint32 t = fileNumber[3]; - fileNumber[3] = t & 0xFFFFFF00 | val; + fileNumber[3] = (t & 0xFFFFFF00) | val; } /****************/ diff --git a/storage/ndb/include/util/ndb_opts.h b/storage/ndb/include/util/ndb_opts.h index f18bb9646cc..59d9eaf4d33 100644 --- a/storage/ndb/include/util/ndb_opts.h +++ b/storage/ndb/include/util/ndb_opts.h @@ -58,40 +58,40 @@ const char *opt_debug= 0; "Set connect string for connecting to ndb_mgmd. " \ "Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " \ "Overrides specifying entries in NDB_CONNECTSTRING and my.cnf", \ - (uchar**) &opt_ndb_connectstring, (uchar**) &opt_ndb_connectstring, \ + &opt_ndb_connectstring, &opt_ndb_connectstring, \ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "ndb-mgmd-host", OPT_NDB_MGMD, \ "Set host and port for connecting to ndb_mgmd. " \ "Syntax: <hostname>[:<port>].", \ - (uchar**) &opt_ndb_mgmd, (uchar**) &opt_ndb_mgmd, 0, \ + &opt_ndb_mgmd, &opt_ndb_mgmd, 0, \ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "ndb-nodeid", OPT_NDB_NODEID, \ "Set node id for this node.", \ - (uchar**) &opt_ndb_nodeid, (uchar**) &opt_ndb_nodeid, 0, \ + &opt_ndb_nodeid, &opt_ndb_nodeid, 0, \ GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "ndb-shm", OPT_NDB_SHM,\ "Allow optimizing using shared memory connections when available",\ - (uchar**) &opt_ndb_shm, (uchar**) &opt_ndb_shm, 0,\ + &opt_ndb_shm, &opt_ndb_shm, 0,\ GET_BOOL, NO_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0 },\ {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION,\ "Select nodes for transactions in a more optimal way",\ - (uchar**) &opt_ndb_optimized_node_selection,\ - (uchar**) &opt_ndb_optimized_node_selection, 0,\ + &opt_ndb_optimized_node_selection,\ + &opt_ndb_optimized_node_selection, 0,\ GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\ { "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\ - (uchar**) &opt_ndb_connectstring, (uchar**) &opt_ndb_connectstring, \ + &opt_ndb_connectstring, &opt_ndb_connectstring, \ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "core-file", OPT_WANT_CORE, "Write core on errors.",\ - (uchar**) &opt_core, (uchar**) &opt_core, 0,\ + &opt_core, &opt_core, 0,\ GET_BOOL, NO_ARG, OPT_WANT_CORE_DEFAULT, 0, 0, 0, 0, 0},\ {"character-sets-dir", OPT_CHARSETS_DIR,\ - "Directory where character sets are.", (uchar**) &charsets_dir,\ - (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}\ + "Directory where character sets are.", &charsets_dir,\ + &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}\ #ifndef DBUG_OFF #define NDB_STD_OPTS(prog_name) \ { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \ - (uchar**) &opt_debug, (uchar**) &opt_debug, \ + &opt_debug, &opt_debug, \ 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \ NDB_STD_OPTS_COMMON #else diff --git a/storage/ndb/src/cw/cpcd/main.cpp b/storage/ndb/src/cw/cpcd/main.cpp index d5c31d610cb..b750c00bc2a 100644 --- a/storage/ndb/src/cw/cpcd/main.cpp +++ b/storage/ndb/src/cw/cpcd/main.cpp @@ -39,22 +39,22 @@ static const char *user = 0; static struct my_option my_long_options[] = { { "work-dir", 'w', "Work directory", - (uchar**) &work_dir, (uchar**) &work_dir, 0, + &work_dir, &work_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "port", 'p', "TCP port to listen on", - (uchar**) &port, (uchar**) &port, 0, + &port, &port, 0, GET_INT, REQUIRED_ARG, CPCD_DEFAULT_TCP_PORT, 0, 0, 0, 0, 0 }, { "syslog", 'S', "Log events to syslog", - (uchar**) &use_syslog, (uchar**) &use_syslog, 0, + &use_syslog, &use_syslog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "logfile", 'L', "File to log events to", - (uchar**) &logfile, (uchar**) &logfile, 0, + &logfile, &logfile, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "debug", 'D', "Enable debug mode", - (uchar**) &debug, (uchar**) &debug, 0, + &debug, &debug, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "user", 'u', "Run as user", - (uchar**) &user, (uchar**) &user, 0, + &user, &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp index 67ce7a1760a..3917d415575 100644 --- a/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp +++ b/storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp @@ -840,13 +840,13 @@ Dbtux::TreeEnt::cmp(const TreeEnt ent) const */ const unsigned version_wrap_limit = (1 << (ZTUP_VERSION_BITS - 1)); if (m_tupVersion < ent.m_tupVersion) { - if (ent.m_tupVersion - m_tupVersion < version_wrap_limit) + if (unsigned(ent.m_tupVersion - m_tupVersion) < version_wrap_limit) return -1; else return +1; } if (m_tupVersion > ent.m_tupVersion) { - if (m_tupVersion - ent.m_tupVersion < version_wrap_limit) + if (unsigned(m_tupVersion - ent.m_tupVersion) < version_wrap_limit) return +1; else return -1; diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp index 72770d35cde..f1e608738e3 100644 --- a/storage/ndb/src/kernel/vm/Configuration.cpp +++ b/storage/ndb/src/kernel/vm/Configuration.cpp @@ -74,35 +74,35 @@ static struct my_option my_long_options[] = { "initial", OPT_INITIAL, "Perform initial start of ndbd, including cleaning the file system. " "Consult documentation before using this", - (uchar**) &_initial, (uchar**) &_initial, 0, + &_initial, &_initial, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nostart", 'n', "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", - (uchar**) &_no_start, (uchar**) &_no_start, 0, + &_no_start, &_no_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "daemon", 'd', "Start ndbd as daemon (default)", - (uchar**) &_daemon, (uchar**) &_daemon, 0, + &_daemon, &_daemon, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, { "nodaemon", OPT_NODAEMON, "Do not start ndbd as daemon, provided for testing purposes", - (uchar**) &_no_daemon, (uchar**) &_no_daemon, 0, + &_no_daemon, &_no_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "foreground", OPT_FOREGROUND, "Run real ndbd in foreground, provided for debugging purposes" " (implies --nodaemon)", - (uchar**) &_foreground, (uchar**) &_foreground, 0, + &_foreground, &_foreground, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nowait-nodes", OPT_NOWAIT_NODES, "Nodes that will not be waited for during start", - (uchar**) &_nowait_nodes, (uchar**) &_nowait_nodes, 0, + &_nowait_nodes, &_nowait_nodes, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "initial-start", OPT_INITIAL_START, "Perform initial start", - (uchar**) &_initialstart, (uchar**) &_initialstart, 0, + &_initialstart, &_initialstart, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "bind-address", OPT_NOWAIT_NODES, "Local bind address", - (uchar**) &_bind_address, (uchar**) &_bind_address, 0, + &_bind_address, &_bind_address, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/mgmclient/main.cpp b/storage/ndb/src/mgmclient/main.cpp index 980530953ad..7049bdd12e0 100644 --- a/storage/ndb/src/mgmclient/main.cpp +++ b/storage/ndb/src/mgmclient/main.cpp @@ -73,11 +73,11 @@ static struct my_option my_long_options[] = NDB_STD_OPTS("ndb_mgm"), { "execute", 'e', "execute command and exit", - (uchar**) &opt_execute_str, (uchar**) &opt_execute_str, 0, + &opt_execute_str, &opt_execute_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "try-reconnect", 't', "Specify number of tries for connecting to ndb_mgmd (0 = infinite)", - (uchar**) &_try_reconnect, (uchar**) &_try_reconnect, 0, + &_try_reconnect, &_try_reconnect, 0, GET_UINT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/mgmsrv/main.cpp b/storage/ndb/src/mgmsrv/main.cpp index 26198a44a23..e0d9a550cd2 100644 --- a/storage/ndb/src/mgmsrv/main.cpp +++ b/storage/ndb/src/mgmsrv/main.cpp @@ -142,29 +142,29 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_mgmd"), { "config-file", 'f', "Specify cluster configuration file", - (uchar**) &opt_config_filename, (uchar**) &opt_config_filename, 0, + &opt_config_filename, &opt_config_filename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "print-full-config", 'P', "Print full config and exit", - (uchar**) &g_print_full_config, (uchar**) &g_print_full_config, 0, + &g_print_full_config, &g_print_full_config, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)", - (uchar**) &opt_daemon, (uchar**) &opt_daemon, 0, + &opt_daemon, &opt_daemon, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, { "interactive", OPT_INTERACTIVE, "Run interactive. Not supported but provided for testing purposes", - (uchar**) &opt_interactive, (uchar**) &opt_interactive, 0, + &opt_interactive, &opt_interactive, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-nodeid-checks", OPT_NO_NODEID_CHECKS, "Do not provide any node id checks", - (uchar**) &g_no_nodeid_checks, (uchar**) &g_no_nodeid_checks, 0, + &g_no_nodeid_checks, &g_no_nodeid_checks, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nodaemon", OPT_NO_DAEMON, "Don't run as daemon, but don't read from stdin", - (uchar**) &opt_non_interactive, (uchar**) &opt_non_interactive, 0, + &opt_non_interactive, &opt_non_interactive, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "mycnf", 256, "Read cluster config from my.cnf", - (uchar**) &opt_mycnf, (uchar**) &opt_mycnf, 0, + &opt_mycnf, &opt_mycnf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/ndbapi/TransporterFacade.hpp b/storage/ndb/src/ndbapi/TransporterFacade.hpp index 23fea8792f7..cbda9de6df1 100644 --- a/storage/ndb/src/ndbapi/TransporterFacade.hpp +++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp @@ -366,8 +366,8 @@ bool TransporterFacade::get_node_stopping(NodeId n) const { const ClusterMgr::Node & node = theClusterMgr->getNodeInfo(n); return (!node.m_state.getSingleUserMode() && - (node.m_state.startLevel == NodeState::SL_STOPPING_1) || - (node.m_state.startLevel == NodeState::SL_STOPPING_2)); + ((node.m_state.startLevel == NodeState::SL_STOPPING_1) || + (node.m_state.startLevel == NodeState::SL_STOPPING_2))); } inline diff --git a/storage/ndb/test/ndbapi/testIndexStat.cpp b/storage/ndb/test/ndbapi/testIndexStat.cpp index 559fade3132..3b3e593081b 100644 --- a/storage/ndb/test/ndbapi/testIndexStat.cpp +++ b/storage/ndb/test/ndbapi/testIndexStat.cpp @@ -1297,43 +1297,43 @@ my_long_options[] = { NDB_STD_OPTS("testIndexStat"), { "loglevel", 1001, "Logging level in this program 0-3 (default 0)", - (uchar **)&g_opts.loglevel, (uchar **)&g_opts.loglevel, 0, + &g_opts.loglevel, &g_opts.loglevel, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "seed", 1002, "Random seed (0=loop number, default -1=random)", - (uchar **)&g_opts.seed, (uchar **)&g_opts.seed, 0, + &g_opts.seed, &g_opts.seed, 0, GET_INT, REQUIRED_ARG, -1, 0, 0, 0, 0, 0 }, { "loop", 1003, "Number of test loops (default 1, 0=forever)", - (uchar **)&g_opts.loop, (uchar **)&g_opts.loop, 0, + &g_opts.loop, &g_opts.loop, 0, GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 }, { "rows", 1004, "Number of rows (default 100000)", - (uchar **)&g_opts.rows, (uchar **)&g_opts.rows, 0, + &g_opts.rows, &g_opts.rows, 0, GET_UINT, REQUIRED_ARG, 100000, 0, 0, 0, 0, 0 }, { "ops", 1005, "Number of index scans per loop (default 1000)", - (uchar **)&g_opts.ops, (uchar **)&g_opts.ops, 0, + &g_opts.ops, &g_opts.ops, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 }, { "dupkeys", 1006, "Pct records per key (min 100, default 1000)", - (uchar **)&g_opts.dupkeys, (uchar **)&g_opts.dupkeys, 0, + &g_opts.dupkeys, &g_opts.dupkeys, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 }, { "scanpct", 1007, "Preferred max pct of total rows per scan (default 5)", - (uchar **)&g_opts.scanpct, (uchar **)&g_opts.scanpct, 0, + &g_opts.scanpct, &g_opts.scanpct, 0, GET_UINT, REQUIRED_ARG, 5, 0, 0, 0, 0, 0 }, { "nullkeys", 1008, "Pct nulls in each key attribute (default 10)", - (uchar **)&g_opts.nullkeys, (uchar **)&g_opts.nullkeys, 0, + &g_opts.nullkeys, &g_opts.nullkeys, 0, GET_UINT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 }, { "eqscans", 1009, "Pct scans for partial/full equality (default 50)", - (uchar **)&g_opts.eqscans, (uchar **)&g_opts.eqscans, 0, + &g_opts.eqscans, &g_opts.eqscans, 0, GET_UINT, REQUIRED_ARG, 50, 0, 0, 0, 0, 0 }, { "dupscans", 1010, "Pct scans using same bounds (default 10)", - (uchar **)&g_opts.dupscans, (uchar **)&g_opts.dupscans, 0, + &g_opts.dupscans, &g_opts.dupscans, 0, GET_UINT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 }, { "keeptable", 1011, "Use existing table and data if any and do not drop", - (uchar **)&g_opts.keeptable, (uchar **)&g_opts.keeptable, 0, + &g_opts.keeptable, &g_opts.keeptable, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-extra-checks", 1012, "Omit expensive consistency checks", - (uchar **)&g_opts.nochecks, (uchar **)&g_opts.nochecks, 0, + &g_opts.nochecks, &g_opts.nochecks, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "abort-on-error", 1013, "Dump core on any error", - (uchar **)&g_opts.abort, (uchar **)&g_opts.abort, 0, + &g_opts.abort, &g_opts.abort, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, diff --git a/storage/ndb/test/ndbapi/test_event_merge.cpp b/storage/ndb/test/ndbapi/test_event_merge.cpp index d40b985adc2..c4109a23119 100644 --- a/storage/ndb/test/ndbapi/test_event_merge.cpp +++ b/storage/ndb/test/ndbapi/test_event_merge.cpp @@ -2184,57 +2184,57 @@ my_long_options[] = { NDB_STD_OPTS("test_event_merge"), { "abort-on-error", 1001, "Do abort() on any error", - (uchar **)&g_opts.abort_on_error, (uchar **)&g_opts.abort_on_error, 0, + &g_opts.abort_on_error, &g_opts.abort_on_error, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "loglevel", 1002, "Logging level in this program 0-3 (default 0)", - (uchar **)&g_opts.loglevel, (uchar **)&g_opts.loglevel, 0, + &g_opts.loglevel, &g_opts.loglevel, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "loop", 1003, "Number of test loops (default 5, 0=forever)", - (uchar **)&g_opts.loop, (uchar **)&g_opts.loop, 0, + &g_opts.loop, &g_opts.loop, 0, GET_INT, REQUIRED_ARG, 5, 0, 0, 0, 0, 0 }, { "maxops", 1004, "Approx number of PK operations per table (default 1000)", - (uchar **)&g_opts.maxops, (uchar **)&g_opts.maxops, 0, + &g_opts.maxops, &g_opts.maxops, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 }, { "maxpk", 1005, "Number of different PK values (default 10, max 1000)", - (uchar **)&g_opts.maxpk, (uchar **)&g_opts.maxpk, 0, + &g_opts.maxpk, &g_opts.maxpk, 0, GET_UINT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 }, { "maxtab", 1006, "Number of tables (default 10, max 100)", - (uchar **)&g_opts.maxtab, (uchar **)&g_opts.maxtab, 0, + &g_opts.maxtab, &g_opts.maxtab, 0, GET_INT, REQUIRED_ARG, 10, 0, 0, 0, 0, 0 }, { "no-blobs", 1007, "Omit blob attributes (5.0: true)", - (uchar **)&g_opts.no_blobs, (uchar **)&g_opts.no_blobs, 0, + &g_opts.no_blobs, &g_opts.no_blobs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-implicit-nulls", 1008, "Insert must include all attrs" " i.e. no implicit NULLs", - (uchar **)&g_opts.no_implicit_nulls, (uchar **)&g_opts.no_implicit_nulls, 0, + &g_opts.no_implicit_nulls, &g_opts.no_implicit_nulls, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-missing-update", 1009, "Update must include all non-PK attrs", - (uchar **)&g_opts.no_missing_update, (uchar **)&g_opts.no_missing_update, 0, + &g_opts.no_missing_update, &g_opts.no_missing_update, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-multiops", 1010, "Allow only 1 operation per commit", - (uchar **)&g_opts.no_multiops, (uchar **)&g_opts.no_multiops, 0, + &g_opts.no_multiops, &g_opts.no_multiops, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-nulls", 1011, "Create no NULL values", - (uchar **)&g_opts.no_nulls, (uchar **)&g_opts.no_nulls, 0, + &g_opts.no_nulls, &g_opts.no_nulls, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "one-blob", 1012, "Only one blob attribute (default 2)", - (uchar **)&g_opts.one_blob, (uchar **)&g_opts.one_blob, 0, + &g_opts.one_blob, &g_opts.one_blob, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "opstring", 1013, "Operations to run e.g. idiucdc (c is commit) or" " iuuc:uudc (the : separates loops)", - (uchar **)&g_opts.opstring, (uchar **)&g_opts.opstring, 0, + &g_opts.opstring, &g_opts.opstring, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "seed", 1014, "Random seed (0=loop number, default -1=random)", - (uchar **)&g_opts.seed, (uchar **)&g_opts.seed, 0, + &g_opts.seed, &g_opts.seed, 0, GET_INT, REQUIRED_ARG, -1, 0, 0, 0, 0, 0 }, { "separate-events", 1015, "Do not combine events per GCI (5.0: true)", - (uchar **)&g_opts.separate_events, (uchar **)&g_opts.separate_events, 0, + &g_opts.separate_events, &g_opts.separate_events, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "tweak", 1016, "Whatever the source says", - (uchar **)&g_opts.tweak, (uchar **)&g_opts.tweak, 0, + &g_opts.tweak, &g_opts.tweak, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "use-table", 1017, "Use existing tables", - (uchar **)&g_opts.use_table, (uchar **)&g_opts.use_table, 0, + &g_opts.use_table, &g_opts.use_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, diff --git a/storage/ndb/test/ndbapi/test_event_multi_table.cpp b/storage/ndb/test/ndbapi/test_event_multi_table.cpp index 36fb6f511ae..7fbd43ef5eb 100644 --- a/storage/ndb/test/ndbapi/test_event_multi_table.cpp +++ b/storage/ndb/test/ndbapi/test_event_multi_table.cpp @@ -258,7 +258,7 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS(""), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/test/run-test/main.cpp b/storage/ndb/test/run-test/main.cpp index b5c4385f5d3..397eaf8b77e 100644 --- a/storage/ndb/test/run-test/main.cpp +++ b/storage/ndb/test/run-test/main.cpp @@ -77,60 +77,60 @@ my_bool opt_core; static struct my_option g_options[] = { { "help", '?', "Display this help and exit.", - (uchar **) &g_help, (uchar **) &g_help, + &g_help, &g_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "clusters", 256, "Cluster", - (uchar **) &g_clusters, (uchar **) &g_clusters, + &g_clusters, &g_clusters, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "replicate", 1024, "replicate", - (uchar **) &g_dummy, (uchar **) &g_dummy, + &g_dummy, &g_dummy, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "log-file", 256, "log-file", - (uchar **) &g_log_filename, (uchar **) &g_log_filename, + &g_log_filename, &g_log_filename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "testcase-file", 'f', "testcase-file", - (uchar **) &g_test_case_filename, (uchar **) &g_test_case_filename, + &g_test_case_filename, &g_test_case_filename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "report-file", 'r', "report-file", - (uchar **) &g_report_filename, (uchar **) &g_report_filename, + &g_report_filename, &g_report_filename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "basedir", 256, "Base path", - (uchar **) &g_basedir, (uchar **) &g_basedir, + &g_basedir, &g_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "baseport", 256, "Base port", - (uchar **) &g_baseport, (uchar **) &g_baseport, + &g_baseport, &g_baseport, 0, GET_INT, REQUIRED_ARG, g_baseport, 0, 0, 0, 0, 0}, { "prefix", 256, "mysql install dir", - (uchar **) &g_prefix, (uchar **) &g_prefix, + &g_prefix, &g_prefix, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "verbose", 'v', "Verbosity", - (uchar **) &g_verbosity, (uchar **) &g_verbosity, + &g_verbosity, &g_verbosity, 0, GET_INT, REQUIRED_ARG, g_verbosity, 0, 0, 0, 0, 0}, { "configure", 256, "configure", - (uchar **) &g_do_setup, (uchar **) &g_do_setup, + &g_do_setup, &g_do_setup, 0, GET_INT, REQUIRED_ARG, g_do_setup, 0, 0, 0, 0, 0 }, { "deploy", 256, "deploy", - (uchar **) &g_do_deploy, (uchar **) &g_do_deploy, + &g_do_deploy, &g_do_deploy, 0, GET_INT, REQUIRED_ARG, g_do_deploy, 0, 0, 0, 0, 0 }, { "sshx", 256, "sshx", - (uchar **) &g_do_sshx, (uchar **) &g_do_sshx, + &g_do_sshx, &g_do_sshx, 0, GET_INT, REQUIRED_ARG, g_do_sshx, 0, 0, 0, 0, 0 }, { "start", 256, "start", - (uchar **) &g_do_start, (uchar **) &g_do_start, + &g_do_start, &g_do_start, 0, GET_INT, REQUIRED_ARG, g_do_start, 0, 0, 0, 0, 0 }, { "fqpn", 256, "Fully qualified path-names ", - (uchar **) &g_fqpn, (uchar **) &g_fqpn, + &g_fqpn, &g_fqpn, 0, GET_INT, REQUIRED_ARG, g_fqpn, 0, 0, 0, 0, 0 }, { "default-ports", 256, "Use default ports when possible", - (uchar **) &g_default_ports, (uchar **) &g_default_ports, + &g_default_ports, &g_default_ports, 0, GET_INT, REQUIRED_ARG, g_default_ports, 0, 0, 0, 0, 0 }, { "mode", 256, "Mode 0=interactive 1=regression 2=bench", - (uchar **) &g_mode, (uchar **) &g_mode, + &g_mode, &g_mode, 0, GET_INT, REQUIRED_ARG, g_mode, 0, 0, 0, 0, 0 }, { "quit", 256, "Quit before starting tests", - (uchar **) &g_mode, (uchar **) &g_do_quit, + &g_mode, &g_do_quit, 0, GET_BOOL, NO_ARG, g_do_quit, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/test/src/NDBT_Test.cpp b/storage/ndb/test/src/NDBT_Test.cpp index 69f3723ca75..b7b830af23d 100644 --- a/storage/ndb/test/src/NDBT_Test.cpp +++ b/storage/ndb/test/src/NDBT_Test.cpp @@ -1195,35 +1195,35 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS(""), { "print", OPT_PRINT, "Print execution tree", - (uchar **) &opt_print, (uchar **) &opt_print, 0, + &opt_print, &opt_print, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_html", OPT_PRINT_HTML, "Print execution tree in html table format", - (uchar **) &opt_print_html, (uchar **) &opt_print_html, 0, + &opt_print_html, &opt_print_html, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_cases", OPT_PRINT_CASES, "Print list of test cases", - (uchar **) &opt_print_cases, (uchar **) &opt_print_cases, 0, + &opt_print_cases, &opt_print_cases, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "records", 'r', "Number of records", - (uchar **) &opt_records, (uchar **) &opt_records, 0, + &opt_records, &opt_records, 0, GET_INT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 }, { "loops", 'l', "Number of loops", - (uchar **) &opt_loops, (uchar **) &opt_loops, 0, + &opt_loops, &opt_loops, 0, GET_INT, REQUIRED_ARG, 5, 0, 0, 0, 0, 0 }, { "seed", 1024, "Random seed", - (uchar **) &opt_seed, (uchar **) &opt_seed, 0, + &opt_seed, &opt_seed, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "testname", 'n', "Name of test to run", - (uchar **) &opt_testname, (uchar **) &opt_testname, 0, + &opt_testname, &opt_testname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "remote_mgm", 'm', "host:port to mgmsrv of remote cluster", - (uchar **) &opt_remote_mgm, (uchar **) &opt_remote_mgm, 0, + &opt_remote_mgm, &opt_remote_mgm, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "timer", 't', "Print execution time", - (uchar **) &opt_timer, (uchar **) &opt_timer, 0, + &opt_timer, &opt_timer, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "verbose", 'v', "Print verbose status", - (uchar **) &opt_verbose, (uchar **) &opt_verbose, 0, + &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/test/tools/connect.cpp b/storage/ndb/test/tools/connect.cpp index 278dbe833ea..d12d1b7a608 100644 --- a/storage/ndb/test/tools/connect.cpp +++ b/storage/ndb/test/tools/connect.cpp @@ -31,14 +31,14 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "loop", 'l', "loops", - (gptr*) &_loop, (gptr*) &_loop, 0, + &_loop, &_loop, 0, GET_INT, REQUIRED_ARG, _loop, 0, 0, 0, 0, 0 }, { "sleep", 's', "Sleep (ms) between connection attempt", - (gptr*) &_sleep, (gptr*) &_sleep, 0, + &_sleep, &_sleep, 0, GET_INT, REQUIRED_ARG, _sleep, 0, 0, 0, 0, 0 }, { "drop", 'd', "Drop event operations before disconnect (0 = no, 1 = yes, else rand", - (gptr*) &_drop, (gptr*) &_drop, 0, + &_drop, &_drop, 0, GET_INT, REQUIRED_ARG, _drop, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/delete_all.cpp b/storage/ndb/tools/delete_all.cpp index 1bf89f5a32f..23d1ef387d2 100644 --- a/storage/ndb/tools/delete_all.cpp +++ b/storage/ndb/tools/delete_all.cpp @@ -36,16 +36,16 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (uchar**) &_dbname, (uchar**) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "transactional", 't', "Single transaction (may run out of operations)", - (uchar**) &_transactional, (uchar**) &_transactional, 0, + &_transactional, &_transactional, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "tupscan", 999, "Run tupscan", - (uchar**) &_tupscan, (uchar**) &_tupscan, 0, + &_tupscan, &_tupscan, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "diskscan", 999, "Run diskcan", - (uchar**) &_diskscan, (uchar**) &_diskscan, 0, + &_diskscan, &_diskscan, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/desc.cpp b/storage/ndb/tools/desc.cpp index 831005139de..f31b4f6ae1b 100644 --- a/storage/ndb/tools/desc.cpp +++ b/storage/ndb/tools/desc.cpp @@ -39,16 +39,16 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (uchar**) &_dbname, (uchar**) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "unqualified", 'u', "Use unqualified table names", - (uchar**) &_unqualified, (uchar**) &_unqualified, 0, + &_unqualified, &_unqualified, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "extra-partition-info", 'p', "Print more info per partition", - (uchar**) &_partinfo, (uchar**) &_partinfo, 0, + &_partinfo, &_partinfo, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "retries", 'r', "Retry every second for # retries", - (uchar**) &_retries, (uchar**) &_retries, 0, + &_retries, &_retries, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/drop_index.cpp b/storage/ndb/tools/drop_index.cpp index ec88f331a80..82dd595f7df 100644 --- a/storage/ndb/tools/drop_index.cpp +++ b/storage/ndb/tools/drop_index.cpp @@ -30,7 +30,7 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (uchar**) &_dbname, (uchar**) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/drop_tab.cpp b/storage/ndb/tools/drop_tab.cpp index 8d07afbbf50..1fba31b5c8a 100644 --- a/storage/ndb/tools/drop_tab.cpp +++ b/storage/ndb/tools/drop_tab.cpp @@ -30,7 +30,7 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (uchar**) &_dbname, (uchar**) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/listTables.cpp b/storage/ndb/tools/listTables.cpp index 45129cb34af..bd70587f77e 100644 --- a/storage/ndb/tools/listTables.cpp +++ b/storage/ndb/tools/listTables.cpp @@ -256,22 +256,22 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_show_tables"), { "database", 'd', "Name of database table is in", - (uchar**) &_dbname, (uchar**) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "loops", 'l', "loops", - (uchar**) &_loops, (uchar**) &_loops, 0, + &_loops, &_loops, 0, GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 }, { "type", 't', "type", - (uchar**) &_type, (uchar**) &_type, 0, + &_type, &_type, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "unqualified", 'u', "Use unqualified table names", - (uchar**) &_unqualified, (uchar**) &_unqualified, 0, + &_unqualified, &_unqualified, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "parsable", 'p', "Return output suitable for mysql LOAD DATA INFILE", - (uchar**) &_parsable, (uchar**) &_parsable, 0, + &_parsable, &_parsable, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "show-temp-status", OPT_SHOW_TMP_STATUS, "Show table temporary flag", - (uchar**) &show_temp_status, (uchar**) &show_temp_status, 0, + &show_temp_status, &show_temp_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/ndb_config.cpp b/storage/ndb/tools/ndb_config.cpp index af36103f947..0df88dc0167 100644 --- a/storage/ndb/tools/ndb_config.cpp +++ b/storage/ndb/tools/ndb_config.cpp @@ -58,37 +58,37 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_config"), { "nodes", 256, "Print nodes", - (uchar**) &g_nodes, (uchar**) &g_nodes, + &g_nodes, &g_nodes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { "connections", 256, "Print connections", - (uchar**) &g_connections, (uchar**) &g_connections, + &g_connections, &g_connections, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { "query", 'q', "Query option(s)", - (uchar**) &g_query, (uchar**) &g_query, + &g_query, &g_query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "host", 256, "Host", - (uchar**) &g_host, (uchar**) &g_host, + &g_host, &g_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "type", 258, "Type of node/connection", - (uchar**) &g_type, (uchar**) &g_type, + &g_type, &g_type, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "id", 258, "Nodeid", - (uchar**) &g_nodeid, (uchar**) &g_nodeid, + &g_nodeid, &g_nodeid, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "nodeid", 258, "Nodeid", - (uchar**) &g_nodeid, (uchar**) &g_nodeid, + &g_nodeid, &g_nodeid, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "fields", 'f', "Field separator", - (uchar**) &g_field_delimiter, (uchar**) &g_field_delimiter, + &g_field_delimiter, &g_field_delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "rows", 'r', "Row separator", - (uchar**) &g_row_delimiter, (uchar**) &g_row_delimiter, + &g_row_delimiter, &g_row_delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "config-file", 256, "Path to config.ini", - (uchar**) &g_config_file, (uchar**) &g_config_file, + &g_config_file, &g_config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "mycnf", 256, "Read config from my.cnf", - (uchar**) &g_mycnf, (uchar**) &g_mycnf, + &g_mycnf, &g_mycnf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp index 7db77524ad8..966c539cee9 100644 --- a/storage/ndb/tools/restore/restore_main.cpp +++ b/storage/ndb/tools/restore/restore_main.cpp @@ -100,99 +100,99 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_restore"), { "connect", 'c', "same as --connect-string", - (uchar**) &opt_connect_str, (uchar**) &opt_connect_str, 0, + &opt_connect_str, &opt_connect_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "nodeid", 'n', "Backup files from node with id", - (uchar**) &ga_nodeId, (uchar**) &ga_nodeId, 0, + &ga_nodeId, &ga_nodeId, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "backupid", 'b', "Backup id", - (uchar**) &ga_backupId, (uchar**) &ga_backupId, 0, + &ga_backupId, &ga_backupId, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "restore_data", 'r', "Restore table data/logs into NDB Cluster using NDBAPI", - (uchar**) &_restore_data, (uchar**) &_restore_data, 0, + &_restore_data, &_restore_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "restore_meta", 'm', "Restore meta data into NDB Cluster using NDBAPI", - (uchar**) &_restore_meta, (uchar**) &_restore_meta, 0, + &_restore_meta, &_restore_meta, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-upgrade", 'u', "Don't upgrade array type for var attributes, which don't resize VAR data and don't change column attributes", - (uchar**) &ga_no_upgrade, (uchar**) &ga_no_upgrade, 0, + &ga_no_upgrade, &ga_no_upgrade, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-restore-disk-objects", 'd', "Dont restore disk objects (tablespace/logfilegroups etc)", - (uchar**) &_no_restore_disk, (uchar**) &_no_restore_disk, 0, + &_no_restore_disk, &_no_restore_disk, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "restore_epoch", 'e', "Restore epoch info into the status table. Convenient on a MySQL Cluster " "replication slave, for starting replication. The row in " NDB_REP_DB "." NDB_APPLY_TABLE " with id 0 will be updated/inserted.", - (uchar**) &ga_restore_epoch, (uchar**) &ga_restore_epoch, 0, + &ga_restore_epoch, &ga_restore_epoch, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "skip-table-check", 's', "Skip table structure check during restore of data", - (uchar**) &ga_skip_table_check, (uchar**) &ga_skip_table_check, 0, + &ga_skip_table_check, &ga_skip_table_check, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "parallelism", 'p', "No of parallel transactions during restore of data." "(parallelism can be 1 to 1024)", - (uchar**) &ga_nParallelism, (uchar**) &ga_nParallelism, 0, + &ga_nParallelism, &ga_nParallelism, 0, GET_INT, REQUIRED_ARG, 128, 1, 1024, 0, 1, 0 }, { "print", OPT_PRINT, "Print metadata, data and log to stdout", - (uchar**) &_print, (uchar**) &_print, 0, + &_print, &_print, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_data", OPT_PRINT_DATA, "Print data to stdout", - (uchar**) &_print_data, (uchar**) &_print_data, 0, + &_print_data, &_print_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_meta", OPT_PRINT_META, "Print meta data to stdout", - (uchar**) &_print_meta, (uchar**) &_print_meta, 0, + &_print_meta, &_print_meta, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_log", OPT_PRINT_LOG, "Print log to stdout", - (uchar**) &_print_log, (uchar**) &_print_log, 0, + &_print_log, &_print_log, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "backup_path", OPT_BACKUP_PATH, "Path to backup files", - (uchar**) &ga_backupPath, (uchar**) &ga_backupPath, 0, + &ga_backupPath, &ga_backupPath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "dont_ignore_systab_0", 'f', "Experimental. Do not ignore system table during restore.", - (uchar**) &ga_dont_ignore_systab_0, (uchar**) &ga_dont_ignore_systab_0, 0, + &ga_dont_ignore_systab_0, &ga_dont_ignore_systab_0, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "ndb-nodegroup-map", OPT_NDB_NODEGROUP_MAP, "Nodegroup map for ndbcluster. Syntax: list of (source_ng, dest_ng)", - (uchar**) &opt_nodegroup_map_str, - (uchar**) &opt_nodegroup_map_str, + &opt_nodegroup_map_str, + &opt_nodegroup_map_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "fields-enclosed-by", OPT_FIELDS_ENCLOSED_BY, "Fields are enclosed by ...", - (uchar**) &opt_fields_enclosed_by, (uchar**) &opt_fields_enclosed_by, 0, + &opt_fields_enclosed_by, &opt_fields_enclosed_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "fields-terminated-by", OPT_FIELDS_TERMINATED_BY, "Fields are terminated by ...", - (uchar**) &opt_fields_terminated_by, - (uchar**) &opt_fields_terminated_by, 0, + &opt_fields_terminated_by, + &opt_fields_terminated_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "fields-optionally-enclosed-by", OPT_FIELDS_OPTIONALLY_ENCLOSED_BY, "Fields are optionally enclosed by ...", - (uchar**) &opt_fields_optionally_enclosed_by, - (uchar**) &opt_fields_optionally_enclosed_by, 0, + &opt_fields_optionally_enclosed_by, + &opt_fields_optionally_enclosed_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "hex", OPT_HEX_FORMAT, "print binary types in hex format", - (uchar**) &opt_hex_format, (uchar**) &opt_hex_format, 0, + &opt_hex_format, &opt_hex_format, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "tab", 'T', "Creates tab separated textfile for each table to " "given path. (creates .txt files)", - (uchar**) &tab_path, (uchar**) &tab_path, 0, + &tab_path, &tab_path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "append", OPT_APPEND, "for --tab append data to file", - (uchar**) &opt_append, (uchar**) &opt_append, 0, + &opt_append, &opt_append, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "lines-terminated-by", OPT_LINES_TERMINATED_BY, "", - (uchar**) &opt_lines_terminated_by, (uchar**) &opt_lines_terminated_by, 0, + &opt_lines_terminated_by, &opt_lines_terminated_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "verbose", OPT_VERBOSE, "verbosity", - (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, + &opt_verbose, &opt_verbose, 0, GET_INT, REQUIRED_ARG, 1, 0, 255, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/select_all.cpp b/storage/ndb/tools/select_all.cpp index 23d5f95f3f7..95dfeab9eed 100644 --- a/storage/ndb/tools/select_all.cpp +++ b/storage/ndb/tools/select_all.cpp @@ -54,43 +54,43 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (uchar**) &_dbname, (uchar**) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "parallelism", 'p', "parallelism", - (uchar**) &_parallelism, (uchar**) &_parallelism, 0, + &_parallelism, &_parallelism, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", - (uchar**) &_lock, (uchar**) &_lock, 0, + &_lock, &_lock, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "order", 'o', "Sort resultset according to index", - (uchar**) &_order, (uchar**) &_order, 0, + &_order, &_order, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "descending", 'z', "Sort descending (requires order flag)", - (uchar**) &_descending, (uchar**) &_descending, 0, + &_descending, &_descending, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "header", 'h', "Print header", - (uchar**) &_header, (uchar**) &_header, 0, + &_header, &_header, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, { "useHexFormat", 'x', "Output numbers in hexadecimal format", - (uchar**) &_useHexFormat, (uchar**) &_useHexFormat, 0, + &_useHexFormat, &_useHexFormat, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "delimiter", 'D', "Column delimiter", - (uchar**) &_delimiter, (uchar**) &_delimiter, 0, + &_delimiter, &_delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "disk", 256, "Dump disk ref", - (uchar**) &_dumpDisk, (uchar**) &_dumpDisk, 0, + &_dumpDisk, &_dumpDisk, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "rowid", 256, "Dump rowid", - (uchar**) &use_rowid, (uchar**) &use_rowid, 0, + &use_rowid, &use_rowid, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "gci", 256, "Dump gci", - (uchar**) &use_gci, (uchar**) &use_gci, 0, + &use_gci, &use_gci, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "tupscan", 't', "Scan in tup order", - (uchar**) &_tup, (uchar**) &_tup, 0, + &_tup, &_tup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nodata", 256, "Dont print data", - (uchar**) &nodata, (uchar**) &nodata, 0, + &nodata, &nodata, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/select_count.cpp b/storage/ndb/tools/select_count.cpp index 73982e886b5..6bdc682c16a 100644 --- a/storage/ndb/tools/select_count.cpp +++ b/storage/ndb/tools/select_count.cpp @@ -43,13 +43,13 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (uchar**) &_dbname, (uchar**) &_dbname, 0, + &_dbname, &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "parallelism", 'p', "parallelism", - (uchar**) &_parallelism, (uchar**) &_parallelism, 0, + &_parallelism, &_parallelism, 0, GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 }, { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", - (uchar**) &_lock, (uchar**) &_lock, 0, + &_lock, &_lock, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/waiter.cpp b/storage/ndb/tools/waiter.cpp index fc2a4b368b1..26c86e6d196 100644 --- a/storage/ndb/tools/waiter.cpp +++ b/storage/ndb/tools/waiter.cpp @@ -44,17 +44,17 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "no-contact", 'n', "Wait for cluster no contact", - (uchar**) &_no_contact, (uchar**) &_no_contact, 0, + &_no_contact, &_no_contact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "not-started", OPT_WAIT_STATUS_NOT_STARTED, "Wait for cluster not started", - (uchar**) &_not_started, (uchar**) &_not_started, 0, + &_not_started, &_not_started, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "single-user", OPT_WAIT_STATUS_SINGLE_USER, "Wait for cluster to enter single user mode", - (uchar**) &_single_user, (uchar**) &_single_user, 0, + &_single_user, &_single_user, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "timeout", 't', "Timeout to wait in seconds", - (uchar**) &_timeout, (uchar**) &_timeout, 0, + &_timeout, &_timeout, 0, GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/perfschema/pfs_events_waits.cc b/storage/perfschema/pfs_events_waits.cc index aae8f9dc8c1..e32a77512cc 100644 --- a/storage/perfschema/pfs_events_waits.cc +++ b/storage/perfschema/pfs_events_waits.cc @@ -39,7 +39,6 @@ bool flag_events_waits_summary_by_thread_by_event_name= true; bool flag_events_waits_summary_by_event_name= true; /** Consumer flag for table EVENTS_WAITS_SUMMARY_BY_INSTANCE. */ bool flag_events_waits_summary_by_instance= true; -bool flag_events_locks_summary_by_thread_by_event_name= true; bool flag_events_locks_summary_by_event_name= true; bool flag_events_locks_summary_by_instance= true; /** Consumer flag for table FILE_SUMMARY_BY_EVENT_NAME. */ @@ -96,9 +95,8 @@ static void copy_events_waits(PFS_events_waits *dest, /* Signal readers they are about to read garbage ... */ dest->m_wait_class= NO_WAIT_CLASS; /* ... that this can generate. */ - memcpy_fixed(dest_body, - source_body, - sizeof(PFS_events_waits) - sizeof(events_waits_class)); + memcpy(dest_body, source_body, + sizeof(PFS_events_waits) - sizeof(events_waits_class)); /* Signal readers the record is now clean again. */ dest->m_wait_class= source->m_wait_class; } diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index abc03302b64..e1e14f20218 100644 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -15,15 +15,19 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -SET(STRINGS_SOURCES bchange.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c +SET(STRINGS_SOURCES bchange.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c ctype-czech.c ctype-euc_kr.c ctype-eucjpms.c ctype-extra.c ctype-gb2312.c ctype-gbk.c ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c dtoa.c int2str.c - is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c r_strinstr.c + is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c - strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c - my_strchr.c strcont.c strinstr.c strnlen.c strappend.c) + strxmov.c strxnmov.c xml.c + my_strchr.c strcont.c strappend.c) +IF(NOT HAVE_STRNLEN) + # OSX does not have strnlen + SET(STRINGS_SOURCES ${STRINGS_SOURCES} strnlen.c) +ENDIF() # Avoid dependencies on perschema data defined in mysys ADD_DEFINITIONS(-DDISABLE_MYSQL_THREAD_H) ADD_CONVENIENCE_LIBRARY(strings ${STRINGS_SOURCES}) diff --git a/strings/Makefile.am b/strings/Makefile.am index fd884a1296a..3a051e38899 100644 --- a/strings/Makefile.am +++ b/strings/Makefile.am @@ -30,20 +30,13 @@ pkglib_LIBRARIES = libmystrings.a # Exact one of ASSEMBLER_X if ASSEMBLER_x86 ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s -CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c dtoa.c strmov.c -else -if ASSEMBLER_sparc32 -# These file MUST all be on the same line!! Otherwise automake -# generats a very broken makefile -ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s -CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c strmov.c +CSRCS = bfill.c bmove.c bchange.c strxnmov.c int2str.c str2int.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c dtoa.c strmov.c else #no assembler ASRCS = # These file MUST all be on the same line!! Otherwise automake # generats a very broken makefile -CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c -endif +CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bchange.c strxnmov.c int2str.c str2int.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c endif libmystrings_a_SOURCES = $(ASRCS) $(CSRCS) @@ -57,11 +50,8 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc longlong2str.c longlong2str-x86.s longlong2str_asm.c \ my_strtoll10.c my_strtoll10-x86.s \ strxmov.c bmove_upp.c strappend.c strcont.c strend.c \ - strfill.c strcend.c is_prefix.c strstr.c strinstr.c \ + strfill.c strcend.c is_prefix.c strstr.c \ strmake.c strnmov.c strmov.c strnlen.c \ - bmove_upp-sparc.s strappend-sparc.s strend-sparc.s \ - strinstr-sparc.s strmake-sparc.s strmov-sparc.s \ - strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \ t_ctype.h my_strchr.c CMakeLists.txt \ CHARSET_INFO.txt diff --git a/strings/bfill.c b/strings/bfill.c index 2750553f48a..ccc063f59e3 100644 --- a/strings/bfill.c +++ b/strings/bfill.c @@ -23,10 +23,6 @@ bfill(dst, len, fill) moves "len" fill characters to "dst". Thus to set a buffer to 80 spaces, do bfill(buff, 80, ' '). - - Note: the "b" routines are there to exploit certain VAX order codes, - but the MOVC5 instruction will only move 65535 characters. The asm - code is presented for your interest and amusement. */ #include <my_global.h> @@ -34,58 +30,6 @@ #if !defined(bfill) && !defined(HAVE_BFILL) -#if VaxAsm - -void bfill(dst, len, fill) -char *dst; -uint len; -int fill; /* actually char */ -{ - asm("movc5 $0,*4(ap),12(ap),8(ap),*4(ap)"); -} - -#elif defined(MC68000) && defined(DS90) - -void bfill(dst, len,fill) /* Optimized with long-fill */ -char *dst; -uint len; -pchar fill; -{ -asm(" movl 8.(a7),d1 "); -asm(" jeq .L9 "); -asm(" movl 4.(a7),a0 "); -asm(" moveq #0,d0 "); -asm(" movb 15.(a7),d0 "); -asm(" movl d2,a1 "); -asm(" movw d0,d2 "); -asm(" aslw #8,d0 "); -asm(" orw d2,d0 "); -asm(" movl d0,d2 "); -asm(" swap d0 "); -asm(" orl d2,d0 "); -asm(" movl a0,d2 "); -asm(" btst #0,d2 "); -asm(" jeq .L1 "); -asm(" movb d0,(a0)+ "); -asm(" subql #1,d1 "); -asm(".L1: movl d1,d2 "); -asm(" lsrl #2,d2 "); -asm(" jcc .L2 "); -asm(" movw d0,(a0)+ "); -asm(" jra .L2 "); -asm(".L3: movl d0,(a0)+ "); -asm(".L2: dbra d2,.L3 "); -asm(" addqw #1,d2 "); -asm(" subql #1,d2 "); -asm(" jcc .L3 "); -asm(" andl #1,d1 "); -asm(" jeq .L8 "); -asm(" movb d0,(a0) "); -asm(".L8: movl a1,d2 "); -asm(".L9: rts "); -} -#else - void bfill(dst, len, fill) register byte *dst; register uint len; @@ -95,4 +39,3 @@ register pchar fill; } #endif -#endif diff --git a/strings/bmove.c b/strings/bmove.c index ae9641a5d58..0aa825558ca 100644 --- a/strings/bmove.c +++ b/strings/bmove.c @@ -30,10 +30,6 @@ has its first two arguments the other way around you may find this a bit easier to get right. No value is returned. - - Note: the "b" routines are there to exploit certain VAX order codes, - but the MOVC3 instruction will only move 65535 characters. The asm - code is presented for your interest and amusement. */ #include <my_global.h> @@ -41,33 +37,6 @@ #if !defined(HAVE_BMOVE) && !defined(bmove) -#if VaxAsm - -void bmove(dst, src, len) - char *dst, *src; - uint len; - { - asm("movc3 12(ap),*8(ap),*4(ap)"); - } - -#else -#if defined(MC68000) && defined(DS90) - -void bmove(dst, src, len) -char *dst,*src; -uint len; /* 0 <= len <= 65535 */ -{ -asm(" movl 12(a7),d0 "); -asm(" subql #1,d0 "); -asm(" blt .L5 "); -asm(" movl 4(a7),a1 "); -asm(" movl 8(a7),a0 "); -asm(".L4: movb (a0)+,(a1)+ "); -asm(" dbf d0,.L4 "); -asm(".L5: "); -} -#else - void bmove(dst, src, len) register char *dst; register const char *src; @@ -75,6 +44,5 @@ register uint len; { while (len-- != 0) *dst++ = *src++; } -#endif -#endif + #endif diff --git a/strings/bmove512.c b/strings/bmove512.c deleted file mode 100644 index c3f0446ead6..00000000000 --- a/strings/bmove512.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* File : bmove512.c - Author : Michael Widenius; - Defines: bmove512() - - bmove512(dst, src, len) moves exactly "len" bytes from the source "src" - to the destination "dst". "src" and "dst" must be alligned on long - boundory and len must be a mutliple of 512 byte. If len is not a - multiple of 512 byte len/512*512+1 bytes is copyed. - bmove512 is moustly used to copy IO_BLOCKS. bmove512 should be the - fastest way to move a mutiple of 512 byte. -*/ - -#include <my_global.h> -#include "m_string.h" - -#ifndef bmove512 - -#ifdef HAVE_LONG_LONG -#define LONG ulonglong -#else -#define LONG ulonglong -#endif - -void bmove512(uchar *to, const uchar *from, register size_t length) -{ - reg1 LONG *f,*t,*end= (LONG*) ((char*) from+length); - - f= (LONG*) from; - t= (LONG*) to; - -#if defined(m88k) || defined(sparc) || defined(HAVE_LONG_LONG) - do { - t[0]=f[0]; t[1]=f[1]; t[2]=f[2]; t[3]=f[3]; - t[4]=f[4]; t[5]=f[5]; t[6]=f[6]; t[7]=f[7]; - t[8]=f[8]; t[9]=f[9]; t[10]=f[10]; t[11]=f[11]; - t[12]=f[12]; t[13]=f[13]; t[14]=f[14]; t[15]=f[15]; - t[16]=f[16]; t[17]=f[17]; t[18]=f[18]; t[19]=f[19]; - t[20]=f[20]; t[21]=f[21]; t[22]=f[22]; t[23]=f[23]; - t[24]=f[24]; t[25]=f[25]; t[26]=f[26]; t[27]=f[27]; - t[28]=f[28]; t[29]=f[29]; t[30]=f[30]; t[31]=f[31]; - t[32]=f[32]; t[33]=f[33]; t[34]=f[34]; t[35]=f[35]; - t[36]=f[36]; t[37]=f[37]; t[38]=f[38]; t[39]=f[39]; - t[40]=f[40]; t[41]=f[41]; t[42]=f[42]; t[43]=f[43]; - t[44]=f[44]; t[45]=f[45]; t[46]=f[46]; t[47]=f[47]; - t[48]=f[48]; t[49]=f[49]; t[50]=f[50]; t[51]=f[51]; - t[52]=f[52]; t[53]=f[53]; t[54]=f[54]; t[55]=f[55]; - t[56]=f[56]; t[57]=f[57]; t[58]=f[58]; t[59]=f[59]; - t[60]=f[60]; t[61]=f[61]; t[62]=f[62]; t[63]=f[63]; -#ifdef HAVE_LONG_LONG - t+=64; f+=64; -#else - t[64]=f[64]; t[65]=f[65]; t[66]=f[66]; t[67]=f[67]; - t[68]=f[68]; t[69]=f[69]; t[70]=f[70]; t[71]=f[71]; - t[72]=f[72]; t[73]=f[73]; t[74]=f[74]; t[75]=f[75]; - t[76]=f[76]; t[77]=f[77]; t[78]=f[78]; t[79]=f[79]; - t[80]=f[80]; t[81]=f[81]; t[82]=f[82]; t[83]=f[83]; - t[84]=f[84]; t[85]=f[85]; t[86]=f[86]; t[87]=f[87]; - t[88]=f[88]; t[89]=f[89]; t[90]=f[90]; t[91]=f[91]; - t[92]=f[92]; t[93]=f[93]; t[94]=f[94]; t[95]=f[95]; - t[96]=f[96]; t[97]=f[97]; t[98]=f[98]; t[99]=f[99]; - t[100]=f[100]; t[101]=f[101]; t[102]=f[102]; t[103]=f[103]; - t[104]=f[104]; t[105]=f[105]; t[106]=f[106]; t[107]=f[107]; - t[108]=f[108]; t[109]=f[109]; t[110]=f[110]; t[111]=f[111]; - t[112]=f[112]; t[113]=f[113]; t[114]=f[114]; t[115]=f[115]; - t[116]=f[116]; t[117]=f[117]; t[118]=f[118]; t[119]=f[119]; - t[120]=f[120]; t[121]=f[121]; t[122]=f[122]; t[123]=f[123]; - t[124]=f[124]; t[125]=f[125]; t[126]=f[126]; t[127]=f[127]; - t+=128; f+=128; -#endif - } while (f < end); -#else - do { - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - *t++ = *f++; *t++ = *f++; *t++ = *f++; *t++ = *f++; - } while (f < end); -#endif - return; -} /* bmove512 */ - -#endif /* bmove512 */ diff --git a/strings/bmove_upp-sparc.s b/strings/bmove_upp-sparc.s deleted file mode 100644 index f745f0fc613..00000000000 --- a/strings/bmove_upp-sparc.s +++ /dev/null @@ -1,40 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "bmove_upp-sparc.s" -.section ".text" - .align 4 - .global bmove_upp - .type bmove_upp,#function - .proc 020 -bmove_upp: - subcc %o2, 1, %o2 ! o2= len - bcs .end - nop -.loop: - sub %o1, 1, %o1 - ldub [%o1], %o3 - sub %o0, 1, %o0 - subcc %o2, 1, %o2 - bcc .loop - stb %o3, [%o0] -.end: - retl - nop -.bmove_upp_end: - .size bmove_upp,.bmove_upp_end-bmove_upp - .ident "Matt Wagner & Monty" diff --git a/strings/bmove_upp.c b/strings/bmove_upp.c index fb47bda2d1d..05e786837f4 100644 --- a/strings/bmove_upp.c +++ b/strings/bmove_upp.c @@ -25,26 +25,8 @@ #include <my_global.h> #include "m_string.h" -#if defined(MC68000) && defined(DS90) - -/* 0 <= len <= 65535 */ -void bmove_upp(byte *dst, const byte *src,uint len) -{ -asm(" movl 12(a7),d0 "); -asm(" subql #1,d0 "); -asm(" blt .L5 "); -asm(" movl 4(a7),a1 "); -asm(" movl 8(a7),a0 "); -asm(".L4: movb -(a0),-(a1) "); -asm(" dbf d0,.L4 "); -asm(".L5: "); -} -#else - void bmove_upp(register uchar *dst, register const uchar *src, register size_t len) { while (len-- != 0) *--dst = *--src; } - -#endif diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index f5221bb3a21..3007d76a5a4 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -994,86 +994,6 @@ static int my_strxfrm_big5(uchar *dest, const uchar *src, int len) #endif -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((char) 255) - -static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str, char *max_str, - size_t *min_length, size_t *max_length) -{ - const char *end= ptr + ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - size_t charlen= res_length / cs->mbmaxlen; - - for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) - { - if (ptr+1 != end && isbig5code(ptr[0],ptr[1])) - { - *min_str++= *max_str++ = *ptr++; - *min_str++= *max_str++ = *ptr; - continue; - } - if (*ptr == escape && ptr+1 != end) - { - ptr++; /* Skip escape */ - if (isbig5code(ptr[0], ptr[1])) - *min_str++= *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++= *max_str++= *ptr; - continue; - } - if (*ptr == w_one) /* '_' in SQL */ - { - *min_str++='\0'; /* This should be min char */ - *max_str++=max_sort_char; - continue; - } - if (*ptr == w_many) /* '%' in SQL */ - { - /* - Calculate length of keys: - 'a\0\0... is the smallest possible string when we have space expand - a\ff\ff... is the biggest possible string - */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : - res_length); - *max_length= res_length; - do { - *min_str++ = 0; - *max_str++ = max_sort_char; - } while (min_str != min_end); - return 0; - } - *min_str++= *max_str++ = *ptr; - } - - *min_length= *max_length= (size_t) (min_str-min_org); - while (min_str != min_end) - *min_str++= *max_str++= ' '; - return 0; -} - - static uint ismbchar_big5(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { @@ -6955,7 +6875,7 @@ static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler = my_strnncollsp_big5, my_strnxfrm_big5, my_strnxfrmlen_simple, - my_like_range_big5, + my_like_range_mb, my_wildcmp_mb, my_strcasecmp_mb, my_instr_mb, @@ -7019,7 +6939,7 @@ CHARSET_INFO my_charset_big5_chinese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF9D5, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_big5_handler, @@ -7052,7 +6972,7 @@ CHARSET_INFO my_charset_big5_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF9FE, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_big5_handler, diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 67555ac4384..df4083c9f8d 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -1812,77 +1812,6 @@ static size_t my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), } -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((char) 255) - -static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str,char *max_str, - size_t *min_length, size_t *max_length) -{ - const char *end=ptr+ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - - while (ptr < end && min_str < min_end) { - if (ismbchar_cp932(cs, ptr, end)) { - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == escape && ptr+1 < end) { - ptr++; /* Skip escape */ - if (ismbchar_cp932(cs, ptr, end)) - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == w_one) { /* '_' in SQL */ - *min_str++ = '\0'; /* This should be min char */ - *max_str++ = max_sort_char; - ptr++; - continue; - } - if (*ptr == w_many) - { /* '%' in SQL */ - *min_length = (size_t)(min_str - min_org); - *max_length = res_length; - do - { - *min_str++= 0; - *max_str++= max_sort_char; - } while (min_str < min_end); - return 0; - } - *min_str++ = *max_str++ = *ptr++; - } - *min_length = *max_length = (size_t) (min_str - min_org); - while (min_str < min_end) - *min_str++ = *max_str++ = ' '; /* Because if key compression */ - return 0; -} - - static uint16 cp932_to_unicode[65536]= { 0x0000, 0x0001, 0x0002, 0x0003, /* 0000 */ @@ -34852,7 +34781,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_cp932, my_strnxfrm_cp932, my_strnxfrmlen_simple, - my_like_range_cp932, + my_like_range_mb, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, my_instr_mb, @@ -34918,7 +34847,7 @@ CHARSET_INFO my_charset_cp932_japanese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -34950,7 +34879,7 @@ CHARSET_INFO my_charset_cp932_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index c2067ac6f6b..7329f9ec09a 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -10029,7 +10029,7 @@ CHARSET_INFO my_charset_euckr_korean_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -10062,7 +10062,7 @@ CHARSET_INFO my_charset_euckr_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 25c15a08d4e..6180e0e1a7a 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -67573,7 +67573,7 @@ CHARSET_INFO my_charset_eucjpms_japanese_ci= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad_char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -67606,7 +67606,7 @@ CHARSET_INFO my_charset_eucjpms_bin= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad_char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 46f3e9c6da5..b1acd643df3 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -6432,7 +6432,7 @@ CHARSET_INFO my_charset_gb2312_chinese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF7FE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -6464,7 +6464,7 @@ CHARSET_INFO my_charset_gb2312_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF7FE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 609bc2ecd27..547c8821229 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -3548,86 +3548,6 @@ static size_t my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), } -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((uchar) 255) - -static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str,char *max_str, - size_t *min_length,size_t *max_length) -{ - const char *end= ptr + ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - size_t charlen= res_length / cs->mbmaxlen; - - for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) - { - if (ptr+1 != end && isgbkcode(ptr[0],ptr[1])) - { - *min_str++= *max_str++ = *ptr++; - *min_str++= *max_str++ = *ptr; - continue; - } - if (*ptr == escape && ptr+1 != end) - { - ptr++; /* Skip escape */ - if (isgbkcode(ptr[0], ptr[1])) - *min_str++= *max_str++ = *ptr; - if (min_str < min_end) - *min_str++= *max_str++= *ptr; - continue; - } - if (*ptr == w_one) /* '_' in SQL */ - { - *min_str++='\0'; /* This should be min char */ - *max_str++=max_sort_char; - continue; - } - if (*ptr == w_many) /* '%' in SQL */ - { - /* - Calculate length of keys: - 'a\0\0... is the smallest possible string when we have space expand - a\ff\ff... is the biggest possible string - */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : - res_length); - *max_length= res_length; - do { - *min_str++= 0; - *max_str++= max_sort_char; - } while (min_str != min_end); - return 0; - } - *min_str++= *max_str++ = *ptr; - } - - *min_length= *max_length = (size_t) (min_str - min_org); - while (min_str != min_end) - *min_str++= *max_str++= ' '; /* Because if key compression */ - return 0; -} - - static uint ismbchar_gbk(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { @@ -10841,7 +10761,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_gbk, my_strnxfrm_gbk, my_strnxfrmlen_simple, - my_like_range_gbk, + my_like_range_mb, my_wildcmp_mb, my_strcasecmp_mb, my_instr_mb, @@ -10906,7 +10826,7 @@ CHARSET_INFO my_charset_gbk_chinese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xA967, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -10938,7 +10858,7 @@ CHARSET_INFO my_charset_gbk_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index b1b381da59e..b2f2e3cd22e 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -604,7 +604,9 @@ my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), DESCRIPTION Write max key: - for non-Unicode character sets: - just set to 255. + just bfill using max_sort_char if max_sort_char is one byte. + In case when max_sort_char is two bytes, fill with double-byte pairs + and optionally pad with a single space character. - for Unicode character set (utf-8): create a buffer with multibyte representation of the max_sort_char character, and copy it into max_str in a loop. @@ -616,12 +618,20 @@ static void pad_max_char(CHARSET_INFO *cs, char *str, char *end) if (!(cs->state & MY_CS_UNICODE)) { - bfill(str, end - str, 255); - return; + if (cs->max_sort_char <= 255) + { + bfill(str, end - str, cs->max_sort_char); + return; + } + buf[0]= cs->max_sort_char >> 8; + buf[1]= cs->max_sort_char & 0xFF; + buflen= 2; + } + else + { + buflen= cs->cset->wc_mb(cs, cs->max_sort_char, (uchar*) buf, + (uchar*) buf + sizeof(buf)); } - - buflen= cs->cset->wc_mb(cs, cs->max_sort_char, (uchar*) buf, - (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); do diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 8a3d3d7425c..2e5f78a30bf 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -335,10 +335,6 @@ long my_strntol_8bit(CHARSET_INFO *cs, int overflow; *err= 0; /* Initialize error indicator */ -#ifdef NOT_USED - if (base < 0 || base == 1 || base > 36) - base = 10; -#endif s = nptr; e = nptr+l; @@ -364,29 +360,6 @@ long my_strntol_8bit(CHARSET_INFO *cs, else negative = 0; -#ifdef NOT_USED - if (base == 16 && s[0] == '0' && (s[1]=='X' || s[1]=='x')) - s += 2; -#endif - -#ifdef NOT_USED - if (base == 0) - { - if (*s == '0') - { - if (s[1]=='X' || s[1]=='x') - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; - } -#endif - save = s; cutoff = ((uint32)~0L) / (uint32) base; cutlim = (uint) (((uint32)~0L) % (uint32) base); @@ -458,10 +431,6 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, int overflow; *err= 0; /* Initialize error indicator */ -#ifdef NOT_USED - if (base < 0 || base == 1 || base > 36) - base = 10; -#endif s = nptr; e = nptr+l; @@ -486,29 +455,6 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, else negative = 0; -#ifdef NOT_USED - if (base == 16 && s[0] == '0' && (s[1]=='X' || s[1]=='x')) - s += 2; -#endif - -#ifdef NOT_USED - if (base == 0) - { - if (*s == '0') - { - if (s[1]=='X' || s[1]=='x') - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; - } -#endif - save = s; cutoff = ((uint32)~0L) / (uint32) base; cutlim = (uint) (((uint32)~0L) % (uint32) base); @@ -571,10 +517,6 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), int overflow; *err= 0; /* Initialize error indicator */ -#ifdef NOT_USED - if (base < 0 || base == 1 || base > 36) - base = 10; -#endif s = nptr; e = nptr+l; @@ -599,29 +541,6 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), else negative = 0; -#ifdef NOT_USED - if (base == 16 && s[0] == '0' && (s[1]=='X'|| s[1]=='x')) - s += 2; -#endif - -#ifdef NOT_USED - if (base == 0) - { - if (*s == '0') - { - if (s[1]=='X' || s[1]=='x') - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; - } -#endif - save = s; cutoff = (~(ulonglong) 0) / (unsigned long int) base; @@ -694,10 +613,6 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs, int overflow; *err= 0; /* Initialize error indicator */ -#ifdef NOT_USED - if (base < 0 || base == 1 || base > 36) - base = 10; -#endif s = nptr; e = nptr+l; @@ -722,29 +637,6 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs, else negative = 0; -#ifdef NOT_USED - if (base == 16 && s[0] == '0' && (s[1]=='X' || s[1]=='x')) - s += 2; -#endif - -#ifdef NOT_USED - if (base == 0) - { - if (*s == '0') - { - if (s[1]=='X' || s[1]=='x') - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; - } -#endif - save = s; cutoff = (~(ulonglong) 0) / (unsigned long int) base; diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 90c76dc3c79..91adf4ebddf 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -1179,86 +1179,6 @@ static size_t my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), } -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((char) 255) - -static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str,char *max_str, - size_t *min_length,size_t *max_length) -{ - const char *end= ptr + ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - size_t charlen= res_length / cs->mbmaxlen; - - for ( ; ptr < end && min_str < min_end && charlen > 0 ; charlen--) - { - if (ismbchar_sjis(cs, ptr, end)) { - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == escape && ptr+1 < end) { - ptr++; /* Skip escape */ - if (ismbchar_sjis(cs, ptr, end)) - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == w_one) { /* '_' in SQL */ - *min_str++ = '\0'; /* This should be min char */ - *max_str++ = max_sort_char; - ptr++; - continue; - } - if (*ptr == w_many) - { /* '%' in SQL */ - /* - Calculate length of keys: - 'a\0\0... is the smallest possible string when we have space expand - a\ff\ff... is the biggest possible string - */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : - res_length); - *max_length= res_length; - do - { - *min_str++= 0; - *max_str++= max_sort_char; - } while (min_str < min_end); - return 0; - } - *min_str++ = *max_str++ = *ptr++; - } - - *min_length= *max_length= (size_t) (min_str - min_org); - while (min_str != min_end) - *min_str++= *max_str++= ' '; /* Because if key compression */ - return 0; -} - - /* SJIS->Unicode conversion table */ static uint16 sjis_to_unicode[65536]= { @@ -34231,7 +34151,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_sjis, my_strnxfrm_sjis, my_strnxfrmlen_simple, - my_like_range_sjis, + my_like_range_mb, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, my_instr_mb, @@ -34297,7 +34217,7 @@ CHARSET_INFO my_charset_sjis_japanese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -34329,7 +34249,7 @@ CHARSET_INFO my_charset_sjis_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 3946f6a83b4..d3b0b93a939 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -134,11 +134,6 @@ my_strntol_mb2_or_mb4(CHARSET_INFO *cs, bs: -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif - overflow= 0; res= 0; save= s; @@ -250,11 +245,6 @@ my_strntoul_mb2_or_mb4(CHARSET_INFO *cs, bs: -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif - overflow= 0; res= 0; save= s; @@ -359,11 +349,6 @@ my_strntoll_mb2_or_mb4(CHARSET_INFO *cs, bs: -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif - overflow = 0; res = 0; save = s; @@ -474,11 +459,6 @@ my_strntoull_mb2_or_mb4(CHARSET_INFO *cs, } while (1); bs: - -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif overflow = 0; res = 0; diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 4fabbdbaeb3..9f4d032ffe0 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -67316,7 +67316,7 @@ CHARSET_INFO my_charset_ujis_japanese_ci= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -67349,7 +67349,7 @@ CHARSET_INFO my_charset_ujis_bin= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/decimal.c b/strings/decimal.c index 99b7ccd3249..7625ed80ec3 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1917,8 +1917,7 @@ static int do_sub(decimal_t *from1, decimal_t *from2, decimal_t *to) int decimal_intg(decimal_t *from) { int res; - dec1 *tmp_res; - tmp_res= remove_leading_zeroes(from, &res); + remove_leading_zeroes(from, &res); return res; } diff --git a/strings/do_ctype.c b/strings/do_ctype.c index d038d313a98..f87d55b6251 100644 --- a/strings/do_ctype.c +++ b/strings/do_ctype.c @@ -140,7 +140,7 @@ void init_case_convert() to_upper[i]= sort_order[i]= to_lower[i]= (char) i; #endif -#if defined(HPUX10) && ASCII_BITS_USED == 8 +#if defined(HPUX10) higher_pos= (uchar *) "\xd0\xd8\xda\xdb\xdc\xd3"; lower_pos= (uchar *) "\xd4\xcc\xce\xdf\xc9\xd7"; #else @@ -166,7 +166,7 @@ void init_case_convert() /* sets upp sortorder; higer_pos character (upper and lower) is */ /* changed to lower_pos character */ -#if defined(HPUX10) && ASCII_BITS_USED == 8 +#if defined(HPUX10) higher_pos= lower_pos= (uchar *) ""; /* Tecknen i r{tt ordning */ #else #ifdef USE_ISO_8859_1 /* As in USG5 ICL-386 */ diff --git a/strings/r_strinstr.c b/strings/r_strinstr.c deleted file mode 100644 index fb1e0c5a090..00000000000 --- a/strings/r_strinstr.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - Author : David - strintstr(src, from, pat) looks for an instance of pat in src - backwards from pos from. pat is not a regex(3) pattern, it is a literal - string which must be matched exactly. - The result 0 if the pattern was not found else it is the start char of - the pattern counted from the begining of the string. -*/ - -#include <my_global.h> -#include "m_string.h" - -size_t r_strinstr(reg1 const char * str, size_t from, reg4 const char * search) -{ - reg2 const char *i, *j; - size_t len = strlen(search); - /* pointer to the last char of buff */ - const char * start = str + from - 1; - /* pointer to the last char of search */ - const char * search_end = search + len - 1; - - skip: - while (start >= str) /* Cant be != because the first char */ - { - if (*start-- == *search_end) - { - i = start; j = search_end - 1; - while (j >= search && start > str) - if (*i-- != *j--) - goto skip; - return (size_t) ((start - len) - str + 3); - } - } - return (0); -} diff --git a/strings/str_test.c b/strings/str_test.c index 0814647472c..7e304fbd10a 100644 --- a/strings/str_test.c +++ b/strings/str_test.c @@ -73,8 +73,6 @@ int main(void) test_arg("strstr(v1,v5)",(long) strstr(v1,v5),0L); test_arg("strstr(v6,v8)",(long) strstr(v6,v8),0L); - test_arg("strinstr(v1,v4)",(long) strinstr(v1,v4),4L); - test_arg("strinstr(v1,v5)",(long) strinstr(v1,v5),0L); test_arg("strlen(from)",(long) strlen(from),(long) F_LEN); test_arg("strlen(\"\")",(long) strlen(""),0L); #ifdef HAVE_STRNLEN diff --git a/strings/strappend-sparc.s b/strings/strappend-sparc.s deleted file mode 100644 index d5add816eb0..00000000000 --- a/strings/strappend-sparc.s +++ /dev/null @@ -1,49 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "strappend-sparc.s" -.section ".text" - .align 4 - .global strappend - .type strappend,#function - .proc 020 -strappend: - add %o0, %o1, %o3 ! o3 = endpos - ldsb [%o0], %o4 -.loop1: - add %o0, 1, %o0 ! find end of str - cmp %o4, 0 - bne,a .loop1 - ldsb [%o0], %o4 - - sub %o0, 1, %o0 - cmp %o0, %o3 - bgeu .end - nop - - stb %o2, [%o0] -.loop2: - add %o0, 1, %o0 - cmp %o0, %o3 - blu,a .loop2 - stb %o2, [%o0] -.end: - retl - stb %g0, [%o3] -.strappend_end: - .size strappend,.strappend_end-strappend - .ident "Matt Wagner & Monty" diff --git a/strings/strcend.c b/strings/strcend.c index 56e31d5f994..e08ad2b1e75 100644 --- a/strings/strcend.c +++ b/strings/strcend.c @@ -25,23 +25,6 @@ #include <my_global.h> #include "m_string.h" -#if defined(MC68000) && defined(DS90) - -char *strcend(const char *s, pchar c) -{ -asm(" movl 4(a7),a0 "); -asm(" movl 8(a7),d1 "); -asm(".L2: movb (a0)+,d0 "); -asm(" cmpb d0,d1 "); -asm(" beq .L1 "); -asm(" tstb d0 "); -asm(" bne .L2 "); -asm(".L1: movl a0,d0 "); -asm(" subql #1,d0 "); -} - -#else - char *strcend(register const char *s, register pchar c) { for (;;) @@ -51,4 +34,3 @@ char *strcend(register const char *s, register pchar c) } } -#endif diff --git a/strings/strend-sparc.s b/strings/strend-sparc.s deleted file mode 100644 index f264fcef32f..00000000000 --- a/strings/strend-sparc.s +++ /dev/null @@ -1,35 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "strend-sparc.s" -.section ".text" - .align 4 - .global strend - .type strend,#function - .proc 0102 -strend: - ldsb [%o0], %o3 ! Handle first char differently to make -.loop: ! a faster loop - add %o0, 1, %o0 - cmp %o3, 0 - bne,a .loop - ldsb [%o0], %o3 - retl - sub %o0,1,%o0 -.strend_end: - .size strend,.strend_end-strend - .ident "Matt Wagner & Monty" diff --git a/strings/strend.c b/strings/strend.c index 4dadf0675dc..d70a5d648d5 100644 --- a/strings/strend.c +++ b/strings/strend.c @@ -24,27 +24,14 @@ is, strend(s)-s == strlen(s). This is useful for adding things at the end of strings. It is redundant, because strchr(s,'\0') could be used instead, but this is clearer and faster. - Beware: the asm version works only if strlen(s) < 65535. */ #include <my_global.h> #include "m_string.h" -#if VaxAsm - -char *strend(s) -const char *s; -{ - asm("locc $0,$65535,*4(ap)"); - asm("movl r1,r0"); -} - -#else /* ~VaxAsm */ - char *strend(register const char *s) { while (*s++); return (char*) (s-1); } -#endif /* VaxAsm */ diff --git a/strings/string.doc b/strings/string.doc index 954f7226759..fcd020b8c60 100644 --- a/strings/string.doc +++ b/strings/string.doc @@ -77,11 +77,6 @@ Speciella användbara nya string-rutiner: The result is a pointer to the first character of the located instance, or NullS if pat does not occur in src. - strinstr(src, pat) looks for an instance of pat in src. pat is not a - regex(3) pattern, it is a literal string which must be matched exactly. - The result 0 if the pattern was not found else it is the start char of - the pattern counted from the begining of the string. - strmake(dst,src,length) moves length characters, or until end, of src to dst and appends a closing NUL to dst. strmake() returns pointer to closing null; diff --git a/strings/strings-not-used.h b/strings/strings-not-used.h deleted file mode 100644 index 8311545f22f..00000000000 --- a/strings/strings-not-used.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef STRINGS_NOT_USED_INCLUDED -#define STRINGS_NOT_USED_INCLUDED - -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* File : strings.h - Author : Richard A. O'Keefe. - Updated: 1 June 1984 - Purpose: Header file for the "string(3C)" package. - - All the routines in this package are the original work of - R.A.O'Keefe. Any resemblance between them and any routines in - licensed software is due entirely to these routines having been - written using the "man 3 string" UNIX manual page, or in some cases - the "man 1 sort" manual page as a specification. See the READ-ME to - find the conditions under which these routines may be used & copied. -*/ - -#ifndef NullS - -#include <my_global.h> /* Define standar vars */ -#include "m_string.h" - -#define NUL '\0' -#define _AlphabetSize 256 - -#endif /* NullS */ -#endif /* STRINGS_NOT_USED_INCLUDED */ diff --git a/strings/strings-x86.s b/strings/strings-x86.s index db7bb0c1274..4872c566685 100644 --- a/strings/strings-x86.s +++ b/strings/strings-x86.s @@ -281,29 +281,6 @@ sf_fo: movl %edx,%eax # Char found here .strstr_end: .size strstr,.strstr_end-strstr - - # Find a substring in string, return index - # Arg: str,search - -.globl strinstr - .type strinstr,@function - -strinstr: - pushl %ebp - movl %esp,%ebp - pushl 12(%ebp) # search - pushl 8(%ebp) # str - call strstr - add $8,%esp - or %eax,%eax - jz si_99 # Not found, return NULL - sub 8(%ebp),%eax # Pos from start - inc %eax # And first pos = 1 -si_99: popl %ebp - ret -.strinstr_end: - .size strinstr,.strinstr_end-strinstr - # Make a string of len length from another string # Arg: dst,src,length # ret: end of dst diff --git a/strings/strinstr-sparc.s b/strings/strinstr-sparc.s deleted file mode 100644 index 5278aff6aa7..00000000000 --- a/strings/strinstr-sparc.s +++ /dev/null @@ -1,43 +0,0 @@ -! Copyright (C) 2000 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "strinstr-sparc.s" -.section ".text" - .align 4 - .global strinstr - .type strinstr,#function - .proc 0102 -strinstr: - save %sp,-96,%sp - or %g0,%i1,%o1 - call strstr,2 ! Result = %o0 - or %g0,%i0,%o0 - orcc %g0,%o0,%o0 - bne .end - sub %o0,%i0,%i0 - ret - restore %g0,%g0,%o0 -.end: - ret - restore %i0,1,%o0 ! Offset for return value is from 1 - -.strinstr_end: - .size strinstr,.strinstr_end-strinstr - .ident "Matt Wagner & Monty" - - - diff --git a/strings/strinstr.c b/strings/strinstr.c deleted file mode 100644 index dce498d61e8..00000000000 --- a/strings/strinstr.c +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* File : strinstr.c - Author : Monty & David - Updated: 1986.12.08 - Defines: strinstr() - - strinstr(src, pat) looks for an instance of pat in src. pat is not a - regex(3) pattern, it is a literal string which must be matched exactly. - The result 0 if the pattern was not found else it is the start char of - the pattern counted from the beginning of the string, where the first - char is 1. -*/ - -#include <my_global.h> -#include "m_string.h" - -size_t strinstr(reg1 const char *str,reg4 const char *search) -{ - reg2 const char *i, *j; - const char *start= str; - - skip: - while (*str != '\0') - { - if (*str++ == *search) - { - i= str; j= search+1; - while (*j) - if (*i++ != *j++) goto skip; - return ((size_t) (str - start)); - } - } - return (0); -} diff --git a/strings/strmake-sparc.s b/strings/strmake-sparc.s deleted file mode 100644 index 36db8efd402..00000000000 --- a/strings/strmake-sparc.s +++ /dev/null @@ -1,43 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "strmake-sparc.s" -.section ".text" - .align 4 - .global strmake - .type strmake,#function - .proc 0102 -strmake: - orcc %g0,%o2,%g0 - be,a .end - nop - ldsb [%o1],%o3 -.loop: - stb %o3,[%o0] - cmp %o3,0 - be .end ! Jump to end on end of string - add %o1,1,%o1 - add %o0,1,%o0 - subcc %o2,1,%o2 - bne,a .loop - ldsb [%o1],%o3 -.end: - retl - stb %g0,[%o0] -.strmake_end: - .size strmake,.strmake_end-strmake - .ident "Matt Wagner & Monty" diff --git a/strings/strmov-sparc.s b/strings/strmov-sparc.s deleted file mode 100644 index f124da2dc9f..00000000000 --- a/strings/strmov-sparc.s +++ /dev/null @@ -1,36 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "strmov-sparc.s" -.section ".text" - .align 4 - .global strmov - .type strmov,#function - .proc 0102 -strmov: -.loop: - ldub [%o1], %o3 - stb %o3, [%o0] - add %o1, 1, %o1 - cmp %o3, 0 - bne,a .loop - add %o0, 1, %o0 - retl - nop -.strmov_end: - .size strmov,.strmov_end-strmov - .ident "Matt Wagner" diff --git a/strings/strmov.c b/strings/strmov.c index eedf22a4ef1..4d4915d27a0 100644 --- a/strings/strmov.c +++ b/strings/strmov.c @@ -29,25 +29,9 @@ #define strmov strmov_overlapp #endif -#if !defined(MC68000) && !defined(DS90) - char *strmov(register char *dst, register const char *src) { while ((*dst++ = *src++)) ; return dst-1; } -#else - -char *strmov(dst, src) - char *dst, *src; -{ - asm(" movl 4(a7),a1 "); - asm(" movl 8(a7),a0 "); - asm(".L4: movb (a0)+,(a1)+ "); - asm(" jne .L4 "); - asm(" movl a1,d0 "); - asm(" subql #1,d0 "); -} - -#endif diff --git a/strings/strnmov-sparc.s b/strings/strnmov-sparc.s deleted file mode 100644 index df0c4bebf03..00000000000 --- a/strings/strnmov-sparc.s +++ /dev/null @@ -1,43 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "strnmov-sparc.s" -.section ".text" - .align 4 - .global strnmov - .type strnmov,#function - .proc 0102 -strnmov: - orcc %g0,%o2,%g0 - be,a .end - nop - ldsb [%o1],%o3 -.loop: - stb %o3,[%o0] - cmp %o3,0 - be .end ! Jump to end on end of string - add %o1,1,%o1 - add %o0,1,%o0 - subcc %o2,1,%o2 - bne,a .loop - ldsb [%o1],%o3 -.end: - retl - nop -.strnmov_end: - .size strnmov,.strnmov_end-strnmov - .ident "Matt Wagner" diff --git a/strings/strstr-sparc.s b/strings/strstr-sparc.s deleted file mode 100644 index 2a6590c9c93..00000000000 --- a/strings/strstr-sparc.s +++ /dev/null @@ -1,72 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - - .file "strstr-sparc.s" -.section ".text" - .align 4 - .global strstr - .type strstr,#function - .proc 0102 -strstr: - -!char *strstr(register const char *str,const char *search) -!{ -! register char *i,*j; -!skipp: -! while (*str != '\0') { -! if (*str++ == *search) { -! i=(char*) str; j=(char*) search+1; - - ldsb [%o1],%o2 ! o2= First char of search -.top: - ldsb [%o0],%o4 ! o4= First char of rest of str - cmp %o4,0 - be .abort ! Found end null ; - cmp %o4,%o2 - bne .top - add %o0,1,%o0 - -.outloop1: - -! while (*j) -! if (*i++ != *j++) goto skipp; - - or %g0,%o0,%o3 - add %o1,1,%o4 ! o4= search+1 - ldsb [%o0],%o5 ! o5= [current_str+1] - -.loop2: - ldsb [%o4],%g4 - add %o4,1,%o4 - cmp %g4,0 - be .end - cmp %o5,%g4 - bne .top - add %o3,1,%o3 - ba .loop2 - ldsb [%o3],%o5 - -.end: - retl - sub %o0,1,%o0 -.abort: - retl - or %g0,0,%o0 - -.strstr_end: - .size strstr,.strstr_end-strstr - .ident "Matt Wagner & Monty" diff --git a/strings/strxmov-sparc.s b/strings/strxmov-sparc.s deleted file mode 100644 index 11ae49a876b..00000000000 --- a/strings/strxmov-sparc.s +++ /dev/null @@ -1,54 +0,0 @@ -! Copyright (C) 2000, 2002 MySQL AB -! -! This library 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 -! of the License. -! -! This library 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 -! Library General Public License for more details. -! -! You should have received a copy of the GNU Library General Public -! License along with this library; if not, write to the Free -! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -! MA 02111-1307, USA - -! -! Note that this function only works on 32 bit sparc systems -! on 64 bits the offsets to %sp are different ! - - .file "strxmov-sparc.s" -.section ".text" - .align 4 - .global strxmov - .type strxmov,#function - .proc 0102 - -strxmov: - st %o2, [%sp+76] ! store 3rd param before other params - st %o3, [%sp+80] ! store 4th param " " - cmp %o1, 0 ! check if no from args - st %o4, [%sp+84] ! store 5th param - be .end - st %o5, [%sp+88] ! store last - add %sp, 76, %o4 ! put pointer to 3rd arg -.loop: - ldub [%o1], %o5 ! set values of src (o1) - add %o1, 1, %o1 ! inc src - stb %o5, [%o0] ! and dst (o2) equal - cmp %o5, 0 ! second while cmp - bne,a .loop - add %o0, 1, %o0 ! inc dst - ld [%o4], %o1 ! get next param - cmp %o1, 0 ! check if last param - bne .loop - add %o4, 4, %o4 ! advance to next param -.end: - retl - stb %g0, [%o0] -.strxmov_end: - .size strxmov,.strxmov_end-strxmov - .ident "Matt Wagner & Monty" - diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index a3640077889..61f9d4881cb 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -5775,215 +5775,6 @@ static void test_set_variable() mysql_stmt_close(stmt1); } -#if NOT_USED - -/* Insert meta info .. */ - -static void test_insert_meta() -{ - MYSQL_STMT *stmt; - int rc; - MYSQL_RES *result; - MYSQL_FIELD *field; - - myheader("test_insert_meta"); - - rc= mysql_autocommit(mysql, TRUE); - myquery(rc); - - rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_insert"); - myquery(rc); - - rc= mysql_query(mysql, "CREATE TABLE test_prep_insert(col1 tinyint, \ - col2 varchar(50), col3 varchar(30))"); - myquery(rc); - - strmov(query, "INSERT INTO test_prep_insert VALUES(10, 'venu1', 'test')"); - stmt= mysql_simple_prepare(mysql, query); - check_stmt(stmt); - - verify_param_count(stmt, 0); - - result= mysql_param_result(stmt); - mytest_r(result); - - mysql_stmt_close(stmt); - - strmov(query, "INSERT INTO test_prep_insert VALUES(?, 'venu', ?)"); - stmt= mysql_simple_prepare(mysql, query); - check_stmt(stmt); - - verify_param_count(stmt, 2); - - result= mysql_param_result(stmt); - mytest(result); - - my_print_result_metadata(result); - - mysql_field_seek(result, 0); - field= mysql_fetch_field(result); - mytest(field); - if (!opt_silent) - fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); - DIE_UNLESS(strcmp(field->name, "col1") == 0); - - field= mysql_fetch_field(result); - mytest(field); - if (!opt_silent) - fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); - DIE_UNLESS(strcmp(field->name, "col3") == 0); - - field= mysql_fetch_field(result); - mytest_r(field); - - mysql_free_result(result); - mysql_stmt_close(stmt); -} - - -/* Update meta info .. */ - -static void test_update_meta() -{ - MYSQL_STMT *stmt; - int rc; - MYSQL_RES *result; - MYSQL_FIELD *field; - - myheader("test_update_meta"); - - rc= mysql_autocommit(mysql, TRUE); - myquery(rc); - - rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_update"); - myquery(rc); - - rc= mysql_query(mysql, "CREATE TABLE test_prep_update(col1 tinyint, \ - col2 varchar(50), col3 varchar(30))"); - myquery(rc); - - strmov(query, "UPDATE test_prep_update SET col1=10, col2='venu1' WHERE col3='test'"); - stmt= mysql_simple_prepare(mysql, query); - check_stmt(stmt); - - verify_param_count(stmt, 0); - - result= mysql_param_result(stmt); - mytest_r(result); - - mysql_stmt_close(stmt); - - strmov(query, "UPDATE test_prep_update SET col1=?, col2='venu' WHERE col3=?"); - stmt= mysql_simple_prepare(mysql, query); - check_stmt(stmt); - - verify_param_count(stmt, 2); - - result= mysql_param_result(stmt); - mytest(result); - - my_print_result_metadata(result); - - mysql_field_seek(result, 0); - field= mysql_fetch_field(result); - mytest(field); - if (!opt_silent) - { - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - } - DIE_UNLESS(strcmp(field->name, "col1") == 0); - DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0); - - field= mysql_fetch_field(result); - mytest(field); - if (!opt_silent) - { - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - } - DIE_UNLESS(strcmp(field->name, "col3") == 0); - DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0); - - field= mysql_fetch_field(result); - mytest_r(field); - - mysql_free_result(result); - mysql_stmt_close(stmt); -} - - -/* Select meta info .. */ - -static void test_select_meta() -{ - MYSQL_STMT *stmt; - int rc; - MYSQL_RES *result; - MYSQL_FIELD *field; - - myheader("test_select_meta"); - - rc= mysql_autocommit(mysql, TRUE); - myquery(rc); - - rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_select"); - myquery(rc); - - rc= mysql_query(mysql, "CREATE TABLE test_prep_select(col1 tinyint, \ - col2 varchar(50), col3 varchar(30))"); - myquery(rc); - - strmov(query, "SELECT * FROM test_prep_select WHERE col1=10"); - stmt= mysql_simple_prepare(mysql, query); - check_stmt(stmt); - - verify_param_count(stmt, 0); - - result= mysql_param_result(stmt); - mytest_r(result); - - strmov(query, "SELECT col1, col3 from test_prep_select WHERE col1=? AND col3='test' AND col2= ?"); - stmt= mysql_simple_prepare(mysql, query); - check_stmt(stmt); - - verify_param_count(stmt, 2); - - result= mysql_param_result(stmt); - mytest(result); - - my_print_result_metadata(result); - - mysql_field_seek(result, 0); - field= mysql_fetch_field(result); - mytest(field); - if (!opt_silent) - { - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - } - DIE_UNLESS(strcmp(field->name, "col1") == 0); - DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0); - - field= mysql_fetch_field(result); - mytest(field); - if (!opt_silent) - { - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - } - DIE_UNLESS(strcmp(field->name, "col2") == 0); - DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0); - - field= mysql_fetch_field(result); - mytest_r(field); - - mysql_free_result(result); - mysql_stmt_close(stmt); -} -#endif - - /* Test FUNCTION field info / DATE_FORMAT() table_name . */ static void test_func_fields() diff --git a/tests/thread_test.c b/tests/thread_test.c index 1a3dd60c1fd..c243a3a7321 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -88,36 +88,36 @@ static struct my_option my_long_options[] = { {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use", (uchar**) &database, (uchar**) &database, + {"database", 'D', "Database to use", &database, &database, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host", (uchar**) &host, (uchar**) &host, 0, GET_STR, + {"host", 'h', "Connect to host", &host, &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "User for login if not current user", (uchar**) &user, - (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user", &user, + &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Write some progress indicators", (uchar**) &verbose, - (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"query", 'Q', "Query to execute in each threads", (uchar**) &query, - (uchar**) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Write some progress indicators", &verbose, + &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"query", 'Q', "Query to execute in each threads", &query, + &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " "order of preference, my.cnf, $MYSQL_TCP_PORT, " #if MYSQL_PORT_DEFAULT == 0 "/etc/services, " #endif "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", - (uchar**) &tcp_port, - (uchar**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection", (uchar**) &unix_socket, - (uchar**) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + &tcp_port, + &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, + {"socket", 'S', "Socket file to use for connection", &unix_socket, + &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"test-count", 'c', "Run test count times (default %d)", - (uchar**) &number_of_tests, (uchar**) &number_of_tests, 0, GET_UINT, + &number_of_tests, &number_of_tests, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, {"thread-count", 't', "Number of threads to start", - (uchar**) &number_of_threads, (uchar**) &number_of_threads, 0, GET_UINT, + &number_of_threads, &number_of_threads, 0, GET_UINT, REQUIRED_ARG, 2, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/unittest/Makefile.am b/unittest/Makefile.am index 6197586b008..da655d1844e 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -13,12 +13,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SUBDIRS = mytap . mysys examples +SUBDIRS = mytap . mysys examples strings EXTRA_DIST = unit.pl CLEANFILES = unit -unittests = mytap mysys @mysql_se_unittest_dirs@ @mysql_pg_unittest_dirs@ +unittests = mytap mysys strings @mysql_se_unittest_dirs@ @mysql_pg_unittest_dirs@ test: perl unit.pl run $(unittests) diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 9853d3cf964..95799be7bb1 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -15,13 +15,6 @@ #include "thr_template.c" -/* at least gcc 3.4.5 and 3.4.6 (but not 3.2.3) on RHEL */ -#if __GNUC__ == 3 && __GNUC_MINOR__ == 4 -#define GCC_BUG_WORKAROUND volatile -#else -#define GCC_BUG_WORKAROUND -#endif - volatile uint32 b32; volatile int32 c32; my_atomic_rwlock_t rwl; @@ -29,8 +22,8 @@ my_atomic_rwlock_t rwl; /* add and sub a random number in a loop. Must get 0 at the end */ pthread_handler_t test_atomic_add(void *arg) { - int m= (*(int *)arg)/2; - GCC_BUG_WORKAROUND int32 x; + int m= (*(int *)arg)/2; + int32 x; for (x= ((int)(intptr)(&m)); m ; m--) { x= (x*m+0x87654321) & INT_MAX32; @@ -52,8 +45,8 @@ volatile int64 a64; /* add and sub a random number in a loop. Must get 0 at the end */ pthread_handler_t test_atomic_add64(void *arg) { - int m= (*(int *)arg)/2; - GCC_BUG_WORKAROUND int64 x; + int m= (*(int *)arg)/2; + int64 x; for (x= ((int64)(intptr)(&m)); m ; m--) { x= (x*m+0xfdecba987654321LL) & INT_MAX64; @@ -128,8 +121,8 @@ pthread_handler_t test_atomic_fas(void *arg) */ pthread_handler_t test_atomic_cas(void *arg) { - int m= (*(int *)arg)/2, ok= 0; - GCC_BUG_WORKAROUND int32 x, y; + int m= (*(int *)arg)/2, ok= 0; + int32 x, y; for (x= ((int)(intptr)(&m)); m ; m--) { my_atomic_rwlock_wrlock(&rwl); diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c index 2f1747d7167..7facb23e7e3 100644 --- a/unittest/mytap/tap.c +++ b/unittest/mytap/tap.c @@ -29,9 +29,9 @@ /* Visual Studio 2003 does not know vsnprintf but knows _vsnprintf. - We don't put this #define in config-win.h because we prefer - my_vsnprintf everywhere instead, except when linking with libmysys - is not desirable - the case here. + We don't put this #define elsewhere because we prefer my_vsnprintf + everywhere instead, except when linking with libmysys is not + desirable - the case here. */ #if defined(_MSC_VER) && ( _MSC_VER == 1310 ) #define vsnprintf _vsnprintf diff --git a/unittest/strings/Makefile.am b/unittest/strings/Makefile.am new file mode 100644 index 00000000000..5b18d89f58e --- /dev/null +++ b/unittest/strings/Makefile.am @@ -0,0 +1,27 @@ +# Copyright 2000, 2010, 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 + +AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include +AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap + +LDADD = $(top_builddir)/unittest/mytap/libmytap.a \ + $(top_builddir)/mysys/libmysys.a \ + $(top_builddir)/dbug/libdbug.a \ + $(top_builddir)/strings/libmystrings.a + +noinst_PROGRAMS = strings-t + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/unittest/strings/strings-t.c b/unittest/strings/strings-t.c new file mode 100644 index 00000000000..278f42e56a5 --- /dev/null +++ b/unittest/strings/strings-t.c @@ -0,0 +1,114 @@ +/* Copyright 2000, 2010, 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 */ + +#include <tap.h> +#include <my_global.h> +#include <my_sys.h> + + +/* + Test that like_range() returns well-formed results. +*/ +static int +test_like_range_for_charset(CHARSET_INFO *cs, const char *src, size_t src_len) +{ + char min_str[32], max_str[32]; + size_t min_len, max_len, min_well_formed_len, max_well_formed_len; + int error= 0; + + cs->coll->like_range(cs, src, src_len, '\\', '_', '%', + sizeof(min_str), min_str, max_str, &min_len, &max_len); + diag("min_len=%d\tmax_len=%d\t%s", (int) min_len, (int) max_len, cs->name); + min_well_formed_len= cs->cset->well_formed_len(cs, + min_str, min_str + min_len, + 10000, &error); + max_well_formed_len= cs->cset->well_formed_len(cs, + max_str, max_str + max_len, + 10000, &error); + if (min_len != min_well_formed_len) + diag("Bad min_str: min_well_formed_len=%d min_str[%d]=0x%02X", + (int) min_well_formed_len, (int) min_well_formed_len, + (uchar) min_str[min_well_formed_len]); + if (max_len != max_well_formed_len) + diag("Bad max_str: max_well_formed_len=%d max_str[%d]=0x%02X", + (int) max_well_formed_len, (int) max_well_formed_len, + (uchar) max_str[max_well_formed_len]); + return + min_len == min_well_formed_len && + max_len == max_well_formed_len ? 0 : 1; +} + + +static CHARSET_INFO *charset_list[]= +{ +#ifdef HAVE_CHARSET_big5 + &my_charset_big5_chinese_ci, + &my_charset_big5_bin, +#endif +#ifdef HAVE_CHARSET_euckr + &my_charset_euckr_korean_ci, + &my_charset_euckr_bin, +#endif +#ifdef HAVE_CHARSET_gb2312 + &my_charset_gb2312_chinese_ci, + &my_charset_gb2312_bin, +#endif +#ifdef HAVE_CHARSET_gbk + &my_charset_gbk_chinese_ci, + &my_charset_gbk_bin, +#endif +#ifdef HAVE_CHARSET_latin1 + &my_charset_latin1, + &my_charset_latin1_bin, +#endif +#ifdef HAVE_CHARSET_sjis + &my_charset_sjis_japanese_ci, + &my_charset_sjis_bin, +#endif +#ifdef HAVE_CHARSET_tis620 + &my_charset_tis620_thai_ci, + &my_charset_tis620_bin, +#endif +#ifdef HAVE_CHARSET_ujis + &my_charset_ujis_japanese_ci, + &my_charset_ujis_bin, +#endif +#ifdef HAVE_CHARSET_utf8 + &my_charset_utf8_general_ci, + &my_charset_utf8_unicode_ci, + &my_charset_utf8_bin, +#endif +}; + + +int main() +{ + size_t i, failed= 0; + + plan(1); + diag("Testing my_like_range_xxx() functions"); + + for (i= 0; i < array_elements(charset_list); i++) + { + CHARSET_INFO *cs= charset_list[i]; + if (test_like_range_for_charset(cs, "abc%", 4)) + { + ++failed; + diag("Failed for %s", cs->name); + } + } + ok(failed == 0, "Testing my_like_range_xxx() functions"); + return exit_status(); +} |