diff options
79 files changed, 2082 insertions, 1196 deletions
diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 450ef9826c2..b329a09d56e 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -151,7 +151,7 @@ IF(UNIX) ENDIF() IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386") - IF(CMAKE_SIZEOF_VOIDP EQUAL 4) + 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") @@ -165,7 +165,7 @@ IF(UNIX) "-g0 -xO3 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic") ENDIF() ELSE() - IF(CMAKE_SIZEOF_VOIDP EQUAL 4) + 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") diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index f610ce9068a..3be739d3122 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -56,7 +56,7 @@ ADD_DEFINITIONS("-D_WIN32_WINNT=0x0501") ADD_DEFINITIONS("-DWIN32_LEAN_AND_MEAN") # Adjust compiler and linker flags -IF(MINGW AND CMAKE_SIZEOF_VOIDP EQUAL 4) +IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4) # mininal architecture flags, i486 enables GCC atomics ADD_DEFINITIONS(-march=i486) ENDIF() @@ -193,4 +193,4 @@ IF(NOT HAVE_SIZE_OF_SSIZE_T) SET(ssize_t SSIZE_T) ENDIF() -SET(FN_NO_CASE_SENSE 1)
\ No newline at end of file +SET(FN_NO_CASE_SENSE 1) diff --git a/configure.in b/configure.in index 0a040cc60ee..32acbfd3dad 100644 --- a/configure.in +++ b/configure.in @@ -27,7 +27,7 @@ AC_PREREQ(2.59) # Remember to also update version.c in ndb. # When changing major version number please also check switch statement # in client/mysqlbinlog.cc:check_master_version(). -AC_INIT([MySQL Server], [5.5.3-m3], [], [mysql]) +AC_INIT([MySQL Server], [5.5.4-m3], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM # USTAR format gives us the possibility to store longer path names in diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 18c4daa0cf2..4e839c7cf6a 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -107,6 +107,22 @@ struct st_mysql_rwlock }; /** + An instrumented prlock structure. + @sa mysql_prlock_t +*/ +struct st_mysql_prlock +{ + /** The real prlock */ + rw_pr_lock_t m_prlock; + /** + The instrumentation hook. + Note that this hook is not conditionally defined, + for binary compatibility of the @c mysql_rwlock_t interface. + */ + struct PSI_rwlock *m_psi; +}; + +/** Type of an instrumented rwlock. @c mysql_rwlock_t is a drop-in replacement for @c pthread_rwlock_t. @sa mysql_rwlock_init @@ -120,6 +136,20 @@ struct st_mysql_rwlock typedef struct st_mysql_rwlock mysql_rwlock_t; /** + Type of an instrumented prlock. + A prlock is a read write lock that 'prefers readers' (pr). + @c mysql_prlock_t is a drop-in replacement for @c rw_pr_lock_t. + @sa mysql_prlock_init + @sa mysql_prlock_rdlock + @sa mysql_prlock_tryrdlock + @sa mysql_prlock_wrlock + @sa mysql_prlock_trywrlock + @sa mysql_prlock_unlock + @sa mysql_prlock_destroy +*/ +typedef struct st_mysql_prlock mysql_prlock_t; + +/** An instrumented cond structure. @sa mysql_cond_t */ @@ -162,6 +192,8 @@ typedef struct st_mysql_cond mysql_cond_t; on some platforms. The proper fix would be to cut these extra dependencies in the calling code. DISABLE_MYSQL_THREAD_H is a work around to limit dependencies. + DISABLE_MYSQL_PRLOCK_H is similar, and is used to disable specifically + the prlock wrappers. */ #ifndef DISABLE_MYSQL_THREAD_H @@ -282,6 +314,19 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_init(K, RW) + Instrumented rw_pr_init. + @c mysql_prlock_init is a replacement for @c rw_pr_init. + @param K The PSI_rwlock_key for this instrumented prlock + @param RW The prlock to initialize +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(K, RW) +#else + #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(RW) +#endif + +/** @def mysql_rwlock_destroy(RW) Instrumented rwlock_destroy. @c mysql_rwlock_destroy is a drop-in replacement @@ -290,6 +335,14 @@ typedef struct st_mysql_cond mysql_cond_t; #define mysql_rwlock_destroy(RW) inline_mysql_rwlock_destroy(RW) /** + @def mysql_prlock_destroy(RW) + Instrumented rw_pr_destroy. + @c mysql_prlock_destroy is a drop-in replacement + for @c rw_pr_destroy. +*/ +#define mysql_prlock_destroy(RW) inline_mysql_prlock_destroy(RW) + +/** @def mysql_rwlock_rdlock(RW) Instrumented rwlock_rdlock. @c mysql_rwlock_rdlock is a drop-in replacement @@ -304,6 +357,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_rdlock(RW) + Instrumented rw_pr_rdlock. + @c mysql_prlock_rdlock is a drop-in replacement + for @c rw_pr_rdlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_rdlock(RW) \ + inline_mysql_prlock_rdlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_rdlock(RW) \ + inline_mysql_prlock_rdlock(RW) +#endif + +/** @def mysql_rwlock_wrlock(RW) Instrumented rwlock_wrlock. @c mysql_rwlock_wrlock is a drop-in replacement @@ -318,6 +385,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_wrlock(RW) + Instrumented rw_pr_wrlock. + @c mysql_prlock_wrlock is a drop-in replacement + for @c rw_pr_wrlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_wrlock(RW) \ + inline_mysql_prlock_wrlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_wrlock(RW) \ + inline_mysql_prlock_wrlock(RW) +#endif + +/** @def mysql_rwlock_tryrdlock(RW) Instrumented rwlock_tryrdlock. @c mysql_rwlock_tryrdlock is a drop-in replacement @@ -332,6 +413,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_tryrdlock(RW) + Instrumented rw_pr_tryrdlock. + @c mysql_prlock_tryrdlock is a drop-in replacement + for @c rw_pr_tryrdlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_tryrdlock(RW) \ + inline_mysql_prlock_tryrdlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_tryrdlock(RW) \ + inline_mysql_prlock_tryrdlock(RW) +#endif + +/** @def mysql_rwlock_trywrlock(RW) Instrumented rwlock_trywrlock. @c mysql_rwlock_trywrlock is a drop-in replacement @@ -346,6 +441,20 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** + @def mysql_prlock_trywrlock(RW) + Instrumented rw_pr_trywrlock. + @c mysql_prlock_trywrlock is a drop-in replacement + for @c rw_pr_trywrlock. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_prlock_trywrlock(RW) \ + inline_mysql_prlock_trywrlock(RW, __FILE__, __LINE__) +#else + #define mysql_prlock_trywrlock(RW) \ + inline_mysql_prlock_trywrlock(RW) +#endif + +/** @def mysql_rwlock_unlock(RW) Instrumented rwlock_unlock. @c mysql_rwlock_unlock is a drop-in replacement @@ -354,8 +463,16 @@ typedef struct st_mysql_cond mysql_cond_t; #define mysql_rwlock_unlock(RW) inline_mysql_rwlock_unlock(RW) /** + @def mysql_prlock_unlock(RW) + Instrumented rw_pr_unlock. + @c mysql_prlock_unlock is a drop-in replacement + for @c rw_pr_unlock. +*/ +#define mysql_prlock_unlock(RW) inline_mysql_prlock_unlock(RW) + +/** @def mysql_cond_init(K, C, A) - Instrumented rwlock_init. + Instrumented cond_init. @c mysql_cond_init is a replacement for @c pthread_cond_init. @param C The cond to initialize @param K The PSI_cond_key for this instrumented cond @@ -599,6 +716,23 @@ static inline int inline_mysql_rwlock_init( return my_rwlock_init(&that->m_rwlock, NULL); } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_init( +#ifdef HAVE_PSI_INTERFACE + PSI_rwlock_key key, +#endif + mysql_prlock_t *that) +{ +#ifdef HAVE_PSI_INTERFACE + that->m_psi= (PSI_server ? PSI_server->init_rwlock(key, &that->m_prlock) + : NULL); +#else + that->m_psi= NULL; +#endif + return rw_pr_init(&that->m_prlock); +} +#endif + static inline int inline_mysql_rwlock_destroy( mysql_rwlock_t *that) { @@ -612,6 +746,21 @@ static inline int inline_mysql_rwlock_destroy( return rwlock_destroy(&that->m_rwlock); } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_destroy( + mysql_prlock_t *that) +{ +#ifdef HAVE_PSI_INTERFACE + if (likely(PSI_server && that->m_psi)) + { + PSI_server->destroy_rwlock(that->m_psi); + that->m_psi= NULL; + } +#endif + return rw_pr_destroy(&that->m_prlock); +} +#endif + static inline int inline_mysql_rwlock_rdlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -638,6 +787,34 @@ static inline int inline_mysql_rwlock_rdlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_rdlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_READLOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_rdwait(locker, src_file, src_line); + } +#endif + result= rw_pr_rdlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_rdwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_wrlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -664,6 +841,34 @@ static inline int inline_mysql_rwlock_wrlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_wrlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_WRITELOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_wrwait(locker, src_file, src_line); + } +#endif + result= rw_pr_wrlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_wrwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_tryrdlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -690,6 +895,34 @@ static inline int inline_mysql_rwlock_tryrdlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_tryrdlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_TRYREADLOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_rdwait(locker, src_file, src_line); + } +#endif + result= rw_pr_tryrdlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_rdwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_trywrlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -716,6 +949,34 @@ static inline int inline_mysql_rwlock_trywrlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_trywrlock( + mysql_prlock_t *that +#ifdef HAVE_PSI_INTERFACE + , const char *src_file, uint src_line +#endif + ) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_rwlock_locker *locker= NULL; + if (likely(PSI_server && that->m_psi)) + { + locker= PSI_server->get_thread_rwlock_locker(that->m_psi, + PSI_RWLOCK_TRYWRITELOCK); + if (likely(locker != NULL)) + PSI_server->start_rwlock_wrwait(locker, src_file, src_line); + } +#endif + result= rw_pr_trywrlock(&that->m_prlock); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_rwlock_wrwait(locker, result); +#endif + return result; +} +#endif + static inline int inline_mysql_rwlock_unlock( mysql_rwlock_t *that) { @@ -733,6 +994,25 @@ static inline int inline_mysql_rwlock_unlock( return result; } +#ifndef DISABLE_MYSQL_PRLOCK_H +static inline int inline_mysql_prlock_unlock( + mysql_prlock_t *that) +{ + int result; +#ifdef HAVE_PSI_INTERFACE + struct PSI_thread *thread; + if (likely(PSI_server && that->m_psi)) + { + thread= PSI_server->get_thread(); + if (likely(thread != NULL)) + PSI_server->unlock_rwlock(thread, that->m_psi); + } +#endif + result= rw_pr_unlock(&that->m_prlock); + return result; +} +#endif + static inline int inline_mysql_cond_init( #ifdef HAVE_PSI_INTERFACE PSI_cond_key key, diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index 4a37dcfdec9..94b66f29419 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -20,9 +20,11 @@ # # This file is public domain and comes with NO WARRANTY of any kind -target = libmysqlclient_r.la -target_defs = -DDONT_USE_RAID -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@ -LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@ +target = libmysqlclient_r.la +target_defs = -DDISABLE_MYSQL_PRLOCK_H -DDONT_USE_RAID \ + -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@ + +LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ $(openssl_includes) @ZLIB_INCLUDES@ diff --git a/mysql-test/collections/default.daily b/mysql-test/collections/default.daily index 52af68328c4..a95e5f4657d 100644 --- a/mysql-test/collections/default.daily +++ b/mysql-test/collections/default.daily @@ -2,3 +2,4 @@ perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collection perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded --vardir=var-emebbed --embedded perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 +perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_ndb_row --vardir=var-rpl_ndb_row --mysqld=--binlog-format=row --suite=rpl_ndb,ndb diff --git a/mysql-test/include/default_my.cnf b/mysql-test/include/default_my.cnf index 6888a69b0a4..83c67638d4e 100644 --- a/mysql-test/include/default_my.cnf +++ b/mysql-test/include/default_my.cnf @@ -30,14 +30,6 @@ loose-enable-performance-schema [mysqlbinlog] disable-force-if-open -# mysql_fix_privilege_tables.sh does not read from [client] so it -# need its own section -[mysql_fix_privilege_tables] -socket= @client.socket -port= @client.port -user= @client.user -password= @client.password - [ENV] MASTER_MYPORT= @mysqld.1.port MASTER_MYSOCK= @mysqld.1.socket diff --git a/mysql-test/include/not_var_link.inc b/mysql-test/include/not_var_link.inc new file mode 100644 index 00000000000..96db4f1dfd5 --- /dev/null +++ b/mysql-test/include/not_var_link.inc @@ -0,0 +1,13 @@ +perl; + open (ISLINK, ">" . $ENV{'MYSQL_TMP_DIR'} . "/mtr_var_link"); + my $mvr= -l $ENV{'MYSQLTEST_VARDIR'} ? 1 : 0; + print ISLINK "let \$mtr_var_link= $mvr;\n"; + close ISLINK; +EOF + +--source $MYSQL_TMP_DIR/mtr_var_link +--remove_file $MYSQL_TMP_DIR/mtr_var_link + +if ($mtr_var_link) { + --skip Test does not work with var being softlink +} diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl index f2c8252c47d..64d7376605e 100755 --- a/mysql-test/lib/v1/mysql-test-run.pl +++ b/mysql-test/lib/v1/mysql-test-run.pl @@ -109,6 +109,7 @@ our $glob_use_embedded_server= 0; our @glob_test_mode; our $glob_basedir; +our $glob_bindir; our $path_charsetsdir; our $path_client_bindir; @@ -157,7 +158,6 @@ our $exe_mysqltest; our $exe_ndbd; our $exe_ndb_mgmd; our $exe_slave_mysqld; -our $exe_im; our $exe_my_print_defaults; our $exe_perror; our $lib_udf_example; @@ -720,13 +720,21 @@ sub command_line_setup () { $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`; chomp($glob_mysql_test_dir); } - $default_vardir= "$glob_mysql_test_dir/var"; + if (defined $ENV{MTR_BINDIR}) + { + $default_vardir= "$ENV{MTR_BINDIR}/mysql-test/var"; + } + else + { + $default_vardir= "$glob_mysql_test_dir/var"; + } # In most cases, the base directory we find everything relative to, # is the parent directory of the "mysql-test" directory. For source # distributions, TAR binary distributions and some other packages. $glob_basedir= dirname($glob_mysql_test_dir); + $glob_bindir= $ENV{'MTR_BINDIR'} || $glob_basedir; # In the RPM case, binaries and libraries are installed in the # default system locations, instead of having our own private base # directory. And we install "/usr/share/mysql-test". Moving up one @@ -792,36 +800,37 @@ sub command_line_setup () { } else { - $path_client_bindir= mtr_path_exists("$glob_basedir/client_release", - "$glob_basedir/client_debug", + $path_client_bindir= mtr_path_exists("$glob_bindir/client_release", + "$glob_bindir/client_debug", vs_config_dirs('client', ''), - "$glob_basedir/client", - "$glob_basedir/bin"); + "$glob_bindir/client", + "$glob_bindir/bin"); } # Look for language files and charsetsdir, use same share - $path_share= mtr_path_exists("$glob_basedir/share/mysql", - "$glob_basedir/sql/share", - "$glob_basedir/share"); + $path_share= mtr_path_exists("$glob_bindir/share/mysql", + "$glob_bindir/sql/share", + "$glob_bindir/share"); $path_language= mtr_path_exists("$path_share"); - $path_charsetsdir= mtr_path_exists("$path_share/charsets"); - + $path_charsetsdir = mtr_path_exists("$glob_basedir/share/mysql/charsets", + "$glob_basedir/sql/share/charsets", + "$glob_basedir/share/charsets"); if (!$opt_extern) { $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), vs_config_dirs('sql', 'mysqld-debug'), - "$glob_basedir/sql/mysqld", + "$glob_bindir/sql/mysqld", "$path_client_bindir/mysqld-max-nt", "$path_client_bindir/mysqld-max", "$path_client_bindir/mysqld-nt", "$path_client_bindir/mysqld", "$path_client_bindir/mysqld-debug", "$path_client_bindir/mysqld-max", - "$glob_basedir/libexec/mysqld", - "$glob_basedir/bin/mysqld", - "$glob_basedir/sbin/mysqld"); + "$glob_bindir/libexec/mysqld", + "$glob_bindir/bin/mysqld", + "$glob_bindir/sbin/mysqld"); # Use the mysqld found above to find out what features are available collect_mysqld_features(); @@ -1563,37 +1572,24 @@ sub collect_mysqld_features_from_running_server () } } -sub executable_setup_im () { - - # Look for instance manager binary - mysqlmanager - $exe_im= - mtr_exe_maybe_exists( - "$glob_basedir/server-tools/instance-manager/mysqlmanager", - "$glob_basedir/libexec/mysqlmanager", - "$glob_basedir/bin/mysqlmanager", - "$glob_basedir/sbin/mysqlmanager"); - - return ($exe_im eq ""); -} - sub executable_setup_ndb () { # Look for ndb tols and binaries - my $ndb_path= mtr_file_exists("$glob_basedir/ndb", - "$glob_basedir/storage/ndb", - "$glob_basedir/bin"); + my $ndb_path= mtr_file_exists("$glob_bindir/ndb", + "$glob_bindir/storage/ndb", + "$glob_bindir/bin"); $exe_ndbd= mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd", "$ndb_path/ndbd", - "$glob_basedir/libexec/ndbd"); + "$glob_bindir/libexec/ndbd"); $exe_ndb_mgm= mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm", "$ndb_path/ndb_mgm"); $exe_ndb_mgmd= mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd", "$ndb_path/ndb_mgmd", - "$glob_basedir/libexec/ndb_mgmd"); + "$glob_bindir/libexec/ndb_mgmd"); $exe_ndb_waiter= mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter", "$ndb_path/ndb_waiter"); @@ -1636,11 +1632,11 @@ sub executable_setup () { $exe_my_print_defaults= mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'), "$path_client_bindir/my_print_defaults", - "$glob_basedir/extra/my_print_defaults"); + "$glob_bindir/extra/my_print_defaults"); # Look for perror $exe_perror= mtr_exe_exists(vs_config_dirs('extra', 'perror'), - "$glob_basedir/extra/perror", + "$glob_bindir/extra/perror", "$path_client_bindir/perror"); # Look for the client binaries @@ -1697,23 +1693,15 @@ sub executable_setup () { } } - if ( ! $opt_skip_im and executable_setup_im()) - { - mtr_warning("Could not find all required instance manager binaries, " . - "all im tests will fail, use --skip-im to " . - "continue without instance manager"); - $instance_manager->{"executable_setup_failed"}= 1; - } - # Look for the udf_example library $lib_udf_example= mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'), - "$glob_basedir/sql/.libs/udf_example.so",); + "$glob_bindir/sql/.libs/udf_example.so",); # Look for the ha_example library $lib_example_plugin= mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'), - "$glob_basedir/storage/example/.libs/ha_example.so",); + "$glob_bindir/storage/example/.libs/ha_example.so",); } @@ -1722,7 +1710,7 @@ sub executable_setup () { { $exe_mysqltest= mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'), - "$glob_basedir/libmysqld/examples/mysqltest_embedded", + "$glob_bindir/libmysqld/examples/mysqltest_embedded", "$path_client_bindir/mysqltest_embedded"); } else @@ -1737,21 +1725,21 @@ sub executable_setup () { $exe_mysql_client_test= mtr_exe_maybe_exists( vs_config_dirs('libmysqld/examples', 'mysql_client_test_embedded'), - "$glob_basedir/libmysqld/examples/mysql_client_test_embedded"); + "$glob_bindir/libmysqld/examples/mysql_client_test_embedded"); } else { $exe_mysql_client_test= mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'), - "$glob_basedir/tests/mysql_client_test", - "$glob_basedir/bin/mysql_client_test"); + "$glob_bindir/tests/mysql_client_test", + "$glob_bindir/bin/mysql_client_test"); } # Look for bug25714 executable which may _not_ exist in # some versions, test using it should be skipped $exe_bug25714= mtr_exe_maybe_exists(vs_config_dirs('tests', 'bug25714'), - "$glob_basedir/tests/bug25714"); + "$glob_bindir/tests/bug25714"); } @@ -1860,13 +1848,13 @@ sub environment_setup () { # are used in favor of the system installed ones if ( $source_dist ) { - push(@ld_library_paths, "$glob_basedir/libmysql/.libs/", - "$glob_basedir/libmysql_r/.libs/", - "$glob_basedir/zlib.libs/"); + push(@ld_library_paths, "$glob_bindir/libmysql/.libs/", + "$glob_bindir/libmysql_r/.libs/", + "$glob_bindir/zlib.libs/"); } else { - push(@ld_library_paths, "$glob_basedir/lib"); + push(@ld_library_paths, "$glob_bindir/lib"); } } @@ -1875,7 +1863,7 @@ sub environment_setup () { # -------------------------------------------------------------------------- if ( $glob_ndbcluster_supported ) { - push(@ld_library_paths, "$glob_basedir/storage/ndb/src/.libs"); + push(@ld_library_paths, "$glob_bindir/storage/ndb/src/.libs"); } # -------------------------------------------------------------------------- @@ -1993,7 +1981,6 @@ sub environment_setup () { # ---------------------------------------------------- if ( ! $opt_skip_im ) { - $ENV{'IM_EXE'}= $exe_im; $ENV{'IM_PATH_PID'}= $instance_manager->{path_pid}; $ENV{'IM_PATH_ANGEL_PID'}= $instance_manager->{path_angel_pid}; $ENV{'IM_PORT'}= $instance_manager->{port}; @@ -2190,14 +2177,14 @@ sub environment_setup () { vs_config_dirs('storage/myisam', 'myisamchk'), vs_config_dirs('myisam', 'myisamchk'), "$path_client_bindir/myisamchk", - "$glob_basedir/storage/myisam/myisamchk", - "$glob_basedir/myisam/myisamchk")); + "$glob_bindir/storage/myisam/myisamchk", + "$glob_bindir/myisam/myisamchk")); $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists( vs_config_dirs('storage/myisam', 'myisampack'), vs_config_dirs('myisam', 'myisampack'), "$path_client_bindir/myisampack", - "$glob_basedir/storage/myisam/myisampack", - "$glob_basedir/myisam/myisampack")); + "$glob_bindir/storage/myisam/myisampack", + "$glob_bindir/myisam/myisampack")); # ---------------------------------------------------- # We are nice and report a bit about our settings @@ -2548,12 +2535,12 @@ sub vs_config_dirs ($$) { if ($opt_vs_config) { - return ("$glob_basedir/$path_part/$opt_vs_config/$exe"); + return ("$glob_bindir/$path_part/$opt_vs_config/$exe"); } - return ("$glob_basedir/$path_part/release/$exe", - "$glob_basedir/$path_part/relwithdebinfo/$exe", - "$glob_basedir/$path_part/debug/$exe"); + return ("$glob_bindir/$path_part/release/$exe", + "$glob_bindir/$path_part/relwithdebinfo/$exe", + "$glob_bindir/$path_part/debug/$exe"); } ############################################################################## diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 2fbbdf0b819..58a289422f4 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1723,26 +1723,8 @@ sub client_debug_arg($$) { } -sub mysql_fix_arguments () { - - return "" ; - - my $exe= - mtr_script_exists("$basedir/scripts/mysql_fix_privilege_tables", - "$path_client_bindir/mysql_fix_privilege_tables"); - my $args; - mtr_init_args(\$args); - mtr_add_arg($args, "--defaults-file=%s", $path_config_file); - - mtr_add_arg($args, "--basedir=%s", $basedir); - mtr_add_arg($args, "--bindir=%s", $path_client_bindir); - mtr_add_arg($args, "--verbose"); - return mtr_args2str($exe, @$args); -} - - sub client_arguments ($;$) { - my $client_name= shift; + my $client_name= shift; my $group_suffix= shift; my $client_exe= mtr_exe_exists("$path_client_bindir/$client_name"); @@ -2083,7 +2065,6 @@ sub environment_setup { $ENV{'MYSQL_UPGRADE'}= client_arguments("mysql_upgrade"); $ENV{'MYSQLADMIN'}= native_path($exe_mysqladmin); $ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments(); - $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= mysql_fix_arguments(); $ENV{'EXE_MYSQL'}= $exe_mysql; # ---------------------------------------------------- @@ -2647,14 +2628,6 @@ sub create_config_file_for_extern { character-sets-dir= $path_charsetsdir local-load= $opt_tmpdir -# mysql_fix_privilege_tables.sh don't read from [client] -[mysql_fix_privilege_tables] -socket = $opts{'socket'} -port = $opts{'port'} -user = $opts{'user'} -password = $opts{'password'} - - EOF ; diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index d43f3b0e0bd..4de7a192546 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -2438,6 +2438,9 @@ t1 CREATE TABLE `t1` ( INSERT INTO t1(subject) VALUES ('abcd'); INSERT INTO t1(subject) VALUES(x'f0909080'); DROP TABLE t1; +CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4, FULLTEXT INDEX(a)); +INSERT INTO t1 VALUES (0xF0A08080 /* U+20000 */ ); +DROP TABLE t1; # # Bug #51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column # diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index fd23bfa0562..3702443d04a 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -207,3 +207,30 @@ insert into t2 (a) values (3); unlock tables; # --> connection con1 drop table t1, t2, t3; +# +# Bug#51710 FLUSH TABLES <view> WITH READ LOCK kills the server +# +drop view if exists v1, v2, v3; +drop table if exists t1, v1; +create table t1 (a int); +create view v1 as select 1; +create view v2 as select * from t1; +create view v3 as select * from v2; +flush table v1, v2, v3 with read lock; +ERROR HY000: 'test.v1' is not BASE TABLE +flush table v1 with read lock; +ERROR HY000: 'test.v1' is not BASE TABLE +flush table v2 with read lock; +ERROR HY000: 'test.v2' is not BASE TABLE +flush table v3 with read lock; +ERROR HY000: 'test.v3' is not BASE TABLE +create temporary table v1 (a int); +flush table v1 with read lock; +ERROR HY000: 'test.v1' is not BASE TABLE +drop view v1; +create table v1 (a int); +flush table v1 with read lock; +drop temporary table v1; +unlock tables; +drop view v2, v3; +drop table t1, v1; diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result index ff6daf6443e..984f0df3d0e 100644 --- a/mysql-test/r/mdl_sync.result +++ b/mysql-test/r/mdl_sync.result @@ -1678,14 +1678,21 @@ insert into t2 values (1);; # # Switching to connection 'handler_con1'. # Wait until INSERT is blocked on table-level lock. -# The below statement should not cause deadlock. +# Sending 'alter table t1 drop column j'. It should not cause +# deadlock. alter table t1 drop column j; -unlock tables; +# Switching to connection 'handler_con2'. +# Wait until ALTER is blocked during upgrade. # # Switching to connection 'default'. # Reap INSERT. +ERROR HY000: Wait on a lock was aborted due to a pending exclusive lock handler t1 close; # +# Switching to connection 'handler_con1'. +# Reaping 'alter table t1 drop column j' +unlock tables; +# Switching to connection 'default'. # Then, check the scenario in which upgrade of SNRW lock to X # lock is blocked by HANDLER which is open in connection currently # waiting to get SW lock on the same table. @@ -2248,6 +2255,8 @@ SET DEBUG_SYNC= 'RESET'; # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null' # failed in open_ltable() # +# Supress warnings written to the log file +call mtr.add_suppression("Wait on a lock was aborted due to a pending exclusive lock"); DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (i INT); CREATE TABLE t2 (i INT); @@ -2271,7 +2280,6 @@ SET DEBUG_SYNC= 'now WAIT_FOR parked'; # Sending: SELECT 1; # connection: con3 -# Sending: ALTER TABLE t1 ADD COLUMN j INT; # connection: default SET DEBUG_SYNC= 'now SIGNAL go'; @@ -2284,8 +2292,6 @@ HANDLER t1 CLOSE; # Reaping SELECT 1 1 1 -# connection: con3 -# Reaping ALTER TABLE t1 ADD COLUMN j INT # connection: default DROP TABLE t1, t2; SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/r/mysqlbinlog_row_innodb.result b/mysql-test/r/mysqlbinlog_row_innodb.result index dd98a12a0de..00a3eb79b64 100644 --- a/mysql-test/r/mysqlbinlog_row_innodb.result +++ b/mysql-test/r/mysqlbinlog_row_innodb.result @@ -2405,10 +2405,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -2767,10 +2767,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3020,10 +3020,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3552,10 +3552,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ diff --git a/mysql-test/r/mysqlbinlog_row_myisam.result b/mysql-test/r/mysqlbinlog_row_myisam.result index 87f9ab877e1..7b0112d0a91 100644 --- a/mysql-test/r/mysqlbinlog_row_myisam.result +++ b/mysql-test/r/mysqlbinlog_row_myisam.result @@ -2405,10 +2405,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -2773,10 +2773,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3028,10 +3028,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ @@ -3568,10 +3568,10 @@ BEGIN ### @38='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ ### @39='' /* STRING(3) meta=65027 nullable=1 is_null=0 */ ### @40='' /* STRING(765) meta=57085 nullable=1 is_null=0 */ -### @41='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @41='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ ### @42='' /* STRING(0) meta=65024 nullable=1 is_null=0 */ -### @43='\x00' /* STRING(2) meta=65026 nullable=1 is_null=0 */ -### @44='\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00' /* STRING(510) meta=61182 nullable=1 is_null=0 */ +### @43='' /* STRING(2) meta=65026 nullable=1 is_null=0 */ +### @44='' /* STRING(510) meta=61182 nullable=1 is_null=0 */ ### @45='' /* VARSTRING(0) meta=0 nullable=1 is_null=0 */ ### @46='' /* VARSTRING(1) meta=1 nullable=1 is_null=0 */ ### @47='' /* VARSTRING(255) meta=255 nullable=1 is_null=0 */ diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result index ddc48b635cf..458343a6b92 100644 --- a/mysql-test/r/partition_column.result +++ b/mysql-test/r/partition_column.result @@ -1,4 +1,44 @@ drop table if exists t1; +CREATE TABLE t1 (a DECIMAL) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN (0)); +ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning +CREATE TABLE t1 (a BLOB) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN ("X")); +ERROR HY000: A BLOB field is not allowed in partition function +CREATE TABLE t1 (a TEXT) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN ("X")); +ERROR HY000: A BLOB field is not allowed in partition function +CREATE TABLE t1 (a FLOAT) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN (0.0)); +ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning +CREATE TABLE t1 (a DOUBLE) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN (0.0)); +ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning +CREATE TABLE t1 (d TIMESTAMP) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN ('2000-01-01'), +PARTITION p1 VALUES LESS THAN ('2040-01-01')); +ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning +CREATE TABLE t1 (d BIT(1)) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN (0), +PARTITION p1 VALUES LESS THAN (1)); +ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning +CREATE TABLE t1 (d ENUM("YES","NO")) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN ("NO"), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning +CREATE TABLE t1 (d SET("Car","MC")) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN ("MC"), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning create table t1 (a int, b int) partition by range columns (a,b) ( partition p0 values less than (maxvalue, 10), @@ -430,16 +470,6 @@ partition by range columns(d) ( partition p0 values less than ('2000-01-01'), partition p1 values less than ('2040-01-01')); ERROR HY000: Partition column values of incorrect type -create table t1 (d timestamp) -partition by range columns(d) -( partition p0 values less than ('2000-01-01'), -partition p1 values less than ('2040-01-01')); -ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning -create table t1 (d bit(1)) -partition by range columns(d) -( partition p0 values less than (0), -partition p1 values less than (1)); -ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning create table t1 (a int, b int) partition by range columns(a,b) (partition p0 values less than (maxvalue, 10)); diff --git a/mysql-test/r/read_only_innodb.result b/mysql-test/r/read_only_innodb.result index 690de085bf9..13e5980f900 100644 --- a/mysql-test/r/read_only_innodb.result +++ b/mysql-test/r/read_only_innodb.result @@ -46,3 +46,174 @@ UNLOCK TABLES; DROP TABLE t1; DROP USER test@localhost; echo End of 5.1 tests +# +# Bug#33669: Transactional temporary tables do not work under --read-only +# +DROP DATABASE IF EXISTS db1; +# Setup user and tables +CREATE USER bug33669@localhost; +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a INT) ENGINE=INNODB; +CREATE TABLE db1.t2 (a INT) ENGINE=INNODB; +INSERT INTO db1.t1 VALUES (1); +INSERT INTO db1.t2 VALUES (2); +GRANT CREATE TEMPORARY TABLES, DROP, INSERT, DELETE, UPDATE, +SELECT, LOCK TABLES ON db1.* TO bug33669@localhost; +SET GLOBAL READ_ONLY = ON; +# Connection con1 (user bug33669): + +# Create, insert and drop temporary table: + +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +INSERT INTO temp VALUES (1); +DROP TABLE temp; + +# Lock base tables and use temporary table: + +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +LOCK TABLES t1 READ, t2 READ; +SELECT * FROM t1; +a +1 +INSERT INTO temp values (1); +SELECT * FROM t2; +a +2 +UNLOCK TABLES; +DROP TABLE temp; + +# Transaction + +BEGIN; +SELECT * FROM t1; +a +1 +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1); +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement +INSERT INTO temp VALUES (1); +SELECT * FROM t2; +a +2 +ROLLBACK; +SELECT * FROM temp; +a +DROP TABLE temp; + +# Lock base table as READ and temporary table as WRITE: + +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +LOCK TABLES t1 READ, temp WRITE; +SELECT * FROM t1; +a +1 +SELECT * FROM temp; +a +INSERT INTO t1 VALUES (1); +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement +INSERT INTO temp VALUES (1); +DROP TABLE temp; +UNLOCK TABLES; + +# Lock temporary table that shadows a base table: + +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB; +LOCK TABLES t1 WRITE; +DROP TABLE t1; +SELECT * FROM t1; +ERROR HY000: Table 't1' was not locked with LOCK TABLES + +# INSERT SELECT from base table into temporary table: + +CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE temp2 LIKE temp1; +BEGIN; +INSERT INTO temp1 VALUES (10); +INSERT INTO temp2 VALUES (10); +INSERT INTO temp1 SELECT * FROM t1; +INSERT INTO temp2 SELECT * FROM t2; +SELECT * FROM temp1 ORDER BY a; +a +1 +10 +SELECT * FROM temp2 ORDER BY a; +a +2 +10 +ROLLBACK; +SELECT * FROM temp1,temp2; +a a +LOCK TABLES t1 READ, t2 READ; +INSERT INTO temp1 VALUES (10); +INSERT INTO temp2 VALUES (10); +INSERT INTO temp1 SELECT * FROM t1; +INSERT INTO temp2 SELECT * FROM t2; +SELECT * FROM temp1 ORDER BY a; +a +1 +10 +SELECT * FROM temp2 ORDER BY a; +a +2 +10 +UNLOCK TABLES; +DELETE temp1, temp2 FROM temp1, temp2; +INSERT INTO temp1 VALUES (10); +INSERT INTO temp2 VALUES (10); +INSERT INTO temp1 SELECT * FROM t1; +INSERT INTO temp2 SELECT * FROM t2; +SELECT * FROM temp1 ORDER BY a; +a +1 +10 +SELECT * FROM temp2 ORDER BY a; +a +2 +10 +DROP TABLE temp1, temp2; + +# INSERT and INSERT SELECT that uses subqueries: +CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE temp2 LIKE temp1; +INSERT INTO temp1 (a) VALUES ((SELECT MAX(a) FROM t1)); +LOCK TABLES t2 READ; +INSERT INTO temp2 (a) VALUES ((SELECT MAX(a) FROM t2)); +UNLOCK TABLES; +LOCK TABLES t1 READ, t2 READ; +INSERT INTO temp1 SELECT * FROM t1 WHERE a < (SELECT MAX(a) FROM t2); +INSERT INTO temp2 SELECT * FROM t2 WHERE a > (SELECT MAX(a) FROM t1); +UNLOCK TABLES; +INSERT INTO temp1 SELECT * FROM t1 WHERE a < (SELECT MAX(a) FROM t2); +INSERT INTO temp2 SELECT * FROM t2 WHERE a > (SELECT MAX(a) FROM t1); +SELECT * FROM temp1 ORDER BY a; +a +1 +1 +1 +SELECT * FROM temp2 ORDER BY a; +a +2 +2 +2 +DROP TABLE temp1, temp2; + +# Multiple table update: + +CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE temp2 LIKE temp1; +INSERT INTO temp1 VALUES (1),(2); +INSERT INTO temp2 VALUES (3),(4); +UPDATE temp1,temp2 SET temp1.a = 5, temp2.a = 10; +SELECT * FROM temp1, temp2; +a a +5 10 +5 10 +5 10 +5 10 +DROP TABLE temp1, temp2; + +# Disconnect and cleanup + +SET GLOBAL READ_ONLY = OFF; +DROP USER bug33669@localhost; +DROP DATABASE db1; diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index fd13f53d02b..672b4d423a3 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -503,3 +503,19 @@ f1 f2-f3 5 0 DROP TABLE t1; End of 5.0 tests + +Bug#50888 valgrind warnings in Field_timestamp::val_str + +SET TIMESTAMP=0; +CREATE TABLE t1(a timestamp); +INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02'); +FLUSH TABLES t1; +SELECT MAX(a) FROM t1; +MAX(a) +2010-03-05 11:08:02 +SELECT a FROM t1; +a +2008-02-23 09:23:45 +2010-03-05 11:08:02 +DROP TABLE t1; +End of Bug#50888 diff --git a/mysql-test/suite/perfschema/r/dml_setup_instruments.result b/mysql-test/suite/perfschema/r/dml_setup_instruments.result index be7d8825364..448aaa7400f 100644 --- a/mysql-test/suite/perfschema/r/dml_setup_instruments.result +++ b/mysql-test/suite/perfschema/r/dml_setup_instruments.result @@ -25,9 +25,10 @@ wait/synch/rwlock/sql/LOCK_system_variables_hash YES YES wait/synch/rwlock/sql/LOCK_sys_init_connect YES YES wait/synch/rwlock/sql/LOCK_sys_init_slave YES YES wait/synch/rwlock/sql/LOGGER::LOCK_logger YES YES +wait/synch/rwlock/sql/MDL_context::waiting_for_lock YES YES +wait/synch/rwlock/sql/MDL_lock::rwlock YES YES wait/synch/rwlock/sql/Query_cache_query::lock YES YES wait/synch/rwlock/sql/THR_LOCK_servers YES YES -wait/synch/rwlock/sql/THR_LOCK_udf YES YES select * from performance_schema.SETUP_INSTRUMENTS where name like 'Wait/Synch/Cond/sql/%' and name not in ( diff --git a/mysql-test/suite/perfschema/r/pfs_upgrade.result b/mysql-test/suite/perfschema/r/pfs_upgrade.result new file mode 100644 index 00000000000..5d444cddc39 --- /dev/null +++ b/mysql-test/suite/perfschema/r/pfs_upgrade.result @@ -0,0 +1,153 @@ +drop table if exists test.user_table; +drop procedure if exists test.user_proc; +drop function if exists test.user_func; +drop event if exists test.user_event; +"Testing mysql_upgrade with TABLE performance_schema.user_table" +create table test.user_table(a int); +use performance_schema; +show tables like "user_table"; +Tables_in_performance_schema (user_table) +user_table +ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database. +ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists +ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists +ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists +ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists +ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists +ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists +ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists +ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists +ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists +ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists +ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists +ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists +ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists +FATAL ERROR: Upgrade failed +show tables like "user_table"; +Tables_in_performance_schema (user_table) +user_table +use test; +drop table test.user_table; +"Testing mysql_upgrade with VIEW performance_schema.user_view" +create view test.user_view as select "Not supposed to be here"; +use performance_schema; +show tables like "user_view"; +Tables_in_performance_schema (user_view) +user_view +ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database. +ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists +ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists +ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists +ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists +ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists +ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists +ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists +ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists +ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists +ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists +ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists +ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists +ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists +FATAL ERROR: Upgrade failed +show tables like "user_view"; +Tables_in_performance_schema (user_view) +user_view +use test; +drop view test.user_view; +"Testing mysql_upgrade with PROCEDURE performance_schema.user_proc" +create procedure test.user_proc() +select "Not supposed to be here"; +update mysql.proc set db='performance_schema' where name='user_proc'; +ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database. +ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists +ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists +ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists +ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists +ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists +ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists +ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists +ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists +ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists +ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists +ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists +ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists +ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists +FATAL ERROR: Upgrade failed +select name from mysql.proc where db='performance_schema'; +name +user_proc +update mysql.proc set db='test' where name='user_proc'; +drop procedure test.user_proc; +"Testing mysql_upgrade with FUNCTION performance_schema.user_func" +create function test.user_func() returns integer +return 0; +update mysql.proc set db='performance_schema' where name='user_func'; +ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database. +ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists +ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists +ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists +ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists +ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists +ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists +ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists +ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists +ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists +ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists +ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists +ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists +ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists +FATAL ERROR: Upgrade failed +select name from mysql.proc where db='performance_schema'; +name +user_func +update mysql.proc set db='test' where name='user_func'; +drop function test.user_func; +"Testing mysql_upgrade with EVENT performance_schema.user_event" +create event test.user_event on schedule every 1 day do +select "not supposed to be here"; +update mysql.event set db='performance_schema' where name='user_event'; +ERROR 1644 (HY000) at line 178: Unexpected content found in the performance_schema database. +ERROR 1050 (42S01) at line 203: Table 'COND_INSTANCES' already exists +ERROR 1050 (42S01) at line 233: Table 'EVENTS_WAITS_CURRENT' already exists +ERROR 1050 (42S01) at line 247: Table 'EVENTS_WAITS_HISTORY' already exists +ERROR 1050 (42S01) at line 261: Table 'EVENTS_WAITS_HISTORY_LONG' already exists +ERROR 1050 (42S01) at line 281: Table 'EVENTS_WAITS_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 302: Table 'EVENTS_WAITS_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 323: Table 'EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 340: Table 'FILE_INSTANCES' already exists +ERROR 1050 (42S01) at line 359: Table 'FILE_SUMMARY_BY_EVENT_NAME' already exists +ERROR 1050 (42S01) at line 379: Table 'FILE_SUMMARY_BY_INSTANCE' already exists +ERROR 1050 (42S01) at line 396: Table 'MUTEX_INSTANCES' already exists +ERROR 1050 (42S01) at line 414: Table 'PERFORMANCE_TIMERS' already exists +ERROR 1050 (42S01) at line 431: Table 'PROCESSLIST' already exists +ERROR 1050 (42S01) at line 449: Table 'RWLOCK_INSTANCES' already exists +ERROR 1050 (42S01) at line 465: Table 'SETUP_CONSUMERS' already exists +ERROR 1050 (42S01) at line 482: Table 'SETUP_INSTRUMENTS' already exists +ERROR 1050 (42S01) at line 502: Table 'SETUP_OBJECTS' already exists +ERROR 1050 (42S01) at line 518: Table 'SETUP_TIMERS' already exists +FATAL ERROR: Upgrade failed +select name from mysql.event where db='performance_schema'; +name +user_event +update mysql.event set db='test' where name='user_event'; +drop event test.user_event; diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test index 749eccca793..755648036ac 100644 --- a/mysql-test/suite/perfschema/t/misc.test +++ b/mysql-test/suite/perfschema/t/misc.test @@ -18,6 +18,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +--source include/not_var_link.inc # # Bug#45496 Performance schema: assertion fails in diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade.test b/mysql-test/suite/perfschema/t/pfs_upgrade.test new file mode 100644 index 00000000000..4902dc73e8a --- /dev/null +++ b/mysql-test/suite/perfschema/t/pfs_upgrade.test @@ -0,0 +1,138 @@ +# 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 + +# Tests for PERFORMANCE_SCHEMA +# Make sure mysql_upgrade does not destroy data in a 'performance_schema' +# database. +# + +--source include/not_embedded.inc +--source include/have_perfschema.inc +--source include/have_lowercase0.inc + +--disable_warnings +drop table if exists test.user_table; +drop procedure if exists test.user_proc; +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`; +--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 + +# Make sure the table is still visible +show tables like "user_table"; + +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`; +--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 + +# Make sure the view is still visible +show tables like "user_view"; + +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() + select "Not supposed to be here"; + +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 + +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 + return 0; + +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 + +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 + select "not supposed to be here"; + +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 + +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/rpl/r/rpl_row_utf16.result b/mysql-test/suite/rpl/r/rpl_row_utf16.result new file mode 100644 index 00000000000..f7e66dd92ee --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_utf16.result @@ -0,0 +1,23 @@ +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 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); +INSERT INTO t1 VALUES ('abc'); +INSERT INTO t1 VALUES (); +#### ON MASTER +SELECT c1, hex(c1) from t1; +c1 abc +hex(c1) 006100620063 +c1 ola +hex(c1) 006F006C0061 +#### ON SLAVE +SELECT c1, hex(c1) FROM t1; +c1 abc +hex(c1) 006100620063 +c1 ola +hex(c1) 006F006C0061 +Comparing tables master:test.t1 and slave:test.t1 +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/r/rpl_row_utf32.result b/mysql-test/suite/rpl/r/rpl_row_utf32.result new file mode 100644 index 00000000000..e07db9c9e48 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_utf32.result @@ -0,0 +1,25 @@ +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; +SET SQL_LOG_BIN=0; +CREATE TABLE t1 (c1 char(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +SET SQL_LOG_BIN=1; +SET @saved_slave_type_conversions= @@global.slave_type_conversions; +include/stop_slave.inc +SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; +include/start_slave.inc +SET SQL_LOG_BIN=0; +CREATE TABLE t1 ( c1 varchar(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +SET SQL_LOG_BIN=1; +INSERT INTO t1(c1) VALUES ('insert into t1'); +DROP TABLE t1; +SET GLOBAL SLAVE_TYPE_CONVERSIONS= @saved_slave_type_conversions; +include/stop_slave.inc +include/start_slave.inc diff --git a/mysql-test/suite/rpl/r/rpl_stm_user_variables.result b/mysql-test/suite/rpl/r/rpl_stm_user_variables.result index 5e758fc02f3..8f43425b201 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_user_variables.result +++ b/mysql-test/suite/rpl/r/rpl_stm_user_variables.result @@ -206,3 +206,19 @@ Comparing tables master:test.t1 and slave:test.t1 TRUNCATE t1; ## check: contents of both tables master's and slave's DROP TABLE t1; +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 ( c INT, PRIMARY KEY (c)) Engine=MyISAM; +CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW SET @aux = -1 ; +SET @aux = 10294947273192243200; +SET @aux1= @aux; +INSERT INTO t1 VALUES (@aux) , (@aux1); +ERROR 23000: Duplicate entry '2147483647' for key 'PRIMARY' +## assertion: master and slave tables are in sync +Comparing tables master:test.t1 and slave:test.t1 +DROP TRIGGER tr1; +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_row_utf16.test b/mysql-test/suite/rpl/t/rpl_row_utf16.test new file mode 100644 index 00000000000..b8f7b724ea1 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_utf16.test @@ -0,0 +1,26 @@ +-- source include/master-slave.inc +-- source include/have_binlog_format_row.inc +-- source include/have_utf16.inc + +# +# BUG#51716: Char column with utf16 character set gives wrong padding on slave +# + +CREATE TABLE t1(c1 CHAR(10) CHARACTER SET utf16 DEFAULT 'ola'); +INSERT INTO t1 VALUES ('abc'); # explicit value is inserted and encoded correctly +INSERT INTO t1 VALUES (); # default value is inserted and encoded correctly + +-- echo #### ON MASTER +--query_vertical SELECT c1, hex(c1) from t1 + +-- sync_slave_with_master + +-- echo #### ON SLAVE +--query_vertical SELECT c1, hex(c1) FROM t1 + +# assertion: tables don't differ +-- let $diff_table_1=master:test.t1 +-- let $diff_table_2=slave:test.t1 +-- source include/diff_tables.inc + +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_row_utf32.test b/mysql-test/suite/rpl/t/rpl_row_utf32.test new file mode 100644 index 00000000000..44ca4b345c0 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_utf32.test @@ -0,0 +1,44 @@ +-- source include/master-slave.inc +-- source include/have_binlog_format_row.inc +-- source include/have_utf32.inc + +# +# BUG#51787 Assertion `(n % 4) == 0' on slave upon INSERT into a table with UTF32 +# + +SET SQL_LOG_BIN=0; +CREATE TABLE t1 (c1 char(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +SET SQL_LOG_BIN=1; + +-- connection slave + +SET @saved_slave_type_conversions= @@global.slave_type_conversions; + +# +# Force test to cover conversion execution path in the +# slave, which also makes use of sql_type method, thence +# can ultimately trigger the assertion. +# +-- source include/stop_slave.inc +SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; +-- source include/start_slave.inc + +SET SQL_LOG_BIN=0; +CREATE TABLE t1 ( c1 varchar(255) DEFAULT NULL, KEY c1 (c1)) DEFAULT CHARSET=utf32; +SET SQL_LOG_BIN=1; + +-- connection master + +INSERT INTO t1(c1) VALUES ('insert into t1'); +DROP TABLE t1; + +--sync_slave_with_master + +# assertion: the slave woul hit an/several assertions: +# before and during slave conversion procedure +# Now that is fixed, it wont. + +SET GLOBAL SLAVE_TYPE_CONVERSIONS= @saved_slave_type_conversions; +-- source include/stop_slave.inc +-- source include/start_slave.inc +-- connection master diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync.test b/mysql-test/suite/rpl/t/rpl_semi_sync.test index c6c4096f0fc..b04541aba21 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync.test @@ -3,10 +3,6 @@ source include/not_embedded.inc; source include/have_innodb.inc; source include/master-slave.inc; -# -- [DISABLED Bug#49557] -# This test case fails on Windows due to Bug#49557. -source include/not_windows.inc; - let $engine_type= InnoDB; #let $engine_type= MyISAM; diff --git a/mysql-test/suite/rpl/t/rpl_stm_user_variables.test b/mysql-test/suite/rpl/t/rpl_stm_user_variables.test index c58acdcb084..05adc597776 100644 --- a/mysql-test/suite/rpl/t/rpl_stm_user_variables.test +++ b/mysql-test/suite/rpl/t/rpl_stm_user_variables.test @@ -139,3 +139,36 @@ TRUNCATE t1; -- connection master DROP TABLE t1; -- sync_slave_with_master + +##################################################################### +# +# BUG#51426 +# +##################################################################### +-- source include/master-slave-reset.inc +-- connection master + +CREATE TABLE t1 ( c INT, PRIMARY KEY (c)) Engine=MyISAM; + +# offending trigger that would reset the unsigned flag for aux before +# binlogging of User_var_log_event would take place. +CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW SET @aux = -1 ; + +SET @aux = 10294947273192243200; +SET @aux1= @aux; +-- error ER_DUP_ENTRY +INSERT INTO t1 VALUES (@aux) , (@aux1); + +-- sync_slave_with_master + +-- echo ## assertion: master and slave tables are in sync +-- let $diff_table_1=master:test.t1 +-- let $diff_table_2=slave:test.t1 +-- source include/diff_tables.inc + +--connection master +DROP TRIGGER tr1; +DROP TABLE t1; + +-- sync_slave_with_master + diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt index 84d2a52b639..711ec42bd8a 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def-master.opt @@ -1 +1 @@ ---default-collation=ucs2_unicode_ci --default-character-set=ucs2,latin1 +--collation-server=ucs2_unicode_ci --character-set-server=ucs2,latin1 diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 8916de670c1..f396d36e5b0 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1763,6 +1763,13 @@ INSERT INTO t1(subject) VALUES ('abcd'); INSERT INTO t1(subject) VALUES(x'f0909080'); DROP TABLE t1; +# +# Make sure fulltext does not crash on supplementary characters +# +CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4, FULLTEXT INDEX(a)); +INSERT INTO t1 VALUES (0xF0A08080 /* U+20000 */ ); +DROP TABLE t1; + --echo # --echo # Bug #51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column --echo # diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 582d2562fc6..0d406338394 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -324,3 +324,34 @@ disconnect con1; --source include/wait_until_disconnected.inc connection default; drop table t1, t2, t3; + +--echo # +--echo # Bug#51710 FLUSH TABLES <view> WITH READ LOCK kills the server +--echo # +--disable_warnings +drop view if exists v1, v2, v3; +drop table if exists t1, v1; +--enable_warnings +create table t1 (a int); +create view v1 as select 1; +create view v2 as select * from t1; +create view v3 as select * from v2; + +--error ER_WRONG_OBJECT +flush table v1, v2, v3 with read lock; +--error ER_WRONG_OBJECT +flush table v1 with read lock; +--error ER_WRONG_OBJECT +flush table v2 with read lock; +--error ER_WRONG_OBJECT +flush table v3 with read lock; +create temporary table v1 (a int); +--error ER_WRONG_OBJECT +flush table v1 with read lock; +drop view v1; +create table v1 (a int); +flush table v1 with read lock; +drop temporary table v1; +unlock tables; +drop view v2, v3; +drop table t1, v1; diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index b9a9241ce32..ef434e33cfa 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -2277,17 +2277,32 @@ let $wait_condition= select count(*) = 1 from information_schema.processlist where state = "Table lock" and info = "insert into t2 values (1)"; --source include/wait_condition.inc ---echo # The below statement should not cause deadlock. -alter table t1 drop column j; -unlock tables; +--echo # Sending 'alter table t1 drop column j'. It should not cause +--echo # deadlock. +send alter table t1 drop column j; +--echo # Switching to connection 'handler_con2'. +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"; +--source include/wait_condition.inc --echo # --echo # Switching to connection 'default'. connection default; --echo # Reap INSERT. +--error ER_LOCK_ABORTED --reap handler t1 close; - --echo # +--echo # Switching to connection 'handler_con1'. +connection handler_con1; +--echo # Reaping 'alter table t1 drop column j' +--reap +unlock tables; +--echo # Switching to connection 'default'. +connection default; + --echo # Then, check the scenario in which upgrade of SNRW lock to X --echo # lock is blocked by HANDLER which is open in connection currently --echo # waiting to get SW lock on the same table. @@ -3220,6 +3235,8 @@ disconnect con2; --echo # failed in open_ltable() --echo # +--echo # Supress warnings written to the log file +call mtr.add_suppression("Wait on a lock was aborted due to a pending exclusive lock"); --disable_warnings DROP TABLE IF EXISTS t1, t2; --enable_warnings @@ -3279,16 +3296,10 @@ let $wait_condition= # since the latter waits on a table-level lock while having a HANDLER # open. This will cause mysql_lock_tables() in con1 fail which before # triggered the assert. ---echo # Sending: ---send ALTER TABLE t1 ADD COLUMN j INT +ALTER TABLE t1 ADD COLUMN j INT; --echo # connection: default connection default; -let $wait_condition= - SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table" - AND info = "ALTER TABLE t1 ADD COLUMN j INT"; ---source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL go'; --echo # connection: con1 @@ -3302,11 +3313,6 @@ connection con2; --echo # Reaping SELECT 1 --reap ---echo # connection: con3 -connection con3; ---echo # Reaping ALTER TABLE t1 ADD COLUMN j INT ---reap - --echo # connection: default connection default; DROP TABLE t1, t2; diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test index a0e944ceb09..d1d2d666a39 100644 --- a/mysql-test/t/partition_column.test +++ b/mysql-test/t/partition_column.test @@ -9,6 +9,59 @@ drop table if exists t1; --enable_warnings # +# Bug#51347: assertion with show create table + partition by columns +# on decimal column +# +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (a DECIMAL) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN (0)); + +--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR +CREATE TABLE t1 (a BLOB) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN ("X")); + +--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR +CREATE TABLE t1 (a TEXT) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN ("X")); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (a FLOAT) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN (0.0)); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (a DOUBLE) +PARTITION BY RANGE COLUMNS (a) +(PARTITION p0 VALUES LESS THAN (0.0)); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (d TIMESTAMP) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN ('2000-01-01'), + PARTITION p1 VALUES LESS THAN ('2040-01-01')); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (d BIT(1)) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN (0), + PARTITION p1 VALUES LESS THAN (1)); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (d ENUM("YES","NO")) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN ("NO"), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (d SET("Car","MC")) +PARTITION BY RANGE COLUMNS(d) +(PARTITION p0 VALUES LESS THAN ("MC"), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +# # BUG#49180, Possible to define empty intervals for column list partitioning # --error ER_RANGE_NOT_INCREASING_ERROR @@ -285,18 +338,6 @@ partition by range columns(d) ( partition p0 values less than ('2000-01-01'), partition p1 values less than ('2040-01-01')); ---error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD -create table t1 (d timestamp) -partition by range columns(d) -( partition p0 values less than ('2000-01-01'), - partition p1 values less than ('2040-01-01')); - ---error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD -create table t1 (d bit(1)) -partition by range columns(d) -( partition p0 values less than (0), - partition p1 values less than (1)); - create table t1 (a int, b int) partition by range columns(a,b) (partition p0 values less than (maxvalue, 10)); diff --git a/mysql-test/t/read_only_innodb.test b/mysql-test/t/read_only_innodb.test index 9e001f2b997..3bb626f2ca7 100644 --- a/mysql-test/t/read_only_innodb.test +++ b/mysql-test/t/read_only_innodb.test @@ -83,3 +83,149 @@ DROP USER test@localhost; disconnect con1; --echo echo End of 5.1 tests + +--echo # +--echo # Bug#33669: Transactional temporary tables do not work under --read-only +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS db1; +--enable_warnings + +--echo # Setup user and tables +CREATE USER bug33669@localhost; +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a INT) ENGINE=INNODB; +CREATE TABLE db1.t2 (a INT) ENGINE=INNODB; +INSERT INTO db1.t1 VALUES (1); +INSERT INTO db1.t2 VALUES (2); +GRANT CREATE TEMPORARY TABLES, DROP, INSERT, DELETE, UPDATE, + SELECT, LOCK TABLES ON db1.* TO bug33669@localhost; +SET GLOBAL READ_ONLY = ON; +connect(con1,localhost,bug33669,,db1); +--echo # Connection con1 (user bug33669): + +--echo +--echo # Create, insert and drop temporary table: +--echo +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +INSERT INTO temp VALUES (1); +DROP TABLE temp; + +--echo +--echo # Lock base tables and use temporary table: +--echo +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +LOCK TABLES t1 READ, t2 READ; +SELECT * FROM t1; +INSERT INTO temp values (1); +SELECT * FROM t2; +UNLOCK TABLES; +DROP TABLE temp; + +--echo +--echo # Transaction +--echo +BEGIN; +SELECT * FROM t1; +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +--error ER_OPTION_PREVENTS_STATEMENT +INSERT INTO t1 VALUES (1); +INSERT INTO temp VALUES (1); +SELECT * FROM t2; +ROLLBACK; +SELECT * FROM temp; +DROP TABLE temp; + +--echo +--echo # Lock base table as READ and temporary table as WRITE: +--echo +CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB; +LOCK TABLES t1 READ, temp WRITE; +SELECT * FROM t1; +SELECT * FROM temp; +--error ER_OPTION_PREVENTS_STATEMENT +INSERT INTO t1 VALUES (1); +INSERT INTO temp VALUES (1); +DROP TABLE temp; +UNLOCK TABLES; + +--echo +--echo # Lock temporary table that shadows a base table: +--echo +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB; +LOCK TABLES t1 WRITE; +DROP TABLE t1; +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t1; + +--echo +--echo # INSERT SELECT from base table into temporary table: +--echo + +CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE temp2 LIKE temp1; +BEGIN; +INSERT INTO temp1 VALUES (10); +INSERT INTO temp2 VALUES (10); +INSERT INTO temp1 SELECT * FROM t1; +INSERT INTO temp2 SELECT * FROM t2; +SELECT * FROM temp1 ORDER BY a; +SELECT * FROM temp2 ORDER BY a; +ROLLBACK; +SELECT * FROM temp1,temp2; +LOCK TABLES t1 READ, t2 READ; +INSERT INTO temp1 VALUES (10); +INSERT INTO temp2 VALUES (10); +INSERT INTO temp1 SELECT * FROM t1; +INSERT INTO temp2 SELECT * FROM t2; +SELECT * FROM temp1 ORDER BY a; +SELECT * FROM temp2 ORDER BY a; +UNLOCK TABLES; +DELETE temp1, temp2 FROM temp1, temp2; +INSERT INTO temp1 VALUES (10); +INSERT INTO temp2 VALUES (10); +INSERT INTO temp1 SELECT * FROM t1; +INSERT INTO temp2 SELECT * FROM t2; +SELECT * FROM temp1 ORDER BY a; +SELECT * FROM temp2 ORDER BY a; +DROP TABLE temp1, temp2; + +--echo +--echo # INSERT and INSERT SELECT that uses subqueries: +CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE temp2 LIKE temp1; +INSERT INTO temp1 (a) VALUES ((SELECT MAX(a) FROM t1)); +LOCK TABLES t2 READ; +INSERT INTO temp2 (a) VALUES ((SELECT MAX(a) FROM t2)); +UNLOCK TABLES; +LOCK TABLES t1 READ, t2 READ; +INSERT INTO temp1 SELECT * FROM t1 WHERE a < (SELECT MAX(a) FROM t2); +INSERT INTO temp2 SELECT * FROM t2 WHERE a > (SELECT MAX(a) FROM t1); +UNLOCK TABLES; +INSERT INTO temp1 SELECT * FROM t1 WHERE a < (SELECT MAX(a) FROM t2); +INSERT INTO temp2 SELECT * FROM t2 WHERE a > (SELECT MAX(a) FROM t1); +SELECT * FROM temp1 ORDER BY a; +SELECT * FROM temp2 ORDER BY a; +DROP TABLE temp1, temp2; + +--echo +--echo # Multiple table update: +--echo + +CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE temp2 LIKE temp1; +INSERT INTO temp1 VALUES (1),(2); +INSERT INTO temp2 VALUES (3),(4); +UPDATE temp1,temp2 SET temp1.a = 5, temp2.a = 10; +SELECT * FROM temp1, temp2; +DROP TABLE temp1, temp2; + +--echo +--echo # Disconnect and cleanup +--echo +disconnect con1; +connection default; +SET GLOBAL READ_ONLY = OFF; +DROP USER bug33669@localhost; +DROP DATABASE db1; diff --git a/mysql-test/t/system_mysql_db_fix30020.test b/mysql-test/t/system_mysql_db_fix30020.test deleted file mode 100644 index 0a7d9dad7c9..00000000000 --- a/mysql-test/t/system_mysql_db_fix30020.test +++ /dev/null @@ -1,108 +0,0 @@ -# Embedded server doesn't support external clients ---source include/not_embedded.inc - -# Don't run this test if $MYSQL_FIX_SYSTEM_TABLES isn't set -# to the location of mysql_fix_privilege_tables.sql -if (`SELECT LENGTH("$MYSQL_FIX_SYSTEM_TABLES") <= 0`) -{ - skip Test need MYSQL_FIX_SYSTEM_TABLES; -} -# check that CSV engine was compiled in, as the test relies on the presence -# of the log tables (which are CSV-based) ---source include/have_csv.inc - -# -# This is the test for mysql_fix_privilege_tables -# It checks that a system tables from mysql 3.20 -# can be upgraded to current system table format -# -# Note: If this test fails, don't be confused about the errors reported -# by mysql-test-run This shows warnings generated by -# mysql_fix_system_tables which should be ignored. -# Instead, concentrate on the errors in r/system_mysql_db.reject - --- disable_result_log --- disable_query_log - -use test; - -# create system tables as in mysql-3.20 - ---disable_warnings -CREATE TABLE db ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(32) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db,User), - KEY User (User) -) -engine=MyISAM; ---enable_warnings - -INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); -INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y'); - ---disable_warnings -CREATE TABLE host ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(32) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db) -) -engine=MyISAM; ---enable_warnings - ---disable_warnings -CREATE TABLE user ( - Host char(60) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Password char(16), - Select_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL, - Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,User) -) -engine=MyISAM; ---enable_warnings - -INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); -INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N'); - -# Call the "shell script" $MYSQL_FIX_SYSTEM_TABLES using system --- system $MYSQL_FIX_SYSTEM_TABLES --database=test > $MYSQLTEST_VARDIR/log/system_mysql_db_fix30020.log 2>&1 --- enable_query_log --- enable_result_log - --- source include/system_db_struct.inc - --- disable_query_log - -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, -procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, -time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, -time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; - --- enable_query_log - -# check that we dropped all system tables -show tables; - -exit; -# End of 4.1 tests diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 2a49e0def1a..5c3a759b589 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -346,3 +346,17 @@ SELECT f1,f2-f3 FROM t1; DROP TABLE t1; --echo End of 5.0 tests + +--echo +--echo Bug#50888 valgrind warnings in Field_timestamp::val_str +--echo + +SET TIMESTAMP=0; +CREATE TABLE t1(a timestamp); +INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02'); +FLUSH TABLES t1; +SELECT MAX(a) FROM t1; +SELECT a FROM t1; +DROP TABLE t1; + +--echo End of Bug#50888 diff --git a/plugin/Makefile.am b/plugin/Makefile.am index 68f1f939836..30ccd1236dd 100644 --- a/plugin/Makefile.am +++ b/plugin/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (C) 2005-2006 MySQL AB +# Copyright (c) 2005, 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 @@ -24,5 +24,10 @@ EXTRA_DIST = fulltext/configure.in SUBDIRS = @mysql_pg_dirs@ DIST_SUBDIRS = @mysql_pg_distdirs@ +# As of 5.5.3-m3, we want to include the plugin files of a debug build in the package +install-exec-hook: + $(mkinstalldirs) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(pkglibdir)/plugin + test ! -d debug || $(TAR) cf - debug | ( cd $(DESTDIR)$(pkglibdir)/plugin && $(TAR) xvf - ) + # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index 8d7bda94ef0..cdf01854442 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -43,19 +43,16 @@ unsigned long long rpl_semi_sync_master_trx_wait_time = 0; char rpl_semi_sync_master_wait_no_slave = 1; -static int getWaitTime(const struct timeval& start_tv); +static int getWaitTime(const struct timespec& start_ts); -#ifdef __WIN__ -static int gettimeofday(struct timeval *tv, void *tz) +static unsigned long long timespec_to_usec(const struct timespec *ts) { - unsigned int ticks; - ticks= GetTickCount(); - tv->tv_usec= ticks*1000; - tv->tv_sec= ticks/1000; - - return 0; -} +#ifndef __WIN__ + return (unsigned long long) ts->tv_sec * TIME_MILLION + ts->tv_nsec / TIME_THOUSAND; +#else + return ts->tv.i64 / 10; #endif /* __WIN__ */ +} /******************************************************************************* * @@ -606,12 +603,12 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, if (getMasterEnabled() && trx_wait_binlog_name) { - struct timeval start_tv; + struct timespec start_ts; struct timespec abstime; - int wait_result, start_time_err; + int wait_result; const char *old_msg= 0; - start_time_err = gettimeofday(&start_tv, 0); + set_timespec(start_ts, 0); /* Acquire the mutex. */ lock(); @@ -679,98 +676,72 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, kWho, wait_file_name_, (unsigned long)wait_file_pos_); } - if (start_time_err == 0) - { - int diff_usecs = start_tv.tv_usec + wait_timeout_ * TIME_THOUSAND; - - /* Calcuate the waiting period. */ + /* Calcuate the waiting period. */ #ifdef __WIN__ - abstime.tv.i64 = (__int64)start_tv.tv_sec * TIME_MILLION * 10; - abstime.tv.i64 += (__int64)diff_usecs * 10; - abstime.max_timeout_msec= (long)wait_timeout_; + abstime.tv.i64 = start_ts.tv.i64 + (__int64)wait_timeout_ * TIME_THOUSAND * 10; + abstime.max_timeout_msec= (long)wait_timeout_; #else - abstime.tv_sec = start_tv.tv_sec; - if (diff_usecs < TIME_MILLION) - { - abstime.tv_nsec = diff_usecs * TIME_THOUSAND; - } - else - { - while (diff_usecs >= TIME_MILLION) - { - abstime.tv_sec++; - diff_usecs -= TIME_MILLION; - } - abstime.tv_nsec = diff_usecs * TIME_THOUSAND; - } + unsigned long long diff_nsecs = + start_ts.tv_nsec + (unsigned long long)wait_timeout_ * TIME_MILLION; + abstime.tv_sec = start_ts.tv_sec; + while (diff_nsecs >= TIME_BILLION) + { + abstime.tv_sec++; + diff_nsecs -= TIME_BILLION; + } + abstime.tv_nsec = diff_nsecs; #endif /* __WIN__ */ - - /* In semi-synchronous replication, we wait until the binlog-dump - * thread has received the reply on the relevant binlog segment from the - * replication slave. - * - * Let us suspend this thread to wait on the condition; - * when replication has progressed far enough, we will release - * these waiting threads. - */ - rpl_semi_sync_master_wait_sessions++; - - if (trace_level_ & kTraceDetail) - sql_print_information("%s: wait %lu ms for binlog sent (%s, %lu)", - kWho, wait_timeout_, - wait_file_name_, (unsigned long)wait_file_pos_); - - wait_result = cond_timewait(&abstime); - rpl_semi_sync_master_wait_sessions--; - - if (wait_result != 0) - { - /* This is a real wait timeout. */ - sql_print_warning("Timeout waiting for reply of binlog (file: %s, pos: %lu), " - "semi-sync up to file %s, position %lu.", - trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos, - reply_file_name_, (unsigned long)reply_file_pos_); - rpl_semi_sync_master_wait_timeouts++; - - /* switch semi-sync off */ - switch_off(); - } - else - { - int wait_time; - - wait_time = getWaitTime(start_tv); - if (wait_time < 0) - { - if (trace_level_ & kTraceGeneral) - { - /* This is a time/gettimeofday function call error. */ - sql_print_error("Replication semi-sync gettimeofday fail1 at " - "wait position (%s, %lu)", - trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos); - } - rpl_semi_sync_master_timefunc_fails++; - } - else - { - rpl_semi_sync_master_trx_wait_num++; - rpl_semi_sync_master_trx_wait_time += wait_time; - } - } + + /* In semi-synchronous replication, we wait until the binlog-dump + * thread has received the reply on the relevant binlog segment from the + * replication slave. + * + * Let us suspend this thread to wait on the condition; + * when replication has progressed far enough, we will release + * these waiting threads. + */ + rpl_semi_sync_master_wait_sessions++; + + if (trace_level_ & kTraceDetail) + sql_print_information("%s: wait %lu ms for binlog sent (%s, %lu)", + kWho, wait_timeout_, + wait_file_name_, (unsigned long)wait_file_pos_); + + wait_result = cond_timewait(&abstime); + rpl_semi_sync_master_wait_sessions--; + + if (wait_result != 0) + { + /* This is a real wait timeout. */ + sql_print_warning("Timeout waiting for reply of binlog (file: %s, pos: %lu), " + "semi-sync up to file %s, position %lu.", + trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos, + reply_file_name_, (unsigned long)reply_file_pos_); + rpl_semi_sync_master_wait_timeouts++; + + /* switch semi-sync off */ + switch_off(); } else { - if (trace_level_ & kTraceGeneral) - { - /* This is a gettimeofday function call error. */ - sql_print_error("Replication semi-sync gettimeofday fail2 at " - "wait position (%s, %lu)", - trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos); + int wait_time; + + wait_time = getWaitTime(start_ts); + if (wait_time < 0) + { + if (trace_level_ & kTraceGeneral) + { + sql_print_error("Replication semi-sync getWaitTime fail at " + "wait position (%s, %lu)", + trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos); + } + rpl_semi_sync_master_timefunc_fails++; + } + else + { + rpl_semi_sync_master_trx_wait_num++; + rpl_semi_sync_master_trx_wait_time += wait_time; } - rpl_semi_sync_master_timefunc_fails++; - - /* switch semi-sync off */ - switch_off(); } } @@ -1080,8 +1051,7 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id, ulong packet_len; int result = -1; - struct timeval start_tv; - int start_time_err= 0; + struct timespec start_ts; ulong trc_level = trace_level_; function_enter(kWho); @@ -1095,7 +1065,7 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id, } if (trc_level & kTraceNetWait) - start_time_err = gettimeofday(&start_tv, 0); + set_timespec(start_ts, 0); /* We flush to make sure that the current event is sent to the network, * instead of being buffered in the TCP/IP stack. @@ -1120,28 +1090,17 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id, if (trc_level & kTraceNetWait) { - if (start_time_err != 0) + int wait_time = getWaitTime(start_ts); + if (wait_time < 0) { sql_print_error("Semi-sync master wait for reply " - "gettimeofday fail to get start time"); + "fail to get wait time."); rpl_semi_sync_master_timefunc_fails++; } else { - int wait_time; - - wait_time = getWaitTime(start_tv); - if (wait_time < 0) - { - sql_print_error("Semi-sync master wait for reply " - "gettimeofday fail to get wait time."); - rpl_semi_sync_master_timefunc_fails++; - } - else - { - rpl_semi_sync_master_net_wait_num++; - rpl_semi_sync_master_net_wait_time += wait_time; - } + rpl_semi_sync_master_net_wait_num++; + rpl_semi_sync_master_net_wait_time += wait_time; } } @@ -1230,24 +1189,23 @@ void ReplSemiSyncMaster::setExportStats() * * Return: * >= 0: the waiting time in microsecons(us) - * < 0: error in gettimeofday or time back traverse + * < 0: error in get time or time back traverse */ -static int getWaitTime(const struct timeval& start_tv) +static int getWaitTime(const struct timespec& start_ts) { unsigned long long start_usecs, end_usecs; - struct timeval end_tv; - int end_time_err; - + struct timespec end_ts; + /* Starting time in microseconds(us). */ - start_usecs = start_tv.tv_sec * TIME_MILLION + start_tv.tv_usec; + start_usecs = timespec_to_usec(&start_ts); /* Get the wait time interval. */ - end_time_err = gettimeofday(&end_tv, 0); + set_timespec(end_ts, 0); /* Ending time in microseconds(us). */ - end_usecs = end_tv.tv_sec * TIME_MILLION + end_tv.tv_usec; + end_usecs = timespec_to_usec(&end_ts); - if (end_time_err != 0 || end_usecs < start_usecs) + if (end_usecs < start_usecs) return -1; return (int)(end_usecs - start_usecs); diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 26dfb243897..3352eb23a73 100755 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -65,7 +65,7 @@ ADD_CUSTOM_TARGET(GenFixPrivs IF(UNIX) FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution - "cd ${CMAKE_BINARY_DIR} && ${CMAKE_CPACK_COMMAND} -G TGZ --config CPackConfig.cmake" ) + "cd ${CMAKE_BINARY_DIR} && '${CMAKE_CPACK_COMMAND}' -G TGZ --config CPackConfig.cmake" ) EXECUTE_PROCESS( COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution ) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 118c312d218..9179995e814 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -23,7 +23,6 @@ EXTRA_PROGRAMS = comp_sql bin_SCRIPTS = @server_scripts@ \ msql2mysql \ mysql_config \ - mysql_fix_privilege_tables \ mysql_fix_extensions \ mysql_setpermission \ mysql_secure_installation \ @@ -45,7 +44,6 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ msql2mysql.sh \ mysql_config.sh \ mysql_config.pl.in \ - mysql_fix_privilege_tables.sh \ mysql_fix_extensions.sh \ mysql_install_db.sh \ mysql_install_db.pl.in \ @@ -82,7 +80,6 @@ CLEANFILES = @server_scripts@ \ make_sharedlib_distribution \ msql2mysql \ mysql_config \ - mysql_fix_privilege_tables \ mysql_fix_extensions \ mysql_setpermission \ mysql_secure_installation \ diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh deleted file mode 100644 index dd5edb699a0..00000000000 --- a/scripts/mysql_fix_privilege_tables.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/sh -# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -# This script is a wrapper to pipe the mysql_fix_privilege_tables.sql -# through the mysql client program to the mysqld server - -# Default values (Can be changed in my.cnf) -password="" -host="localhost" -user="root" -sql_only=0 -basedir="@prefix@" -verbose=0 -args="" -# no elaborate fallback here; with no argument, it will happen in "mysql" -port="" -socket="" -database="mysql" -bindir="" -pkgdatadir="@pkgdatadir@" -print_defaults_bindir="." - -file=mysql_fix_privilege_tables.sql - -# The following test is to make this script compatible with the 4.0 where -# the single argument could be a password -if test "$#" = 1 -then - case "$1" in - --*) ;; - *) old_style_password="$1" ; shift ;; - esac -fi - -# The following code is almost identical to the code in mysql_install_db.sh - -case "$1" in - --no-defaults|--defaults-file=*|--defaults-extra-file=*) - defaults="$1"; shift - ;; -esac - -parse_arguments() { - # We only need to pass arguments through to the server if we don't - # handle them here. So, we collect unrecognized options (passed on - # the command line) into the args variable. - pick_args= - if test "$1" = PICK-ARGS-FROM-ARGV - then - pick_args=1 - shift - fi - - for arg do - case "$arg" in - --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --password=*) password=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --host=*) host=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --sql|--sql-only) sql_only=1 ;; - --verbose) verbose=1 ;; - --port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;; - --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;; - --database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;; - --bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"` - print_defaults_bindir=$bindir - ;; - *) - if test -n "$pick_args" - then - # This sed command makes sure that any special chars are quoted, - # so the arg gets passed exactly to the server. - args="$args "`echo "$arg" | sed -e 's,\([^=a-zA-Z0-9_.-]\),\\\\\1,g'` - fi - ;; - esac - done -} - -# Get first arguments from the my.cfg file, groups [mysqld] and -# [mysql_install_db], and then merge with the command line arguments - -print_defaults=my_print_defaults -for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra -do - if test -x $dir/my_print_defaults - then - print_defaults="$dir/my_print_defaults" - break - fi -done - -parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables` -parse_arguments PICK-ARGS-FROM-ARGV "$@" - -if test -z "$password" -then - password=$old_style_password -fi - -# Find where 'mysql' command is located - -dirname=`dirname "$0"` - -if test -z "$bindir" -then - for i in @bindir@ $basedir/bin "$dirname/../client" - do - if test -f $i/mysql - then - bindir=$i - break - fi - done -fi - -if test -z "$bindir" -then - echo "Could not find MySQL command-line client (mysql)." - echo "Please use --basedir to specify the directory where MySQL is installed." - exit 1 -fi - -cmd="$bindir/mysql --no-defaults --default-character-set=latin1 --force --user=$user --host=$host" -if test ! -z "$port"; then - cmd="$cmd --port=$port" -fi -if test ! -z "$socket"; then - cmd="$cmd --socket=$socket" -fi -cmd="$cmd --database=$database" - -if test $sql_only = 1 -then - cmd="cat" -fi - -# Find where first mysql_fix_privilege_tables.sql is located -for i in $basedir/support-files $basedir/share $basedir/share/mysql \ - $basedir/scripts $pkgdatadir . "$dirname" -do - if test -f $i/$file - then - pkgdatadir=$i - break - fi -done - -sql_file="$pkgdatadir/$file" -if test ! -f $sql_file -then - echo "Could not find file '$file'." - echo "Please use --basedir to specify the directory where MySQL is installed" - exit 1 -fi - -s_echo() -{ - if test $sql_only = 0 - then - echo $1 - fi -} - -s_echo "This script updates all the mysql privilege tables to be usable by" -s_echo "the current version of MySQL" -s_echo "" - -if test $verbose = 1 -then - s_echo "You can safely ignore all 'Duplicate column' and 'Unknown column' errors" - s_echo "because these just mean that your tables are already up to date." - s_echo "This script is safe to run even if your tables are already up to date!" - s_echo "" -fi - -run_cmd() { - # Password argument is added here to allow for spaces in password. - - if test ! -z "$password" - then - cat $sql_file | $cmd --password="$password" - else - cat $sql_file | $cmd - fi -} - -if test $verbose = 0 -then - run_cmd > /dev/null 2>&1 -else - run_cmd > /dev/null -fi -if test $? = 0 -then - s_echo "done" -else - s_echo "Got a failure from command:" - s_echo "cat $sql_file | $cmd" - s_echo "Please check the above output and try again." - if test $verbose = 0 - then - s_echo "" - s_echo "Running the script with the --verbose option may give you some information" - s_echo "of what went wrong." - fi - s_echo "" - s_echo "If you get an 'Access denied' error, you should run this script again and" - s_echo "give the MySQL root user password as an argument with the --password= option" -fi diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index bcbedae4d0f..69d6d6d7feb 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -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 @@ -100,18 +100,92 @@ CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_b CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM; +-- +-- PERFORMANCE SCHEMA INSTALLATION +-- Note that this script is also reused by mysql_upgrade, +-- so we have to be very careful here to not destroy any +-- existing database named 'performance_schema' if it +-- can contain user data. +-- In case of downgrade, it's ok to drop unknown tables +-- from a future version, as long as they belong to the +-- performance schema engine. +-- + +set @have_old_pfs= (select count(*) from information_schema.schemata where schema_name='performance_schema'); + +SET @l1="SET @broken_tables = (select count(*) from information_schema.tables"; +SET @l2=" where engine != \'PERFORMANCE_SCHEMA\' and table_schema=\'performance_schema\')"; +SET @cmd=concat(@l1,@l2); + +-- Work around for bug#49542 +SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_tables = 0'); +PREPARE stmt FROM @str; +EXECUTE stmt; +DROP PREPARE stmt; + +SET @l1="SET @broken_views = (select count(*) from information_schema.views"; +SET @l2=" where table_schema='performance_schema')"; +SET @cmd=concat(@l1,@l2); + +-- Work around for bug#49542 +SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_views = 0'); +PREPARE stmt FROM @str; +EXECUTE stmt; +DROP PREPARE stmt; + +SET @broken_routines = (select count(*) from mysql.proc where db='performance_schema'); + +SET @broken_events = (select count(*) from mysql.event where db='performance_schema'); + +SET @broken_pfs= (select @broken_tables + @broken_views + @broken_routines + @broken_events); -- -- The performance schema database. --- This database is always created, even in --without-perfschema builds, +-- Only drop and create the database if this is safe (no broken_pfs). +-- This database is created, even in --without-perfschema builds, -- so that the database name is always reserved by the MySQL implementation. -- -set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO'); +SET @cmd= "DROP DATABASE IF EXISTS performance_schema"; + +SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0'); +PREPARE stmt FROM @str; +EXECUTE stmt; +DROP PREPARE stmt; -DROP DATABASE IF EXISTS performance_schema; +SET @cmd= "CREATE DATABASE performance_schema character set utf8"; -CREATE DATABASE performance_schema character set utf8; +SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0'); +PREPARE stmt FROM @str; +EXECUTE stmt; +DROP PREPARE stmt; + +-- +-- Unlike 'performance_schema', the 'mysql' database is reserved already, +-- so no user procedure is supposed to be there +-- +drop procedure if exists mysql.die; +create procedure mysql.die() signal sqlstate 'HY000' set message_text='Unexpected content found in the performance_schema database.'; + +-- +-- For broken upgrades, SIGNAL the error +-- + +SET @cmd="call mysql.die()"; + +SET @str = IF(@broken_pfs > 0, @cmd, 'SET @dummy = 0'); +PREPARE stmt FROM @str; +EXECUTE stmt; +DROP PREPARE stmt; + +drop procedure mysql.die; + +-- +-- From this point, only create the performance schema tables +-- if the server is build with performance schema +-- + +set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO'); -- -- TABLE COND_INSTANCES diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 8551e4cd6c9..6ddb9ef4c9c 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -5,10 +5,6 @@ # because these just mean that your tables are already up to date. # This script is safe to run even if your tables are already up to date! -# On unix, you should use the mysql_fix_privilege_tables script to execute -# this sql script. -# On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' - set sql_mode=''; set storage_engine=MyISAM; diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index f08e870d5e0..5420ebd908e 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -54,6 +54,8 @@ Usage: $0 [OPTIONS] --mysqld=FILE Use the specified file as mysqld --mysqld-version=VERSION Use "mysqld-VERSION" as mysqld --nice=NICE Set the scheduling priority of mysqld + --plugin-dir=DIR Plugins are under DIR or DIR/VERSION, if + VERSION is given --skip-kill-mysqld Don't try to kill stray mysqld processes --syslog Log messages to syslog with 'logger' --skip-syslog Log messages to error log (default) @@ -172,6 +174,7 @@ parse_arguments() { --basedir=*) MY_BASEDIR_VERSION="$val" ;; --datadir=*) DATADIR="$val" ;; --pid-file=*) pid_file="$val" ;; + --plugin-dir=*) PLUGIN_DIR="$val" ;; --user=*) user="$val"; SET_USER=1 ;; # these might have been set in a [mysqld_safe] section of my.cnf @@ -189,6 +192,7 @@ parse_arguments() { if test -n "$val" then MYSQLD="mysqld-$val" + PLUGIN_VARIANT="/$val" else MYSQLD="mysqld" fi @@ -695,8 +699,10 @@ fi cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS" +plugin_dir="${PLUGIN_DIR:-@pkgplugindir@}${PLUGIN_VARIANT}" + for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ - "--datadir=$DATADIR" "$USER_OPTION" + "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION" do cmd="$cmd "`shell_quote_string "$i"` done diff --git a/sql/events.cc b/sql/events.cc index d8bf549321e..a2375b1274b 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 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 @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysql_priv.h" #include "events.h" @@ -367,15 +367,14 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, { sql_print_error("Event Error: An error occurred while creating query string, " "before writing it into binary log."); - /* Restore the state of binlog format */ - DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); - if (save_binlog_row_based) - thd->set_current_stmt_binlog_format_row(); - DBUG_RETURN(TRUE); + ret= TRUE; + } + else + { + /* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER + will be written into the binary log as the definer for the SQL thread. */ + ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length()); } - /* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER - will be written into the binary log as the definer for the SQL thread. */ - ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length()); } } mysql_mutex_unlock(&LOCK_event_metadata); @@ -1017,7 +1016,11 @@ Events::dump_internal_status() puts("LLA = Last Locked At LUA = Last Unlocked At"); puts("WOC = Waiting On Condition DL = Data Locked"); - mysql_mutex_lock(&LOCK_event_metadata); + /* + opt_event_scheduler should only be accessed while + holding LOCK_global_system_variables. + */ + mysql_mutex_lock(&LOCK_global_system_variables); if (opt_event_scheduler == EVENTS_DISABLED) puts("The Event Scheduler is disabled"); else @@ -1026,7 +1029,7 @@ Events::dump_internal_status() event_queue->dump_internal_status(); } - mysql_mutex_unlock(&LOCK_event_metadata); + mysql_mutex_unlock(&LOCK_global_system_variables); DBUG_VOID_RETURN; } diff --git a/sql/events.h b/sql/events.h index 881ade37cbf..380b0d97f0a 100644 --- a/sql/events.h +++ b/sql/events.h @@ -1,6 +1,6 @@ #ifndef _EVENT_H_ #define _EVENT_H_ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 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 @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @defgroup Event_Scheduler Event Scheduler @@ -83,6 +83,7 @@ public: See sys_var.cc */ enum enum_opt_event_scheduler { EVENTS_OFF, EVENTS_ON, EVENTS_DISABLED }; + /* Protected using LOCK_global_system_variables only. */ static uint opt_event_scheduler; static mysql_mutex_t LOCK_event_metadata; static bool check_if_system_tables_error(); @@ -107,9 +108,6 @@ public: destroy_mutexes(); static bool - switch_event_scheduler_state(enum enum_opt_event_scheduler new_state); - - static bool create_event(THD *thd, Event_parse_data *parse_data, bool if_exists); static bool diff --git a/sql/field.cc b/sql/field.cc index 51235d9f0e8..8efa765a4bc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6613,8 +6613,20 @@ uchar *Field_string::pack(uchar *to, const uchar *from, local_char_length= my_charpos(field_charset, from, from+length, local_char_length); set_if_smaller(length, local_char_length); - while (length && from[length-1] == field_charset->pad_char) - length--; + + /* + TODO: change charset interface to add a new function that does + the following or add a flag to lengthsp to do it itself + (this is for not packing padding adding bytes in BINARY + fields). + */ + if (field_charset->mbmaxlen == 1) + { + while (length && from[length-1] == field_charset->pad_char) + length --; + } + else + length= field_charset->cset->lengthsp(field_charset, (const char*) from, length); // Length always stored little-endian *to++= (uchar) length; @@ -6680,7 +6692,7 @@ Field_string::unpack(uchar *to, memcpy(to, from, length); // Pad the string with the pad character of the fields charset - bfill(to + length, field_length - length, field_charset->pad_char); + field_charset->cset->fill(field_charset, (char*) to + length, field_length - length, field_charset->pad_char); return from+length; } diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 279d5b4c242..7097c0a1a46 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -2346,7 +2346,6 @@ static int open_ndb_binlog_index(THD *thd, TABLE **ndb_binlog_index) thd->proc_info= "Opening " NDB_REP_DB "." NDB_REP_TABLE; tables->required_type= FRMTYPE_TABLE; - uint counter; thd->clear_error(); if (open_and_lock_tables(thd, tables, FALSE, 0)) { @@ -2374,7 +2373,6 @@ int ndb_add_ndb_binlog_index(THD *thd, void *_row) { ndb_binlog_index_row &row= *(ndb_binlog_index_row *) _row; int error= 0; - bool need_reopen; /* Turn of binlogging to prevent the table changes to be written to the binary log. diff --git a/sql/item.h b/sql/item.h index 9f64c0110ec..a5c664dd159 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3122,14 +3122,16 @@ protected: bool value_cached; public: Item_cache(): - example(0), used_table_map(0), cached_field(0), cached_field_type(MYSQL_TYPE_STRING), + example(0), used_table_map(0), cached_field(0), + cached_field_type(MYSQL_TYPE_STRING), value_cached(0) { fixed= 1; null_value= 1; } Item_cache(enum_field_types field_type_arg): - example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg), + example(0), used_table_map(0), cached_field(0), + cached_field_type(field_type_arg), value_cached(0) { fixed= 1; @@ -3233,10 +3235,9 @@ class Item_cache_str: public Item_cache public: Item_cache_str(const Item *item) : - Item_cache(), value(0), + Item_cache(item->field_type()), value(0), is_varbinary(item->type() == FIELD_ITEM && - ((const Item_field *) item)->field->type() == - MYSQL_TYPE_VARCHAR && + cached_field_type == MYSQL_TYPE_VARCHAR && !((const Item_field *) item)->field->has_charset()) {} double val_real(); diff --git a/sql/item_func.cc b/sql/item_func.cc index ca8f5d00bb1..391ddfa4a7c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4766,6 +4766,7 @@ int get_var_with_binlog(THD *thd, enum_sql_command sql_command, user_var_event->user_var_event= var_entry; user_var_event->type= var_entry->type; user_var_event->charset_number= var_entry->collation.collation->number; + user_var_event->unsigned_flag= var_entry->unsigned_flag; if (!var_entry->value) { /* NULL value*/ diff --git a/sql/lock.cc b/sql/lock.cc index 3ff131bb828..7937878073e 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -89,15 +89,15 @@ extern HASH open_cache; #define GET_LOCK_UNLOCK 1 #define GET_LOCK_STORE_LOCKS 2 -static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table,uint count, - uint flags, TABLE **write_locked); +static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, + uint flags); static int lock_external(THD *thd, TABLE **table,uint count); static int unlock_external(THD *thd, TABLE **table,uint count); static void print_lock_error(int error, const char *); /* Map the return value of thr_lock to an error from errmsg.txt */ static int thr_lock_errno_to_mysql[]= -{ 0, 1, ER_LOCK_WAIT_TIMEOUT, ER_LOCK_DEADLOCK }; +{ 0, ER_LOCK_ABORTED, ER_LOCK_WAIT_TIMEOUT, ER_LOCK_DEADLOCK }; /** Perform semantic checks for mysql_lock_tables. @@ -107,17 +107,18 @@ static int thr_lock_errno_to_mysql[]= @param flags Lock flags @return 0 if all the check passed, non zero if a check failed. */ -int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags) +static int +lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags) { - bool log_table_write_query; - uint system_count; - uint i; + uint system_count, i; + bool is_superuser, log_table_write_query; - DBUG_ENTER("mysql_lock_tables_check"); + DBUG_ENTER("lock_tables_check"); system_count= 0; + is_superuser= thd->security_ctx->master_access & SUPER_ACL; log_table_write_query= (is_log_table_write_query(thd->lex->sql_command) - || ((flags & MYSQL_LOCK_PERF_SCHEMA) != 0)); + || ((flags & MYSQL_LOCK_LOG_TABLE) != 0)); for (i=0 ; i<count; i++) { @@ -148,10 +149,16 @@ int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags) } } - if ((t->s->table_category == TABLE_CATEGORY_SYSTEM) && - (t->reginfo.lock_type >= TL_WRITE_ALLOW_WRITE)) + if (t->reginfo.lock_type >= TL_WRITE_ALLOW_WRITE) { - system_count++; + if (t->s->table_category == TABLE_CATEGORY_SYSTEM) + system_count++; + + if (t->db_stat & HA_READ_ONLY) + { + my_error(ER_OPEN_AS_READONLY, MYF(0), t->alias); + DBUG_RETURN(1); + } } /* @@ -172,6 +179,20 @@ int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags) thd->mdl_context.is_lock_owner(MDL_key::TABLE, t->s->db.str, t->s->table_name.str, MDL_SHARED))); + + /* + Prevent modifications to base tables if READ_ONLY is activated. + In any case, read only does not apply to temporary tables. + */ + if (!(flags & MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY) && !t->s->tmp_table) + { + if (t->reginfo.lock_type >= TL_WRITE_ALLOW_WRITE && + !is_superuser && opt_readonly && !thd->slave_thread) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); + DBUG_RETURN(1); + } + } } /* @@ -248,157 +269,69 @@ static void reset_lock_data_and_free(MYSQL_LOCK **mysql_lock) @param tables An array of pointers to the tables to lock. @param count The number of tables to lock. @param flags Options: - MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK Ignore a global read lock MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY Ignore SET GLOBAL READ_ONLY - MYSQL_LOCK_IGNORE_FLUSH Ignore a flush tables. MYSQL_LOCK_IGNORE_TIMEOUT Use maximum timeout value. - @param need_reopen Out parameter, TRUE if some tables were altered - or deleted and should be reopened by caller. - - @note Caller of this function should always be ready to handle request to - reopen table unless there are external invariants which guarantee - that such thing won't be needed (for example we are obtaining lock - on table on which we already have exclusive metadata lock). @retval A lock structure pointer on success. - @retval NULL on error or if some tables should be reopen. + @retval NULL if an error or if wait on a lock was killed. */ -MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, - uint flags, bool *need_reopen) +MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags) { - MYSQL_LOCK *sql_lock; - TABLE *write_lock_used; int rc; - - DBUG_ENTER("mysql_lock_tables"); - - *need_reopen= FALSE; - - if (mysql_lock_tables_check(thd, tables, count, flags)) - DBUG_RETURN (NULL); - + MYSQL_LOCK *sql_lock; ulong timeout= (flags & MYSQL_LOCK_IGNORE_TIMEOUT) ? LONG_TIMEOUT : thd->variables.lock_wait_timeout; - for (;;) - { - if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS, - &write_lock_used))) - break; + DBUG_ENTER("mysql_lock_tables"); - if (global_read_lock && write_lock_used && - ! (flags & MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK)) - { - /* - Someone has issued LOCK ALL TABLES FOR READ and we want a write lock - Wait until the lock is gone - */ - if (thd->global_read_lock.wait_if_global_read_lock(thd, 1, 1)) - { - /* Clear the lock type of all lock data to avoid reusage. */ - reset_lock_data_and_free(&sql_lock); - break; - } - if (thd->version != refresh_version) - { - /* Clear the lock type of all lock data to avoid reusage. */ - reset_lock_data_and_free(&sql_lock); - goto retry; - } - } + if (lock_tables_check(thd, tables, count, flags)) + DBUG_RETURN(NULL); - if (!(flags & MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY) && - write_lock_used && - opt_readonly && - !(thd->security_ctx->master_access & SUPER_ACL) && - !thd->slave_thread) - { - /* - Someone has issued SET GLOBAL READ_ONLY=1 and we want a write lock. - We do not wait for READ_ONLY=0, and fail. - */ - reset_lock_data_and_free(&sql_lock); - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); - break; - } + if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS))) + DBUG_RETURN(NULL); - thd_proc_info(thd, "System lock"); - DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info)); - if (sql_lock->table_count && lock_external(thd, sql_lock->table, - sql_lock->table_count)) - { - /* Clear the lock type of all lock data to avoid reusage. */ - reset_lock_data_and_free(&sql_lock); - break; - } - DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info)); - /* Copy the lock data array. thr_multi_lock() reorders its contens. */ - memcpy(sql_lock->locks + sql_lock->lock_count, sql_lock->locks, - sql_lock->lock_count * sizeof(*sql_lock->locks)); - /* Lock on the copied half of the lock data array. */ - 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)]; - if (rc > 1) /* a timeout or a deadlock */ - { - if (sql_lock->table_count) - (void) unlock_external(thd, sql_lock->table, sql_lock->table_count); - reset_lock_data_and_free(&sql_lock); - my_error(rc, MYF(0)); - break; - } - else if (rc == 1) /* aborted or killed */ - { - /* - reset_lock_data is required here. If thr_multi_lock fails it - resets lock type for tables, which were locked before (and - including) one that caused error. Lock type for other tables - preserved. - */ - reset_lock_data(sql_lock); - sql_lock->lock_count= 0; // Locks are already freed - // Fall through: unlock, reset lock data, free and retry - } - else - { - /* Success */ - break; - } - thd_proc_info(thd, 0); - - /* going to retry, unlock all tables */ - if (sql_lock->lock_count) - thr_multi_unlock(sql_lock->locks, sql_lock->lock_count); + thd_proc_info(thd, "System lock"); + DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info)); + if (sql_lock->table_count && lock_external(thd, sql_lock->table, + sql_lock->table_count)) + { + /* Clear the lock type of all lock data to avoid reusage. */ + reset_lock_data_and_free(&sql_lock); + goto end; + } + /* Copy the lock data array. thr_multi_lock() reorders its contents. */ + memcpy(sql_lock->locks + sql_lock->lock_count, sql_lock->locks, + sql_lock->lock_count * sizeof(*sql_lock->locks)); + /* Lock on the copied half of the lock data array. */ + 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)]; + if (rc) + { if (sql_lock->table_count) (void) unlock_external(thd, sql_lock->table, sql_lock->table_count); - - /* - If thr_multi_lock fails it resets lock type for tables, which - were locked before (and including) one that caused error. Lock - type for other tables preserved. - */ reset_lock_data_and_free(&sql_lock); -retry: - /* Let upper level close all used tables and retry or give error. */ - *need_reopen= TRUE; - break; + if (! thd->killed) + my_error(rc, MYF(0)); } +end: thd_proc_info(thd, 0); + if (thd->killed) { thd->send_kill_message(); if (sql_lock) { - mysql_unlock_tables(thd,sql_lock); - sql_lock=0; + mysql_unlock_tables(thd, sql_lock); + sql_lock= 0; } } thd->set_time_after_lock(); - DBUG_RETURN (sql_lock); + DBUG_RETURN(sql_lock); } @@ -459,9 +392,7 @@ void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock) void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count) { MYSQL_LOCK *sql_lock; - TABLE *write_lock_used; - if ((sql_lock= get_lock_data(thd, table, count, GET_LOCK_UNLOCK, - &write_lock_used))) + if ((sql_lock= get_lock_data(thd, table, count, GET_LOCK_UNLOCK))) mysql_unlock_tables(thd, sql_lock); } @@ -603,9 +534,7 @@ void mysql_lock_downgrade_write(THD *thd, TABLE *table, thr_lock_type new_lock_type) { MYSQL_LOCK *locked; - TABLE *write_lock_used; - if ((locked = get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK, - &write_lock_used))) + if ((locked = get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK))) { for (uint i=0; i < locked->lock_count; i++) thr_downgrade_write_lock(locked->locks[i], new_lock_type); @@ -619,11 +548,9 @@ void mysql_lock_downgrade_write(THD *thd, TABLE *table, void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock) { MYSQL_LOCK *locked; - TABLE *write_lock_used; DBUG_ENTER("mysql_lock_abort"); - if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK, - &write_lock_used))) + if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK))) { for (uint i=0; i < locked->lock_count; i++) thr_abort_locks(locked->locks[i]->lock, upgrade_lock); @@ -648,12 +575,10 @@ void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock) bool mysql_lock_abort_for_thread(THD *thd, TABLE *table) { MYSQL_LOCK *locked; - TABLE *write_lock_used; bool result= FALSE; DBUG_ENTER("mysql_lock_abort_for_thread"); - if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK, - &write_lock_used))) + if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK))) { for (uint i=0; i < locked->lock_count; i++) { @@ -848,11 +773,10 @@ static int unlock_external(THD *thd, TABLE **table,uint count) @param flags One of: - GET_LOCK_UNLOCK : If we should send TL_IGNORE to store lock - GET_LOCK_STORE_LOCKS : Store lock info in TABLE - @param write_lock_used Store pointer to last table with WRITE_ALLOW_WRITE */ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, - uint flags, TABLE **write_lock_used) + uint flags) { uint i,tables,lock_count; MYSQL_LOCK *sql_lock; @@ -861,9 +785,8 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, DBUG_ENTER("get_lock_data"); DBUG_ASSERT((flags == GET_LOCK_UNLOCK) || (flags == GET_LOCK_STORE_LOCKS)); - DBUG_PRINT("info", ("count %d", count)); - *write_lock_used=0; + for (i=tables=lock_count=0 ; i < count ; i++) { TABLE *t= table_ptr[i]; @@ -895,24 +818,12 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, { TABLE *table; enum thr_lock_type lock_type; + THR_LOCK_DATA **org_locks = locks; if ((table=table_ptr[i])->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE) continue; lock_type= table->reginfo.lock_type; DBUG_ASSERT(lock_type != TL_WRITE_DEFAULT && lock_type != TL_READ_DEFAULT); - if (lock_type >= TL_WRITE_ALLOW_WRITE) - { - *write_lock_used=table; - if (table->db_stat & HA_READ_ONLY) - { - my_error(ER_OPEN_AS_READONLY,MYF(0),table->alias); - /* Clear the lock type of the lock data that are stored already. */ - sql_lock->lock_count= (uint) (locks - sql_lock->locks); - reset_lock_data_and_free(&sql_lock); - DBUG_RETURN(0); - } - } - THR_LOCK_DATA **org_locks = locks; locks_start= locks; locks= table->file->store_lock(thd, locks, (flags & GET_LOCK_UNLOCK) ? TL_IGNORE : diff --git a/sql/log.cc b/sql/log.cc index ce9d75089d1..279782d271b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -4671,7 +4671,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) /* setting flags for user var log event */ uchar flags= User_var_log_event::UNDEF_F; - if (user_var_event->user_var_event->unsigned_flag) + if (user_var_event->unsigned_flag) flags|= User_var_log_event::UNSIGNED_F; User_var_log_event e(thd, user_var_event->user_var_event->name.str, diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 9b46ad83b14..e87c3688cac 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -1455,8 +1455,6 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli) */ if (!thd->lock) { - bool need_reopen= 1; /* To execute the first lap of the loop below */ - /* lock_tables() reads the contents of thd->lex, so they must be initialized. Contrary to in @@ -1465,80 +1463,31 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli) */ lex_start(thd); - while ((error= lock_tables(thd, rli->tables_to_lock, - rli->tables_to_lock_count, 0, - &need_reopen))) + if ((error= lock_tables(thd, rli->tables_to_lock, + rli->tables_to_lock_count, 0))) { - if (!need_reopen) - { - if (thd->is_slave_error || thd->is_fatal_error) - { - /* - Error reporting borrowed from Query_log_event with many excessive - simplifications (we don't honour --slave-skip-errors) - */ - uint actual_error= thd->net.last_errno; - rli->report(ERROR_LEVEL, actual_error, - "Error '%s' in %s event: when locking tables", - (actual_error ? thd->net.last_error : - "unexpected success or fatal error"), - get_type_str()); - thd->is_fatal_error= 1; - } - else - { - rli->report(ERROR_LEVEL, error, - "Error in %s event: when locking tables", - get_type_str()); - } - const_cast<Relay_log_info*>(rli)->slave_close_thread_tables(thd); - DBUG_RETURN(error); - } - - /* - So we need to reopen the tables. - - We need to flush the pending RBR event, since it keeps a - pointer to an open table. - - ALTERNATIVE SOLUTION (not implemented): Extract a pointer to - the pending RBR event and reset the table pointer after the - tables has been reopened. - - NOTE: For this new scheme there should be no pending event: - need to add code to assert that is the case. - */ - error= thd->binlog_flush_pending_rows_event(FALSE); - if (error) + if (thd->is_slave_error || thd->is_fatal_error) { - rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, - ER(ER_SLAVE_FATAL_ERROR), - "call to binlog_flush_pending_rows_event() failed"); - thd->is_slave_error= 1; - DBUG_RETURN(error); + /* + Error reporting borrowed from Query_log_event with many excessive + simplifications (we don't honour --slave-skip-errors) + */ + uint actual_error= thd->net.last_errno; + rli->report(ERROR_LEVEL, actual_error, + "Error '%s' in %s event: when locking tables", + (actual_error ? thd->net.last_error : + "unexpected success or fatal error"), + get_type_str()); + thd->is_fatal_error= 1; } - TABLE_LIST *tables= rli->tables_to_lock; - close_tables_for_reopen(thd, &tables, NULL); - - uint tables_count= rli->tables_to_lock_count; - if ((error= open_tables(thd, &tables, &tables_count, 0))) + else { - if (thd->is_slave_error || thd->is_fatal_error) - { - /* - Error reporting borrowed from Query_log_event with many excessive - simplifications (we don't honour --slave-skip-errors) - */ - uint actual_error= thd->net.last_errno; - rli->report(ERROR_LEVEL, actual_error, - "Error '%s' on reopening tables", - (actual_error ? thd->net.last_error : - "unexpected success or fatal error")); - thd->is_slave_error= 1; - } - const_cast<Relay_log_info*>(rli)->slave_close_thread_tables(thd); - DBUG_RETURN(error); + rli->report(ERROR_LEVEL, error, + "Error in %s event: when locking tables", + get_type_str()); } + const_cast<Relay_log_info*>(rli)->slave_close_thread_tables(thd); + DBUG_RETURN(error); } /* diff --git a/sql/mdl.cc b/sql/mdl.cc index f9a4e10aade..ddf518fbb1c 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -19,6 +19,54 @@ #include <hash.h> #include <mysqld_error.h> +#ifdef HAVE_PSI_INTERFACE +static PSI_mutex_key key_MDL_map_mutex; +static PSI_mutex_key key_MDL_context_signal_mutex; + +static PSI_mutex_info all_mdl_mutexes[]= +{ + { &key_MDL_map_mutex, "MDL_map::mutex", PSI_FLAG_GLOBAL}, + { &key_MDL_context_signal_mutex, "MDL_context::signal", 0} +}; + +static PSI_rwlock_key key_MDL_lock_rwlock; +static PSI_rwlock_key key_MDL_context_waiting_for_rwlock; + +static PSI_rwlock_info all_mdl_rwlocks[]= +{ + { &key_MDL_lock_rwlock, "MDL_lock::rwlock", 0}, + { &key_MDL_context_waiting_for_rwlock, "MDL_context::waiting_for_lock", 0} +}; + +static PSI_cond_key key_MDL_context_signal_cond; + +static PSI_cond_info all_mdl_conds[]= +{ + { &key_MDL_context_signal_cond, "MDL_context::signal", 0} +}; + +/** + Initialise all the performance schema instrumentation points + used by the MDL subsystem. +*/ +static void init_mdl_psi_keys(void) +{ + const char *category= "sql"; + int count; + + if (PSI_server == NULL) + return; + + count= array_elements(all_mdl_mutexes); + PSI_server->register_mutex(category, all_mdl_mutexes, count); + + count= array_elements(all_mdl_rwlocks); + PSI_server->register_rwlock(category, all_mdl_rwlocks, count); + + count= array_elements(all_mdl_conds); + PSI_server->register_cond(category, all_mdl_conds, count); +} +#endif /* HAVE_PSI_INTERFACE */ void notify_shared_lock(THD *thd, MDL_ticket *conflicting_ticket); @@ -178,7 +226,7 @@ public: If m_wrlock prefers readers (actually ignoring pending writers is enough) ctxA and ctxB will continue and no deadlock will occur. */ - rw_pr_lock_t m_rwlock; + mysql_prlock_t m_rwlock; bool is_empty() const { @@ -240,12 +288,12 @@ public: m_ref_release(0), m_is_destroyed(FALSE) { - rw_pr_init(&m_rwlock); + mysql_prlock_init(key_MDL_lock_rwlock, &m_rwlock); } virtual ~MDL_lock() { - rw_pr_destroy(&m_rwlock); + mysql_prlock_destroy(&m_rwlock); } inline static void destroy(MDL_lock *lock); public: @@ -368,6 +416,11 @@ void mdl_init() { DBUG_ASSERT(! mdl_initialized); mdl_initialized= TRUE; + +#ifdef HAVE_PSI_INTERFACE + init_mdl_psi_keys(); +#endif + mdl_locks.init(); } @@ -393,7 +446,7 @@ void mdl_destroy() void MDL_map::init() { - mysql_mutex_init(NULL /* pfs key */,&m_mutex, NULL); + mysql_mutex_init(key_MDL_map_mutex, &m_mutex, NULL); my_hash_init(&m_locks, &my_charset_bin, 16 /* FIXME */, 0, 0, mdl_locks_key, 0, 0); } @@ -507,7 +560,7 @@ bool MDL_map::move_from_hash_to_lock_mutex(MDL_lock *lock) lock->m_ref_usage++; mysql_mutex_unlock(&m_mutex); - rw_pr_wrlock(&lock->m_rwlock); + mysql_prlock_wrlock(&lock->m_rwlock); lock->m_ref_release++; if (unlikely(lock->m_is_destroyed)) { @@ -522,7 +575,7 @@ bool MDL_map::move_from_hash_to_lock_mutex(MDL_lock *lock) */ uint ref_usage= lock->m_ref_usage; uint ref_release= lock->m_ref_release; - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); if (ref_usage == ref_release) MDL_lock::destroy(lock); return TRUE; @@ -565,7 +618,7 @@ void MDL_map::remove(MDL_lock *lock) lock->m_is_destroyed= TRUE; ref_usage= lock->m_ref_usage; ref_release= lock->m_ref_release; - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); mysql_mutex_unlock(&m_mutex); if (ref_usage == ref_release) MDL_lock::destroy(lock); @@ -586,9 +639,9 @@ MDL_context::MDL_context() m_deadlock_weight(0), m_signal(NO_WAKE_UP) { - rw_pr_init(&m_waiting_for_lock); - mysql_mutex_init(NULL /* pfs key */, &m_signal_lock, NULL); - mysql_cond_init(NULL /* pfs key */, &m_signal_cond, NULL); + mysql_prlock_init(key_MDL_context_waiting_for_rwlock, &m_waiting_for_lock); + mysql_mutex_init(key_MDL_context_signal_mutex, &m_signal_lock, NULL); + mysql_cond_init(key_MDL_context_signal_mutex, &m_signal_cond, NULL); } @@ -608,7 +661,7 @@ void MDL_context::destroy() { DBUG_ASSERT(m_tickets.is_empty()); - rw_pr_destroy(&m_waiting_for_lock); + mysql_prlock_destroy(&m_waiting_for_lock); mysql_mutex_destroy(&m_signal_lock); mysql_cond_destroy(&m_signal_cond); } @@ -1098,7 +1151,7 @@ MDL_lock::can_grant_lock(enum_mdl_type type_arg, void MDL_lock::remove_ticket(Ticket_list MDL_lock::*list, MDL_ticket *ticket) { - rw_pr_wrlock(&m_rwlock); + mysql_prlock_wrlock(&m_rwlock); (this->*list).remove_ticket(ticket); if (is_empty()) mdl_locks.remove(this); @@ -1109,7 +1162,7 @@ void MDL_lock::remove_ticket(Ticket_list MDL_lock::*list, MDL_ticket *ticket) which now might be able to do it. Wake them up! */ wake_up_waiters(); - rw_pr_unlock(&m_rwlock); + mysql_prlock_unlock(&m_rwlock); } } @@ -1129,9 +1182,9 @@ bool MDL_lock::has_pending_conflicting_lock(enum_mdl_type type) mysql_mutex_assert_not_owner(&LOCK_open); - rw_pr_rdlock(&m_rwlock); + mysql_prlock_rdlock(&m_rwlock); result= (m_waiting.bitmap() & incompatible_granted_types_bitmap()[type]); - rw_pr_unlock(&m_rwlock); + mysql_prlock_unlock(&m_rwlock); return result; } @@ -1325,7 +1378,7 @@ MDL_context::try_acquire_lock(MDL_request *mdl_request) { ticket->m_lock= lock; lock->m_granted.add_ticket(ticket); - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); m_tickets.push_front(ticket); @@ -1335,7 +1388,7 @@ MDL_context::try_acquire_lock(MDL_request *mdl_request) { /* We can't get here if we allocated a new lock. */ DBUG_ASSERT(! lock->is_empty()); - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); MDL_ticket::destroy(ticket); } @@ -1376,9 +1429,9 @@ MDL_context::clone_ticket(MDL_request *mdl_request) ticket->m_lock= mdl_request->ticket->m_lock; mdl_request->ticket= ticket; - rw_pr_wrlock(&ticket->m_lock->m_rwlock); + mysql_prlock_wrlock(&ticket->m_lock->m_rwlock); ticket->m_lock->m_granted.add_ticket(ticket); - rw_pr_unlock(&ticket->m_lock->m_rwlock); + mysql_prlock_unlock(&ticket->m_lock->m_rwlock); m_tickets.push_front(ticket); @@ -1484,7 +1537,7 @@ bool MDL_context::acquire_lock_impl(MDL_request *mdl_request, if (ticket->is_upgradable_or_exclusive()) lock->notify_shared_locks(this); - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); set_deadlock_weight(mdl_request->get_deadlock_weight()); will_wait_for(ticket); @@ -1519,7 +1572,7 @@ bool MDL_context::acquire_lock_impl(MDL_request *mdl_request, my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); return TRUE; } - rw_pr_wrlock(&lock->m_rwlock); + mysql_prlock_wrlock(&lock->m_rwlock); } lock->m_waiting.remove_ticket(ticket); @@ -1529,7 +1582,7 @@ bool MDL_context::acquire_lock_impl(MDL_request *mdl_request, (*lock->cached_object_release_hook)(lock->cached_object); lock->cached_object= NULL; - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); m_tickets.push_front(ticket); @@ -1674,7 +1727,7 @@ MDL_context::upgrade_shared_lock_to_exclusive(MDL_ticket *mdl_ticket, is_new_ticket= ! has_lock(mdl_svp, mdl_xlock_request.ticket); /* Merge the acquired and the original lock. @todo: move to a method. */ - rw_pr_wrlock(&mdl_ticket->m_lock->m_rwlock); + mysql_prlock_wrlock(&mdl_ticket->m_lock->m_rwlock); if (is_new_ticket) mdl_ticket->m_lock->m_granted.remove_ticket(mdl_xlock_request.ticket); /* @@ -1686,7 +1739,7 @@ MDL_context::upgrade_shared_lock_to_exclusive(MDL_ticket *mdl_ticket, mdl_ticket->m_type= MDL_EXCLUSIVE; mdl_ticket->m_lock->m_granted.add_ticket(mdl_ticket); - rw_pr_unlock(&mdl_ticket->m_lock->m_rwlock); + mysql_prlock_unlock(&mdl_ticket->m_lock->m_rwlock); if (is_new_ticket) { @@ -1704,7 +1757,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, MDL_ticket *ticket; bool result= FALSE; - rw_pr_rdlock(&m_rwlock); + mysql_prlock_rdlock(&m_rwlock); Ticket_iterator granted_it(m_granted); Ticket_iterator waiting_it(m_waiting); @@ -1756,7 +1809,7 @@ bool MDL_lock::find_deadlock(MDL_ticket *waiting_ticket, } end: - rw_pr_unlock(&m_rwlock); + mysql_prlock_unlock(&m_rwlock); return result; } @@ -1765,7 +1818,7 @@ bool MDL_context::find_deadlock(Deadlock_detection_context *deadlock_ctx) { bool result= FALSE; - rw_pr_rdlock(&m_waiting_for_lock); + mysql_prlock_rdlock(&m_waiting_for_lock); if (m_waiting_for) { @@ -1794,14 +1847,14 @@ bool MDL_context::find_deadlock(Deadlock_detection_context *deadlock_ctx) deadlock_ctx->victim= this; else if (deadlock_ctx->victim->m_deadlock_weight >= m_deadlock_weight) { - rw_pr_unlock(&deadlock_ctx->victim->m_waiting_for_lock); + mysql_prlock_unlock(&deadlock_ctx->victim->m_waiting_for_lock); deadlock_ctx->victim= this; } else - rw_pr_unlock(&m_waiting_for_lock); + mysql_prlock_unlock(&m_waiting_for_lock); } else - rw_pr_unlock(&m_waiting_for_lock); + mysql_prlock_unlock(&m_waiting_for_lock); return result; } @@ -1827,7 +1880,7 @@ bool MDL_context::find_deadlock() if (deadlock_ctx.victim != this) { deadlock_ctx.victim->awake(VICTIM_WAKE_UP); - rw_pr_unlock(&deadlock_ctx.victim->m_waiting_for_lock); + mysql_prlock_unlock(&deadlock_ctx.victim->m_waiting_for_lock); /* After adding new arc to waiting graph we found that it participates in some loop (i.e. there is a deadlock). We decided to destroy this @@ -1840,7 +1893,7 @@ bool MDL_context::find_deadlock() else { DBUG_ASSERT(&deadlock_ctx.victim->m_waiting_for_lock == &m_waiting_for_lock); - rw_pr_unlock(&deadlock_ctx.victim->m_waiting_for_lock); + mysql_prlock_unlock(&deadlock_ctx.victim->m_waiting_for_lock); return TRUE; } } @@ -1897,14 +1950,14 @@ MDL_context::wait_for_lock(MDL_request *mdl_request, ulong lock_wait_timeout) if (lock->can_grant_lock(mdl_request->type, this)) { - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); return FALSE; } MDL_ticket *pending_ticket; if (! (pending_ticket= MDL_ticket::create(this, mdl_request->type))) { - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); return TRUE; } @@ -1913,7 +1966,7 @@ MDL_context::wait_for_lock(MDL_request *mdl_request, ulong lock_wait_timeout) lock->m_waiting.add_ticket(pending_ticket); wait_reset(); - rw_pr_unlock(&lock->m_rwlock); + mysql_prlock_unlock(&lock->m_rwlock); set_deadlock_weight(MDL_DEADLOCK_WEIGHT_DML); will_wait_for(pending_ticket); @@ -2064,7 +2117,7 @@ void MDL_ticket::downgrade_exclusive_lock(enum_mdl_type type) if (m_type != MDL_EXCLUSIVE) return; - rw_pr_wrlock(&m_lock->m_rwlock); + mysql_prlock_wrlock(&m_lock->m_rwlock); /* To update state of MDL_lock object correctly we need to temporarily exclude ticket from the granted queue and then include it back. @@ -2073,7 +2126,7 @@ void MDL_ticket::downgrade_exclusive_lock(enum_mdl_type type) m_type= type; m_lock->m_granted.add_ticket(this); m_lock->wake_up_waiters(); - rw_pr_unlock(&m_lock->m_rwlock); + mysql_prlock_unlock(&m_lock->m_rwlock); } diff --git a/sql/mdl.h b/sql/mdl.h index 42461f6ac2f..124151798ae 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -628,7 +628,7 @@ private: important as deadlock detector won't work correctly otherwise. @sa Comment for MDL_lock::m_rwlock. */ - rw_pr_lock_t m_waiting_for_lock; + mysql_prlock_t m_waiting_for_lock; MDL_ticket *m_waiting_for; uint m_deadlock_weight; /** @@ -652,9 +652,9 @@ private: void will_wait_for(MDL_ticket *pending_ticket) { - rw_pr_wrlock(&m_waiting_for_lock); + mysql_prlock_wrlock(&m_waiting_for_lock); m_waiting_for= pending_ticket; - rw_pr_unlock(&m_waiting_for_lock); + mysql_prlock_unlock(&m_waiting_for_lock); } void set_deadlock_weight(uint weight) @@ -670,9 +670,9 @@ private: void stop_waiting() { - rw_pr_wrlock(&m_waiting_for_lock); + mysql_prlock_wrlock(&m_waiting_for_lock); m_waiting_for= NULL; - rw_pr_unlock(&m_waiting_for_lock); + mysql_prlock_unlock(&m_waiting_for_lock); } void wait_reset() diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4e672f1d6c7..b398baa064e 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1590,8 +1590,7 @@ inline bool open_and_lock_tables(THD *thd, TABLE_LIST *tables, TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l, thr_lock_type lock_type, uint flags); bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags); -bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags, - bool *need_reopen); +bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags); TABLE *open_temporary_table(THD *thd, const char *path, const char *db, const char *table_name, bool link_in_list); bool rm_temporary_table(handlerton *base, char *path); @@ -2145,14 +2144,13 @@ extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher, extern struct st_VioSSLFd * ssl_acceptor_fd; #endif /* HAVE_OPENSSL */ -MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, - uint flags, bool *need_reopen); +MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags); /* mysql_lock_tables() and open_table() flags bits */ -#define MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001 -#define MYSQL_LOCK_IGNORE_FLUSH 0x0002 +#define MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK 0x0001 +#define MYSQL_OPEN_IGNORE_FLUSH 0x0002 #define MYSQL_OPEN_TEMPORARY_ONLY 0x0004 #define MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY 0x0008 -#define MYSQL_LOCK_PERF_SCHEMA 0x0010 +#define MYSQL_LOCK_LOG_TABLE 0x0010 #define MYSQL_OPEN_TAKE_UPGRADABLE_MDL 0x0020 /** Do not try to acquire a metadata lock on the table: we @@ -2182,8 +2180,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, #define MYSQL_LOCK_IGNORE_TIMEOUT 0x1000 /** Please refer to the internals manual. */ -#define MYSQL_OPEN_REOPEN (MYSQL_LOCK_IGNORE_FLUSH |\ - MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK |\ +#define MYSQL_OPEN_REOPEN (MYSQL_OPEN_IGNORE_FLUSH |\ + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |\ MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |\ MYSQL_LOCK_IGNORE_TIMEOUT |\ MYSQL_OPEN_GET_NEW_TABLE |\ diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index feb35527b62..8171d028326 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -340,7 +340,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const /** */ -void show_sql_type(enum_field_types type, uint16 metadata, String *str) +void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_INFO *field_cs) { DBUG_ENTER("show_sql_type"); DBUG_PRINT("enter", ("type: %d, metadata: 0x%x", type, metadata)); @@ -489,7 +489,7 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str) uint bytes= (((metadata >> 4) & 0x300) ^ 0x300) + (metadata & 0x00ff); uint32 length= cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(), - "char(%d)", bytes / cs->mbmaxlen); + "char(%d)", bytes / field_cs->mbmaxlen); str->length(length); } break; @@ -579,7 +579,7 @@ can_convert_field_to(Field *field, DBUG_ENTER("can_convert_field_to"); #ifndef DBUG_OFF char field_type_buf[MAX_FIELD_WIDTH]; - String field_type(field_type_buf, sizeof(field_type_buf), field->charset()); + String field_type(field_type_buf, sizeof(field_type_buf), &my_charset_latin1); field->sql_type(field_type); DBUG_PRINT("enter", ("field_type: %s, target_type: %d, source_type: %d, source_metadata: 0x%x", field_type.c_ptr_safe(), field->real_type(), source_type, metadata)); @@ -822,9 +822,9 @@ table_def::compatible_with(THD *thd, Relay_log_info *rli, const char *tbl_name= table->s->table_name.str; char source_buf[MAX_FIELD_WIDTH]; char target_buf[MAX_FIELD_WIDTH]; - String source_type(source_buf, sizeof(source_buf), field->charset()); - String target_type(target_buf, sizeof(target_buf), field->charset()); - show_sql_type(type(col), field_metadata(col), &source_type); + String source_type(source_buf, sizeof(source_buf), &my_charset_latin1); + String target_type(target_buf, sizeof(target_buf), &my_charset_latin1); + show_sql_type(type(col), field_metadata(col), &source_type, field->charset()); field->sql_type(target_type); rli->report(ERROR_LEVEL, ER_SLAVE_CONVERSION_FAILED, ER(ER_SLAVE_CONVERSION_FAILED), @@ -842,8 +842,8 @@ table_def::compatible_with(THD *thd, Relay_log_info *rli, { char source_buf[MAX_FIELD_WIDTH]; char target_buf[MAX_FIELD_WIDTH]; - String source_type(source_buf, sizeof(source_buf), table->field[col]->charset()); - String target_type(target_buf, sizeof(target_buf), table->field[col]->charset()); + String source_type(source_buf, sizeof(source_buf), &my_charset_latin1); + String target_type(target_buf, sizeof(target_buf), &my_charset_latin1); tmp_table->field[col]->sql_type(source_type); table->field[col]->sql_type(target_type); DBUG_PRINT("debug", ("Field %s - conversion required." diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 9861c03137f..4b680c1788d 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6321,3 +6321,6 @@ ER_SPATIAL_MUST_HAVE_GEOM_COL 42000 ER_TOO_LONG_INDEX_COMMENT eng "Comment for index '%-.64s' is too long (max = %lu)" + +ER_LOCK_ABORTED + eng "Wait on a lock was aborted due to a pending exclusive lock" diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b4c9aa576d0..a85a863abd9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2421,7 +2421,7 @@ open_table_get_mdl_lock(THD *thd, TABLE_LIST *table_list, required to remedy problem appeared during attempt to open table. flags Bitmap of flags to modify how open works: - MYSQL_LOCK_IGNORE_FLUSH - Open table even if + MYSQL_OPEN_IGNORE_FLUSH - Open table even if someone has done a flush or there is a pending exclusive metadata lock requests against it (i.e. request high priority metadata lock). @@ -2480,6 +2480,31 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, TMP_TABLE_KEY_EXTRA); /* + We need this to work for all tables, including temporary + tables, for backwards compatibility. But not under LOCK + TABLES, since under LOCK TABLES one can't use a non-prelocked + table. This code only works for updates done inside DO/SELECT + f1() statements, normal DML is handled by means of + sql_command_flags. + */ + if (global_read_lock && table_list->lock_type >= TL_WRITE_ALLOW_WRITE && + ! (flags & MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK) && + ! thd->locked_tables_mode) + { + /* + Someone has issued FLUSH TABLES WITH READ LOCK and we want + a write lock. Wait until the lock is gone. + */ + if (thd->global_read_lock.wait_if_global_read_lock(thd, 1, 1)) + DBUG_RETURN(TRUE); + + if (thd->version != refresh_version) + { + (void) ot_ctx->request_backoff_action(Open_table_context::OT_WAIT_TDC); + DBUG_RETURN(TRUE); + } + } + /* Unless requested otherwise, try to resolve this table in the list of temporary tables of this thread. In MySQL temporary tables are always thread-local and "shadow" possible base tables with the @@ -2680,7 +2705,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, if (!thd->open_tables) thd->version=refresh_version; else if ((thd->version != refresh_version) && - ! (flags & MYSQL_LOCK_IGNORE_FLUSH)) + ! (flags & MYSQL_OPEN_IGNORE_FLUSH)) { /* Someone did a refresh while thread was opening tables */ mysql_mutex_unlock(&LOCK_open); @@ -2811,7 +2836,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, if (share->version != refresh_version) { - if (!(flags & MYSQL_LOCK_IGNORE_FLUSH)) + if (!(flags & MYSQL_OPEN_IGNORE_FLUSH)) { /* We already have an MDL lock. But we have encountered an old @@ -3293,7 +3318,6 @@ bool Locked_tables_list::reopen_tables(THD *thd) { Open_table_context ot_ctx_unused(thd, LONG_TIMEOUT); - bool lt_refresh_unused; size_t reopen_count= 0; MYSQL_LOCK *lock; MYSQL_LOCK *merged_lock; @@ -3333,7 +3357,7 @@ Locked_tables_list::reopen_tables(THD *thd) break something else. */ lock= mysql_lock_tables(thd, m_reopen_array, reopen_count, - MYSQL_OPEN_REOPEN, <_refresh_unused); + MYSQL_OPEN_REOPEN); thd->in_lock_tables= 0; if (lock == NULL || (merged_lock= mysql_lock_merge(thd->lock, lock)) == NULL) @@ -5061,7 +5085,6 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type, TABLE *table; Open_table_context ot_ctx(thd, (lock_flags & MYSQL_LOCK_IGNORE_TIMEOUT) ? LONG_TIMEOUT : thd->variables.lock_wait_timeout); - bool refresh; bool error; DBUG_ENTER("open_ltable"); @@ -5073,8 +5096,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type, /* open_ltable can be used only for BASIC TABLEs */ table_list->required_type= FRMTYPE_TABLE; -retry: - while ((error= open_table(thd, table_list, thd->mem_root, &ot_ctx, 0)) && + while ((error= open_table(thd, table_list, thd->mem_root, &ot_ctx, lock_flags)) && ot_ctx.can_recover_from_failed_open()) { /* @@ -5120,18 +5142,9 @@ retry: DBUG_ASSERT(thd->lock == 0); // You must lock everything at once if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK) if (! (thd->lock= mysql_lock_tables(thd, &table_list->table, 1, - lock_flags, &refresh))) + lock_flags))) { - if (refresh) - { - close_thread_tables(thd); - table_list->table= NULL; - table_list->mdl_request.ticket= NULL; - thd->mdl_context.rollback_to_savepoint(ot_ctx.start_of_statement_svp()); - goto retry; - } - else - table= 0; + table= 0; } } } @@ -5168,42 +5181,27 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables, Prelocking_strategy *prelocking_strategy) { uint counter; - bool need_reopen; - /* - Remember the set of metadata locks which this connection - managed to acquire before the start of the current statement. - It can be either transaction-scope locks, or HANDLER locks, - or LOCK TABLES locks. If mysql_lock_tables() fails with - need_reopen request, we'll use it to instruct - close_tables_for_reopen() to release all locks of this - statement. - */ - MDL_ticket *start_of_statement_svp= thd->mdl_context.mdl_savepoint(); DBUG_ENTER("open_and_lock_tables"); DBUG_PRINT("enter", ("derived handling: %d", derived)); - for ( ; ; ) - { - if (open_tables(thd, &tables, &counter, flags, prelocking_strategy)) - DBUG_RETURN(TRUE); - DBUG_EXECUTE_IF("sleep_open_and_lock_after_open", { - const char *old_proc_info= thd->proc_info; - thd->proc_info= "DBUG sleep"; - my_sleep(6000000); - thd->proc_info= old_proc_info;}); - - if (!lock_tables(thd, tables, counter, flags, - &need_reopen)) - break; - if (!need_reopen) - DBUG_RETURN(TRUE); - close_tables_for_reopen(thd, &tables, start_of_statement_svp); - } + if (open_tables(thd, &tables, &counter, flags, prelocking_strategy)) + DBUG_RETURN(TRUE); + + DBUG_EXECUTE_IF("sleep_open_and_lock_after_open", { + const char *old_proc_info= thd->proc_info; + thd->proc_info= "DBUG sleep"; + my_sleep(6000000); + thd->proc_info= old_proc_info;}); + + if (lock_tables(thd, tables, counter, flags)) + DBUG_RETURN(TRUE); + if (derived && (mysql_handle_derived(thd->lex, &mysql_derived_prepare) || (thd->fill_derived_tables() && mysql_handle_derived(thd->lex, &mysql_derived_filling)))) DBUG_RETURN(TRUE); /* purecov: inspected */ + DBUG_RETURN(FALSE); } @@ -5216,7 +5214,7 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables, thd - thread handler tables - list of tables for open flags - bitmap of flags to modify how the tables will be open: - MYSQL_LOCK_IGNORE_FLUSH - open table even if someone has + MYSQL_OPEN_IGNORE_FLUSH - open table even if someone has done a flush or namelock on it. RETURN @@ -5261,37 +5259,28 @@ static void mark_real_tables_as_free_for_reuse(TABLE_LIST *table) } -/* - Lock all tables in list +/** + Lock all tables in a list. - SYNOPSIS - lock_tables() - thd Thread handler - tables Tables to lock - count Number of opened tables - flags Options (see mysql_lock_tables() for details) - need_reopen Out parameter which if TRUE indicates that some - tables were dropped or altered during this call - and therefore invoker should reopen tables and - try to lock them once again (in this case - lock_tables() will also return error). + @param thd Thread handler + @param tables Tables to lock + @param count Number of opened tables + @param flags Options (see mysql_lock_tables() for details) - NOTES - You can't call lock_tables twice, as this would break the dead-lock-free - handling thr_lock gives us. You most always get all needed locks at - once. + You can't call lock_tables() while holding thr_lock locks, as + this would break the dead-lock-free handling thr_lock gives us. + You must always get all needed locks at once. - If query for which we are calling this function marked as requiring - prelocking, this function will change locked_tables_mode to - LTM_PRELOCKED. + If the query for which we are calling this function is marked as + requiring prelocking, this function will change + locked_tables_mode to LTM_PRELOCKED. - RETURN VALUES - 0 ok - -1 Error + @retval FALSE Success. + @retval TRUE A lock wait timeout, deadlock or out of memory. */ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, - uint flags, bool *need_reopen) + uint flags) { TABLE_LIST *table; @@ -5302,7 +5291,6 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, */ DBUG_ASSERT(thd->locked_tables_mode <= LTM_LOCK_TABLES || !thd->lex->requires_prelocking()); - *need_reopen= FALSE; if (!tables && !thd->lex->requires_prelocking()) DBUG_RETURN(thd->decide_logging_format(tables)); @@ -5347,7 +5335,7 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, DEBUG_SYNC(thd, "before_lock_tables_takes_lock"); if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start), - flags, need_reopen))) + flags))) DBUG_RETURN(TRUE); DEBUG_SYNC(thd, "after_lock_tables_takes_lock"); @@ -8869,7 +8857,7 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list, thd->reset_n_backup_open_tables_state(backup); if (open_and_lock_tables(thd, table_list, FALSE, - MYSQL_LOCK_IGNORE_FLUSH | + MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT)) { lex->restore_backup_query_tables_list(&query_tables_list_backup); @@ -8957,11 +8945,11 @@ open_system_table_for_update(THD *thd, TABLE_LIST *one_table) TABLE * open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup) { - uint flags= ( MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK | + uint flags= ( MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | - MYSQL_LOCK_IGNORE_FLUSH | + MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT | - MYSQL_LOCK_PERF_SCHEMA); + MYSQL_LOCK_LOG_TABLE); TABLE *table; /* Save value that is changed in mysql_lock_tables() */ ulonglong save_utime_after_lock= thd->utime_after_lock; @@ -8989,8 +8977,7 @@ open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup) open tables cannot be accepted when restoring the open tables state. */ - if (thd->killed) - close_thread_tables(thd); + close_thread_tables(thd); thd->restore_backup_open_tables_state(backup); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 8ce3cee3c36..de6d92eccfd 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -75,6 +75,7 @@ typedef struct st_user_var_events ulong length; Item_result type; uint charset_number; + bool unsigned_flag; } BINLOG_USER_VAR_EVENT; #define RP_LOCK_LOG_IS_ALREADY_LOCKED 1 @@ -1161,9 +1162,7 @@ public: class Drop_table_error_handler : public Internal_error_handler { public: - Drop_table_error_handler(Internal_error_handler *err_handler) - :m_err_handler(err_handler) - { } + Drop_table_error_handler() {} public: bool handle_condition(THD *thd, @@ -1174,7 +1173,6 @@ public: MYSQL_ERROR ** cond_hdl); private: - Internal_error_handler *m_err_handler; }; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 75855020127..e700dd93a55 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -934,7 +934,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } else { - Drop_table_error_handler err_handler(thd->get_internal_handler()); + Drop_table_error_handler err_handler; thd->push_internal_handler(&err_handler); error= -1; diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 3afeb4164bd..dfa06495e9d 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -405,6 +405,56 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables) } +/** + A helper class to process an error from mysql_lock_tables(). + HANDLER READ statement's attempt to lock the subject table + may get aborted if there is a pending DDL. In that case + we close the table, reopen it, and try to read again. + This is implicit and obscure, since HANDLER position + is lost in the process, but it's the legacy server + behaviour we should preserve. +*/ + +class Sql_handler_lock_error_handler: public Internal_error_handler +{ +public: + virtual + bool handle_condition(THD *thd, + uint sql_errno, + const char *sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* msg, + MYSQL_ERROR **cond_hdl); + + bool need_reopen() const { return m_need_reopen; }; + void init() { m_need_reopen= FALSE; }; +private: + bool m_need_reopen; +}; + + +/** + Handle an error from mysql_lock_tables(). + Ignore ER_LOCK_ABORTED errors. +*/ + +bool +Sql_handler_lock_error_handler:: +handle_condition(THD *thd, + uint sql_errno, + const char *sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* msg, + MYSQL_ERROR **cond_hdl) +{ + *cond_hdl= NULL; + if (sql_errno == ER_LOCK_ABORTED) + m_need_reopen= TRUE; + + return m_need_reopen; +} + + /* Read from a HANDLER table. @@ -442,7 +492,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, uint num_rows; uchar *UNINIT_VAR(key); uint UNINIT_VAR(key_len); - bool need_reopen; + Sql_handler_lock_error_handler sql_handler_lock_error; DBUG_ENTER("mysql_ha_read"); DBUG_PRINT("enter",("'%s'.'%s' as '%s'", tables->db, tables->table_name, tables->alias)); @@ -506,8 +556,12 @@ retry: thd->open_tables= hash_tables->table; - lock= mysql_lock_tables(thd, &thd->open_tables, 1, 0, &need_reopen); + sql_handler_lock_error.init(); + thd->push_internal_handler(&sql_handler_lock_error); + + lock= mysql_lock_tables(thd, &thd->open_tables, 1, 0); + thd->pop_internal_handler(); /* In 5.1 and earlier, mysql_lock_tables() could replace the TABLE object with another one (reopen it). This is no longer the case @@ -517,8 +571,9 @@ retry: /* Restore previous context. */ thd->open_tables= backup_open_tables; - if (need_reopen) + if (sql_handler_lock_error.need_reopen()) { + DBUG_ASSERT(!lock && !thd->is_error()); mysql_ha_close_table(thd, hash_tables); goto retry; } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 26fb4e4e4e4..7423dd9d292 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2396,7 +2396,8 @@ void kill_delayed_threads(void) bool Delayed_insert::open_and_lock_table() { if (!(table= open_n_lock_single_table(&thd, &table_list, - TL_WRITE_DELAYED, 0))) + TL_WRITE_DELAYED, + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK))) { thd.fatal_error(); // Abort waiting inserts return TRUE; @@ -2557,7 +2558,6 @@ pthread_handler_t handle_delayed_insert(void *arg) if (di->tables_in_use && ! thd->lock && !thd->killed) { - bool need_reopen; /* Request for new delayed insert. Lock the table, but avoid to be blocked by a global read lock. @@ -2568,30 +2568,10 @@ pthread_handler_t handle_delayed_insert(void *arg) handler will close the table and finish when the outstanding inserts are done. */ - if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, - MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK, - &need_reopen))) + if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, 0))) { - if (need_reopen && !thd->killed) - { - /* - We were waiting to obtain TL_WRITE_DELAYED (probably due to - someone having or requesting TL_WRITE_ALLOW_READ) and got - aborted. Try to reopen table and if it fails die. - */ - TABLE_LIST *tl_ptr = &di->table_list; - close_tables_for_reopen(thd, &tl_ptr, NULL); - di->table= 0; - if (di->open_and_lock_table()) - { - thd->killed= THD::KILL_CONNECTION; - } - } - else - { - /* Fatal error */ - thd->killed= THD::KILL_CONNECTION; - } + /* Fatal error */ + thd->killed= THD::KILL_CONNECTION; } mysql_cond_broadcast(&di->cond_client); } @@ -3542,7 +3522,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, List_iterator_fast<Item> it(*items); Item *item; Field *tmp_field; - bool not_used; DBUG_ENTER("create_table_from_items"); tmp_table.alias= 0; @@ -3666,8 +3645,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, since it won't wait for the table lock (we have exclusive metadata lock on the table) and thus can't get aborted. */ - if (! ((*lock)= mysql_lock_tables(thd, &table, 1, - MYSQL_LOCK_IGNORE_FLUSH, ¬_used)) || + if (! ((*lock)= mysql_lock_tables(thd, &table, 1, 0)) || hooks->postlock(&table, 1)) { if (*lock) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6403ad99282..23e0d8c0d70 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1631,6 +1631,14 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, - you can't flush WITH READ LOCK a non-existent table - you can't flush WITH READ LOCK under LOCK TABLES - currently incompatible with the GRL (@todo: fix) + + Effect on views and temporary tables. + ------------------------------------ + You can only apply this command to existing base tables. + If a view with such name exists, ER_WRONG_OBJECT is returned. + If a temporary table with such name exists, it's ignored: + if there is a base table, it's used, otherwise ER_NO_SUCH_TABLE + is returned. */ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) @@ -1665,6 +1673,21 @@ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) if (lock_table_names(thd, all_tables)) goto error; + for (table_list= all_tables; table_list; + table_list= table_list->next_global) + { + /* Remove the table from cache. */ + mysql_mutex_lock(&LOCK_open); + tdc_remove_table(thd, TDC_RT_REMOVE_ALL, + table_list->db, + table_list->table_name); + mysql_mutex_unlock(&LOCK_open); + + /* Skip views and temporary tables. */ + table_list->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */ + table_list->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */ + } + if (open_and_lock_tables(thd, all_tables, FALSE, MYSQL_OPEN_HAS_MDL_LOCK, &lock_tables_prelocking_strategy) || diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index d400e96ce7e..cfb57475b68 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2128,8 +2128,6 @@ static int check_part_field(enum_field_types sql_type, } switch (sql_type) { - case MYSQL_TYPE_NEWDECIMAL: - case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -2151,6 +2149,8 @@ static int check_part_field(enum_field_types sql_type, *result_type= STRING_RESULT; *need_cs_check= TRUE; return FALSE; + case MYSQL_TYPE_NEWDECIMAL: + case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_NULL: case MYSQL_TYPE_FLOAT: diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 31e3baca764..94a35db3a2d 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -3769,7 +3769,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) if (state == Query_arena::PREPARED) state= Query_arena::EXECUTED; - if (this->lex->sql_command == SQLCOM_CALL) + if (error == 0 && this->lex->sql_command == SQLCOM_CALL) { if (is_sql_prepare()) thd->protocol_text.send_out_parameters(&this->lex->param_list); @@ -3777,7 +3777,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) thd->protocol->send_out_parameters(&this->lex->param_list); } - /* Log COM_EXECUTE to the general log. Note, that in case of SQL prepared statements this causes two records to be output: diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8b8e223ad02..542a0378bf4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2934,7 +2934,7 @@ fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables, */ lex->sql_command= SQLCOM_SHOW_FIELDS; res= open_normal_and_derived_tables(thd, show_table_list, - (MYSQL_LOCK_IGNORE_FLUSH | + (MYSQL_OPEN_IGNORE_FLUSH | MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL | (can_deadlock ? MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0))); @@ -3516,7 +3516,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) show_table_list->i_s_requested_object= schema_table->i_s_requested_object; res= open_normal_and_derived_tables(thd, show_table_list, - (MYSQL_LOCK_IGNORE_FLUSH | + (MYSQL_OPEN_IGNORE_FLUSH | MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL | (can_deadlock ? MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0))); lex->sql_command= save_sql_command; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8ba8c50b01e..2a9e01daf18 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1811,7 +1811,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, my_bool drop_temporary) { bool error; - Drop_table_error_handler err_handler(thd->get_internal_handler()); + Drop_table_error_handler err_handler; DBUG_ENTER("mysql_rm_table"); @@ -4426,7 +4426,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, MY_STAT stat_info; Open_table_context ot_ctx_unused(thd, LONG_TIMEOUT); DBUG_ENTER("prepare_for_repair"); - uint reopen_for_repair_flags= (MYSQL_LOCK_IGNORE_FLUSH | + uint reopen_for_repair_flags= (MYSQL_OPEN_IGNORE_FLUSH | MYSQL_OPEN_HAS_MDL_LOCK); if (!(check_opt->sql_flags & TT_USEFRM)) @@ -7155,7 +7155,7 @@ view_err: tbl.table_name= tbl.alias= tmp_name; /* Table is in thd->temporary_tables */ (void) open_table(thd, &tbl, thd->mem_root, &ot_ctx_unused, - MYSQL_LOCK_IGNORE_FLUSH); + MYSQL_OPEN_IGNORE_FLUSH); new_table= tbl.table; } else diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 1643bce8ddd..62a35335374 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -203,33 +203,26 @@ int mysql_update(THD *thd, SQL_SELECT *select; READ_RECORD info; SELECT_LEX *select_lex= &thd->lex->select_lex; - bool need_reopen; ulonglong id; List<Item> all_fields; THD::killed_state killed_status= THD::NOT_KILLED; MDL_ticket *start_of_statement_svp= thd->mdl_context.mdl_savepoint(); DBUG_ENTER("mysql_update"); - for ( ; ; ) - { - if (open_tables(thd, &table_list, &table_count, 0)) - DBUG_RETURN(1); + if (open_tables(thd, &table_list, &table_count, 0)) + DBUG_RETURN(1); - if (table_list->multitable_view) - { - DBUG_ASSERT(table_list->view != 0); - DBUG_PRINT("info", ("Switch to multi-update")); - /* pass counter value */ - thd->lex->table_count= table_count; - /* convert to multiupdate */ - DBUG_RETURN(2); - } - if (!lock_tables(thd, table_list, table_count, 0, &need_reopen)) - break; - if (!need_reopen) - DBUG_RETURN(1); - close_tables_for_reopen(thd, &table_list, start_of_statement_svp); + if (table_list->multitable_view) + { + DBUG_ASSERT(table_list->view != 0); + DBUG_PRINT("info", ("Switch to multi-update")); + /* pass counter value */ + thd->lex->table_count= table_count; + /* convert to multiupdate */ + DBUG_RETURN(2); } + if (lock_tables(thd, table_list, table_count, 0)) + DBUG_RETURN(1); if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) || (thd->fill_derived_tables() && @@ -963,17 +956,14 @@ int mysql_multi_update_prepare(THD *thd) uint table_count= lex->table_count; const bool using_lock_tables= thd->locked_tables_mode != LTM_NONE; bool original_multiupdate= (thd->lex->sql_command == SQLCOM_UPDATE_MULTI); - bool need_reopen= FALSE; MDL_ticket *start_of_statement_svp= thd->mdl_context.mdl_savepoint(); DBUG_ENTER("mysql_multi_update_prepare"); /* following need for prepared statements, to run next time multi-update */ thd->lex->sql_command= SQLCOM_UPDATE_MULTI; -reopen_tables: - /* open tables and create derived ones, but do not lock and fill them */ - if (((original_multiupdate || need_reopen) && + if ((original_multiupdate && open_tables(thd, &table_list, &table_count, 0)) || mysql_handle_derived(lex, &mysql_derived_prepare)) DBUG_RETURN(TRUE); @@ -1089,58 +1079,11 @@ reopen_tables: /* now lock and fill tables */ if (!thd->stmt_arena->is_stmt_prepare() && - lock_tables(thd, table_list, table_count, 0, &need_reopen)) + lock_tables(thd, table_list, table_count, 0)) { - if (!need_reopen) - DBUG_RETURN(TRUE); - - DBUG_PRINT("info", ("lock_tables failed, reopening")); - - /* - We have to reopen tables since some of them were altered or dropped - during lock_tables() or something was done with their triggers. - Let us do some cleanups to be able do setup_table() and setup_fields() - once again. - */ - List_iterator_fast<Item> it(*fields); - Item *item; - while ((item= it++)) - item->cleanup(); - - /* - To not to hog memory (as a result of the - unit->reinit_exec_mechanism() call below): - */ - lex->unit.cleanup(); - - for (SELECT_LEX *sl= lex->all_selects_list; - sl; - sl= sl->next_select_in_list()) - { - SELECT_LEX_UNIT *unit= sl->master_unit(); - unit->reinit_exec_mechanism(); // reset unit->prepared flags - /* - Reset 'clean' flag back to force normal execution of - unit->cleanup() in Prepared_statement::cleanup_stmt() - (call to lex->unit.cleanup() above sets this flag to TRUE). - */ - unit->unclean(); - } - - /* - Also we need to cleanup Natural_join_column::table_field items. - To not to traverse a join tree we will cleanup whole - thd->free_list (in PS execution mode that list may not contain - items from 'fields' list, so the cleanup above is necessary to. - */ - cleanup_items(thd->free_list); - cleanup_items(thd->stmt_arena->free_list); - close_tables_for_reopen(thd, &table_list, start_of_statement_svp); - - DEBUG_SYNC(thd, "multi_update_reopen_tables"); - - goto reopen_tables; + DBUG_RETURN(TRUE); } + /* @todo: downgrade the metadata locks here. */ /* Check that we are not using table that we are updating, but we should diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 2e239a9161c..e14286210b4 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006 MySQL AB, 2009-2010 Sun Microsystems, Inc. +/* Copyright (c) 2002, 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 @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* How to add new variables: @@ -647,32 +647,40 @@ static bool event_scheduler_check(sys_var *self, THD *thd, set_var *var) } static bool event_scheduler_update(sys_var *self, THD *thd, enum_var_type type) { + uint opt_event_scheduler_value= Events::opt_event_scheduler; mysql_mutex_unlock(&LOCK_global_system_variables); /* Events::start() is heavyweight. In particular it creates a new THD, which takes LOCK_global_system_variables internally. Thus we have to release it here. We need to re-take it before returning, though. - And we need to take it *without* holding Events::LOCK_event_metadata. + + Note that since we release LOCK_global_system_variables before calling + start/stop, there is a possibility that the server variable + can become out of sync with the real event scheduler state. + + This can happen with two concurrent statments if the first gets + interrupted after start/stop but before retaking + LOCK_global_system_variables. However, this problem should be quite + rare and it's difficult to avoid it without opening up possibilities + for deadlocks. See bug#51160. */ - bool ret= Events::opt_event_scheduler == Events::EVENTS_ON + bool ret= opt_event_scheduler_value == Events::EVENTS_ON ? Events::start() : Events::stop(); - mysql_mutex_unlock(&Events::LOCK_event_metadata); mysql_mutex_lock(&LOCK_global_system_variables); - mysql_mutex_lock(&Events::LOCK_event_metadata); if (ret) my_error(ER_EVENT_SET_VAR_ERROR, MYF(0)); return ret; } -static PolyLock_mutex PLock_event_metadata(&Events::LOCK_event_metadata); + static Sys_var_enum Sys_event_scheduler( "event_scheduler", "Enable the event scheduler. Possible values are " "ON, OFF, and DISABLED (keep the event scheduler completely " "deactivated, it cannot be activated run-time)", GLOBAL_VAR(Events::opt_event_scheduler), CMD_LINE(OPT_ARG), event_scheduler_names, DEFAULT(Events::EVENTS_OFF), - &PLock_event_metadata, NOT_IN_BINLOG, + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(event_scheduler_check), ON_UPDATE(event_scheduler_update)); #endif diff --git a/sql/tztime.cc b/sql/tztime.cc index 632dca1ce44..7d88b7276f2 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1668,7 +1668,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) open all time zone tables to see if they exist. */ if (open_and_lock_tables(thd, tz_tables, FALSE, - MYSQL_LOCK_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT)) + MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT)) { sql_print_warning("Can't open and lock time zone table: %s " "trying to live without them", thd->stmt_da->message()); diff --git a/sql/udf_example.c b/sql/udf_example.c index 73256bb5529..fa1b44178ac 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -107,7 +107,7 @@ ** option. ** ** If you can't get AGGREGATES to work, check that you have the column -** 'type' in the mysql.func table. If not, run 'mysql_fix_privilege_tables'. +** 'type' in the mysql.func table. If not, run 'mysql_upgrade'. ** */ diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index a11007c8472..42f05530d41 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -196,7 +196,7 @@ ENDIF() # Removing compiler optimizations for innodb/mem/* files on 64-bit Windows # due to 64-bit compiler error, See MySQL Bug #19424, #36366, #34297 -IF (MSVC AND CMAKE_SIZEOF_VOIDP EQUAL 8) +IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.c mem/mem0pool.c PROPERTIES COMPILE_FLAGS -Od) ENDIF() diff --git a/storage/perfschema/pfs_instr.cc b/storage/perfschema/pfs_instr.cc index 28b54cc6979..fbaac621dfb 100644 --- a/storage/perfschema/pfs_instr.cc +++ b/storage/perfschema/pfs_instr.cc @@ -746,6 +746,26 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass, } } + char safe_buffer[FN_REFLEN]; + const char *safe_filename; + + if (len >= FN_REFLEN) + { + /* + The instrumented code uses file names that exceeds FN_REFLEN. + This could be legal for instrumentation on non mysys APIs, + so we support it. + Truncate the file name so that: + - it fits into pfs->m_filename + - it is safe to use mysys apis to normalize the file name. + */ + memcpy(safe_buffer, filename, FN_REFLEN - 2); + safe_buffer[FN_REFLEN - 1]= 0; + safe_filename= safe_buffer; + } + else + safe_filename= filename; + /* Normalize the file name to avoid duplicates when using aliases: - absolute or relative paths @@ -759,7 +779,7 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass, Ignore errors, the file may not exist. my_realpath always provide a best effort result in buffer. */ - (void) my_realpath(buffer, filename, MYF(0)); + (void) my_realpath(buffer, safe_filename, MYF(0)); normalized_filename= buffer; normalized_length= strlen(normalized_filename); diff --git a/storage/perfschema/unittest/pfs-t.cc b/storage/perfschema/unittest/pfs-t.cc index fcbaf4aeb8f..2b64aec3416 100644 --- a/storage/perfschema/unittest/pfs-t.cc +++ b/storage/perfschema/unittest/pfs-t.cc @@ -37,14 +37,25 @@ PFS_file* lookup_file_by_name(const char* name) uint i; PFS_file *pfs; uint len= strlen(name); + size_t dirlen; + const char *filename; + uint filename_length;; for (i= 0; i < file_max; i++) { pfs= & file_array[i]; if (pfs->m_lock.is_populated()) { - if ((len == pfs->m_filename_length) && - (strncmp(name, pfs->m_filename, pfs->m_filename_length) == 0)) + /* + When a file "foo" is instrumented, the name is normalized + to "/path/to/current/directory/foo", so we remove the + directory name here to find it back. + */ + dirlen= dirname_length(pfs->m_filename); + filename= pfs->m_filename + dirlen; + filename_length= pfs->m_filename_length - dirlen; + if ((len == filename_length) && + (strncmp(name, filename, filename_length) == 0)) return pfs; } } diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 98b598c3c2c..b1b381da59e 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -1123,8 +1123,16 @@ size_t my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) continue; } b+= mb_len; - pg= (wc >> 8) & 0xFF; - clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page; + if (wc > 0xFFFF) + { + if (wc >= 0x20000 && wc <= 0x3FFFD) /* CJK Ideograph Extension B, C */ + clen+= 1; + } + else + { + pg= (wc >> 8) & 0xFF; + clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page; + } clen++; } return clen; @@ -1136,7 +1144,7 @@ int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, { my_wc_t wc; int res= cs->cset->mb_wc(cs, &wc, s, e); - if (res <= 0) + if (res <= 0 || wc > 0xFFFF) *ctype= 0; else *ctype= my_uni_ctype[wc>>8].ctype ? diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 7c7f841bd37..d7c750b81a6 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -561,6 +561,14 @@ install -d $RBR%{_libdir} install -d $RBR%{_mandir} install -d $RBR%{_sbindir} +# Get the plugin files from the debug build +mkdir $RBR/tmp-debug-plugin $MBD/plugin/debug +( cd $RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-debug-%{mysql_version}/plugin + make install DESTDIR=$RBR/tmp-debug-plugin + mv $RBR/tmp-debug-plugin/usr/local/mysql/lib/mysql/plugin/* $MBD/plugin/debug/ + # From here, the install hook in "plugin/Makefile.am" will do the rest. +) +rmdir -p $RBR/tmp-debug-plugin/usr/local/mysql/lib/mysql/plugin # Install all binaries (cd $MBD && make install DESTDIR=$RBR testroot=%{_datadir}) @@ -841,7 +849,6 @@ fi %attr(755, root, root) %{_bindir}/myisampack %attr(755, root, root) %{_bindir}/mysql_convert_table_format %attr(755, root, root) %{_bindir}/mysql_fix_extensions -%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables %attr(755, root, root) %{_bindir}/mysql_install_db %attr(755, root, root) %{_bindir}/mysql_secure_installation %attr(755, root, root) %{_bindir}/mysql_setpermission @@ -859,10 +866,6 @@ fi %attr(755, root, root) %{_bindir}/resolve_stack_dump %attr(755, root, root) %{_bindir}/resolveip -%attr(755, root, root) %{_libdir}/mysql/plugin/ha_example.so* -%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so* -%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so* - %if %{WITH_TCMALLOC} %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target} %endif @@ -873,6 +876,9 @@ fi %attr(755, root, root) %{_libdir}/mysql/plugin/ha_example.so* %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so* %attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so* +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/ha_example.so* +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_master.so* +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_slave.so* %if %{WITH_TCMALLOC} %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target} @@ -1007,6 +1013,12 @@ fi %{_libdir}/mysql/plugin/semisync_master.la %{_libdir}/mysql/plugin/semisync_slave.a %{_libdir}/mysql/plugin/semisync_slave.la +%{_libdir}/mysql/plugin/debug/ha_example.a +%{_libdir}/mysql/plugin/debug/ha_example.la +%{_libdir}/mysql/plugin/debug/semisync_master.a +%{_libdir}/mysql/plugin/debug/semisync_master.la +%{_libdir}/mysql/plugin/debug/semisync_slave.a +%{_libdir}/mysql/plugin/debug/semisync_slave.la %files shared %defattr(-, root, root, 0755) @@ -1042,6 +1054,12 @@ fi # merging BK trees) ############################################################################## %changelog +* Wed Mar 10 2010 Joerg Bruehe <joerg.bruehe@sun.com> + +- Take the result of the debug plugin build and put it into the optimized tree, + so that it becomes part of the final installation; + include the files in the packlist. Part of the fixes for bug#49022. + * Mon Mar 01 2010 Joerg Bruehe <joerg.bruehe@sun.com> - Set "Oracle and/or its affiliates" as the vendor and copyright owner, @@ -1086,6 +1104,10 @@ fi - Fix some problems with the directives around "tcmalloc" (experimental), remove erroneous traces of the InnoDB plugin (that is 5.1 only). +* Fri Oct 06 2009 Magnus Blaudd <mvensson@mysql.com> + +- Removed mysql_fix_privilege_tables + * Fri Oct 02 2009 Alexander Nozdrin <alexander.nozdrin@sun.com> - "mysqlmanager" got removed from version 5.4, all references deleted. diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 8f4c44e2c82..8112a2a3c0d 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -19373,7 +19373,7 @@ static struct my_tests_st my_tests[]= { #endif { "test_bug41078", test_bug41078 }, { "test_bug44495", test_bug44495 }, - /* XXX { "test_bug49972", test_bug49972 }, */ + { "test_bug49972", test_bug49972 }, { 0, 0 } }; |