diff options
188 files changed, 2808 insertions, 833 deletions
diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index cb61f9cfd70..b5f1c7b200e 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -90,22 +90,19 @@ SSL_LIBRARY=--with-ssl if [ "x$warning_mode" != "xpedantic" ]; then # Both C and C++ warnings - warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W" - warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare" - warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable" + warnings="-Wall -Wextra -Wunused -Wwrite-strings" # For more warnings, uncomment the following line -# warnings="$global_warnings -Wshadow" +# warnings="$warnings -Wshadow" # C warnings - c_warnings="$warnings -Wunused-parameter" + c_warnings="$warnings" # C++ warnings - cxx_warnings="$warnings" + cxx_warnings="$warnings -Wno-unused-parameter" # cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo" - cxx_warnings="$cxx_warnings -Wreorder" cxx_warnings="$cxx_warnings -Wctor-dtor-privacy -Wnon-virtual-dtor" # Added unless --with-debug=full - debug_extra_cflags="-O0 -g3 -gdwarf-2" #1 -Wuninitialized" + debug_extra_cflags="-O0 -g3 -gdwarf-2" else warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE" c_warnings="$warnings" diff --git a/BUILD/check-cpu b/BUILD/check-cpu index eb001ee61ae..f9f5d423f4f 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -187,69 +187,76 @@ check_cpu () { cc=$CC fi - if test "x$compiler" = "x" ; then - cc_ver=`$cc --version | sed 1q` - cc_verno=`echo $cc_ver | sed -e 's/^.*(GCC)//g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'` + if test "x$core2" = "xyes" ; then + cpu_arg="core2" + fi + + if test "x$compiler" != "x" ; then + return 0 + fi + + # check if compiler is gcc and dump its version + cc_verno=`$cc -dumpversion 2>/dev/null` + if test "x$?" = "x0" ; then set -- `echo $cc_verno | tr '.' ' '` + cc_ver="GCC" cc_major=$1 cc_minor=$2 cc_patch=$3 cc_comp=`expr $cc_major '*' 100 '+' $cc_minor` - - case "$cc_ver--$cc_verno" in - *GCC*) - # different gcc backends (and versions) have different CPU flags - case `gcc -dumpmachine` in - i?86-* | x86_64-*) - if test "$cc_comp" -lt 304 ; then - check_cpu_cflags="-mcpu=${cpu_arg}" - elif test "$cc_comp" -ge 402 ; then - check_cpu_cflags="-mtune=native" - else - check_cpu_cflags="-mtune=${cpu_arg}" - fi - ;; - ppc-*) - check_cpu_cflags="-mcpu=${cpu_arg} -mtune=${cpu_arg}" - ;; - *) - check_cpu_cflags="" - return - ;; - esac - ;; - 2.95.*) - # GCC 2.95 doesn't expose its name in --version output - check_cpu_cflags="-m${cpu_arg}" - ;; - *) - check_cpu_cflags="" - return - ;; - esac - # now we check whether the compiler really understands the cpu type - touch __test.c - - while [ "$cpu_arg" ] ; do - printf "testing $cpu_arg ... " >&2 - - # compile check - eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null - if test "x$?" = "x0" ; then - echo ok >&2 - break; - fi + fi - echo failed >&2 + case "$cc_ver--$cc_verno" in + *GCC*) + # different gcc backends (and versions) have different CPU flags + case `gcc -dumpmachine` in + i?86-* | x86_64-*) + if test "$cc_comp" -lt 304 ; then + check_cpu_cflags="-mcpu=${cpu_arg}" + elif test "$cc_comp" -ge 402 ; then + check_cpu_cflags="-mtune=native" + else + check_cpu_cflags="-mtune=${cpu_arg}" + fi + ;; + ppc-*) + check_cpu_cflags="-mcpu=${cpu_arg} -mtune=${cpu_arg}" + ;; + *) + check_cpu_cflags="" + return + ;; + esac + ;; + 2.95.*) + # GCC 2.95 doesn't expose its name in --version output + check_cpu_cflags="-m${cpu_arg}" + ;; + *) check_cpu_cflags="" + return + ;; + esac + + # now we check whether the compiler really understands the cpu type + touch __test.c + + while [ "$cpu_arg" ] ; do + printf "testing $cpu_arg ... " >&2 + + # compile check + eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null + if test "x$?" = "x0" ; then + echo ok >&2 break; - done - rm __test.* - fi - if test "x$core2" = "xyes" ; then - cpu_arg="core2" - fi + fi + + echo failed >&2 + check_cpu_cflags="" + break; + done + rm __test.* return 0 } - + check_cpu diff --git a/CMakeLists.txt b/CMakeLists.txt index cb71cb6aefc..4ff2507dcc3 100755..100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,27 @@ IF(DEFINED ENV{CPPFLAGS}) ADD_DEFINITIONS($ENV{CPPFLAGS}) ENDIF() +# +# Control aspects of the development environment which are +# specific to MySQL maintainers and developers. +# +OPTION(MYSQL_MAINTAINER_MODE "MySQL maintainer-specific development environment" OFF) +# Whether the maintainer mode should be enabled. +IF(MYSQL_MAINTAINER_MODE) + IF(CMAKE_COMPILER_IS_GNUCC) + SET(MY_MAINTAINER_C_WARNINGS "-Wall -Wextra -Wunused -Wwrite-strings -Werror" + CACHE STRING "C warning options used in maintainer builds.") + ENDIF() + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_C_WARNINGS} -Wno-unused-parameter" + CACHE STRING "C++ warning options used in maintainer builds.") + ENDIF() + # Do not make warnings in checks into errors. + IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error") + ENDIF() +ENDIF() + # Add macros INCLUDE(character_sets) INCLUDE(zlib) @@ -226,6 +247,19 @@ MYSQL_CHECK_SSL() # Add readline or libedit. MYSQL_CHECK_READLINE() +# +# Setup maintainer mode options by the end. Platform checks are +# not run with the warning options as to not perturb fragile checks +# (i.e. do not make warnings into errors). +# +IF(MYSQL_MAINTAINER_MODE) + # Set compiler flags required under maintainer mode. + MESSAGE(STATUS "C warning options: ${MY_MAINTAINER_C_WARNINGS}") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}") + MESSAGE(STATUS "C++ warning options: ${MY_MAINTAINER_CXX_WARNINGS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}") +ENDIF() + IF(NOT WITHOUT_SERVER) SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "") # Add storage engines and plugins. diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index d0bb8d43edd..d0bb8d43edd 100755..100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt diff --git a/client/mysql.cc b/client/mysql.cc index a31c503b9a2..abf01d8127d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -88,7 +88,6 @@ extern "C" { #endif #endif -#undef bcmp // Fix problem with new readline #if defined(__WIN__) #include <conio.h> #else diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index f491485b77a..277c2d62544 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -436,7 +436,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname, ptr= fname + target_dir_name_len; memcpy(ptr,bname,blen); ptr+= blen; - ptr+= my_sprintf(ptr, (ptr, "-%x", file_id)); + ptr+= sprintf(ptr, "-%x", file_id); if ((file= create_unique_file(fname,ptr)) < 0) { diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 025f6c2bd2b..ce733e57db6 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -696,8 +696,7 @@ static int handle_request_for_tables(char *tables, uint length) if (opt_all_in_1) { /* No backticks here as we added them before */ - query_length= my_sprintf(query, - (query, "%s TABLE %s %s", op, tables, options)); + query_length= sprintf(query, "%s TABLE %s %s", op, tables, options); } else { diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 0b9f42acfe8..bb05400e0d8 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -657,8 +657,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table, char query[1024],*end; MYSQL_RES *result; MYSQL_ROW row; - ulong rows; - LINT_INIT(rows); + ulong UNINIT_VAR(rows); if (mysql_select_db(mysql,db)) { diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9e28183c735..c8ec6c981ef 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5827,7 +5827,7 @@ int read_command(struct st_command** command_ptr) (struct st_command*) my_malloc(sizeof(*command), MYF(MY_WME|MY_ZEROFILL))) || insert_dynamic(&q_lines, (uchar*) &command)) - die(NullS); + die("Out of memory"); command->type= Q_UNKNOWN; read_command_buf[0]= 0; @@ -6314,7 +6314,7 @@ void init_win_path_patterns() } if (insert_dynamic(&patterns, (uchar*) &p)) - die(NullS); + die("Out of memory"); DBUG_PRINT("info", ("p: %s", p)); while (*p) @@ -9406,8 +9406,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count, for (i=1 ; i <= found_sets ; i++) { pos=from[found_set[i-1].table_offset]; - rep_str[i].found= !bcmp((const uchar*) pos, - (const uchar*) "\\^", 3) ? 2 : 1; + rep_str[i].found= !memcmp(pos, "\\^", 3) ? 2 : 1; rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ @@ -9535,8 +9534,8 @@ void copy_bits(REP_SET *to,REP_SET *from) int cmp_bits(REP_SET *set1,REP_SET *set2) { - return bcmp((uchar*) set1->bits,(uchar*) set2->bits, - sizeof(uint) * set1->size_of_bits); + return memcmp(set1->bits, set2->bits, + sizeof(uint) * set1->size_of_bits); } @@ -9605,17 +9604,15 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset) uint start_at_word(char * pos) { - return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) || - !bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0); + return (((!memcmp(pos, "\\b",2) && pos[2]) || + !memcmp(pos, "\\^", 2)) ? 1 : 0); } uint end_of_word(char * pos) { char * end=strend(pos); - return ((end > pos+2 && !bcmp((const uchar*) end-2, - (const uchar*) "\\b", 2)) || - (end >= pos+2 && !bcmp((const uchar*) end-2, - (const uchar*) "\\$",2))) ? 1 : 0; + return ((end > pos+2 && !memcmp(end-2, "\\b", 2)) || + (end >= pos+2 && !memcmp(end-2, "\\$",2))) ? 1 : 0; } /**************************************************************************** diff --git a/cmake/configure.pl b/cmake/configure.pl index fba417365fc..5be47ce5a31 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -184,6 +184,12 @@ foreach my $option (@ARGV) $cmakeargs = $cmakeargs." -DWITH_DEBUG_FULL=1"; next; } + if ($option =~ /mysql-maintainer-mode/) + { + $cmakeargs = $cmakeargs." -DMYSQL_MAINTAINER_MODE=" . + ($option =~ /enable/ ? "1" : "0"); + next; + } $option = uc($option); $option =~ s/-/_/g; diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index ade6cdb747f..ade6cdb747f 100755..100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 68b6f2a6ddf..e07e3f54aa8 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -30,7 +30,6 @@ SET(HAVE_ASM_MSR_H CACHE INTERNAL "") SET(HAVE_BACKTRACE CACHE INTERNAL "") SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "") SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "") -SET(HAVE_BCMP CACHE INTERNAL "") SET(HAVE_BFILL CACHE INTERNAL "") SET(HAVE_BMOVE CACHE INTERNAL "") SET(HAVE_BSD_SIGNALS CACHE INTERNAL "") diff --git a/cmd-line-utils/readline/Makefile.am b/cmd-line-utils/readline/Makefile.am index 40e74ccaf55..48d3af34412 100644 --- a/cmd-line-utils/readline/Makefile.am +++ b/cmd-line-utils/readline/Makefile.am @@ -31,4 +31,4 @@ noinst_HEADERS = readline.h chardefs.h keymaps.h \ EXTRA_DIST= emacs_keymap.c vi_keymap.c CMakeLists.txt -DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR +DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR -D_GNU_SOURCE=1 diff --git a/config.h.cmake b/config.h.cmake index 7bef260cf4e..2d877ed853f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -125,7 +125,6 @@ #cmakedefine HAVE_AIOWAIT 1 #cmakedefine HAVE_ALARM 1 #cmakedefine HAVE_ALLOCA 1 -#cmakedefine HAVE_BCMP 1 #cmakedefine HAVE_BFILL 1 #cmakedefine HAVE_BMOVE 1 #cmakedefine HAVE_BZERO 1 diff --git a/config/ac-macros/maintainer.m4 b/config/ac-macros/maintainer.m4 new file mode 100644 index 00000000000..1b7df75d6f7 --- /dev/null +++ b/config/ac-macros/maintainer.m4 @@ -0,0 +1,64 @@ +# +# Control aspects of the development environment which are +# specific to MySQL maintainers and developers. +# +AC_DEFUN([MY_MAINTAINER_MODE], [ + AC_MSG_CHECKING([whether to enable the maintainer-specific development environment]) + AC_ARG_ENABLE([mysql-maintainer-mode], + [AS_HELP_STRING([--enable-mysql-maintainer-mode], + [Enable a MySQL maintainer-specific development environment])], + [USE_MYSQL_MAINTAINER_MODE=$enableval], + [USE_MYSQL_MAINTAINER_MODE=no]) + AC_MSG_RESULT([$USE_MYSQL_MAINTAINER_MODE]) +]) + +# Set warning options required under maintainer mode. +AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS], [ + # Setup GCC warning options. + AS_IF([test "$GCC" = "yes"], [ + C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Werror" + CXX_WARNINGS="${C_WARNINGS} -Wno-unused-parameter" + ]) + + # Test whether the warning options work. + # Test C options + AS_IF([test -n "$C_WARNINGS"], [ + save_CFLAGS="$CFLAGS" + AC_MSG_CHECKING([whether to use C warning options ${C_WARNINGS}]) + AC_LANG_PUSH(C) + CFLAGS="$CFLAGS ${C_WARNINGS}" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [myac_c_warning_flags=yes], + [myac_c_warning_flags=no]) + AC_LANG_POP() + AC_MSG_RESULT([$myac_c_warning_flags]) + CFLAGS="$save_CFLAGS" + ]) + + # Test C++ options + AS_IF([test -n "$CXX_WARNINGS"], [ + save_CXXFLAGS="$CXXFLAGS" + AC_MSG_CHECKING([whether to use C++ warning options ${CXX_WARNINGS}]) + AC_LANG_PUSH(C++) + CXXFLAGS="$CXXFLAGS ${CXX_WARNINGS}" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [myac_cxx_warning_flags=yes], + [myac_cxx_warning_flags=no]) + AC_LANG_POP() + AC_MSG_RESULT([$myac_cxx_warning_flags]) + CXXFLAGS="$save_CXXFLAGS" + ]) + + # Set compile flag variables. + AS_IF([test "$myac_c_warning_flags" = "yes"], [ + AM_CFLAGS="${AM_CFLAGS} ${C_WARNINGS}" + AC_SUBST([AM_CFLAGS])]) + AS_IF([test "$myac_cxx_warning_flags" = "yes"], [ + AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS}" + AC_SUBST([AM_CXXFLAGS])]) +]) + + +# Set compiler flags required under maintainer mode. +AC_DEFUN([MY_MAINTAINER_MODE_SETUP], [ + AS_IF([test "$USE_MYSQL_MAINTAINER_MODE" = "yes"], + [MY_MAINTAINER_MODE_WARNINGS]) +]) diff --git a/configure.cmake b/configure.cmake index 462e359ee7d..ab3d706ee01 100644 --- a/configure.cmake +++ b/configure.cmake @@ -273,7 +273,6 @@ CHECK_FUNCTION_EXISTS (backtrace HAVE_BACKTRACE) CHECK_FUNCTION_EXISTS (backtrace_symbols HAVE_BACKTRACE_SYMBOLS) CHECK_FUNCTION_EXISTS (backtrace_symbols_fd HAVE_BACKTRACE_SYMBOLS_FD) CHECK_FUNCTION_EXISTS (printstack HAVE_PRINTSTACK) -CHECK_FUNCTION_EXISTS (bcmp HAVE_BCMP) CHECK_FUNCTION_EXISTS (bfill HAVE_BFILL) CHECK_FUNCTION_EXISTS (bmove HAVE_BMOVE) CHECK_FUNCTION_EXISTS (bsearch HAVE_BSEARCH) diff --git a/configure.in b/configure.in index 88ce1a1379f..a2f0c432681 100644 --- a/configure.in +++ b/configure.in @@ -80,6 +80,7 @@ MYSQL_TCP_PORT_DEFAULT=3306 MYSQL_UNIX_ADDR_DEFAULT="/tmp/mysql.sock" dnl Include m4 +sinclude(config/ac-macros/maintainer.m4) sinclude(config/ac-macros/alloca.m4) sinclude(config/ac-macros/check_cpu.m4) sinclude(config/ac-macros/character_sets.m4) @@ -118,6 +119,8 @@ AC_SUBST(SHARED_LIB_MAJOR_VERSION) AC_SUBST(SHARED_LIB_VERSION) AC_SUBST(AVAILABLE_LANGUAGES) +# Whether the maintainer mode should be enabled. +MY_MAINTAINER_MODE # Canonicalize the configuration name. @@ -284,40 +287,6 @@ AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL']) AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf) AC_CHECK_PROG(DVIS, tex, manual.dvi) -#check the return type of sprintf -AC_MSG_CHECKING("return type of sprintf") -AC_TRY_RUN([ - int main() - { - char* s = "hello"; - char buf[6]; - if((int)sprintf(buf, s) == strlen(s)) - return 0; - - return -1; - } - ], - [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf]) - AC_MSG_RESULT("int")], - [AC_TRY_RUN([ - int main() - { - char* s = "hello"; - char buf[6]; - if((char*)sprintf(buf,s) == buf + strlen(s)) - return 0; - return -1; - } ], - [AC_DEFINE(SPRINTF_RETURNS_PTR, [1], [Broken sprintf]) - AC_MSG_RESULT("ptr")], - [AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf]) - AC_MSG_RESULT("garbage")] - )], - # Cross compile, assume POSIX - [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf]) - AC_MSG_RESULT("int (we assume)")] -) - AC_PATH_PROG(uname_prog, uname, no) # We should go through this and put all the explictly system dependent @@ -494,7 +463,16 @@ if test "$GCC" != "yes" || expr "$CC" : ".*icc.*" then ABI_CHECK="" else - ABI_CHECK="abi_check" + # Workaround GCC >= 4.5 - See Bug#52514 + case `$CC -dumpversion` in + [[4-9]].[[5-9]]*) + AC_MSG_WARN([ABI check disabled (GCC >= 4.5)]) + ABI_CHECK="" + ;; + *) + ABI_CHECK="abi_check" + ;; + esac fi AC_SUBST(ABI_CHECK) @@ -2212,7 +2190,7 @@ MYSQL_TYPE_QSORT AC_FUNC_UTIME_NULL AC_FUNC_VPRINTF -AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \ +AC_CHECK_FUNCS(alarm bfill bmove bsearch bzero \ chsize cuserid fchmod fcntl \ fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \ getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \ @@ -2995,6 +2973,12 @@ do done AC_SUBST(sql_union_dirs) +# +# Setup maintainer mode options by the end to not disturb +# system and other checks. +# +MY_MAINTAINER_MODE_SETUP + # Some usefull subst AC_SUBST(CC) AC_SUBST(GXX) diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt index 4cf6dd88cb7..4cf6dd88cb7 100755..100644 --- a/dbug/CMakeLists.txt +++ b/dbug/CMakeLists.txt diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index 27fc31cbdde..27fc31cbdde 100755..100644 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt diff --git a/extra/comp_err.c b/extra/comp_err.c index c85aef7bcc5..3c56770650f 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -665,9 +665,9 @@ static struct message *find_message(struct errors *err, const char *lang, static ha_checksum checksum_format_specifier(const char* msg) { ha_checksum chksum= 0; - const char* p= msg; - const char* start= 0; - int num_format_specifiers= 0; + const uchar* p= (const uchar*) msg; + const uchar* start= NULL; + uint32 num_format_specifiers= 0; while (*p) { diff --git a/extra/replace.c b/extra/replace.c index 1a887ac3e21..bbe70ba586e 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -648,7 +648,7 @@ static REPLACE *init_replace(char * *from, char * *to,uint count, for (i=1 ; i <= found_sets ; i++) { pos=from[found_set[i-1].table_offset]; - rep_str[i].found= (my_bool) (!bcmp(pos,"\\^",3) ? 2 : 1); + rep_str[i].found= (my_bool) (!memcmp(pos,"\\^",3) ? 2 : 1); rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ @@ -776,8 +776,8 @@ static void copy_bits(REP_SET *to,REP_SET *from) static int cmp_bits(REP_SET *set1,REP_SET *set2) { - return bcmp((uchar*) set1->bits,(uchar*) set2->bits, - sizeof(uint) * set1->size_of_bits); + return memcmp(set1->bits, set2->bits, + sizeof(uint) * set1->size_of_bits); } @@ -849,14 +849,14 @@ static short find_found(FOUND_SET *found_set,uint table_offset, static uint start_at_word(char * pos) { - return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0); + return (((!memcmp(pos,"\\b",2) && pos[2]) || !memcmp(pos,"\\^",2)) ? 1 : 0); } static uint end_of_word(char * pos) { char * end=strend(pos); - return ((end > pos+2 && !bcmp(end-2,"\\b",2)) || - (end >= pos+2 && !bcmp(end-2,"\\$",2))) ? + return ((end > pos+2 && !memcmp(end-2,"\\b",2)) || + (end >= pos+2 && !memcmp(end-2,"\\$",2))) ? 1 : 0; } diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt index 82d7e5b7581..82d7e5b7581 100755..100644 --- a/extra/yassl/CMakeLists.txt +++ b/extra/yassl/CMakeLists.txt diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index 28d7f1b5693..b968ec1e6c3 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -953,8 +953,9 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info) info->set = true; } } - fgets(line,sizeof(line), file); // get blank line - begin = ftell(file); + // get blank line + if (fgets(line, sizeof(line), file)) + begin = ftell(file); } } diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt index 2c43756b6f4..2c43756b6f4 100755..100644 --- a/extra/yassl/taocrypt/CMakeLists.txt +++ b/extra/yassl/taocrypt/CMakeLists.txt diff --git a/extra/yassl/taocrypt/include/blowfish.hpp b/extra/yassl/taocrypt/include/blowfish.hpp index 90d2c014b4c..94bbab7aea8 100644 --- a/extra/yassl/taocrypt/include/blowfish.hpp +++ b/extra/yassl/taocrypt/include/blowfish.hpp @@ -51,7 +51,7 @@ public: enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 }; Blowfish(CipherDir DIR, Mode MODE) - : Mode_BASE(BLOCK_SIZE, DIR, MODE) {} + : Mode_BASE(BLOCK_SIZE, DIR, MODE), sbox_(pbox_ + ROUNDS + 2) {} #ifdef DO_BLOWFISH_ASM void Process(byte*, const byte*, word32); @@ -62,8 +62,8 @@ private: static const word32 p_init_[ROUNDS + 2]; static const word32 s_init_[4 * 256]; - word32 pbox_[ROUNDS + 2]; - word32 sbox_[4 * 256]; + word32 pbox_[ROUNDS + 2 + 4 * 256]; + word32* sbox_; void crypt_block(const word32 in[2], word32 out[2]) const; void AsmProcess(const byte* in, byte* out) const; diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index b59f61a1cde..9d12b253dd6 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -35,10 +35,7 @@ // Handler for pure virtual functions namespace __Crun { - static void pure_error(void) - { - assert("Pure virtual method called." == "Aborted"); - } + void pure_error(void); } // namespace __Crun #endif // __sun @@ -54,16 +51,7 @@ extern "C" { #else #include "kernelc.hpp" #endif - -/* Disallow inline __cxa_pure_virtual() */ -static int __cxa_pure_virtual() __attribute__((noinline, used)); -static int __cxa_pure_virtual() -{ - // oops, pure virtual called! - assert(!"Pure virtual method called. Aborted"); - return 0; -} - + int __cxa_pure_virtual () __attribute__ ((weak)); } // extern "C" #endif // __GNUC__ > 2 diff --git a/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp index b2b42d3dcf0..63eff1d91fc 100644 --- a/extra/yassl/taocrypt/src/aes.cpp +++ b/extra/yassl/taocrypt/src/aes.cpp @@ -51,7 +51,7 @@ void AES::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } - else if (mode_ == CBC) + else if (mode_ == CBC) { if (dir_ == ENCRYPTION) while (blocks--) { r_[0] ^= *(word32*)in; @@ -78,6 +78,7 @@ void AES::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } + } } #endif // DO_AES_ASM diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index c221ce3d6cb..47a660d5c96 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -186,10 +186,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x, struct WindowSlider { - WindowSlider(const Integer &exp, bool fastNegate, + WindowSlider(const Integer &expIn, bool fastNegateIn, unsigned int windowSizeIn=0) - : exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn), - windowBegin(0), fastNegate(fastNegate), firstTime(true), + : exp(expIn), windowModulus(Integer::One()), windowSize(windowSizeIn), + windowBegin(0), fastNegate(fastNegateIn), firstTime(true), finished(false) { if (windowSize == 0) diff --git a/extra/yassl/taocrypt/src/blowfish.cpp b/extra/yassl/taocrypt/src/blowfish.cpp index 66ff4d829d7..2097b045278 100644 --- a/extra/yassl/taocrypt/src/blowfish.cpp +++ b/extra/yassl/taocrypt/src/blowfish.cpp @@ -53,7 +53,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } - else if (mode_ == CBC) + else if (mode_ == CBC) { if (dir_ == ENCRYPTION) while (blocks--) { r_[0] ^= *(word32*)in; @@ -78,6 +78,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } + } } #endif // DO_BLOWFISH_ASM diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 85733b88aa9..b054e98bef4 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -283,21 +283,23 @@ DWord() {} word GetHighHalfAsBorrow() const {return 0-halfs_.high;} private: + struct dword_struct + { + #ifdef LITTLE_ENDIAN_ORDER + word low; + word high; + #else + word high; + word low; + #endif + }; + union { #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE dword whole_; #endif - struct - { - #ifdef LITTLE_ENDIAN_ORDER - word low; - word high; - #else - word high; - word low; - #endif - } halfs_; + struct dword_struct halfs_; }; }; @@ -1214,20 +1216,24 @@ public: #define AS1(x) #x ";" #define AS2(x, y) #x ", " #y ";" #define AddPrologue \ + word res; \ __asm__ __volatile__ \ ( \ "push %%ebx;" /* save this manually, in case of -fPIC */ \ - "mov %2, %%ebx;" \ + "mov %3, %%ebx;" \ ".intel_syntax noprefix;" \ "push ebp;" #define AddEpilogue \ "pop ebp;" \ ".att_syntax prefix;" \ "pop %%ebx;" \ - : \ + "mov %%eax, %0;" \ + : "=g" (res) \ : "c" (C), "d" (A), "m" (B), "S" (N) \ : "%edi", "memory", "cc" \ - ); + ); \ + return res; + #define MulPrologue \ __asm__ __volatile__ \ ( \ diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index 402645c93fd..11dd4dc6d66 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -84,12 +84,23 @@ namespace STL = STL_NAMESPACE; } -#if defined(__ICC) || defined(__INTEL_COMPILER) +#ifdef __sun + +// Handler for pure virtual functions +namespace __Crun { + void pure_error() { + assert(!"Aborted: pure virtual method called."); + } +} + +#endif + +#if defined(__ICC) || defined(__INTEL_COMPILER) || (__GNUC__ > 2) extern "C" { int __cxa_pure_virtual() { - assert("Pure virtual method called." == "Aborted"); + assert(!"Aborted: pure virtual method called."); return 0; } @@ -166,14 +177,6 @@ word Crop(word value, unsigned int size) #ifdef TAOCRYPT_X86ASM_AVAILABLE -#ifndef _MSC_VER - static jmp_buf s_env; - static void SigIllHandler(int) - { - longjmp(s_env, 1); - } -#endif - bool HaveCpuId() { diff --git a/extra/yassl/taocrypt/src/twofish.cpp b/extra/yassl/taocrypt/src/twofish.cpp index 84dd35f9191..71601c08162 100644 --- a/extra/yassl/taocrypt/src/twofish.cpp +++ b/extra/yassl/taocrypt/src/twofish.cpp @@ -54,7 +54,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } - else if (mode_ == CBC) + else if (mode_ == CBC) { if (dir_ == ENCRYPTION) while (blocks--) { r_[0] ^= *(word32*)in; @@ -82,6 +82,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } + } } #endif // DO_TWOFISH_ASM diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp index 31fad36aaba..283c929a2e1 100644 --- a/extra/yassl/testsuite/test.hpp +++ b/extra/yassl/testsuite/test.hpp @@ -155,6 +155,11 @@ inline void err_sys(const char* msg) } +extern "C" { + static int PasswordCallBack(char*, int, int, void*); +} + + static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata) { strncpy(passwd, "12345678", sz); diff --git a/include/Makefile.am b/include/Makefile.am index 3357772e7c9..e4f34c3c0b5 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -45,7 +45,7 @@ noinst_HEADERS = config-win.h lf.h my_bit.h \ my_vle.h my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \ atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \ - atomic/solaris.h mysql/innodb_priv.h + atomic/solaris.h mysql/innodb_priv.h my_compiler.h EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base \ CMakeLists.txt \ diff --git a/include/m_string.h b/include/m_string.h index 71d52ec4549..c2779c63941 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -36,10 +36,6 @@ /* need by my_vsnprintf */ #include <stdarg.h> -#ifdef _AIX -#undef HAVE_BCMP -#endif - /* This is needed for the definitions of bzero... on solaris */ #if defined(HAVE_STRINGS_H) #include <strings.h> @@ -63,14 +59,10 @@ /* Unixware 7 */ #if !defined(HAVE_BFILL) # define bfill(A,B,C) memset((A),(C),(B)) -# define bmove_align(A,B,C) memcpy((A),(B),(C)) #endif -#if !defined(HAVE_BCMP) -# define bcopy(s, d, n) memcpy((d), (s), (n)) -# define bcmp(A,B,C) memcmp((A),(B),(C)) -# define bzero(A,B) memset((A),0,(B)) -# define bmove_align(A,B,C) memcpy((A),(B),(C)) +#if !defined(bzero) && !defined(HAVE_BZERO) +# define bzero(A,B) memset((A),0,(B)) #endif #if defined(__cplusplus) @@ -116,19 +108,6 @@ extern char _dig_vec_lower[]; extern void bfill(uchar *dst,size_t len,pchar fill); #endif -#if !defined(bzero) && !defined(HAVE_BZERO) -extern void bzero(uchar * dst,size_t len); -#endif - -#if !defined(bcmp) && !defined(HAVE_BCMP) -extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len); -#endif -#ifdef HAVE_purify -extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len); -#undef bcmp -#define bcmp(A,B,C) my_bcmp((A),(B),(C)) -#endif /* HAVE_purify */ - #ifndef bmove512 extern void bmove512(uchar *dst,const uchar *src,size_t len); #endif diff --git a/include/my_alarm.h b/include/my_alarm.h index dd2d5642f5f..fa396cf02f9 100644 --- a/include/my_alarm.h +++ b/include/my_alarm.h @@ -36,14 +36,14 @@ extern ulong my_time_to_wait_for_lock; #define ALARM_END (void) signal(SIGALRM,alarm_signal); \ (void) alarm(alarm_old); #define ALARM_TEST my_have_got_alarm -#ifdef DONT_REMEMBER_SIGNAL +#ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY #define ALARM_REINIT (void) alarm(MY_HOW_OFTEN_TO_ALARM); \ (void) signal(SIGALRM,my_set_alarm_variable);\ my_have_got_alarm=0; #else #define ALARM_REINIT (void) alarm((uint) MY_HOW_OFTEN_TO_ALARM); \ my_have_got_alarm=0; -#endif /* DONT_REMEMBER_SIGNAL */ +#endif /* SIGNAL_HANDLER_RESET_ON_DELIVERY */ #else #define ALARM_VARIABLES long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1 #define ALARM_INIT diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 314dac983b0..0caf2da12d0 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -159,22 +159,6 @@ static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2) #define bitmap_set_all(MAP) \ (memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP)))) -/** - check, set and clear a bit of interest of an integer. - - If the bit is out of range @retval -1. Otherwise - bit_is_set @return 0 or 1 reflecting the bit is set or not; - bit_do_set @return 1 (bit is set 1) - bit_do_clear @return 0 (bit is cleared to 0) -*/ - -#define bit_is_set(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - (((I) & (ULL(1) << (B))) == 0 ? 0 : 1) : -1) -#define bit_do_set(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - ((I) |= (ULL(1) << (B)), 1) : -1) -#define bit_do_clear(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - ((I) &= ~(ULL(1) << (B)), 0) : -1) - #ifdef __cplusplus } #endif diff --git a/include/my_compiler.h b/include/my_compiler.h new file mode 100644 index 00000000000..1cd46ff4260 --- /dev/null +++ b/include/my_compiler.h @@ -0,0 +1,129 @@ +#ifndef MY_COMPILER_INCLUDED +#define MY_COMPILER_INCLUDED + +/* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + Header for compiler-dependent features. + + Intended to contain a set of reusable wrappers for preprocessor + macros, attributes, pragmas, and any other features that are + specific to a target compiler. +*/ + +#include <my_global.h> /* stddef.h offsetof */ + +/** + Compiler-dependent internal convenience macros. +*/ + +/* GNU C/C++ */ +#if defined __GNUC__ +/* Any after 2.95... */ +# define MY_ALIGN_EXT + +/* Microsoft Visual C++ */ +#elif defined _MSC_VER +# define MY_ALIGNOF(type) __alignof(type) +# define MY_ALIGNED(n) __declspec(align(n)) + +/* Oracle Solaris Studio */ +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# if __SUNPRO_C >= 0x590 +# define MY_ALIGN_EXT +# endif + +/* IBM XL C/C++ */ +#elif defined __xlC__ +# if __xlC__ >= 0x0600 +# define MY_ALIGN_EXT +# endif + +/* HP aCC */ +#elif defined(__HP_aCC) || defined(__HP_cc) +# if (__HP_aCC >= 60000) || (__HP_cc >= 60000) +# define MY_ALIGN_EXT +# endif +#endif + +#ifdef MY_ALIGN_EXT +/** Specifies the minimum alignment of a type. */ +# define MY_ALIGNOF(type) __alignof__(type) +/** Determine the alignment requirement of a type. */ +# define MY_ALIGNED(n) __attribute__((__aligned__((n)))) +#endif + +/** + Generic compiler-dependent features. +*/ +#ifndef MY_ALIGNOF +# ifdef __cplusplus + template<typename type> struct my_alignof_helper { char m1; type m2; }; + /* Invalid for non-POD types, but most compilers give the right answer. */ +# define MY_ALIGNOF(type) offsetof(my_alignof_helper<type>, m2) +# else +# define MY_ALIGNOF(type) offsetof(struct { char m1; type m2; }, m2) +# endif +#endif + +/** + C++ Type Traits +*/ + +#ifdef __cplusplus + +/** + Opaque storage with a particular alignment. +*/ +# if defined(MY_ALIGNED) +/* Partial specialization used due to MSVC++. */ +template<size_t alignment> struct my_alignment_imp; +template<> struct MY_ALIGNED(1) my_alignment_imp<1> {}; +template<> struct MY_ALIGNED(2) my_alignment_imp<2> {}; +template<> struct MY_ALIGNED(4) my_alignment_imp<4> {}; +template<> struct MY_ALIGNED(8) my_alignment_imp<8> {}; +template<> struct MY_ALIGNED(16) my_alignment_imp<16> {}; +/* ... expand as necessary. */ +# else +template<size_t alignment> +struct my_alignment_imp { double m1; }; +# endif + +/** + A POD type with a given size and alignment. + + @remark If the compiler does not support a alignment attribute + (MY_ALIGN macro), the default alignment of a double is + used instead. + + @tparam size The minimum size. + @tparam alignment The desired alignment: 1, 2, 4, 8 or 16. +*/ +template <size_t size, size_t alignment> +struct my_aligned_storage +{ + union + { + char data[size]; + my_alignment_imp<alignment> align; + }; +}; + +#endif /* __cplusplus */ + +#include <my_attribute.h> + +#endif /* MY_COMPILER_INCLUDED */ diff --git a/include/my_global.h b/include/my_global.h index 678a63d7af2..b0db017c565 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -577,26 +577,34 @@ extern "C" int madvise(void *addr, size_t len, int behav); #endif /* Does the system remember a signal handler after a signal ? */ -#ifndef HAVE_BSD_SIGNALS -#define DONT_REMEMBER_SIGNAL +#if !defined(HAVE_BSD_SIGNALS) && !defined(HAVE_SIGACTION) +#define SIGNAL_HANDLER_RESET_ON_DELIVERY #endif -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) -#define LINT_INIT(var) var=0 /* No uninitialize-warning */ +/* + Deprecated workaround for false-positive uninitialized variables + warnings. Those should be silenced using tool-specific heuristics. + + Enabled by default for g++ due to the bug referenced below. +*/ +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \ + (defined(__GNUC__) && defined(__cplusplus)) +#define LINT_INIT(var) var= 0 #else #define LINT_INIT(var) #endif -/* +/* Suppress uninitialized variable warning without generating code. The _cplusplus is a temporary workaround for C++ code pending a fix - for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). + for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). */ -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(__cplusplus) || \ - !defined(__GNUC__) +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \ + defined(__cplusplus) || !defined(__GNUC__) #define UNINIT_VAR(x) x= 0 #else +/* GCC specific self-initialization which inhibits the warning. */ #define UNINIT_VAR(x) x= x #endif @@ -620,7 +628,6 @@ typedef unsigned short ushort; #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) #define test_all_bits(a,b) (((a) & (b)) == (b)) -#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1)) #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) /* Define some general constants */ @@ -641,7 +648,7 @@ typedef unsigned short ushort; #define my_const_cast(A) (A) #endif -#include <my_attribute.h> +#include <my_compiler.h> /* Wen using the embedded library, users might run into link problems, @@ -1012,20 +1019,6 @@ typedef long long my_ptrdiff_t; #define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B)) -#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B)) -#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))] - -#ifdef __cplusplus -template <size_t sz> struct Aligned_char_array -{ - union { - void *v; // Ensures alignment. - char arr[sz]; // The actual buffer. - } u; - void* arr() { return &u.arr[0]; } -}; -#endif /* __cplusplus */ - /* Custom version of standard offsetof() macro which can be used to get offsets of members in class for non-POD types (according to the current @@ -1553,17 +1546,6 @@ do { doubleget_union _tmp; \ #endif /* WORDS_BIGENDIAN */ -/* sprintf does not always return the number of bytes :- */ -#ifdef SPRINTF_RETURNS_INT -#define my_sprintf(buff,args) sprintf args -#else -#ifdef SPRINTF_RETURNS_PTR -#define my_sprintf(buff,args) ((int)(sprintf args - buff)) -#else -#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff)) -#endif -#endif - #ifndef THREAD #define thread_safe_increment(V,L) (V)++ #define thread_safe_decrement(V,L) (V)-- diff --git a/include/myisam.h b/include/myisam.h index d590a29c1b3..7547f6b475e 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -55,8 +55,6 @@ extern "C" { #define MI_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */ #define MI_NAME_IEXT ".MYI" #define MI_NAME_DEXT ".MYD" -/* Max extra space to use when sorting keys */ -#define MI_MAX_TEMP_LENGTH 2*1024L*1024L*1024L /* Possible values for myisam_block_size (must be power of 2) */ #define MI_KEY_BLOCK_LENGTH 1024 /* default key block length */ diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 2ae09c1707a..2ae09c1707a 100755..100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index e972a6bdec8..53264f2e559 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -38,7 +38,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \ strmake.lo strend.lo \ strnlen.lo strfill.lo is_prefix.lo \ int2str.lo str2int.lo strinstr.lo strcont.lo \ - strcend.lo bcmp.lo ctype-latin1.lo \ + strcend.lo ctype-latin1.lo \ bchange.lo bmove.lo bmove_upp.lo longlong2str.lo \ strtoull.lo strtoll.lo llstr.lo my_vsnprintf.lo \ ctype.lo ctype-simple.lo ctype-bin.lo ctype-mb.lo \ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e4f01dad88b..02ed93fa501 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -316,7 +316,7 @@ sig_handler my_pipe_sig_handler(int sig __attribute__((unused))) { DBUG_PRINT("info",("Hit by signal %d",sig)); -#ifdef DONT_REMEMBER_SIGNAL +#ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY (void) signal(SIGPIPE, my_pipe_sig_handler); #endif } @@ -2117,7 +2117,12 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) stmt->insert_id= mysql->insert_id; if (res) { - set_stmt_errmsg(stmt, net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } DBUG_RETURN(0); @@ -2328,7 +2333,12 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row) buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - set_stmt_errmsg(stmt, net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, net); return 1; } if ((*mysql->methods->read_rows_from_cursor)(stmt)) @@ -3015,7 +3025,12 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, buff, sizeof(buff), (uchar*) data, length, 1, stmt)) { - set_stmt_errmsg(stmt, &mysql->net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, &mysql->net); DBUG_RETURN(1); } } @@ -4017,6 +4032,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) case MYSQL_TYPE_TIME: field->max_length= 15; /* 19:23:48.123456 */ param->skip_result= skip_result_with_length; + break; case MYSQL_TYPE_DATE: field->max_length= 10; /* 2003-11-11 */ param->skip_result= skip_result_with_length; @@ -4430,7 +4446,12 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - set_stmt_errmsg(stmt, net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } } diff --git a/mysql-test/include/diff_tables.inc b/mysql-test/include/diff_tables.inc index ad42615511a..d6216f3fe1e 100644 --- a/mysql-test/include/diff_tables.inc +++ b/mysql-test/include/diff_tables.inc @@ -65,17 +65,13 @@ let $_diff_table=$diff_table_2; let $_diff_i=2; while ($_diff_i) { - # Parse out any leading "master:" or "slave:" from the table - # specification and connect the appropriate server. - let $_diff_conn_master=`SELECT SUBSTR('$_diff_table', 1, 7) = 'master:'`; - if ($_diff_conn_master) { - let $_diff_table=`SELECT SUBSTR('$_diff_table', 8)`; - connection master; - } - let $_diff_conn_slave=`SELECT SUBSTR('$_diff_table', 1, 6) = 'slave:'`; - if ($_diff_conn_slave) { - let $_diff_table=`SELECT SUBSTR('$_diff_table', 7)`; - connection slave; + # Parse out any leading "master:" or "slave:" from the table specification +# and connect the appropriate server. + let $_pos= `SELECT LOCATE(':', '$_diff_table')`; + let $_diff_conn=`SELECT SUBSTR('$_diff_table', 1, $_pos-1)`; + if (`SELECT 'XX$_diff_conn' <> 'XX'`) { + let $_diff_table=`SELECT SUBSTR('$_diff_table', $_pos+1)`; + connection $_diff_conn; } # Sanity-check the input. diff --git a/mysql-test/include/parser_bug21114.inc b/mysql-test/include/parser_bug21114.inc index eb709d5cc03..eb709d5cc03 100755..100644 --- a/mysql-test/include/parser_bug21114.inc +++ b/mysql-test/include/parser_bug21114.inc diff --git a/mysql-test/include/rpl_diff_tables.inc b/mysql-test/include/rpl_diff_tables.inc new file mode 100644 index 00000000000..c3a45578a79 --- /dev/null +++ b/mysql-test/include/rpl_diff_tables.inc @@ -0,0 +1,35 @@ +# ############################################################################# +# Check whether the given table is consistent between different master and +# slaves +# +# Usage: +# --let $diff_table= test.t1 +# --let $diff_server_list= master, slave, slave2 +# --source include/rpl_diff_tables.inc +# ############################################################################# + +if (`SELECT "XX$diff_table" = "XX"`) +{ + --die diff_table is null. +} + +--let $_servers= master, slave +if (`SELECT "XX$diff_server_list" <> "XX"`) +{ + --let $_servers= $diff_server_list +} + +--let $_master= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)` +--let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_master') + 2))` +connection $_master; +while (`SELECT "XX$_servers" <> "XX"`) +{ + --let $_slave= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)` + --let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_slave') + 2))` + + --sync_slave_with_master $_slave + --let $diff_table_1= $_master:$diff_table + --let $diff_table_2= $_slave:$diff_table + --source include/diff_tables.inc + connection $_slave; +} diff --git a/mysql-test/include/show_msg.inc b/mysql-test/include/show_msg.inc index 659dce14686..659dce14686 100755..100644 --- a/mysql-test/include/show_msg.inc +++ b/mysql-test/include/show_msg.inc diff --git a/mysql-test/include/show_msg80.inc b/mysql-test/include/show_msg80.inc index 42fb35edbcc..42fb35edbcc 100755..100644 --- a/mysql-test/include/show_msg80.inc +++ b/mysql-test/include/show_msg80.inc diff --git a/mysql-test/lib/My/Handles.pm b/mysql-test/lib/My/Handles.pm index 66ee22b403f..66ee22b403f 100755..100644 --- a/mysql-test/lib/My/Handles.pm +++ b/mysql-test/lib/My/Handles.pm diff --git a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc index f72b851d0b6..f72b851d0b6 100755..100644 --- a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 50c433b9b39..1c778362975 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -159,7 +159,7 @@ int main(int argc, char* const argv[] ) signal(SIGCHLD, handle_signal); signal(SIGABRT, handle_abort); - sprintf(safe_process_name, "safe_process[%d]", own_pid); + sprintf(safe_process_name, "safe_process[%ld]", (long) own_pid); message("Started"); diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc index 8fffede0b62..8fffede0b62 100755..100644 --- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc diff --git a/mysql-test/r/bug46080.result b/mysql-test/r/bug46080.result index 44f6bba8db6..44f6bba8db6 100755..100644 --- a/mysql-test/r/bug46080.result +++ b/mysql-test/r/bug46080.result diff --git a/mysql-test/r/ctype_eucjpms.result b/mysql-test/r/ctype_eucjpms.result index bd25b1beed4..bd25b1beed4 100755..100644 --- a/mysql-test/r/ctype_eucjpms.result +++ b/mysql-test/r/ctype_eucjpms.result diff --git a/mysql-test/r/error_simulation.result b/mysql-test/r/error_simulation.result index fc58687cc86..b6b79cb596b 100644 --- a/mysql-test/r/error_simulation.result +++ b/mysql-test/r/error_simulation.result @@ -48,5 +48,40 @@ Got one of the listed errors SET SESSION debug=DEFAULT; DROP TABLE t1; # +# Bug#41660: Sort-index_merge for non-first join table may require +# O(#scans) memory +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); +CREATE TABLE t2 (a INT, b INT, filler CHAR(100), KEY(a), KEY(b)); +INSERT INTO t2 SELECT 1000, 1000, 'filler' FROM t1 A, t1 B, t1 C; +INSERT INTO t2 VALUES (1, 1, 'data'); +# the example query uses LEFT JOIN only for the sake of being able to +# demonstrate the issue with a very small dataset. (left outer join +# disables the use of join buffering, so we get the second table +# re-scanned for every record in the outer table. if we used inner join, +# we would need to have thousands of records and/or more columns in both +# tables so that the join buffer is filled and re-scans are triggered). +SET SESSION debug = '+d,only_one_Unique_may_be_created'; +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON ( t2.a < 10 OR t2.b < 10 ); +id select_type table type possible_keys key key_len ref rows Extra +x x x x x x x x x +x x x x x x x x x Using sort_union(a,b); Using where +SELECT * FROM t1 LEFT JOIN t2 ON ( t2.a < 10 OR t2.b < 10 ); +a a b filler +0 1 1 data +1 1 1 data +2 1 1 data +3 1 1 data +4 1 1 data +5 1 1 data +6 1 1 data +7 1 1 data +8 1 1 data +9 1 1 data +SET SESSION debug = DEFAULT; +DROP TABLE t1, t2; +# # End of 5.1 tests # diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index ffdacc43735..fdeec2755ca 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -750,4 +750,24 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables DROP TABLE t1; # +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# End of 5.1 tests diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result index 8d0f34f3bda..552ff564a89 100644 --- a/mysql-test/r/func_like.result +++ b/mysql-test/r/func_like.result @@ -169,3 +169,17 @@ select 'andre%' like 'andreÊ%' escape 'Ê'; select _cp1251'andre%' like convert('andreÊ%' using cp1251) escape 'Ê'; _cp1251'andre%' like convert('andreÊ%' using cp1251) escape 'Ê' 1 +End of 4.1 tests +# +# Bug #54575: crash when joining tables with unique set column +# +CREATE TABLE t1(a SET('a') NOT NULL, UNIQUE KEY(a)); +CREATE TABLE t2(b INT PRIMARY KEY); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +INSERT INTO t2 VALUES (1), (2), (3); +SELECT 1 FROM t2 JOIN t1 ON 1 LIKE a GROUP BY a; +1 +DROP TABLE t1, t2; +End of 5.1 tests diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index c69de0f307b..daf043860a4 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -532,3 +532,19 @@ Warnings: Warning 1292 Truncated incorrect INTEGER value: 'd' DROP TABLE t1,t2; End of 5.0 tests +# +# Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set +# +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1,'f'); +CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1)); +INSERT INTO t2 VALUES (2,'m'); +INSERT INTO t2 VALUES (3,'m'); +INSERT INTO t2 VALUES (11,NULL); +INSERT INTO t2 VALUES (12,'k'); +SELECT MAX(t1.f1) field1 +FROM t1 JOIN t2 ON t2.f2 LIKE 'x' +HAVING field1 < 7; +field1 +DROP TABLE t1,t2; +End of 5.1 tests diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index eb3abc3f0c9..968d42b1dc0 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1681,6 +1681,16 @@ COUNT(*) DROP USER nonpriv; DROP TABLE db1.t1; DROP DATABASE db1; + +Bug#54422 query with = 'variables' + +CREATE TABLE variables(f1 INT); +SELECT COLUMN_DEFAULT, TABLE_NAME +FROM INFORMATION_SCHEMA.COLUMNS +WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'variables'; +COLUMN_DEFAULT TABLE_NAME +NULL variables +DROP TABLE variables; End of 5.1 tests. # # Additional test for WL#3726 "DDL locking for all metadata objects" diff --git a/mysql-test/r/information_schema_parameters.result b/mysql-test/r/information_schema_parameters.result index db04f5c0bd3..288f22e2ea3 100644 --- a/mysql-test/r/information_schema_parameters.result +++ b/mysql-test/r/information_schema_parameters.result @@ -25,7 +25,7 @@ WHERE table_schema = 'information_schema' ORDER BY ordinal_position; TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME SPECIFIC_CATALOG ORDINAL_POSITION 1 COLUMN_DEFAULT @@ -44,7 +44,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME SPECIFIC_SCHEMA ORDINAL_POSITION 2 COLUMN_DEFAULT @@ -63,7 +63,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME SPECIFIC_NAME ORDINAL_POSITION 3 COLUMN_DEFAULT @@ -82,7 +82,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME ORDINAL_POSITION ORDINAL_POSITION 4 COLUMN_DEFAULT 0 @@ -101,7 +101,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME PARAMETER_MODE ORDINAL_POSITION 5 COLUMN_DEFAULT NULL @@ -120,7 +120,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME PARAMETER_NAME ORDINAL_POSITION 6 COLUMN_DEFAULT NULL @@ -139,7 +139,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME DATA_TYPE ORDINAL_POSITION 7 COLUMN_DEFAULT @@ -158,7 +158,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME CHARACTER_MAXIMUM_LENGTH ORDINAL_POSITION 8 COLUMN_DEFAULT NULL @@ -177,7 +177,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME CHARACTER_OCTET_LENGTH ORDINAL_POSITION 9 COLUMN_DEFAULT NULL @@ -196,7 +196,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME NUMERIC_PRECISION ORDINAL_POSITION 10 COLUMN_DEFAULT NULL @@ -215,7 +215,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME NUMERIC_SCALE ORDINAL_POSITION 11 COLUMN_DEFAULT NULL @@ -234,7 +234,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME CHARACTER_SET_NAME ORDINAL_POSITION 12 COLUMN_DEFAULT NULL @@ -253,7 +253,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME COLLATION_NAME ORDINAL_POSITION 13 COLUMN_DEFAULT NULL @@ -272,7 +272,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME DTD_IDENTIFIER ORDINAL_POSITION 14 COLUMN_DEFAULT NULL @@ -291,7 +291,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME parameters +TABLE_NAME PARAMETERS COLUMN_NAME ROUTINE_TYPE ORDINAL_POSITION 15 COLUMN_DEFAULT diff --git a/mysql-test/r/information_schema_routines.result b/mysql-test/r/information_schema_routines.result index 664ec6bf748..aa4766f0a6b 100644 --- a/mysql-test/r/information_schema_routines.result +++ b/mysql-test/r/information_schema_routines.result @@ -40,7 +40,7 @@ WHERE table_schema = 'information_schema' ORDER BY ordinal_position; TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME SPECIFIC_NAME ORDINAL_POSITION 1 COLUMN_DEFAULT @@ -59,7 +59,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME ROUTINE_CATALOG ORDINAL_POSITION 2 COLUMN_DEFAULT @@ -78,7 +78,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME ROUTINE_SCHEMA ORDINAL_POSITION 3 COLUMN_DEFAULT @@ -97,7 +97,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME ROUTINE_NAME ORDINAL_POSITION 4 COLUMN_DEFAULT @@ -116,7 +116,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME ROUTINE_TYPE ORDINAL_POSITION 5 COLUMN_DEFAULT @@ -135,7 +135,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME DATA_TYPE ORDINAL_POSITION 6 COLUMN_DEFAULT @@ -154,7 +154,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME CHARACTER_MAXIMUM_LENGTH ORDINAL_POSITION 7 COLUMN_DEFAULT NULL @@ -173,7 +173,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME CHARACTER_OCTET_LENGTH ORDINAL_POSITION 8 COLUMN_DEFAULT NULL @@ -192,7 +192,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME NUMERIC_PRECISION ORDINAL_POSITION 9 COLUMN_DEFAULT NULL @@ -211,7 +211,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME NUMERIC_SCALE ORDINAL_POSITION 10 COLUMN_DEFAULT NULL @@ -230,7 +230,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME CHARACTER_SET_NAME ORDINAL_POSITION 11 COLUMN_DEFAULT NULL @@ -249,7 +249,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME COLLATION_NAME ORDINAL_POSITION 12 COLUMN_DEFAULT NULL @@ -268,7 +268,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME DTD_IDENTIFIER ORDINAL_POSITION 13 COLUMN_DEFAULT NULL @@ -287,7 +287,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME ROUTINE_BODY ORDINAL_POSITION 14 COLUMN_DEFAULT @@ -306,7 +306,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME ROUTINE_DEFINITION ORDINAL_POSITION 15 COLUMN_DEFAULT NULL @@ -325,7 +325,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME EXTERNAL_NAME ORDINAL_POSITION 16 COLUMN_DEFAULT NULL @@ -344,7 +344,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME EXTERNAL_LANGUAGE ORDINAL_POSITION 17 COLUMN_DEFAULT NULL @@ -363,7 +363,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME PARAMETER_STYLE ORDINAL_POSITION 18 COLUMN_DEFAULT @@ -382,7 +382,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME IS_DETERMINISTIC ORDINAL_POSITION 19 COLUMN_DEFAULT @@ -401,7 +401,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME SQL_DATA_ACCESS ORDINAL_POSITION 20 COLUMN_DEFAULT @@ -420,7 +420,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME SQL_PATH ORDINAL_POSITION 21 COLUMN_DEFAULT NULL @@ -439,7 +439,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME SECURITY_TYPE ORDINAL_POSITION 22 COLUMN_DEFAULT @@ -458,7 +458,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME CREATED ORDINAL_POSITION 23 COLUMN_DEFAULT 0000-00-00 00:00:00 @@ -477,7 +477,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME LAST_ALTERED ORDINAL_POSITION 24 COLUMN_DEFAULT 0000-00-00 00:00:00 @@ -496,7 +496,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME SQL_MODE ORDINAL_POSITION 25 COLUMN_DEFAULT @@ -515,7 +515,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME ROUTINE_COMMENT ORDINAL_POSITION 26 COLUMN_DEFAULT NULL @@ -534,7 +534,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME DEFINER ORDINAL_POSITION 27 COLUMN_DEFAULT @@ -553,7 +553,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME CHARACTER_SET_CLIENT ORDINAL_POSITION 28 COLUMN_DEFAULT @@ -572,7 +572,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME COLLATION_CONNECTION ORDINAL_POSITION 29 COLUMN_DEFAULT @@ -591,7 +591,7 @@ PRIVILEGES # COLUMN_COMMENT TABLE_CATALOG def TABLE_SCHEMA information_schema -TABLE_NAME routines +TABLE_NAME ROUTINES COLUMN_NAME DATABASE_COLLATION ORDINAL_POSITION 30 COLUMN_DEFAULT diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index a7407cfa699..1c59f41cfc0 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -503,4 +503,33 @@ DROP TABLE t1; CREATE TABLE t1 (id INT NOT NULL); LOAD DATA LOCAL INFILE 'tb.txt' INTO TABLE t1; DROP TABLE t1; +# +# Bug #51876 : crash/memory underrun when loading data with ucs2 +# and reverse() function +# +# Problem # 1 (original report): wrong parsing of ucs2 data +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +Warnings: +Warning 1366 Incorrect integer value: '?' for column 'a' at row 1 +Warning 1366 Incorrect integer value: '?' for column 'a' at row 2 +# should return 2 zeroes (as the value is truncated) +SELECT * FROM t1; +a +0 +0 +DROP TABLE t1; +# Problem # 2 : if you write and read ucs2 data to a file they're lost +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +# should return 0 and 1 (10 reversed) +SELECT * FROM t1; +a +0 +1 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/lowercase_mixed_tmpdir_innodb.result b/mysql-test/r/lowercase_mixed_tmpdir_innodb.result index a478b49cfda..a478b49cfda 100755..100644 --- a/mysql-test/r/lowercase_mixed_tmpdir_innodb.result +++ b/mysql-test/r/lowercase_mixed_tmpdir_innodb.result diff --git a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result index c37dc41c495..33c87ec101c 100644 --- a/mysql-test/r/lowercase_view.result +++ b/mysql-test/r/lowercase_view.result @@ -148,3 +148,20 @@ a DROP VIEW v1; DROP TABLE t1; End of 5.0 tests. +# +# Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS +# returns nothing +# +CREATE TABLE `ttt` ( +`f1` char(3) NOT NULL, +PRIMARY KEY (`f1`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +SELECT count(COLUMN_NAME) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = +'TTT'; +count(COLUMN_NAME) +1 +SELECT count(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TTT'; +count(*) +1 +DROP TABLE `ttt`; +End of 5.0 tests. diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index 394beb042a5..58f6ffd4040 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -169,4 +169,46 @@ DROP PROCEDURE testproc; WARNING: NULL values of the 'character_set_client' column ('mysql.proc' table) have been updated with a default value (latin1). Please verify if necessary. WARNING: NULL values of the 'collation_connection' column ('mysql.proc' table) have been updated with a default value (latin1_swedish_ci). Please verify if necessary. WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been updated with default values. Please verify if necessary. +# +# Bug #53613: mysql_upgrade incorrectly revokes +# TRIGGER privilege on given table +# +GRANT USAGE ON *.* TO 'user3'@'%'; +GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'; +Run mysql_upgrade with all privileges on a user +mtr.global_suppressions OK +mtr.test_suppressions OK +mysql.columns_priv OK +mysql.db OK +mysql.event OK +mysql.func OK +mysql.general_log +Error : You can't use locks with log tables. +status : OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.host OK +mysql.ndb_binlog_index OK +mysql.plugin OK +mysql.proc OK +mysql.procs_priv OK +mysql.servers OK +mysql.slow_log +Error : You can't use locks with log tables. +status : OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.user OK +SHOW GRANTS FOR 'user3'@'%'; +Grants for user3@% +GRANT USAGE ON *.* TO 'user3'@'%' +GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%' +DROP USER 'user3'@'%'; +End of 5.1 tests The --upgrade-system-tables option was used, databases won't be touched. diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index b518522e2bf..b193a269288 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4856,6 +4856,21 @@ a b c SELECT * FROM t1 WHERE 102 < c; a b c DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL); +INSERT INTO t1 VALUES (), (), (); +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; End of 5.1 tests # # Bug#54515: Crash in opt_range.cc::get_best_group_min_max on diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index e3aa87876ed..72d63e47d9a 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4988,3 +4988,20 @@ t1_id total_amount DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; +# +# Bug #52711: Segfault when doing EXPLAIN SELECT with +# union...order by (select... where...) +# +CREATE TABLE t1 (a VARCHAR(10), FULLTEXT KEY a (a)); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); +# Should not crash +EXPLAIN +SELECT * FROM t2 UNION SELECT * FROM t2 +ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +# Should not crash +SELECT * FROM t2 UNION SELECT * FROM t2 +ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +DROP TABLE t1,t2; +End of 5.1 tests diff --git a/mysql-test/std_data/intersect-bug50389.tsv b/mysql-test/std_data/intersect-bug50389.tsv new file mode 100644 index 00000000000..f84359603a8 --- /dev/null +++ b/mysql-test/std_data/intersect-bug50389.tsv @@ -0,0 +1,441 @@ +3304605 1221256 0 0 abcdefghijklmnopwrst +3304606 1221259 0 0 abcdefghijklmnopwrst +3304607 1221260 0 0 asdfghjklzxcvbnm +3304629 1221273 0 0 asdfghjklzxcvbnm +3304630 1221273 0 0 asdfghjklzxcvbnm +3304634 1221259 0 0 asdfghjklzxcvbnm +3304644 1221278 0 0 abcdefghijklmnopwrst +3304648 1221278 0 0 abcdefghijklmnopwrst +3304649 1221278 0 1 asdfghjklzxcvbnm +3304650 1221278 0 0 asdfghjklzxcvbnm +3304651 1221282 0 0 abcdefghijklmnopwrst +3304660 1221287 0 0 asdfghjklzxcvbnm +3304662 1221288 0 0 abcdefghijklmnopwrst +3304663 1221288 0 0 abcdefghijklmnopwrst +3304664 1221290 0 0 abcdefghijklmnopwrst +3304670 1221290 0 0 asdfghjklzxcvbnm +3304671 1221292 0 0 abcdefghijklmnopwrst +3304672 1221287 0 0 asdfghjklzxcvbnm +3304673 1221294 0 0 asdfghjklzxcvbnm +3304674 1221287 0 0 asdfghjklzxcvbnm +3304676 1221296 0 0 abcdefghijklmnopwrst +3304677 1221287 0 0 abcdefghijklmnopwrst +3304678 1221287 0 0 abcdefghijklmnopwrst +3304679 1221297 0 0 asdfghjklzxcvbnm +3304680 1221290 0 0 abcdefghijklmnopwrst +3304681 1221290 0 0 abcdefghijklmnopwrst +3304685 1221300 0 0 asdfghjklzxcvbnm +3304687 1221302 0 0 abcdefghijklmnopwrst +3304688 1221296 1221298 0 abcdefghijklmnopwrst +3304692 1221309 0 0 asdfghjklzxcvbnm +3304694 1221309 0 0 asdfghjklzxcvbnm +3304695 1221290 0 0 abcdefghijklmnopwrst +3304696 1221313 0 0 asdfghjklzxcvbnm +3304701 1221314 0 0 asdfghjklzxcvbnm +3304703 1221313 0 0 abcdefghijklmnopwrst +3304707 1221313 0 0 asdfghjklzxcvbnm +3304709 1221313 0 0 abcdefghijklmnopwrst +3304713 1221314 0 0 abcdefghijklmnopwrst +3304715 1221317 0 0 abcdefghijklmnopwrst +3304717 1221319 0 0 asdfghjklzxcvbnm +3304718 1221320 0 0 abcdefghijklmnopwrst +3304723 1221314 0 0 abcdefghijklmnopwrst +3304724 1221314 0 0 asdfghjklzxcvbnm +3304725 1221300 0 0 asdfghjklzxcvbnm +3304726 1221314 0 0 asdfghjklzxcvbnm +3304730 1221326 0 0 asdfghjklzxcvbnm +3304732 1221328 0 0 asdfghjklzxcvbnm +3304733 1221329 0 0 asdfghjklzxcvbnm +3304745 1221331 0 0 abcdefghijklmnopwrst +3304747 1221300 0 0 abcdefghijklmnopwrst +3304752 1221332 0 0 asdfghjklzxcvbnm +3304756 1221333 0 0 asdfghjklzxcvbnm +3304765 1221336 0 0 asdfghjklzxcvbnm +3304767 1221338 0 0 abcdefghijklmnopwrst +3304769 1221340 0 0 asdfghjklzxcvbnm +3304770 1221328 0 0 asdfghjklzxcvbnm +3304771 1221328 0 0 abcdefghijklmnopwrst +3304773 1221340 0 0 asdfghjklzxcvbnm +3304774 1221340 0 0 abcdefghijklmnopwrst +3304775 1221338 1221342 1 asdfghjklzxcvbnm +3304778 1221345 0 0 asdfghjklzxcvbnm +3304786 1221332 0 0 asdfghjklzxcvbnm +3304787 1221347 0 0 abcdefghijklmnopwrst +3304789 1221347 0 0 asdfghjklzxcvbnm +3304793 1221349 0 0 abcdefghijklmnopwrst +3304794 1221350 0 0 asdfghjklzxcvbnm +3304800 1221290 0 0 asdfghjklzxcvbnm +3304802 1221290 0 0 asdfghjklzxcvbnm +3304803 1221290 0 0 asdfghjklzxcvbnm +3304810 1221356 0 0 asdfghjklzxcvbnm +3304811 1221356 0 0 asdfghjklzxcvbnm +3304821 1221364 0 0 asdfghjklzxcvbnm +3304823 1221365 0 0 asdfghjklzxcvbnm +3304824 1221366 0 0 abcdefghijklmnopwrst +3304825 1221365 0 0 asdfghjklzxcvbnm +3304826 1221367 0 0 asdfghjklzxcvbnm +3304828 1221369 0 0 abcdefghijklmnopwrst +3304829 1221366 1221368 0 asdfghjklzxcvbnm +3304831 1221372 0 0 abcdefghijklmnopwrst +3304832 1221364 1221373 0 abcdefghijklmnopwrst +3304833 1221364 1221371 0 asdfghjklzxcvbnm +3304834 1221364 0 0 abcdefghijklmnopwrst +3304836 1221375 0 0 abcdefghijklmnopwrst +3304837 1221364 0 0 abcdefghijklmnopwrst +3304838 1221364 1221376 0 asdfghjklzxcvbnm +3304840 1221372 0 0 asdfghjklzxcvbnm +3304842 1221372 0 1 abcdefghijklmnopwrst +3304844 1221372 0 0 asdfghjklzxcvbnm +3304845 1221372 0 0 abcdefghijklmnopwrst +3304847 1221382 0 0 abcdefghijklmnopwrst +3304848 1221372 0 0 abcdefghijklmnopwrst +3304849 1221372 0 0 asdfghjklzxcvbnm +3304852 1221364 1221378 0 asdfghjklzxcvbnm +3304853 1221383 0 0 abcdefghijklmnopwrst +3304854 1221384 0 0 asdfghjklzxcvbnm +3304855 1221347 0 0 asdfghjklzxcvbnm +3304858 1221383 0 0 abcdefghijklmnopwrst +3304862 1221386 0 0 abcdefghijklmnopwrst +3304864 1221387 0 0 abcdefghijklmnopwrst +3304867 1221389 0 0 abcdefghijklmnopwrst +3304868 1221390 0 0 asdfghjklzxcvbnm +3304869 1221391 0 0 asdfghjklzxcvbnm +3304871 1221393 0 0 asdfghjklzxcvbnm +3304874 1221395 0 0 abcdefghijklmnopwrst +3304877 1221396 0 0 abcdefghijklmnopwrst +3304879 1221396 0 0 asdfghjklzxcvbnm +3304882 1221398 0 0 abcdefghijklmnopwrst +3304883 1221399 0 0 abcdefghijklmnopwrst +3304884 1221400 0 0 abcdefghijklmnopwrst +3304889 1221405 0 0 abcdefghijklmnopwrst +3304895 1221409 0 0 asdfghjklzxcvbnm +3304899 1221395 0 0 asdfghjklzxcvbnm +3304900 1221395 0 0 asdfghjklzxcvbnm +3304902 1221395 0 0 abcdefghijklmnopwrst +3304903 1221395 0 0 asdfghjklzxcvbnm +3304924 1221414 0 0 abcdefghijklmnopwrst +3304925 1221415 0 0 asdfghjklzxcvbnm +3304935 1221416 0 0 asdfghjklzxcvbnm +3304936 1221418 0 0 asdfghjklzxcvbnm +3304944 1221419 0 0 abcdefghijklmnopwrst +3304959 1221427 0 0 asdfghjklzxcvbnm +3304963 1221415 0 0 asdfghjklzxcvbnm +3304964 1221428 0 0 asdfghjklzxcvbnm +3304965 1221429 0 0 abcdefghijklmnopwrst +3304978 1221433 0 0 abcdefghijklmnopwrst +3304986 1221437 0 0 asdfghjklzxcvbnm +3304988 1221439 0 0 asdfghjklzxcvbnm +3304994 1221441 0 0 asdfghjklzxcvbnm +3304996 1221442 0 0 asdfghjklzxcvbnm +3304998 1221443 0 0 asdfghjklzxcvbnm +3305003 1221446 0 0 abcdefghijklmnopwrst +3305008 1221433 0 0 abcdefghijklmnopwrst +3305009 1221447 0 0 asdfghjklzxcvbnm +3305012 1221447 0 0 asdfghjklzxcvbnm +3305013 1221449 0 0 abcdefghijklmnopwrst +3305015 1221451 0 0 asdfghjklzxcvbnm +3305019 1221453 0 0 asdfghjklzxcvbnm +3305023 1221449 0 0 asdfghjklzxcvbnm +3305026 1221456 0 0 abcdefghijklmnopwrst +3305028 1221457 0 0 asdfghjklzxcvbnm +3305032 1221449 0 0 asdfghjklzxcvbnm +3305037 1221453 0 0 asdfghjklzxcvbnm +3305040 1221451 0 0 asdfghjklzxcvbnm +3305061 1221446 0 0 abcdefghijklmnopwrst +3305175 1221457 0 0 abcdefghijklmnopwrst +3305304 1221453 0 0 abcdefghijklmnopwrst +3305308 1221453 0 1 abcdefghijklmnopwrst +3305333 1221457 1221577 0 asdfghjklzxcvbnm +3305335 1221453 0 0 asdfghjklzxcvbnm +3305354 1221457 0 1 asdfghjklzxcvbnm +3306089 1221442 0 0 abcdefghijklmnopwrst +3306090 1221442 0 0 abcdefghijklmnopwrst +3306092 1221442 0 0 asdfghjklzxcvbnm +3306345 1221366 0 0 asdfghjklzxcvbnm +3306349 1221366 0 0 asdfghjklzxcvbnm +3306419 1221364 1221371 0 asdfghjklzxcvbnm +3307390 1221453 0 0 abcdefghijklmnopwrst +3308002 1221416 1221417 0 abcdefghijklmnopwrst +3308331 1221366 1222821 0 abcdefghijklmnopwrst +3309991 1221347 0 0 asdfghjklzxcvbnm +3311917 1221287 0 0 abcdefghijklmnopwrst +3311937 1221287 0 0 abcdefghijklmnopwrst +3311945 1221287 0 0 asdfghjklzxcvbnm +3311955 1221287 0 0 abcdefghijklmnopwrst +3311961 1221287 0 0 asdfghjklzxcvbnm +3311963 1221287 0 1 asdfghjklzxcvbnm +3311968 1221287 0 0 asdfghjklzxcvbnm +3311974 1221287 0 1 abcdefghijklmnopwrst +3311976 1221287 0 1 abcdefghijklmnopwrst +3311981 1221287 0 1 abcdefghijklmnopwrst +3311985 1221287 0 1 asdfghjklzxcvbnm +3312014 1221287 0 0 abcdefghijklmnopwrst +3312018 1221287 0 1 abcdefghijklmnopwrst +3312025 1221287 0 0 abcdefghijklmnopwrst +3312027 1221287 0 0 abcdefghijklmnopwrst +3312030 1221287 0 0 abcdefghijklmnopwrst +3313755 1221288 0 0 abcdefghijklmnopwrst +3313767 1221288 0 0 asdfghjklzxcvbnm +3314668 1221290 0 0 asdfghjklzxcvbnm +3314670 1221290 0 0 abcdefghijklmnopwrst +3323440 1221338 0 0 abcdefghijklmnopwrst +3323736 1221338 0 0 asdfghjklzxcvbnm +3323739 1221338 0 0 asdfghjklzxcvbnm +3324077 1221290 0 0 asdfghjklzxcvbnm +3324081 1221290 0 0 abcdefghijklmnopwrst +3324082 1221290 0 0 abcdefghijklmnopwrst +3324639 1221457 1221563 1 asdfghjklzxcvbnm +3326180 1221287 0 0 abcdefghijklmnopwrst +3326204 1221287 0 0 asdfghjklzxcvbnm +3326945 1221457 1221563 1 asdfghjklzxcvbnm +3328393 1221364 1221373 0 asdfghjklzxcvbnm +3328966 1221287 0 0 abcdefghijklmnopwrst +3329875 1221457 1382427 0 abcdefghijklmnopwrst +3333449 1221278 1231113 0 abcdefghijklmnopwrst +3336022 1221457 0 0 abcdefghijklmnopwrst +3340069 1221364 1221373 0 abcdefghijklmnopwrst +3340073 1221364 1221373 0 abcdefghijklmnopwrst +3340563 1221290 0 0 asdfghjklzxcvbnm +3341553 1221453 0 0 abcdefghijklmnopwrst +3345868 1221287 0 0 asdfghjklzxcvbnm +3345873 1221287 0 0 abcdefghijklmnopwrst +3345879 1221287 0 0 asdfghjklzxcvbnm +3346860 1221457 0 0 abcdefghijklmnopwrst +3347053 1221287 0 0 asdfghjklzxcvbnm +3347109 1221287 0 1 abcdefghijklmnopwrst +3350589 1221372 1236415 0 abcdefghijklmnopwrst +3350594 1221372 1236415 1 asdfghjklzxcvbnm +3353871 1221457 0 0 asdfghjklzxcvbnm +3354727 1221364 1221373 0 abcdefghijklmnopwrst +3355270 1221393 0 1 abcdefghijklmnopwrst +3357638 1221287 0 0 asdfghjklzxcvbnm +3357644 1221287 0 0 abcdefghijklmnopwrst +3357648 1221287 0 0 abcdefghijklmnopwrst +3357651 1221287 0 0 asdfghjklzxcvbnm +3357661 1221287 0 0 abcdefghijklmnopwrst +3357678 1221287 0 0 abcdefghijklmnopwrst +3357697 1221287 0 0 asdfghjklzxcvbnm +3357737 1221287 0 0 asdfghjklzxcvbnm +3357744 1221287 0 0 abcdefghijklmnopwrst +3357754 1221287 0 1 asdfghjklzxcvbnm +3357760 1221287 0 1 abcdefghijklmnopwrst +3357774 1221287 0 1 abcdefghijklmnopwrst +3357779 1221287 0 0 abcdefghijklmnopwrst +3357796 1221287 0 0 asdfghjklzxcvbnm +3357814 1221287 0 0 asdfghjklzxcvbnm +3357833 1221287 0 1 asdfghjklzxcvbnm +3357835 1221287 0 0 abcdefghijklmnopwrst +3357840 1221287 0 1 asdfghjklzxcvbnm +3357842 1221287 0 0 abcdefghijklmnopwrst +3357845 1221287 0 1 abcdefghijklmnopwrst +3357849 1221287 0 1 abcdefghijklmnopwrst +3357852 1221287 0 0 abcdefghijklmnopwrst +3358935 1221443 0 1 abcdefghijklmnopwrst +3358967 1221443 0 1 abcdefghijklmnopwrst +3359181 1221256 0 0 abcdefghijklmnopwrst +3360512 1221319 0 0 asdfghjklzxcvbnm +3362004 1221287 0 0 abcdefghijklmnopwrst +3362009 1221287 0 1 abcdefghijklmnopwrst +3362358 1221287 0 0 asdfghjklzxcvbnm +3363214 1221287 0 0 abcdefghijklmnopwrst +3363238 1221287 0 1 asdfghjklzxcvbnm +3363616 1221287 0 1 asdfghjklzxcvbnm +3363631 1221287 0 0 asdfghjklzxcvbnm +3364281 1221287 0 0 abcdefghijklmnopwrst +3365900 1221347 0 0 asdfghjklzxcvbnm +3365901 1221347 0 0 asdfghjklzxcvbnm +3365906 1221347 0 0 asdfghjklzxcvbnm +3365907 1221347 0 0 asdfghjklzxcvbnm +3365910 1221347 0 0 abcdefghijklmnopwrst +3365936 1221347 0 0 abcdefghijklmnopwrst +3367846 1221287 0 0 abcdefghijklmnopwrst +3368011 1221428 0 0 abcdefghijklmnopwrst +3369882 1221300 0 0 asdfghjklzxcvbnm +3370856 1221443 0 0 asdfghjklzxcvbnm +3370861 1221443 1221445 0 abcdefghijklmnopwrst +3375327 1221443 0 0 abcdefghijklmnopwrst +3375333 1221443 1221445 0 abcdefghijklmnopwrst +3376219 1221453 0 1 abcdefghijklmnopwrst +3376228 1221453 0 0 abcdefghijklmnopwrst +3376238 1221453 0 0 asdfghjklzxcvbnm +3376243 1221453 0 0 abcdefghijklmnopwrst +3376248 1221453 0 1 abcdefghijklmnopwrst +3376254 1221453 0 0 abcdefghijklmnopwrst +3376263 1221453 0 0 abcdefghijklmnopwrst +3376272 1221453 0 1 asdfghjklzxcvbnm +3376281 1221453 0 0 asdfghjklzxcvbnm +3376290 1221453 0 0 abcdefghijklmnopwrst +3376296 1221453 0 1 abcdefghijklmnopwrst +3376301 1221453 0 0 asdfghjklzxcvbnm +3376350 1221453 0 0 asdfghjklzxcvbnm +3379002 1221453 0 0 abcdefghijklmnopwrst +3379015 1221453 0 0 asdfghjklzxcvbnm +3379025 1221453 0 0 abcdefghijklmnopwrst +3379032 1221453 0 0 asdfghjklzxcvbnm +3380181 1221372 1245650 0 asdfghjklzxcvbnm +3380186 1221372 1245650 0 abcdefghijklmnopwrst +3380190 1221372 1245650 0 asdfghjklzxcvbnm +3380195 1221372 1245650 0 abcdefghijklmnopwrst +3380202 1221372 1245650 0 asdfghjklzxcvbnm +3380683 1221287 0 0 asdfghjklzxcvbnm +3382317 1221453 0 0 abcdefghijklmnopwrst +3382417 1221287 0 0 asdfghjklzxcvbnm +3383523 1221338 0 1 abcdefghijklmnopwrst +3387213 1221287 0 0 abcdefghijklmnopwrst +3388139 1221453 0 0 asdfghjklzxcvbnm +3398039 1221443 1251164 0 abcdefghijklmnopwrst +3401835 1221453 0 0 asdfghjklzxcvbnm +3412582 1221443 1255886 0 asdfghjklzxcvbnm +3412583 1221443 1255886 0 asdfghjklzxcvbnm +3413795 1221443 1255886 0 asdfghjklzxcvbnm +3413813 1221443 1256258 0 asdfghjklzxcvbnm +3420306 1221453 0 0 asdfghjklzxcvbnm +3420354 1221453 0 0 asdfghjklzxcvbnm +3425653 1221443 0 0 abcdefghijklmnopwrst +3425658 1221443 0 0 asdfghjklzxcvbnm +3431409 1221453 0 0 asdfghjklzxcvbnm +3432510 1221443 1262320 0 asdfghjklzxcvbnm +3432513 1221443 1262320 0 asdfghjklzxcvbnm +3444444 1221443 1262320 0 abcdefghijklmnopwrst +3445447 1221287 0 1 asdfghjklzxcvbnm +3448662 1221338 0 0 asdfghjklzxcvbnm +3450032 1221347 0 0 abcdefghijklmnopwrst +3450259 1221453 0 0 abcdefghijklmnopwrst +3452176 1221453 0 0 asdfghjklzxcvbnm +3459239 1221347 0 0 asdfghjklzxcvbnm +3463196 1221347 0 0 abcdefghijklmnopwrst +3468759 1221453 0 0 abcdefghijklmnopwrst +3470988 1221457 0 0 asdfghjklzxcvbnm +3477116 1221287 0 0 asdfghjklzxcvbnm +3477639 1221372 1277136 0 abcdefghijklmnopwrst +3477656 1221372 1277136 0 asdfghjklzxcvbnm +3488071 1221256 1238964 0 abcdefghijklmnopwrst +3488079 1221256 0 0 asdfghjklzxcvbnm +3488108 1221256 0 1 asdfghjklzxcvbnm +3507126 1221287 0 1 asdfghjklzxcvbnm +3511898 1221347 0 0 asdfghjklzxcvbnm +3521780 1221453 0 0 abcdefghijklmnopwrst +3536908 1221287 0 0 abcdefghijklmnopwrst +3544231 1221329 0 1 asdfghjklzxcvbnm +3545379 1221329 1298955 0 abcdefghijklmnopwrst +3545384 1221329 1298955 0 abcdefghijklmnopwrst +3545387 1221329 1298955 0 abcdefghijklmnopwrst +3545389 1221329 1298955 1 abcdefghijklmnopwrst +3545398 1221329 1298955 1 abcdefghijklmnopwrst +3555715 1221287 0 0 asdfghjklzxcvbnm +3563557 1221329 1298955 0 abcdefghijklmnopwrst +3564322 1221338 0 0 asdfghjklzxcvbnm +3565475 1221453 0 0 abcdefghijklmnopwrst +3577588 1221287 0 0 asdfghjklzxcvbnm +3600047 1221453 0 0 abcdefghijklmnopwrst +3600062 1221453 0 0 asdfghjklzxcvbnm +3600071 1221453 0 0 abcdefghijklmnopwrst +3600080 1221453 0 1 abcdefghijklmnopwrst +3600086 1221453 0 0 asdfghjklzxcvbnm +3600091 1221453 0 1 abcdefghijklmnopwrst +3600097 1221453 0 0 asdfghjklzxcvbnm +3600103 1221453 0 0 asdfghjklzxcvbnm +3600106 1221453 0 0 abcdefghijklmnopwrst +3600113 1221453 0 0 abcdefghijklmnopwrst +3600119 1221453 0 0 asdfghjklzxcvbnm +3600124 1221453 0 0 abcdefghijklmnopwrst +3600144 1221453 0 0 asdfghjklzxcvbnm +3600152 1221453 0 0 asdfghjklzxcvbnm +3600165 1221453 0 0 asdfghjklzxcvbnm +3610561 1221287 0 0 abcdefghijklmnopwrst +3617030 1221329 0 0 asdfghjklzxcvbnm +3628347 1221443 1327098 0 abcdefghijklmnopwrst +3628348 1221443 1327098 0 abcdefghijklmnopwrst +3628646 1221443 0 0 asdfghjklzxcvbnm +3633673 1221372 1328838 0 abcdefghijklmnopwrst +3648489 1221443 0 0 asdfghjklzxcvbnm +3648490 1221443 0 0 asdfghjklzxcvbnm +3648534 1221443 1333827 0 asdfghjklzxcvbnm +3653046 1221329 1298955 0 asdfghjklzxcvbnm +3662680 1221287 0 0 asdfghjklzxcvbnm +3699529 1221288 0 0 asdfghjklzxcvbnm +3706659 1221453 0 0 asdfghjklzxcvbnm +3723399 1221287 0 1 asdfghjklzxcvbnm +3749934 1221278 0 0 abcdefghijklmnopwrst +3761370 1221443 1371176 0 asdfghjklzxcvbnm +3765884 1221443 1333827 0 abcdefghijklmnopwrst +3772880 1221457 0 0 abcdefghijklmnopwrst +3779574 1221457 1372998 1 abcdefghijklmnopwrst +3784656 1221457 1372998 1 abcdefghijklmnopwrst +3784700 1221457 1372998 1 abcdefghijklmnopwrst +3784744 1221457 1382427 0 abcdefghijklmnopwrst +3796187 1221457 1382427 1 abcdefghijklmnopwrst +3796193 1221457 0 0 abcdefghijklmnopwrst +3817277 1221457 1382427 0 asdfghjklzxcvbnm +3828282 1221457 0 0 abcdefghijklmnopwrst +3828297 1221457 0 0 abcdefghijklmnopwrst +3828300 1221457 0 0 abcdefghijklmnopwrst +3833022 1221287 0 0 asdfghjklzxcvbnm +3856380 1221457 1395359 0 asdfghjklzxcvbnm +3856391 1221457 0 0 asdfghjklzxcvbnm +3861413 1221256 0 0 abcdefghijklmnopwrst +3864734 1221393 0 1 abcdefghijklmnopwrst +3868051 1221329 0 0 abcdefghijklmnopwrst +3868059 1221329 0 0 abcdefghijklmnopwrst +3869088 1221329 0 0 abcdefghijklmnopwrst +3878669 1221329 1298955 0 asdfghjklzxcvbnm +3878684 1221329 1298955 0 asdfghjklzxcvbnm +3881785 1221287 0 0 abcdefghijklmnopwrst +3882333 1221287 0 0 asdfghjklzxcvbnm +3882389 1221287 0 0 abcdefghijklmnopwrst +3908680 1221372 1245650 0 asdfghjklzxcvbnm +3908690 1221372 1245650 0 asdfghjklzxcvbnm +3908697 1221372 1245650 0 abcdefghijklmnopwrst +3911434 1221453 0 0 abcdefghijklmnopwrst +3911446 1221453 0 0 asdfghjklzxcvbnm +3911448 1221453 0 0 abcdefghijklmnopwrst +3911489 1221453 0 0 abcdefghijklmnopwrst +3917384 1221453 0 0 abcdefghijklmnopwrst +3939602 1221457 0 1 asdfghjklzxcvbnm +3962210 1221453 0 0 asdfghjklzxcvbnm +3963734 1221457 0 0 asdfghjklzxcvbnm +3977364 1221287 0 0 asdfghjklzxcvbnm +3981725 1221453 0 0 abcdefghijklmnopwrst +4042952 1221453 0 0 abcdefghijklmnopwrst +4042953 1221453 0 0 abcdefghijklmnopwrst +4042958 1221453 0 0 abcdefghijklmnopwrst +4042960 1221453 0 1 abcdefghijklmnopwrst +4042965 1221453 0 0 asdfghjklzxcvbnm +4066893 1221453 0 1 abcdefghijklmnopwrst +4066896 1221453 0 0 abcdefghijklmnopwrst +4066900 1221453 0 0 abcdefghijklmnopwrst +4066908 1221453 0 0 abcdefghijklmnopwrst +4066912 1221453 0 0 asdfghjklzxcvbnm +4066915 1221453 0 0 asdfghjklzxcvbnm +4066919 1221453 0 0 abcdefghijklmnopwrst +4066924 1221453 0 0 asdfghjklzxcvbnm +4066929 1221453 0 0 abcdefghijklmnopwrst +4066934 1221453 0 0 asdfghjklzxcvbnm +4066941 1221453 0 0 abcdefghijklmnopwrst +4066946 1221453 0 0 asdfghjklzxcvbnm +4066955 1221453 0 0 abcdefghijklmnopwrst +4116291 1221433 1487238 0 asdfghjklzxcvbnm +4116295 1221433 1487238 0 abcdefghijklmnopwrst +4116450 1221433 1487238 0 abcdefghijklmnopwrst +4121149 1221287 0 0 asdfghjklzxcvbnm +4137325 1221453 0 0 abcdefghijklmnopwrst +4149051 1221287 0 0 abcdefghijklmnopwrst +4162347 1221287 0 0 abcdefghijklmnopwrst +4164485 1221457 0 1 asdfghjklzxcvbnm +4174706 1221457 0 0 abcdefghijklmnopwrst +4178645 1221457 0 0 abcdefghijklmnopwrst +4180122 1221457 1382427 0 asdfghjklzxcvbnm +4180925 1221457 1382427 0 asdfghjklzxcvbnm +4186417 1221457 0 0 abcdefghijklmnopwrst +4189624 1221457 0 1 asdfghjklzxcvbnm +4203132 1221453 0 0 asdfghjklzxcvbnm +4228206 1221457 0 0 abcdefghijklmnopwrst +4278829 1221453 0 0 abcdefghijklmnopwrst +4326422 1221453 0 0 abcdefghijklmnopwrst +4337061 1221287 0 0 abcdefghijklmnopwrst +4379354 1221287 0 0 abcdefghijklmnopwrst +4404901 1221457 0 0 abcdefghijklmnopwrst +4494153 1221457 0 0 abcdefghijklmnopwrst +4535721 1221287 0 0 asdfghjklzxcvbnm +4559596 1221457 0 0 abcdefghijklmnopwrst +4617751 1221393 0 0 abcdefghijklmnopwrst diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result index 58c444c9571..7fb5e50a219 100644 --- a/mysql-test/suite/binlog/r/binlog_base64_flag.result +++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result @@ -91,3 +91,14 @@ iONkSBcBAAAAKwAAAMQBAAAQABAAAAAAAAEAA//4AQAAAAMAMTIzAQAAAA== '; ERROR HY000: master may suffer from http://bugs.mysql.com/bug.php?id=37426 so slave stops; check error log on slave for more info drop table t1, char63_utf8, char128_utf8; +# +# Bug #54393: crash and/or valgrind errors in +# mysql_client_binlog_statement +# +BINLOG ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use +BINLOG '123'; +BINLOG '-2079193929'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use +BINLOG 'xç↓%~∙Dâ•’Æ’â•¡'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result index 43108222866..43108222866 100755..100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result diff --git a/mysql-test/suite/binlog/t/binlog_base64_flag.test b/mysql-test/suite/binlog/t/binlog_base64_flag.test index e6271ec6ccc..3f1e4e98bec 100644 --- a/mysql-test/suite/binlog/t/binlog_base64_flag.test +++ b/mysql-test/suite/binlog/t/binlog_base64_flag.test @@ -150,3 +150,16 @@ iONkSBcBAAAAKwAAAMQBAAAQABAAAAAAAAEAA//4AQAAAAMAMTIzAQAAAA== '; drop table t1, char63_utf8, char128_utf8; + + +--echo # +--echo # Bug #54393: crash and/or valgrind errors in +--echo # mysql_client_binlog_statement +--echo # +--error ER_SYNTAX_ERROR +BINLOG ''; +BINLOG '123'; +--error ER_SYNTAX_ERROR +BINLOG '-2079193929'; +--error ER_SYNTAX_ERROR +BINLOG 'xç↓%~∙Dâ•’Æ’â•¡'; diff --git a/mysql-test/suite/funcs_1/r/is_basics_mixed.result b/mysql-test/suite/funcs_1/r/is_basics_mixed.result index ce0bb69e5ee..3ac17803688 100644 --- a/mysql-test/suite/funcs_1/r/is_basics_mixed.result +++ b/mysql-test/suite/funcs_1/r/is_basics_mixed.result @@ -328,7 +328,7 @@ ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_ SELECT table_schema,table_name FROM information_schema.tables WHERE table_schema = 'information_schema' AND table_name = 'tables'; table_schema table_name -information_schema tables +information_schema TABLES SELECT * FROM information_schema.table_privileges WHERE table_schema = 'information_schema'; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE diff --git a/mysql-test/suite/ibmdb2i/include/have_i54.inc b/mysql-test/suite/ibmdb2i/include/have_i54.inc index 7054e196153..7054e196153 100755..100644 --- a/mysql-test/suite/ibmdb2i/include/have_i54.inc +++ b/mysql-test/suite/ibmdb2i/include/have_i54.inc diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result index 8276b401073..8276b401073 100755..100644 --- a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result index 311e800e1b0..311e800e1b0 100755..100644 --- a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test index ea29b5abcd4..ea29b5abcd4 100755..100644 --- a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test index da69b5d9148..da69b5d9148 100755..100644 --- a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 6d92d14e735..b418b62ec90 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -2468,6 +2468,76 @@ ENGINE=InnoDB; INSERT INTO t1 VALUES (0, 77, 1, 3); UPDATE t1 SET d = 0 WHERE b = 77 AND c = 25; DROP TABLE t1; +# +# Bug#50389 Using intersect does not return all rows +# +CREATE TABLE t1 ( +f1 INT(10) NOT NULL, +f2 INT(10), +f3 INT(10), +f4 TINYINT(4), +f5 VARCHAR(50), +PRIMARY KEY (f1), +KEY idx1 (f2,f5,f4), +KEY idx2 (f2,f4) +) ENGINE=InnoDB; +LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1; +SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, +3470988,3305175,3329875,3817277,3856380,3796193, +3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; +f1 f2 f3 f4 f5 +3305175 1221457 0 0 abcdefghijklmnopwrst +3329875 1221457 1382427 0 abcdefghijklmnopwrst +3336022 1221457 0 0 abcdefghijklmnopwrst +3346860 1221457 0 0 abcdefghijklmnopwrst +3772880 1221457 0 0 abcdefghijklmnopwrst +3784744 1221457 1382427 0 abcdefghijklmnopwrst +3796193 1221457 0 0 abcdefghijklmnopwrst +4228206 1221457 0 0 abcdefghijklmnopwrst +4494153 1221457 0 0 abcdefghijklmnopwrst +4559596 1221457 0 0 abcdefghijklmnopwrst +EXPLAIN SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, +3470988,3305175,3329875,3817277,3856380,3796193, +3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge PRIMARY,idx1,idx2 idx2,idx1,PRIMARY 7,60,4 NULL 1 Using intersect(idx2,idx1,PRIMARY); Using where +DROP TABLE t1; +# +# Bug#51431 Wrong sort order after import of dump file +# +CREATE TABLE t1 ( +f1 INT(11) NOT NULL, +f2 int(11) NOT NULL, +f3 int(11) NOT NULL, +f4 tinyint(1) NOT NULL, +PRIMARY KEY (f1), +UNIQUE KEY (f2, f3), +KEY (f4) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1), +(6,1,996,1), (7,1,997,1), (8,1,998,1), (10,1,999,1), (11,1,9910,1), +(16,1,9911,1), (17,1,9912,1), (18,1,9913,1), (19,1,9914,1), (20,1,9915,1), +(21,1,9916,1), (22,1,9917,1), (23,1,9918,1), (24,1,9919,1), (25,1,9920,1), +(26,1,9921,1), (27,1,9922,1); +FLUSH TABLES; +SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; +f1 f2 f3 f4 +27 1 9922 1 +26 1 9921 1 +25 1 9920 1 +24 1 9919 1 +23 1 9918 1 +EXPLAIN SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range f2,f4 f4 1 NULL 11 Using where +DROP TABLE t1; End of 5.1 tests # # Test for bug #39932 "create table fails if column for FK is in different diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index 09e076c0506..fcd54075ecc 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -676,6 +676,67 @@ UPDATE t1 SET d = 0 WHERE b = 77 AND c = 25; DROP TABLE t1; +--echo # +--echo # Bug#50389 Using intersect does not return all rows +--echo # + +CREATE TABLE t1 ( + f1 INT(10) NOT NULL, + f2 INT(10), + f3 INT(10), + f4 TINYINT(4), + f5 VARCHAR(50), + PRIMARY KEY (f1), + KEY idx1 (f2,f5,f4), + KEY idx2 (f2,f4) +) ENGINE=InnoDB; + +LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1; + +SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, + 3470988,3305175,3329875,3817277,3856380,3796193, + 3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; + +EXPLAIN SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, + 3470988,3305175,3329875,3817277,3856380,3796193, + 3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; + +DROP TABLE t1; + +--echo # +--echo # Bug#51431 Wrong sort order after import of dump file +--echo # + +CREATE TABLE t1 ( + f1 INT(11) NOT NULL, + f2 int(11) NOT NULL, + f3 int(11) NOT NULL, + f4 tinyint(1) NOT NULL, + PRIMARY KEY (f1), + UNIQUE KEY (f2, f3), + KEY (f4) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES +(1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1), +(6,1,996,1), (7,1,997,1), (8,1,998,1), (10,1,999,1), (11,1,9910,1), +(16,1,9911,1), (17,1,9912,1), (18,1,9913,1), (19,1,9914,1), (20,1,9915,1), +(21,1,9916,1), (22,1,9917,1), (23,1,9918,1), (24,1,9919,1), (25,1,9920,1), +(26,1,9921,1), (27,1,9922,1); + +FLUSH TABLES; + +SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; +EXPLAIN SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/suite/rpl/r/rpl_current_user.result b/mysql-test/suite/rpl/r/rpl_current_user.result new file mode 100644 index 00000000000..69c20078531 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_current_user.result @@ -0,0 +1,205 @@ +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; +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.*"); + +# On slave2 +# Connect slave2 to slave +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=SLAVE_MYPORT;, +MASTER_LOG_FILE='slave-bin.000001', MASTER_USER='root'; +START SLAVE; + +# [On master] +DROP VIEW IF EXISTS v_user; +DROP VIEW IF EXISTS v_tables_priv; +DROP VIEW IF EXISTS v_procs_priv; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS my_grant; +DROP PROCEDURE IF EXISTS my_revoke; +DROP FUNCTION IF EXISTS my_user; +DROP EVENT IF EXISTS e1; +CREATE TABLE t1(c1 char(100)); +CREATE VIEW test.v_user AS SELECT * FROM mysql.user WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_tables_priv AS SELECT * FROM mysql.tables_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_procs_priv AS SELECT * FROM mysql.procs_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_event AS SELECT definer FROM mysql.event WHERE name = 'e1'; +CREATE PROCEDURE p1() SELECT 1; +# bug48321_1-01234 has the max length(16) of user. +GRANT ALL PRIVILEGES ON *.* TO 'bug48321_1-01234'@'localhost' WITH GRANT OPTION; + +# Make sure the max lengths of user and host +# the user name is too lengh +GRANT CREATE USER ON *.* TO '01234567890123456'@'fakehost'; +ERROR HY000: String '01234567890123456' is too long for user name (should be no longer than 16) +# the host name is too lengh +GRANT CREATE USER ON *.* TO 'fakename'@'0123456789012345678901234567890123456789012345678901234567890'; +ERROR HY000: String '0123456789012345678901234567890123456789012345678901234567890' is too long for host name (should be no longer than 60) + +# User 'bug48321_1-01234' connects to master by conn1 +# [On conn1] +# Verify 'REVOKE ALL' statement +REVOKE ALL PRIVILEGES, GRANT OPTION FROM CURRENT_USER(); +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'GRANT ... ON TABLE ...' statement +GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'GRANT ... ON PROCEDURE...' statement +GRANT ALTER ROUTINE, EXECUTE ON PROCEDURE p1 TO CURRENT_USER(); +Comparing tables master:test.v_procs_priv and slave:test.v_procs_priv +Comparing tables master:test.v_procs_priv and slave2:test.v_procs_priv + +# Verify 'GRANT ... ON *.* ...' statement +GRANT ALL PRIVILEGES ON *.* TO CURRENT_USER() WITH GRANT OPTION; +Comparing tables master:test.v_procs_priv and slave:test.v_procs_priv +Comparing tables master:test.v_procs_priv and slave2:test.v_procs_priv + +# Verify 'REVOKE ... ON TABLE ...' statement +REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'REVOKE ... ON PROCEDURE...' statement +REVOKE ALTER ROUTINE, EXECUTE ON PROCEDURE p1 FROM CURRENT_USER(); +Comparing tables master:test.v_procs_priv and slave:test.v_procs_priv +Comparing tables master:test.v_procs_priv and slave2:test.v_procs_priv + +# Verify 'REVOKE ... ON *.* ...' statement +REVOKE ALL PRIVILEGES ON *.* FROM CURRENT_USER(); +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'GRANT ...' statement in the procedure +CREATE PROCEDURE my_grant() +GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +call my_grant; +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'REVOKE ... ON TABLE ...' statement in the procedure +CREATE PROCEDURE my_revoke() +REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +call my_revoke; +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'RENAME USER ...' statement +RENAME USER CURRENT_USER TO 'bug48321_2'@'localhost'; +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'DROP USER ...' statement +GRANT CREATE USER ON *.* TO 'bug48321_2'@'localhost'; +DROP USER CURRENT_USER(); +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'ALTER EVENT...' statement +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT * FROM t1; +# Explicitly assign CURRENT_USER() to definer +ALTER DEFINER=CURRENT_USER() EVENT e1 ENABLE; +Comparing tables master:test.v_event and slave:test.v_event +Comparing tables master:test.v_event and slave2:test.v_event + +# Session user will be set as definer, if the statement does not assign +# a definer +ALTER EVENT e1 ENABLE; +Comparing tables master:test.v_event and slave:test.v_event +Comparing tables master:test.v_event and slave2:test.v_event + +# Verify that this patch does not affect the calling of CURRENT_USER() +# in the other statements +# [On master] +INSERT INTO t1 VALUES(CURRENT_USER()), ('1234'); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +SELECT * FROM t1; +c1 +root@localhost +1234 +# [On slave] +SELECT * FROM t1; +c1 +@ +1234 +# [On slave2] +SELECT * FROM t1; +c1 +@ +1234 +# [On master] +UPDATE t1 SET c1=CURRENT_USER() WHERE c1='1234'; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +SELECT * FROM t1; +c1 +root@localhost +root@localhost +# [On slave] +SELECT * FROM t1; +c1 +@ +@ +# [On slave2] +SELECT * FROM t1; +c1 +@ +@ +# [On master] +DELETE FROM t1 WHERE c1=CURRENT_USER(); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +SELECT * FROM t1; +c1 +# [On slave] +SELECT * FROM t1; +c1 +# [On slave2] +SELECT * FROM t1; +c1 +# [On master] +CREATE TABLE t2(c1 char(100)); +CREATE FUNCTION my_user() RETURNS VARCHAR(64) +SQL SECURITY INVOKER +BEGIN +INSERT INTO t2 VALUES(CURRENT_USER()); +RETURN CURRENT_USER(); +END | +INSERT INTO t1 VALUES(my_user()); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +SELECT * FROM t1; +c1 +root@localhost +SELECT * FROM t2; +c1 +root@localhost +# [On slave] +SELECT * FROM t1; +c1 +@ +SELECT * FROM t2; +c1 +@ +# [On slave2] +SELECT * FROM t1; +c1 +@ +SELECT * FROM t2; +c1 +@ + +# END +DROP TABLE t1, t2; +DROP VIEW v_user, v_tables_priv, v_procs_priv, v_event; +DROP PROCEDURE p1; +DROP PROCEDURE my_grant; +DROP PROCEDURE my_revoke; +DROP FUNCTION my_user; +DROP EVENT e1; diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result index dd0a2d89d54..daef153cdef 100644 --- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result +++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result @@ -750,7 +750,7 @@ test_rpl e2 root@localhost SYSTEM RECURRING NULL 1 # # NULL ENABLED 1 latin1 lat USE test_rpl; SHOW EVENTS; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -test_rpl e2 @ SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +test_rpl e2 root@localhost SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci ==========MASTER========== SELECT COUNT(*) FROM t1; COUNT(*) diff --git a/mysql-test/suite/rpl/t/rpl_current_user.cnf b/mysql-test/suite/rpl/t/rpl_current_user.cnf new file mode 100644 index 00000000000..999ee727a88 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_current_user.cnf @@ -0,0 +1,9 @@ +!include ../my.cnf + +[mysqld.3] +server-id=3 +log-bin=slave-bin + +[ENV] +SLAVE_MYPORT1= @mysqld.3.port +SLAVE_MYSOCK1= @mysqld.3.socket diff --git a/mysql-test/suite/rpl/t/rpl_current_user.test b/mysql-test/suite/rpl/t/rpl_current_user.test new file mode 100644 index 00000000000..79816ef6c95 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_current_user.test @@ -0,0 +1,239 @@ +############################################################################## +# BUG#48321 CURRENT_USER() incorrectly replicated for DROP/RENAME USER, +# REVOKE, GRANT, ALTER EVENT +# +# Calling CURRENT_USER() results into inconsistency between slave and master, +# as the slave SQL thread has different user with common users. +# +# After the patch for bug#48321, session's user will be written into query log +# event if CURRENT_USER() is called in 'DROP/RENAME USER', 'REVOKE', 'GRANT', +# 'ALTER EVENT'. +# +############################################################################## +source include/master-slave.inc; +source include/have_binlog_format_statement.inc; +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.*"); + +--echo +--echo # On slave2 +connect (slave2,127.0.0.1,root,,test,$SLAVE_MYPORT1,); +connection slave2; + +--echo # Connect slave2 to slave +--replace_result $SLAVE_MYPORT SLAVE_MYPORT; +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$SLAVE_MYPORT, + MASTER_LOG_FILE='slave-bin.000001', MASTER_USER='root'; +START SLAVE; +source include/wait_for_slave_to_start.inc; + +--echo +--echo # [On master] +connection master; +--disable_warnings +DROP VIEW IF EXISTS v_user; +DROP VIEW IF EXISTS v_tables_priv; +DROP VIEW IF EXISTS v_procs_priv; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS my_grant; +DROP PROCEDURE IF EXISTS my_revoke; +DROP FUNCTION IF EXISTS my_user; +DROP EVENT IF EXISTS e1; +--enable_warnings +CREATE TABLE t1(c1 char(100)); +CREATE VIEW test.v_user AS SELECT * FROM mysql.user WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_tables_priv AS SELECT * FROM mysql.tables_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_procs_priv AS SELECT * FROM mysql.procs_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_event AS SELECT definer FROM mysql.event WHERE name = 'e1'; +CREATE PROCEDURE p1() SELECT 1; +--echo # bug48321_1-01234 has the max length(16) of user. +GRANT ALL PRIVILEGES ON *.* TO 'bug48321_1-01234'@'localhost' WITH GRANT OPTION; + +--echo +--echo # Make sure the max lengths of user and host +--echo # the user name is too lengh +--error 1470 +GRANT CREATE USER ON *.* TO '01234567890123456'@'fakehost'; +--echo # the host name is too lengh +--error 1470 +GRANT CREATE USER ON *.* TO 'fakename'@'0123456789012345678901234567890123456789012345678901234567890'; + +--echo +--echo # User 'bug48321_1-01234' connects to master by conn1 +connect (conn1, 127.0.0.1, 'bug48321_1-01234'@'localhost',,); +connection conn1; +--echo # [On conn1] +--echo # Verify 'REVOKE ALL' statement +REVOKE ALL PRIVILEGES, GRANT OPTION FROM CURRENT_USER(); +let $diff_table= test.v_user; +let $diff_server_list= master, slave, slave2; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ... ON TABLE ...' statement +connection conn1; +GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ... ON PROCEDURE...' statement +connection conn1; +GRANT ALTER ROUTINE, EXECUTE ON PROCEDURE p1 TO CURRENT_USER(); +let $diff_table= test.v_procs_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ... ON *.* ...' statement +connection conn1; +GRANT ALL PRIVILEGES ON *.* TO CURRENT_USER() WITH GRANT OPTION; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON TABLE ...' statement +connection conn1; +REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON PROCEDURE...' statement +connection conn1; +REVOKE ALTER ROUTINE, EXECUTE ON PROCEDURE p1 FROM CURRENT_USER(); +let $diff_table= test.v_procs_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON *.* ...' statement +connection conn1; +REVOKE ALL PRIVILEGES ON *.* FROM CURRENT_USER(); +let $diff_table= test.v_user; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ...' statement in the procedure +connection conn1; +CREATE PROCEDURE my_grant() + GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +call my_grant; +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON TABLE ...' statement in the procedure +connection conn1; +CREATE PROCEDURE my_revoke() + REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +call my_revoke; +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'RENAME USER ...' statement +connection conn1; +RENAME USER CURRENT_USER TO 'bug48321_2'@'localhost'; +let $diff_table= test.v_user; +source include/rpl_diff_tables.inc; + +disconnect conn1; + +--echo +--echo # Verify 'DROP USER ...' statement +connection master; +GRANT CREATE USER ON *.* TO 'bug48321_2'@'localhost'; +connect (conn1, 127.0.0.1, 'bug48321_2'@'localhost',,); +connection conn1; +DROP USER CURRENT_USER(); +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'ALTER EVENT...' statement +connection master; +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT * FROM t1; + +--echo # Explicitly assign CURRENT_USER() to definer +ALTER DEFINER=CURRENT_USER() EVENT e1 ENABLE; +let $diff_table= test.v_event; +source include/rpl_diff_tables.inc; + +connection master; +--echo +--echo # Session user will be set as definer, if the statement does not assign +--echo # a definer +ALTER EVENT e1 ENABLE; +sync_slave_with_master; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify that this patch does not affect the calling of CURRENT_USER() +--echo # in the other statements +connection master; +--echo # [On master] +INSERT INTO t1 VALUES(CURRENT_USER()), ('1234'); +SELECT * FROM t1; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +--echo # [On slave2] +sync_slave_with_master slave2; +SELECT * FROM t1; + +connection master; +--echo # [On master] +UPDATE t1 SET c1=CURRENT_USER() WHERE c1='1234'; +SELECT * FROM t1; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +sync_slave_with_master slave2; +--echo # [On slave2] +SELECT * FROM t1; + +connection master; +--echo # [On master] +DELETE FROM t1 WHERE c1=CURRENT_USER(); +SELECT * FROM t1; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +sync_slave_with_master slave2; +--echo # [On slave2] +SELECT * FROM t1; + +connection master; +--echo # [On master] +CREATE TABLE t2(c1 char(100)); + +DELIMITER |; +CREATE FUNCTION my_user() RETURNS VARCHAR(64) + SQL SECURITY INVOKER +BEGIN + INSERT INTO t2 VALUES(CURRENT_USER()); + RETURN CURRENT_USER(); +END | +DELIMITER ;| + +INSERT INTO t1 VALUES(my_user()); +SELECT * FROM t1; +SELECT * FROM t2; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +SELECT * FROM t2; +sync_slave_with_master slave2; +--echo # [On slave2] +SELECT * FROM t1; +SELECT * FROM t2; + +--echo +--echo # END +connection master; +DROP TABLE t1, t2; +DROP VIEW v_user, v_tables_priv, v_procs_priv, v_event; +DROP PROCEDURE p1; +DROP PROCEDURE my_grant; +DROP PROCEDURE my_revoke; +DROP FUNCTION my_user; +DROP EVENT e1; +sync_slave_with_master; +sync_slave_with_master slave2; +source include/master-slave-end.inc; diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index 7a48a2e3231..f6edacfaa29 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -45,7 +45,6 @@ SHOW CREATE TABLE t1; SELECT * FROM t1; DROP TABLE t1; - --echo # --echo # Bug#42064: low memory crash when importing hex strings, in Item_hex_string::Item_hex_string --echo # @@ -60,6 +59,36 @@ SET SESSION debug=DEFAULT; DROP TABLE t1; +-- echo # +-- echo # Bug#41660: Sort-index_merge for non-first join table may require +-- echo # O(#scans) memory +-- echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); + +CREATE TABLE t2 (a INT, b INT, filler CHAR(100), KEY(a), KEY(b)); +INSERT INTO t2 SELECT 1000, 1000, 'filler' FROM t1 A, t1 B, t1 C; +INSERT INTO t2 VALUES (1, 1, 'data'); + +--echo # the example query uses LEFT JOIN only for the sake of being able to +--echo # demonstrate the issue with a very small dataset. (left outer join +--echo # disables the use of join buffering, so we get the second table +--echo # re-scanned for every record in the outer table. if we used inner join, +--echo # we would need to have thousands of records and/or more columns in both +--echo # tables so that the join buffer is filled and re-scans are triggered). + +SET SESSION debug = '+d,only_one_Unique_may_be_created'; + +--replace_column 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON ( t2.a < 10 OR t2.b < 10 ); +SELECT * FROM t1 LEFT JOIN t2 ON ( t2.a < 10 OR t2.b < 10 ); + +SET SESSION debug = DEFAULT; + +DROP TABLE t1, t2; + --echo # --echo # End of 5.1 tests --echo # diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 61ae812d874..6efeb2866e6 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -540,5 +540,20 @@ EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); DROP TABLE t1; --echo # +--echo # Bug#54477: Crash on IN / CASE with NULL arguments +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); + +SELECT 1 IN (NULL, a) FROM t1; + +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; + +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; + +DROP TABLE t1; + +--echo # --echo End of 5.1 tests diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index 741ea5533da..1204d04d9a0 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -112,5 +112,19 @@ select 'andre%' like 'andreÊ%' escape 'Ê'; # select _cp1251'andre%' like convert('andreÊ%' using cp1251) escape 'Ê'; -# -# End of 4.1 tests + +--echo End of 4.1 tests + + +--echo # +--echo # Bug #54575: crash when joining tables with unique set column +--echo # +CREATE TABLE t1(a SET('a') NOT NULL, UNIQUE KEY(a)); +CREATE TABLE t2(b INT PRIMARY KEY); +INSERT INTO t1 VALUES (); +INSERT INTO t2 VALUES (1), (2), (3); +SELECT 1 FROM t2 JOIN t1 ON 1 LIKE a GROUP BY a; +DROP TABLE t1, t2; + + +--echo End of 5.1 tests diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 65bf9518a5c..c808e747523 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -544,3 +544,24 @@ ORDER BY t1.f2; DROP TABLE t1,t2; --echo End of 5.0 tests + +--echo # +--echo # Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set +--echo # + +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1,'f'); + +CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1)); +INSERT INTO t2 VALUES (2,'m'); +INSERT INTO t2 VALUES (3,'m'); +INSERT INTO t2 VALUES (11,NULL); +INSERT INTO t2 VALUES (12,'k'); + +SELECT MAX(t1.f1) field1 +FROM t1 JOIN t2 ON t2.f2 LIKE 'x' +HAVING field1 < 7; + +DROP TABLE t1,t2; + +--echo End of 5.1 tests diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 456cacf2fe1..b7bc662864e 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1416,6 +1416,15 @@ DROP USER nonpriv; DROP TABLE db1.t1; DROP DATABASE db1; +--echo +--echo Bug#54422 query with = 'variables' +--echo + +CREATE TABLE variables(f1 INT); +SELECT COLUMN_DEFAULT, TABLE_NAME +FROM INFORMATION_SCHEMA.COLUMNS +WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'variables'; +DROP TABLE variables; --echo End of 5.1 tests. diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 27c4cc8a75c..06054d1990d 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -570,4 +570,36 @@ DROP TABLE t1; connection default; disconnect con1; + +--echo # +--echo # Bug #51876 : crash/memory underrun when loading data with ucs2 +--echo # and reverse() function +--echo # + +--echo # Problem # 1 (original report): wrong parsing of ucs2 data +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +--echo # should return 2 zeroes (as the value is truncated) +SELECT * FROM t1; + +DROP TABLE t1; +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/tmpp.txt; + + +--echo # Problem # 2 : if you write and read ucs2 data to a file they're lost +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +--echo # should return 0 and 1 (10 reversed) +SELECT * FROM t1; + +DROP TABLE t1; +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/tmpp2.txt; + + --echo End of 5.1 tests diff --git a/mysql-test/t/lowercase_view.test b/mysql-test/t/lowercase_view.test index d6612b3e6b9..52be911cde0 100644 --- a/mysql-test/t/lowercase_view.test +++ b/mysql-test/t/lowercase_view.test @@ -160,4 +160,26 @@ SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; + +--echo End of 5.0 tests. + + +--echo # +--echo # Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS +--echo # returns nothing +--echo # + +CREATE TABLE `ttt` ( + `f1` char(3) NOT NULL, + PRIMARY KEY (`f1`) +) ENGINE=myisam DEFAULT CHARSET=latin1; + +SELECT count(COLUMN_NAME) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = +'TTT'; +SELECT count(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TTT'; + +DROP TABLE `ttt`; + + --echo End of 5.0 tests. + diff --git a/mysql-test/t/mysql_delimiter_19799.sql b/mysql-test/t/mysql_delimiter_19799.sql index 2a3d4378492..2a3d4378492 100755..100644 --- a/mysql-test/t/mysql_delimiter_19799.sql +++ b/mysql-test/t/mysql_delimiter_19799.sql diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 83d97954222..3ea612d2ca7 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -108,6 +108,23 @@ DROP PROCEDURE testproc; --cat_file $MYSQLTEST_VARDIR/tmp/41569.txt --remove_file $MYSQLTEST_VARDIR/tmp/41569.txt + +--echo # +--echo # Bug #53613: mysql_upgrade incorrectly revokes +--echo # TRIGGER privilege on given table +--echo # + +GRANT USAGE ON *.* TO 'user3'@'%'; +GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'; +--echo Run mysql_upgrade with all privileges on a user +--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +SHOW GRANTS FOR 'user3'@'%'; + +DROP USER 'user3'@'%'; + +--echo End of 5.1 tests + + # # Test the --upgrade-system-tables option # diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 6f2d34459eb..495b6002986 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4117,6 +4117,17 @@ SELECT * FROM t1 WHERE 102 < c; DROP TABLE t1; +--echo # +--echo # Bug #54459: Assertion failed: param.sort_length, +--echo # file .\filesort.cc, line 149 (part II) +--echo # +CREATE TABLE t1(a ENUM('') NOT NULL); +INSERT INTO t1 VALUES (), (), (); +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +DROP TABLE t1; + + --echo End of 5.1 tests --echo # diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 06aaf5dfb7f..2e442e7f897 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3921,3 +3921,28 @@ GROUP BY DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; + + +--echo # +--echo # Bug #52711: Segfault when doing EXPLAIN SELECT with +--echo # union...order by (select... where...) +--echo # + +CREATE TABLE t1 (a VARCHAR(10), FULLTEXT KEY a (a)); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); + +--echo # Should not crash +--disable_result_log +EXPLAIN +SELECT * FROM t2 UNION SELECT * FROM t2 + ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); + +--echo # Should not crash +SELECT * FROM t2 UNION SELECT * FROM t2 + ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +DROP TABLE t1,t2; +--enable_result_log + +--echo End of 5.1 tests diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index b7d31948d23..b7d31948d23 100755..100644 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 83615c82e2a..83615c82e2a 100755..100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c index 07851ab6e92..9350babc176 100644 --- a/mysys/mf_loadpath.c +++ b/mysys/mf_loadpath.c @@ -42,7 +42,7 @@ char * my_load_path(char * to, const char *path, if (is_cur) is_cur=2; /* Remove current dir */ if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)+is_cur),MYF(0))) - (void) strncat(buff, path+is_cur, FN_REFLEN); + (void) strncat(buff, path+is_cur, FN_REFLEN-1); else (void) strnmov(buff, path, FN_REFLEN); /* Return org file name */ } diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index e418d329db8..c6e6a3a429e 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -47,7 +47,7 @@ void pack_dirname(char * to, const char *from) buff_length= strlen(buff); d_length= (size_t) (start-to); if ((start == to || - (buff_length == d_length && !bcmp(buff,start,d_length))) && + (buff_length == d_length && !memcmp(buff,start,d_length))) && *start != FN_LIBCHAR && *start) { /* Put current dir before */ bchange((uchar*) to, d_length, (uchar*) buff, buff_length, strlen(to)+1); @@ -65,7 +65,7 @@ void pack_dirname(char * to, const char *from) } if (length > 1 && length < d_length) { /* test if /xx/yy -> ~/yy */ - if (bcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR) + if (memcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR) { to[0]=FN_HOMELIB; /* Filename begins with ~ */ (void) strmov_overlapp(to+1,to+length); @@ -75,7 +75,7 @@ void pack_dirname(char * to, const char *from) { /* Test if cwd is ~/... */ if (length > 1 && length < buff_length) { - if (bcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR) + if (memcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR) { buff[0]=FN_HOMELIB; (void) strmov_overlapp(buff+1,buff+length); @@ -161,7 +161,7 @@ size_t cleanup_dirname(register char *to, const char *from) *pos = FN_LIBCHAR; if (*pos == FN_LIBCHAR) { - if ((size_t) (pos-start) > length && bcmp(pos-length,parent,length) == 0) + if ((size_t) (pos-start) > length && memcmp(pos-length,parent,length) == 0) { /* If .../../; skip prev */ pos-=length; if (pos != start) @@ -192,7 +192,7 @@ size_t cleanup_dirname(register char *to, const char *from) end_parentdir=pos; while (pos >= start && *pos != FN_LIBCHAR) /* remove prev dir */ pos--; - if (pos[1] == FN_HOMELIB || bcmp(pos,parent,length) == 0) + if (pos[1] == FN_HOMELIB || memcmp(pos,parent,length) == 0) { /* Don't remove ~user/ */ pos=strmov(end_parentdir+1,parent); *pos=FN_LIBCHAR; @@ -201,7 +201,7 @@ size_t cleanup_dirname(register char *to, const char *from) } } else if ((size_t) (pos-start) == length-1 && - !bcmp(start,parent+1,length-1)) + !memcmp(start,parent+1,length-1)) start=pos; /* Starts with "../" */ else if (pos-start > 0 && pos[-1] == FN_LIBCHAR) { diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 25d2f3fda30..3de05fa8664 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -508,10 +508,8 @@ uint bitmap_get_first_set(const MY_BITMAP *map) if (*byte_ptr & (1 << k)) return (i*32) + (j*8) + k; } - DBUG_ASSERT(0); } } - DBUG_ASSERT(0); } } return MY_BIT_NONE; @@ -534,7 +532,7 @@ uint bitmap_get_first(const MY_BITMAP *map) { byte_ptr= (uchar*)data_ptr; for (j=0; ; j++, byte_ptr++) - { + { if (*byte_ptr != 0xFF) { for (k=0; ; k++) @@ -542,10 +540,8 @@ uint bitmap_get_first(const MY_BITMAP *map) if (!(*byte_ptr & (1 << k))) return (i*32) + (j*8) + k; } - DBUG_ASSERT(0); } } - DBUG_ASSERT(0); } } return MY_BIT_NONE; diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index 87e6519cafe..9ca22f2201e 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -47,7 +47,7 @@ my_bool my_gethwaddr(uchar *to) uchar *buf, *next, *end, *addr; struct if_msghdr *ifm; struct sockaddr_dl *sdl; - int i, res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0}; + int res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0}; if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) goto err; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 807e07d4f06..7443405f97c 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -28,7 +28,7 @@ typedef void (*init_func_p)(const struct my_option *option, void *variable, static void default_reporter(enum loglevel level, const char *format, ...); my_error_reporter my_getopt_error_reporter= &default_reporter; -static int findopt(char *, uint, const struct my_option **, char **); +static int findopt(char *, uint, const struct my_option **, const char **); my_bool getopt_compare_strings(const char *, const char *, uint); static longlong getopt_ll(char *arg, const struct my_option *optp, int *err); static ulonglong getopt_ull(char *, const struct my_option *, int *); @@ -113,8 +113,8 @@ int handle_options(int *argc, char ***argv, uint opt_found, argvpos= 0, length; my_bool end_of_options= 0, must_be_var, set_maximum_value, option_is_loose; - char **pos, **pos_end, *optend, *UNINIT_VAR(prev_found), - *opt_str, key_name[FN_REFLEN]; + char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN]; + const char *UNINIT_VAR(prev_found); const struct my_option *optp; void *value; int error, i; @@ -185,7 +185,6 @@ int handle_options(int *argc, char ***argv, Find first the right option. Return error in case of an ambiguous, or unknown option */ - LINT_INIT(prev_found); optp= longopts; if (!(opt_found= findopt(opt_str, length, &optp, &prev_found))) { @@ -695,10 +694,10 @@ ret: static int findopt(char *optpat, uint length, const struct my_option **opt_res, - char **ffname) + const char **ffname) { uint count; - struct my_option *opt= (struct my_option *) *opt_res; + const struct my_option *opt= *opt_res; for (count= 0; opt->name; opt++) { @@ -709,8 +708,9 @@ static int findopt(char *optpat, uint length, return 1; if (!count) { + /* We only need to know one prev */ count= 1; - *ffname= (char *) opt->name; /* We only need to know one prev */ + *ffname= opt->name; } else if (strcmp(*ffname, opt->name)) { diff --git a/mysys/my_handler.c b/mysys/my_handler.c index 3f8af553db6..48d100f2d3f 100644 --- a/mysys/my_handler.c +++ b/mysys/my_handler.c @@ -269,7 +269,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); a+=a_length; b+=b_length; - break; } break; case HA_KEYTYPE_INT8: diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 555ac1cf990..9ca18eeaf1b 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -306,7 +306,7 @@ sig_handler process_alarm(int sig __attribute__((unused))) #if defined(MAIN) && !defined(__bsdi__) printf("thread_alarm in process_alarm\n"); fflush(stdout); #endif -#ifdef DONT_REMEMBER_SIGNAL +#ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY my_sigset(thr_client_alarm, process_alarm); /* int. thread system calls */ #endif return; @@ -325,7 +325,7 @@ sig_handler process_alarm(int sig __attribute__((unused))) #endif process_alarm_part2(sig); #ifndef USE_ALARM_THREAD -#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND) +#if defined(SIGNAL_HANDLER_RESET_ON_DELIVERY) && !defined(USE_ONE_SIGNAL_HAND) my_sigset(THR_SERVER_ALARM,process_alarm); #endif mysql_mutex_unlock(&LOCK_alarm); @@ -523,12 +523,12 @@ void thr_alarm_info(ALARM_INFO *info) */ -static sig_handler thread_alarm(int sig) +static sig_handler thread_alarm(int sig __attribute__((unused))) { #ifdef MAIN printf("thread_alarm\n"); fflush(stdout); #endif -#ifdef DONT_REMEMBER_SIGNAL +#ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY my_sigset(sig,thread_alarm); /* int. thread system calls */ #endif } @@ -797,7 +797,7 @@ static sig_handler print_signal_warning(int sig) { printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name()); fflush(stdout); -#ifdef DONT_REMEMBER_SIGNAL +#ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY my_sigset(sig,print_signal_warning); /* int. thread system calls */ #endif if (sig == SIGALRM) diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index cff1b9b9845..9d10ba1fb01 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -122,8 +122,7 @@ static int check_lock(struct st_lock_list *list, const char* lock_type, { THR_LOCK_DATA *data,**prev; uint count=0; - THR_LOCK_OWNER *first_owner; - LINT_INIT(first_owner); + THR_LOCK_OWNER *UNINIT_VAR(first_owner); prev= &list->data; if (list->data) diff --git a/plugin/daemon_example/Makefile.am b/plugin/daemon_example/Makefile.am index 75151bdd4d9..d60271521b3 100644 --- a/plugin/daemon_example/Makefile.am +++ b/plugin/daemon_example/Makefile.am @@ -28,14 +28,14 @@ EXTRA_LTLIBRARIES = libdaemon_example.la pkgplugin_LTLIBRARIES = @plugin_daemon_example_shared_target@ libdaemon_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices -libdaemon_example_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +libdaemon_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN libdaemon_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN libdaemon_example_la_SOURCES = daemon_example.cc EXTRA_LIBRARIES = libdaemon_example.a noinst_LIBRARIES = @plugin_daemon_example_static_target@ -libdaemon_example_a_CXXFLAGS = $(AM_CFLAGS) +libdaemon_example_a_CXXFLAGS = $(AM_CXXFLAGS) libdaemon_example_a_CFLAGS = $(AM_CFLAGS) libdaemon_example_a_SOURCES= daemon_example.cc EXTRA_DIST = CMakeLists.txt diff --git a/plugin/semisync/Makefile.am b/plugin/semisync/Makefile.am index 0022d600f57..ec1ecee46a2 100644 --- a/plugin/semisync/Makefile.am +++ b/plugin/semisync/Makefile.am @@ -26,12 +26,12 @@ noinst_HEADERS = semisync.h semisync_master.h semisync_slave.h pkgplugin_LTLIBRARIES = semisync_master.la semisync_slave.la semisync_master_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices -semisync_master_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +semisync_master_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_master_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_master_la_SOURCES = semisync.cc semisync_master.cc semisync_master_plugin.cc semisync_slave_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices -semisync_slave_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +semisync_slave_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_slave_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_slave_la_SOURCES = semisync.cc semisync_slave.cc semisync_slave_plugin.cc diff --git a/regex/CMakeLists.txt b/regex/CMakeLists.txt index 02132eefaad..02132eefaad 100755..100644 --- a/regex/CMakeLists.txt +++ b/regex/CMakeLists.txt diff --git a/regex/regcomp.c b/regex/regcomp.c index b203d4941e1..81c435ed552 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -690,7 +690,6 @@ register cset *cs; case '-': SETERROR(REG_ERANGE); return; /* NOTE RETURN */ - break; default: c = '\0'; break; @@ -1564,13 +1563,13 @@ struct parse *p; register struct re_guts *g; { register sop *scan; - sop *start; - register sop *newstart; + sop *UNINIT_VAR(start); + register sop *UNINIT_VAR(newstart); register sopno newlen; register sop s; register char *cp; register sopno i; - LINT_INIT(start); LINT_INIT(newstart); + /* avoid making error situations worse */ if (p->error != 0) return; diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 84472c3a5c3..84472c3a5c3 100755..100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt diff --git a/scripts/mysql_secure_installation.pl.in b/scripts/mysql_secure_installation.pl.in index 25339f9b916..0cd99267cdb 100755 --- a/scripts/mysql_secure_installation.pl.in +++ b/scripts/mysql_secure_installation.pl.in @@ -208,7 +208,7 @@ sub remove_anonymous_users { } sub remove_remote_root { - if (do_query("DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';")) { + if (do_query("DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');")) { print " ... Success!\n"; } else { print " ... Failed!\n"; diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index 25d6343ee2c..ed789677bf0 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -17,6 +17,7 @@ config=".my.cnf.$$" command=".mysql.$$" +mysql_client="" trap "interrupt" 2 @@ -37,10 +38,26 @@ prepare() { chmod 600 $config $command } +find_mysql_client() +{ + for n in ./bin/mysql mysql + do + $n --no-defaults --help > /dev/null 2>&1 + status=$? + if test $status -eq 0 + then + mysql_client=$n + return + fi + done + echo "Can't find a 'mysql' client in PATH or ./bin" + exit 1 +} + do_query() { echo "$1" >$command #sed 's,^,> ,' < $command # Debugging - mysql --defaults-file=$config <$command + $mysql_client --defaults-file=$config <$command return $? } @@ -147,7 +164,7 @@ remove_anonymous_users() { } remove_remote_root() { - do_query "DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';" + do_query "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');" if [ $? -eq 0 ]; then echo " ... Success!" else @@ -204,6 +221,7 @@ cleanup() { # The actual script starts here prepare +find_mysql_client set_echo_compat echo diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 3b6f0cccf20..2020971fb1a 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -69,7 +69,7 @@ ALTER TABLE tables_priv COLLATE utf8_general_ci DEFAULT '' NOT NULL, MODIFY Table_priv set('Select','Insert','Update','Delete','Create', 'Drop','Grant','References','Index','Alter', - 'Create View','Show view') + 'Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, COMMENT='Table privileges'; @@ -603,8 +603,6 @@ ALTER TABLE host MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAU ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; ALTER TABLE db MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; -ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL; - UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0; # diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 0a09e945022..ac6c2ace890 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -1024,30 +1024,21 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type) int my_time_to_str(const MYSQL_TIME *l_time, char *to) { uint extra_hours= 0; - return my_sprintf(to, (to, "%s%02u:%02u:%02u", - (l_time->neg ? "-" : ""), - extra_hours+ l_time->hour, - l_time->minute, - l_time->second)); + return sprintf(to, "%s%02u:%02u:%02u", (l_time->neg ? "-" : ""), + extra_hours+ l_time->hour, l_time->minute, l_time->second); } int my_date_to_str(const MYSQL_TIME *l_time, char *to) { - return my_sprintf(to, (to, "%04u-%02u-%02u", - l_time->year, - l_time->month, - l_time->day)); + return sprintf(to, "%04u-%02u-%02u", + l_time->year, l_time->month, l_time->day); } int my_datetime_to_str(const MYSQL_TIME *l_time, char *to) { - return my_sprintf(to, (to, "%04u-%02u-%02u %02u:%02u:%02u", - l_time->year, - l_time->month, - l_time->day, - l_time->hour, - l_time->minute, - l_time->second)); + return sprintf(to, "%04u-%02u-%02u %02u:%02u:%02u", + l_time->year, l_time->month, l_time->day, + l_time->hour, l_time->minute, l_time->second); } diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 7107a68ee84..7107a68ee84 100755..100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index aa4d376d86e..aa4d376d86e 100755..100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc diff --git a/sql/examples/CMakeLists.txt b/sql/examples/CMakeLists.txt index 3c5cc23ec3b..3c5cc23ec3b 100755..100644 --- a/sql/examples/CMakeLists.txt +++ b/sql/examples/CMakeLists.txt diff --git a/sql/field.cc b/sql/field.cc index bfaaf10b141..56d60ff5b28 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8280,7 +8280,13 @@ int Field_set::store(longlong nr, bool unsigned_val) { ASSERT_COLUMN_MARKED_FOR_WRITE; int error= 0; - ulonglong max_nr= set_bits(ulonglong, typelib->count); + ulonglong max_nr; + + if (sizeof(ulonglong)*8 <= typelib->count) + max_nr= ULONGLONG_MAX; + else + max_nr= (ULL(1) << typelib->count) - 1; + if ((ulonglong) nr > max_nr) { nr&= max_nr; @@ -10135,7 +10141,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, { /* DBL_DIG is enough to print '-[digits].E+###' */ char str_nr[DBL_DIG + 8]; - uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr)); + uint str_len= sprintf(str_nr, "%g", nr); make_truncated_value_warning(thd, level, str_nr, str_len, ts_type, field_name); } diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 90a4802082b..bd3cd780bc5 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4371,6 +4371,58 @@ int ha_partition::index_read_last_map(uchar *buf, const uchar *key, /* + Optimization of the default implementation to take advantage of dynamic + partition pruning. +*/ +int ha_partition::index_read_idx_map(uchar *buf, uint index, + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag) +{ + int error= HA_ERR_KEY_NOT_FOUND; + DBUG_ENTER("ha_partition::index_read_idx_map"); + + if (find_flag == HA_READ_KEY_EXACT) + { + uint part; + m_start_key.key= key; + m_start_key.keypart_map= keypart_map; + m_start_key.flag= find_flag; + m_start_key.length= calculate_key_len(table, index, m_start_key.key, + m_start_key.keypart_map); + + get_partition_set(table, buf, index, &m_start_key, &m_part_spec); + + /* How can it be more than one partition with the current use? */ + DBUG_ASSERT(m_part_spec.start_part == m_part_spec.end_part); + + for (part= m_part_spec.start_part; part <= m_part_spec.end_part; part++) + { + if (bitmap_is_set(&(m_part_info->used_partitions), part)) + { + error= m_file[part]->index_read_idx_map(buf, index, key, + keypart_map, find_flag); + if (error != HA_ERR_KEY_NOT_FOUND && + error != HA_ERR_END_OF_FILE) + break; + } + } + } + else + { + /* + If not only used with READ_EXACT, we should investigate if possible + to optimize for other find_flag's as well. + */ + DBUG_ASSERT(0); + /* fall back on the default implementation */ + error= handler::index_read_idx_map(buf, index, key, keypart_map, find_flag); + } + DBUG_RETURN(error); +} + + +/* Read next record in a forward index scan SYNOPSIS diff --git a/sql/ha_partition.h b/sql/ha_partition.h index eec3cb71537..cdbfb2163c7 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -36,8 +36,7 @@ enum partition_keywords HA_CAN_FULLTEXT | \ HA_DUPLICATE_POS | \ HA_CAN_SQL_HANDLER | \ - HA_CAN_INSERT_DELAYED | \ - HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) + HA_CAN_INSERT_DELAYED) class ha_partition :public handler { private: @@ -431,6 +430,15 @@ public: virtual int index_init(uint idx, bool sorted); virtual int index_end(); + /** + @breif + Positions an index cursor to the index specified in the hanlde. Fetches the + row if available. If the key value is null, begin at first key of the + index. + */ + virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag); /* These methods are used to jump to next or previous entry in the index scan. There are also methods to jump to first and last entry. @@ -749,9 +757,6 @@ public: HA_PRIMARY_KEY_REQUIRED_FOR_POSITION: Does the storage engine need a PK for position? - Used with hidden primary key in InnoDB. - Hidden primary keys cannot be supported by partitioning, since the - partitioning expressions columns must be a part of the primary key. (InnoDB) HA_FILE_BASED is always set for partition handler since we use a diff --git a/sql/handler.h b/sql/handler.h index 5e08ed23bef..96095798d18 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -100,7 +100,10 @@ #define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15) /* If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position() - uses a primary key. Without primary key, we can't call position(). + uses a primary key given by the record argument. + Without primary key, we can't call position(). + If not set, the position is returned as the current rows position + regardless of what argument is given. */ #define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) #define HA_CAN_RTREEKEYS (1 << 17) @@ -1533,10 +1536,9 @@ public: virtual int rnd_next(uchar *buf)=0; virtual int rnd_pos(uchar * buf, uchar *pos)=0; /** - One has to use this method when to find - random position by record as the plain - position() call doesn't work for some - handlers for random position. + This function only works for handlers having + HA_PRIMARY_KEY_REQUIRED_FOR_POSITION set. + It will return the row with the PK given in the record argument. */ virtual int rnd_pos_by_record(uchar *record) { @@ -1554,6 +1556,12 @@ public: { return HA_ERR_WRONG_COMMAND; } virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key) { return (ha_rows) 10; } + /* + If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, then it sets ref + (reference to the row, aka position, with the primary key given in + the record). + Otherwise it set ref to the current row. + */ virtual void position(const uchar *record)=0; virtual int info(uint)=0; // see my_base.h for full description virtual void get_dynamic_partition_info(PARTITION_STATS *stat_info, diff --git a/sql/item.cc b/sql/item.cc index 05363f41d07..13b4aa96c76 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4400,8 +4400,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) context->first_name_resolution_table, context->last_name_resolution_table, reference, REPORT_ALL_ERRORS, - !any_privileges && - TRUE, TRUE); + !any_privileges, TRUE); } return -1; } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 3c871bc0663..d31799d7e60 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2777,6 +2777,8 @@ Item *Item_func_case::find_item(String *str) /* Compare every WHEN argument with it and return the first match */ for (uint i=0 ; i < ncases ; i+=2) { + if (args[i]->real_item()->type() == NULL_ITEM) + continue; cmp_type= item_cmp_type(left_result_type, args[i]->result_type()); DBUG_ASSERT(cmp_type != ROW_RESULT); DBUG_ASSERT(cmp_items[(uint)cmp_type]); @@ -4007,9 +4009,17 @@ longlong Item_func_in::val_int() return (longlong) (!null_value && tmp != negated); } + if ((null_value= args[0]->real_item()->type() == NULL_ITEM)) + return 0; + have_null= 0; for (uint i= 1 ; i < arg_count ; i++) { + if (args[i]->real_item()->type() == NULL_ITEM) + { + have_null= TRUE; + continue; + } Item_result cmp_type= item_cmp_type(left_result_type, args[i]->result_type()); in_item= cmp_items[(uint)cmp_type]; DBUG_ASSERT(in_item); @@ -4571,13 +4581,14 @@ Item_func::optimize_type Item_func_like::select_optimize() const if (args[1]->const_item()) { String* res2= args[1]->val_str((String *)&cmp.value2); + const char *ptr2; - if (!res2) + if (!res2 || !(ptr2= res2->ptr())) return OPTIMIZE_NONE; - if (*res2->ptr() != wild_many) + if (*ptr2 != wild_many) { - if (args[0]->result_type() != STRING_RESULT || *res2->ptr() != wild_one) + if (args[0]->result_type() != STRING_RESULT || *ptr2 != wild_one) return OPTIMIZE_OP; } } diff --git a/sql/item_create.cc b/sql/item_create.cc index 5f30a10d1e0..672e59986d5 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -5131,8 +5131,6 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, CHARSET_INFO *cs) { Item *UNINIT_VAR(res); - ulong len; - uint dec; switch (cast_type) { case ITEM_CAST_BINARY: @@ -5155,11 +5153,10 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, break; case ITEM_CAST_DECIMAL: { - if (c_len == NULL) - { - len= 0; - } - else + ulong len= 0; + uint dec= 0; + + if (c_len) { ulong decoded_size; errno= 0; @@ -5173,11 +5170,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, len= decoded_size; } - if (c_dec == NULL) - { - dec= 0; - } - else + if (c_dec) { ulong decoded_size; errno= 0; @@ -5213,12 +5206,9 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, } case ITEM_CAST_CHAR: { + int len= -1; CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection); - if (c_len == NULL) - { - len= LL(-1); - } - else + if (c_len) { ulong decoded_size; errno= 0; @@ -5228,7 +5218,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), "cast as char", MAX_FIELD_BLOBLENGTH); return NULL; } - len= decoded_size; + len= (int) decoded_size; } res= new (thd->mem_root) Item_char_typecast(a, len, real_cs); break; diff --git a/sql/item_func.cc b/sql/item_func.cc index 2d5848e314e..833eac6893b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5069,6 +5069,7 @@ bool Item_func_get_user_var::set_value(THD *thd, bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); + DBUG_ASSERT(thd->lex->exchange); if (Item::fix_fields(thd, ref) || !(entry= get_variable(&thd->user_vars, name, 1))) return TRUE; @@ -5078,7 +5079,9 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) of fields in LOAD DATA INFILE. (Since Item_user_var_as_out_param is used only there). */ - entry->collation.set(thd->variables.collation_database); + entry->collation.set(thd->lex->exchange->cs ? + thd->lex->exchange->cs : + thd->variables.collation_database); entry->update_query_id= thd->query_id; return FALSE; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index feff03e704a..1c2c1cfe512 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -775,13 +775,11 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, str->append(hours_i < 12 ? "AM" : "PM",2); break; case 'r': - length= my_sprintf(intbuff, - (intbuff, - ((l_time->hour % 24) < 12) ? - "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM", - (l_time->hour+11)%12+1, - l_time->minute, - l_time->second)); + length= sprintf(intbuff, ((l_time->hour % 24) < 12) ? + "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM", + (l_time->hour+11)%12+1, + l_time->minute, + l_time->second); str->append(intbuff, length); break; case 'S': @@ -790,12 +788,8 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, str->append_with_prefill(intbuff, length, 2, '0'); break; case 'T': - length= my_sprintf(intbuff, - (intbuff, - "%02d:%02d:%02d", - l_time->hour, - l_time->minute, - l_time->second)); + length= sprintf(intbuff, "%02d:%02d:%02d", + l_time->hour, l_time->minute, l_time->second); str->append(intbuff, length); break; case 'U': @@ -3057,12 +3051,12 @@ String *Item_func_maketime::val_str(String *str) char buf[28]; char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10); int len = (int)(ptr - buf) + - my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second)); + sprintf(ptr, ":%02u:%02u", (uint) minute, (uint) second); make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, buf, len, MYSQL_TIMESTAMP_TIME, NullS); } - + if (make_time_with_warn((DATE_TIME_FORMAT *) 0, <ime, str)) { null_value= 1; diff --git a/sql/log.cc b/sql/log.cc index 521cedffc81..b398cb1e73f 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2076,7 +2076,7 @@ static int find_uniq_filename(char *name) file_info= dir_info->dir_entry; for (i= dir_info->number_off_files ; i-- ; file_info++) { - if (bcmp((uchar*) file_info->name, (uchar*) start, length) == 0 && + if (memcmp(file_info->name, start, length) == 0 && test_if_number(file_info->name+length, &number,0)) { set_if_bigger(max_found,(ulong) number); diff --git a/sql/log_event.cc b/sql/log_event.cc index 52275a4b6bd..5236a2794cf 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1654,17 +1654,17 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr, int i, end; char buff[512], *pos; pos= buff; - pos+= my_sprintf(buff, (buff, "%s", dec.sign() ? "-" : "")); + pos+= sprintf(buff, "%s", dec.sign() ? "-" : ""); end= ROUND_UP(dec.frac) + ROUND_UP(dec.intg)-1; for (i=0; i < end; i++) - pos+= my_sprintf(pos, (pos, "%09d.", dec.buf[i])); - pos+= my_sprintf(pos, (pos, "%09d", dec.buf[i])); + pos+= sprintf(pos, "%09d.", dec.buf[i]); + pos+= sprintf(pos, "%09d", dec.buf[i]); my_b_printf(file, "%s", buff); my_snprintf(typestr, typestr_length, "DECIMAL(%d,%d)", precision, decimals); return bin_size; } - + case MYSQL_TYPE_FLOAT: { float fl; @@ -2324,6 +2324,53 @@ bool Query_log_event::write(IO_CACHE* file) start+= 4; } + if (thd && thd->is_current_user_used()) + { + LEX_STRING user; + LEX_STRING host; + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); + + if (thd->slave_thread && thd->has_invoker()) + { + /* user will be null, if master is older than this patch */ + user= thd->get_invoker_user(); + host= thd->get_invoker_host(); + } + else if (thd->security_ctx->priv_user) + { + Security_context *ctx= thd->security_ctx; + + user.length= strlen(ctx->priv_user); + user.str= ctx->priv_user; + if (ctx->priv_host[0] != '\0') + { + host.str= ctx->priv_host; + host.length= strlen(ctx->priv_host); + } + } + + if (user.length > 0) + { + *start++= Q_INVOKER; + + /* + Store user length and user. The max length of use is 16, so 1 byte is + enough to store the user's length. + */ + *start++= (uchar)user.length; + memcpy(start, user.str, user.length); + start+= user.length; + + /* + Store host length and host. The max length of host is 60, so 1 byte is + enough to store the host's length. + */ + *start++= (uchar)host.length; + memcpy(start, host.str, host.length); + start+= host.length; + } + } /* NOTE: When adding new status vars, please don't forget to update the MAX_SIZE_LOG_EVENT_STATUS in log_event.h and update the function @@ -2366,6 +2413,8 @@ bool Query_log_event::write(IO_CACHE* file) Query_log_event::Query_log_event() :Log_event(), data_buf(0) { + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); } @@ -2408,6 +2457,9 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, { time_t end_time; + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); + error_code= errcode; time(&end_time); @@ -2654,6 +2706,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, bool catalog_nz= 1; DBUG_ENTER("Query_log_event::Query_log_event(char*,...)"); + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); common_header_len= description_event->common_header_len; post_header_len= description_event->post_header_len[event_type-1]; DBUG_PRINT("info",("event_len: %u common_header_len: %d post_header_len: %d", @@ -2808,6 +2862,20 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, data_written= master_data_written= uint4korr(pos); pos+= 4; break; + case Q_INVOKER: + { + CHECK_SPACE(pos, end, 1); + user.length= *pos++; + CHECK_SPACE(pos, end, user.length); + user.str= (char *)pos; + pos+= user.length; + + CHECK_SPACE(pos, end, 1); + host.length= *pos++; + CHECK_SPACE(pos, end, host.length); + host.str= (char *)pos; + pos+= host.length; + } default: /* That's why you must write status vars in growing order of code */ DBUG_PRINT("info",("Query_log_event has unknown status vars (first has\ @@ -2821,12 +2889,16 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, time_zone_len + 1 + data_len + 1 + QUERY_CACHE_FLAGS_SIZE + + user.length + 1 + + host.length + 1 + db_len + 1, MYF(MY_WME)))) #else if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1 + time_zone_len + 1 + - data_len + 1, + data_len + 1 + + user.length + 1 + + host.length + 1, MYF(MY_WME)))) #endif DBUG_VOID_RETURN; @@ -2849,6 +2921,11 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, if (time_zone_len) copy_str_and_move(&time_zone_str, &start, time_zone_len); + if (user.length > 0) + copy_str_and_move((const char **)&(user.str), &start, user.length); + if (host.length > 0) + copy_str_and_move((const char **)&(host.str), &start, host.length); + /** if time_zone_len or catalog_len are 0, then time_zone and catalog are uninitialized at this point. shouldn't they point to the @@ -2984,7 +3061,7 @@ void Query_log_event::print_query_header(IO_CACHE* file, if (likely(charset_inited) && (unlikely(!print_event_info->charset_inited || - bcmp((uchar*) print_event_info->charset, (uchar*) charset, 6)))) + memcmp(print_event_info->charset, charset, 6)))) { CHARSET_INFO *cs_info= get_charset(uint2korr(charset), MYF(MY_WME)); if (cs_info) @@ -3007,8 +3084,8 @@ void Query_log_event::print_query_header(IO_CACHE* file, } if (time_zone_len) { - if (bcmp((uchar*) print_event_info->time_zone_str, - (uchar*) time_zone_str, time_zone_len+1)) + if (memcmp(print_event_info->time_zone_str, + time_zone_str, time_zone_len+1)) { my_b_printf(file,"SET @@session.time_zone='%s'%s\n", time_zone_str, print_event_info->delimiter); @@ -3254,7 +3331,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, thd->variables.collation_database= thd->db_charset; thd->table_map_for_update= (table_map)table_map_for_update; - + thd->set_invoker(&user, &host); /* Execute the query (note that we bypass dispatch_command()) */ Parser_state parser_state; if (!parser_state.init(thd, thd->query(), thd->query_length())) @@ -5713,7 +5790,7 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) double real_val; char real_buf[FMT_G_BUFSIZE(14)]; float8get(real_val, val); - my_sprintf(real_buf, (real_buf, "%.14g", real_val)); + sprintf(real_buf, "%.14g", real_val); my_b_printf(&cache, ":=%s%s\n", real_buf, print_event_info->delimiter); break; case INT_RESULT: @@ -6472,10 +6549,9 @@ void Append_block_log_event::print(FILE* file, void Append_block_log_event::pack_info(Protocol *protocol) { char buf[256]; - uint length; - length= (uint) my_sprintf(buf, - (buf, ";file_id=%u;block_len=%u", file_id, - block_len)); + size_t length; + length= my_snprintf(buf, sizeof(buf), ";file_id=%u;block_len=%u", + file_id, block_len); protocol->store(buf, length, &my_charset_bin); } @@ -6630,9 +6706,9 @@ void Delete_file_log_event::print(FILE* file, void Delete_file_log_event::pack_info(Protocol *protocol) { char buf[64]; - uint length; - length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); - protocol->store(buf, (int32) length, &my_charset_bin); + size_t length; + length= my_snprintf(buf, sizeof(buf), ";file_id=%u", (uint) file_id); + protocol->store(buf, length, &my_charset_bin); } #endif @@ -6728,9 +6804,9 @@ void Execute_load_log_event::print(FILE* file, void Execute_load_log_event::pack_info(Protocol *protocol) { char buf[64]; - uint length; - length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); - protocol->store(buf, (int32) length, &my_charset_bin); + size_t length; + length= my_snprintf(buf, sizeof(buf), ";file_id=%u", (uint) file_id); + protocol->store(buf, length, &my_charset_bin); } @@ -8656,7 +8732,7 @@ Rows_log_event::write_row(const Relay_log_info *const rli, TABLE *table= m_table; // pointer to event's table int error; - int keynum; + int UNINIT_VAR(keynum); auto_afree_ptr<char> key(NULL); /* fill table->record[0] with default values */ @@ -8850,19 +8926,19 @@ Rows_log_event::write_row(const Relay_log_info *const rli, #endif -int +int Write_rows_log_event::do_exec_row(const Relay_log_info *const rli) { DBUG_ASSERT(m_table != NULL); int error= write_row(rli, slave_exec_mode == SLAVE_EXEC_MODE_IDEMPOTENT); - + if (error && !thd->is_error()) { DBUG_ASSERT(0); my_error(ER_UNKNOWN_ERROR, MYF(0)); } - - return error; + + return error; } #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ diff --git a/sql/log_event.h b/sql/log_event.h index 0119b11cc23..5d7250d8ebd 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -270,7 +270,8 @@ struct sql_ex_info 1 + 2 /* type, lc_time_names_number */ + \ 1 + 2 /* type, charset_database_number */ + \ 1 + 8 /* type, table_map_for_update */ + \ - 1 + 4 /* type, master_data_written */) + 1 + 4 /* type, master_data_written */ + \ + 1 + 16 + 1 + 60/* type, user_len, user, host_len, host */) #define MAX_LOG_EVENT_HEADER ( /* in order of Query_log_event::write */ \ LOG_EVENT_HEADER_LEN + /* write_header */ \ QUERY_HEADER_LEN + /* write_data */ \ @@ -339,6 +340,8 @@ struct sql_ex_info #define Q_MASTER_DATA_WRITTEN_CODE 10 +#define Q_INVOKER 11 + /* Intvar event post-header */ /* Intvar event data */ @@ -1610,6 +1613,8 @@ protected: */ class Query_log_event: public Log_event { + LEX_STRING user; + LEX_STRING host; protected: Log_event::Byte* data_buf; public: diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 9263578e0b5..88df4970816 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -418,7 +418,7 @@ copy_extra_record_fields(TABLE *table, DBUG_ASSERT(master_reclength <= table->s->reclength); if (master_reclength < table->s->reclength) - bmove_align(table->record[0] + master_reclength, + memcpy(table->record[0] + master_reclength, table->record[1] + master_reclength, table->s->reclength - master_reclength); @@ -697,7 +697,7 @@ static int find_and_fetch_row(TABLE *table, uchar *key) rnd_pos() returns the record in table->record[0], so we have to move it to table->record[1]. */ - bmove_align(table->record[1], table->record[0], table->s->reclength); + memcpy(table->record[1], table->record[0], table->s->reclength); DBUG_RETURN(error); } @@ -1190,7 +1190,7 @@ int Update_rows_log_event_old::do_exec_row(TABLE *table) overwriting the default values that where put there by the unpack_row() function. */ - bmove_align(table->record[0], m_after_image, table->s->reclength); + memcpy(table->record[0], m_after_image, table->s->reclength); copy_extra_record_fields(table, m_master_reclength, m_width); /* diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 68f9b582dd2..8a31cec6721 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -305,12 +305,12 @@ print_decimal(const my_decimal *dec) int i, end; char buff[512], *pos; pos= buff; - pos+= my_sprintf(buff, (buff, "Decimal: sign: %d intg: %d frac: %d { ", - dec->sign(), dec->intg, dec->frac)); + pos+= sprintf(buff, "Decimal: sign: %d intg: %d frac: %d { ", + dec->sign(), dec->intg, dec->frac); end= ROUND_UP(dec->frac)+ROUND_UP(dec->intg)-1; for (i=0; i < end; i++) - pos+= my_sprintf(pos, (pos, "%09d, ", dec->buf[i])); - pos+= my_sprintf(pos, (pos, "%09d }\n", dec->buf[i])); + pos+= sprintf(pos, "%09d, ", dec->buf[i]); + pos+= sprintf(pos, "%09d }\n", dec->buf[i]); fputs(buff, DBUG_FILE); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ddc5c17ba4b..367d488a22c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1323,7 +1323,7 @@ extern "C" sig_handler print_signal_warning(int sig) { if (global_system_variables.log_warnings) sql_print_warning("Got signal %d from thread %ld", sig,my_thread_id()); -#ifdef DONT_REMEMBER_SIGNAL +#ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY my_sigset(sig,print_signal_warning); /* int. thread system calls */ #endif #if !defined(__WIN__) @@ -2346,7 +2346,6 @@ extern "C" sig_handler handle_segfault(int sig) { time_t curr_time; struct tm tm; - THD *thd=current_thd; /* Strictly speaking, one needs a mutex here @@ -2406,13 +2405,15 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n", #endif /* HAVE_LINUXTHREADS */ #ifdef HAVE_STACKTRACE + THD *thd=current_thd; + if (!(test_flags & TEST_NO_STACKTRACE)) { - fprintf(stderr,"thd: 0x%lx\n",(long) thd); - fprintf(stderr,"\ -Attempting backtrace. You can use the following information to find out\n\ -where mysqld died. If you see no messages after this, something went\n\ -terribly wrong...\n"); + fprintf(stderr, "thd: 0x%lx\n",(long) thd); + fprintf(stderr, "Attempting backtrace. You can use the following " + "information to find out\nwhere mysqld died. If " + "you see no messages after this, something went\n" + "terribly wrong...\n"); my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL, my_thread_stack_size); } @@ -6109,7 +6110,7 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff) { var->type= SHOW_CHAR; var->value= buff; - my_sprintf(buff, (buff, "%.3f",active_mi->heartbeat_period)); + sprintf(buff, "%.3f", active_mi->heartbeat_period); } else var->type= SHOW_UNDEF; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 48235ba588a..af5b4b7c7d6 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1227,7 +1227,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() QUICK_INDEX_MERGE_SELECT::QUICK_INDEX_MERGE_SELECT(THD *thd_param, TABLE *table) - :pk_quick_select(NULL), thd(thd_param) + :unique(NULL), pk_quick_select(NULL), thd(thd_param) { DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::QUICK_INDEX_MERGE_SELECT"); index= MAX_KEY; @@ -1269,6 +1269,7 @@ QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT() List_iterator_fast<QUICK_RANGE_SELECT> quick_it(quick_selects); QUICK_RANGE_SELECT* quick; DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT"); + delete unique; quick_it.rewind(); while ((quick= quick_it++)) quick->file= NULL; @@ -7716,7 +7717,7 @@ check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree, if (unlikely(param->thd->killed != 0)) return HA_POS_ERROR; - + keynr=param->real_keynr[idx]; param->range_count++; if (!tmp_min_flag && ! tmp_max_flag && @@ -8252,7 +8253,6 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() List_iterator_fast<QUICK_RANGE_SELECT> cur_quick_it(quick_selects); QUICK_RANGE_SELECT* cur_quick; int result; - Unique *unique; handler *file= head->file; DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::read_keys_and_merge"); @@ -8271,9 +8271,22 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() if (cur_quick->init() || cur_quick->reset()) DBUG_RETURN(1); - unique= new Unique(refpos_order_cmp, (void *)file, - file->ref_length, - thd->variables.sortbuff_size); + if (unique == NULL) + { + DBUG_EXECUTE_IF("index_merge_may_not_create_a_Unique", abort(); ); + DBUG_EXECUTE_IF("only_one_Unique_may_be_created", + DBUG_SET("+d,index_merge_may_not_create_a_Unique"); ); + + unique= new Unique(refpos_order_cmp, (void *)file, + file->ref_length, + thd->variables.sortbuff_size); + } + else + unique->reset(); + + DBUG_ASSERT(file->ref_length == unique->get_size()); + DBUG_ASSERT(thd->variables.sortbuff_size == unique->get_max_in_memory_size()); + if (!unique) DBUG_RETURN(1); for (;;) @@ -8288,10 +8301,7 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() if (cur_quick->file->inited != handler::NONE) cur_quick->file->ha_index_end(); if (cur_quick->init() || cur_quick->reset()) - { - delete unique; DBUG_RETURN(1); - } } if (result) @@ -8299,17 +8309,13 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() if (result != HA_ERR_END_OF_FILE) { cur_quick->range_end(); - delete unique; DBUG_RETURN(result); } break; } if (thd->killed) - { - delete unique; DBUG_RETURN(1); - } /* skip row if it will be retrieved by clustered PK scan */ if (pk_quick_select && pk_quick_select->row_in_ranges()) @@ -8318,10 +8324,7 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() cur_quick->file->position(cur_quick->record); result= unique->unique_add((char*)cur_quick->file->ref); if (result) - { - delete unique; DBUG_RETURN(1); - } } /* @@ -8330,7 +8333,6 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() sequence. */ result= unique->get(head); - delete unique; doing_pk_scan= FALSE; /* index_merge currently doesn't support "using index" at all */ head->set_keyread(FALSE); @@ -8448,6 +8450,7 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() if ((error= quick->get_next())) DBUG_RETURN(error); } + quick->file->position(quick->record); } memcpy(last_rowid, quick->file->ref, head->file->ref_length); last_rowid_count= 1; @@ -10425,7 +10428,7 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg, ha_rows records_arg, uint key_infix_len_arg, uchar *key_infix_arg, MEM_ROOT *parent_alloc, bool is_index_scan_arg) - :join(join_arg), index_info(index_info_arg), + :file(table->file), join(join_arg), index_info(index_info_arg), group_prefix_len(group_prefix_len_arg), group_key_parts(group_key_parts_arg), have_min(have_min_arg), have_max(have_max_arg), have_agg_distinct(have_agg_distinct_arg), @@ -10435,7 +10438,6 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg, is_index_scan(is_index_scan_arg) { head= table; - file= head->file; index= use_index; record= head->record[0]; tmp_record= head->record[1]; diff --git a/sql/opt_range.h b/sql/opt_range.h index 7f05bdb64f0..0d4000002b0 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -520,6 +520,7 @@ public: class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I { + Unique *unique; public: QUICK_INDEX_MERGE_SELECT(THD *thd, TABLE *table); ~QUICK_INDEX_MERGE_SELECT(); @@ -703,7 +704,7 @@ private: class QUICK_GROUP_MIN_MAX_SELECT : public QUICK_SELECT_I { private: - handler *file; /* The handler used to get data. */ + handler * const file; /* The handler used to get data. */ JOIN *join; /* Descriptor of the current query */ KEY *index_info; /* The index chosen for data access */ uchar *record; /* Buffer where the next record is returned. */ diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 5b0b681c3a6..43934551016 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -109,8 +109,8 @@ char *partition_info::create_default_partition_names(uint part_no, { do { - my_sprintf(move_ptr, (move_ptr,"p%u", (start_no + i))); - move_ptr+=MAX_PART_NAME_SIZE; + sprintf(move_ptr, "p%u", (start_no + i)); + move_ptr+= MAX_PART_NAME_SIZE; } while (++i < num_parts_arg); } else @@ -177,7 +177,7 @@ char *partition_info::create_subpartition_name(uint subpart_no, if (likely(ptr != NULL)) { - my_sprintf(ptr, (ptr, "%ssp%u", part_name, subpart_no)); + my_snprintf(ptr, size_alloc, "%ssp%u", part_name, subpart_no); } else { diff --git a/sql/protocol.cc b/sql/protocol.cc index ac78ac88ec6..3f957dcc2de 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1166,16 +1166,12 @@ bool Protocol_text::store(MYSQL_TIME *tm) #endif char buff[40]; uint length; - length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d", - (int) tm->year, - (int) tm->month, - (int) tm->day, - (int) tm->hour, - (int) tm->minute, - (int) tm->second)); + length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d", + (int) tm->year, (int) tm->month, + (int) tm->day, (int) tm->hour, + (int) tm->minute, (int) tm->second); if (tm->second_part) - length+= my_sprintf(buff+length,(buff+length, ".%06d", - (int)tm->second_part)); + length+= sprintf(buff+length, ".%06d", (int) tm->second_part); return net_store_data((uchar*) buff, length); } @@ -1209,13 +1205,11 @@ bool Protocol_text::store_time(MYSQL_TIME *tm) char buff[40]; uint length; uint day= (tm->year || tm->month) ? 0 : tm->day; - length= my_sprintf(buff,(buff, "%s%02ld:%02d:%02d", - tm->neg ? "-" : "", - (long) day*24L+(long) tm->hour, - (int) tm->minute, - (int) tm->second)); + length= sprintf(buff, "%s%02ld:%02d:%02d", tm->neg ? "-" : "", + (long) day*24L+(long) tm->hour, (int) tm->minute, + (int) tm->second); if (tm->second_part) - length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part)); + length+= sprintf(buff+length, ".%06d", (int) tm->second_part); return net_store_data((uchar*) buff, length); } diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc index 55418cbec84..5d2a3f61b1e 100644 --- a/sql/rpl_handler.cc +++ b/sql/rpl_handler.cc @@ -89,24 +89,27 @@ int get_user_var_str(const char *name, char *value, int delegates_init() { - static Aligned_char_array<sizeof(Trans_delegate)> trans_mem; - static Aligned_char_array<sizeof(Binlog_storage_delegate)> storage_mem; + static my_aligned_storage<sizeof(Trans_delegate), MY_ALIGNOF(long)> trans_mem; + static my_aligned_storage<sizeof(Binlog_storage_delegate), + MY_ALIGNOF(long)> storage_mem; #ifdef HAVE_REPLICATION - static Aligned_char_array<sizeof(Binlog_transmit_delegate)> transmit_mem; - static Aligned_char_array<sizeof(Binlog_relay_IO_delegate)> relay_io_mem; + static my_aligned_storage<sizeof(Binlog_transmit_delegate), + MY_ALIGNOF(long)> transmit_mem; + static my_aligned_storage<sizeof(Binlog_relay_IO_delegate), + MY_ALIGNOF(long)> relay_io_mem; #endif - if (!(transaction_delegate= new (trans_mem.arr()) Trans_delegate) + if (!(transaction_delegate= new (trans_mem.data) Trans_delegate) || (!transaction_delegate->is_inited()) || !(binlog_storage_delegate= - new (storage_mem.arr()) Binlog_storage_delegate) + new (storage_mem.data) Binlog_storage_delegate) || (!binlog_storage_delegate->is_inited()) #ifdef HAVE_REPLICATION || !(binlog_transmit_delegate= - new (transmit_mem.arr()) Binlog_transmit_delegate) + new (transmit_mem.data) Binlog_transmit_delegate) || (!binlog_transmit_delegate->is_inited()) || !(binlog_relay_io_delegate= - new (relay_io_mem.arr()) Binlog_relay_IO_delegate) + new (relay_io_mem.data) Binlog_relay_IO_delegate) || (!binlog_relay_io_delegate->is_inited()) #endif /* HAVE_REPLICATION */ ) diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 308f6d7f06e..cda876ee764 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -479,16 +479,13 @@ int flush_master_info(Master_info* mi, (1 + mi->ignore_server_ids.elements), MYF(MY_WME)); if (!ignore_server_ids_buf) DBUG_RETURN(1); - for (ulong i= 0, cur_len= my_sprintf(ignore_server_ids_buf, - (ignore_server_ids_buf, "%u", - mi->ignore_server_ids.elements)); - i < mi->ignore_server_ids.elements; i++) + ulong cur_len= sprintf(ignore_server_ids_buf, "%u", + mi->ignore_server_ids.elements); + for (ulong i= 0; i < mi->ignore_server_ids.elements; i++) { ulong s_id; get_dynamic(&mi->ignore_server_ids, (uchar*) &s_id, i); - cur_len +=my_sprintf(ignore_server_ids_buf + cur_len, - (ignore_server_ids_buf + cur_len, - " %lu", s_id)); + cur_len+= sprintf(ignore_server_ids_buf + cur_len, " %lu", s_id); } } @@ -509,7 +506,7 @@ int flush_master_info(Master_info* mi, of file we don't care about this garbage. */ char heartbeat_buf[sizeof(mi->heartbeat_period) * 4]; // buffer to suffice always - my_sprintf(heartbeat_buf, (heartbeat_buf, "%.3f", mi->heartbeat_period)); + sprintf(heartbeat_buf, "%.3f", mi->heartbeat_period); my_b_seek(file, 0L); my_b_printf(file, "%u\n%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n%s\n%s\n%s\n%s\n%s\n%d\n%s\n%s\n%s\n", diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 08377fe887d..03c369394bf 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1138,8 +1138,7 @@ bool Relay_log_info::cached_charset_compare(char *charset) const { DBUG_ENTER("Relay_log_info::cached_charset_compare"); - if (bcmp((uchar*) cached_charset, (uchar*) charset, - sizeof(cached_charset))) + if (memcmp(cached_charset, charset, sizeof(cached_charset))) { memcpy(const_cast<char*>(cached_charset), charset, sizeof(cached_charset)); DBUG_RETURN(1); diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 2c6a9e5d9b9..6f66905eb5d 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -517,10 +517,12 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str, CHARSET_ bool is_conversion_ok(int order, Relay_log_info *rli) { DBUG_ENTER("is_conversion_ok"); - bool allow_non_lossy= - bit_is_set(slave_type_conversions_options, SLAVE_TYPE_CONVERSIONS_ALL_NON_LOSSY); - bool allow_lossy= - bit_is_set(slave_type_conversions_options, SLAVE_TYPE_CONVERSIONS_ALL_LOSSY); + bool allow_non_lossy, allow_lossy; + + allow_non_lossy = slave_type_conversions_options & + (ULL(1) << SLAVE_TYPE_CONVERSIONS_ALL_NON_LOSSY); + allow_lossy= slave_type_conversions_options & + (ULL(1) << SLAVE_TYPE_CONVERSIONS_ALL_LOSSY); DBUG_PRINT("enter", ("order: %d, flags:%s%s", order, allow_non_lossy ? " ALL_NON_LOSSY" : "", diff --git a/sql/slave.cc b/sql/slave.cc index 58b23c44bc7..d41d0479dde 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1528,7 +1528,7 @@ when it try to get the value of TIME_ZONE global variable from master."; the period is an ulonglong of nano-secs. */ llstr((ulonglong) (mi->heartbeat_period*1000000000UL), llbuf); - my_sprintf(query, (query, query_format, llbuf)); + sprintf(query, query_format, llbuf); if (mysql_real_query(mysql, query, strlen(query)) && !check_io_slave_killed(mi->io_thd, mi, NULL)) @@ -1934,17 +1934,17 @@ bool show_master_info(THD* thd, Master_info* mi) ulong s_id, slen; char sbuff[FN_REFLEN]; get_dynamic(&mi->ignore_server_ids, (uchar*) &s_id, i); - slen= my_sprintf(sbuff, (sbuff, (i==0? "%lu" : ", %lu"), s_id)); + slen= sprintf(sbuff, (i==0? "%lu" : ", %lu"), s_id); if (cur_len + slen + 4 > FN_REFLEN) { /* break the loop whenever remained space could not fit ellipses on the next cycle */ - my_sprintf(buff + cur_len, (buff + cur_len, "...")); + sprintf(buff + cur_len, "..."); break; } - cur_len += my_sprintf(buff + cur_len, (buff + cur_len, "%s", sbuff)); + cur_len += sprintf(buff + cur_len, "%s", sbuff); } protocol->store(buff, &my_charset_bin); } @@ -2295,7 +2295,7 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli) DBUG_PRINT("info", ("thd->options: %s%s; rli->last_event_start_time: %lu", FLAGSTR(thd->variables.option_bits, OPTION_NOT_AUTOCOMMIT), FLAGSTR(thd->variables.option_bits, OPTION_BEGIN), - rli->last_event_start_time)); + (ulong) rli->last_event_start_time)); /* Execute the event to change the database and update the binary @@ -3125,8 +3125,8 @@ pthread_handler_t handle_slave_sql(void *arg) char llbuff[22],llbuff1[22]; char saved_log_name[FN_REFLEN]; char saved_master_log_name[FN_REFLEN]; - my_off_t saved_log_pos; - my_off_t saved_master_log_pos; + my_off_t UNINIT_VAR(saved_log_pos); + my_off_t UNINIT_VAR(saved_master_log_pos); my_off_t saved_skip= 0; Relay_log_info* rli = &((Master_info*)arg)->rli; diff --git a/sql/spatial.cc b/sql/spatial.cc index fcf06119db9..f96196cb836 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -36,7 +36,7 @@ static Geometry::Class_info **ci_collection_end= Geometry::ci_collection+Geometry::wkb_last + 1; Geometry::Class_info::Class_info(const char *name, int type_id, - void(*create_func)(void *)): + create_geom_t create_func): m_type_id(type_id), m_create_func(create_func) { m_name.str= (char *) name; @@ -45,39 +45,39 @@ Geometry::Class_info::Class_info(const char *name, int type_id, ci_collection[type_id]= this; } -static void create_point(void *buffer) +static Geometry *create_point(char *buffer) { - new(buffer) Gis_point; + return new (buffer) Gis_point; } -static void create_linestring(void *buffer) +static Geometry *create_linestring(char *buffer) { - new(buffer) Gis_line_string; + return new (buffer) Gis_line_string; } -static void create_polygon(void *buffer) +static Geometry *create_polygon(char *buffer) { - new(buffer) Gis_polygon; + return new (buffer) Gis_polygon; } -static void create_multipoint(void *buffer) +static Geometry *create_multipoint(char *buffer) { - new(buffer) Gis_multi_point; + return new (buffer) Gis_multi_point; } -static void create_multipolygon(void *buffer) +static Geometry *create_multipolygon(char *buffer) { - new(buffer) Gis_multi_polygon; + return new (buffer) Gis_multi_polygon; } -static void create_multilinestring(void *buffer) +static Geometry *create_multilinestring(char *buffer) { - new(buffer) Gis_multi_line_string; + return new (buffer) Gis_multi_line_string; } -static void create_geometrycollection(void *buffer) +static Geometry *create_geometrycollection(char *buffer) { - new(buffer) Gis_geometry_collection; + return new (buffer) Gis_geometry_collection; } @@ -131,10 +131,9 @@ Geometry::Class_info *Geometry::find_class(const char *name, uint32 len) Geometry *Geometry::create_by_typeid(Geometry_buffer *buffer, int type_id) { Class_info *ci; - if (!(ci= find_class((int) type_id))) + if (!(ci= find_class(type_id))) return NULL; - (*ci->m_create_func)(buffer->buf.arr()); - return my_reinterpret_cast(Geometry *)(buffer->buf.arr()); + return (*ci->m_create_func)(buffer->data); } @@ -172,9 +171,7 @@ Geometry *Geometry::create_from_wkt(Geometry_buffer *buffer, if (!(ci= find_class(name.str, name.length)) || wkt->reserve(1 + 4, 512)) return NULL; - (*ci->m_create_func)((void *)buffer); - Geometry *result= (Geometry *)buffer; - + Geometry *result= (*ci->m_create_func)(buffer->data); wkt->q_append((char) wkb_ndr); wkt->q_append((uint32) result->get_class_info()->m_type_id); if (trs->check_next_symbol('(') || diff --git a/sql/spatial.h b/sql/spatial.h index aabbb7a1b97..b0c609ceeef 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -17,6 +17,7 @@ #define _spatial_h #include "sql_string.h" /* String, LEX_STRING */ +#include <my_compiler.h> #ifdef HAVE_SPATIAL @@ -229,15 +230,18 @@ public: { wkb_xdr= 0, /* Big Endian */ wkb_ndr= 1 /* Little Endian */ - }; + }; + + /** Callback which creates Geometry objects on top of a given placement. */ + typedef Geometry *(*create_geom_t)(char *); class Class_info { public: LEX_STRING m_name; int m_type_id; - void (*m_create_func)(void *); - Class_info(const char *name, int type_id, void(*create_func)(void *)); + create_geom_t m_create_func; + Class_info(const char *name, int type_id, create_geom_t create_func); }; virtual const Class_info *get_class_info() const=0; @@ -525,10 +529,8 @@ public: const Class_info *get_class_info() const; }; -struct Geometry_buffer -{ - Aligned_char_array<sizeof(Gis_point)> buf; -}; +struct Geometry_buffer : public + my_aligned_storage<sizeof(Gis_point), MY_ALIGNOF(Gis_point)> {}; #endif /*HAVE_SPATAIAL*/ #endif diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index ec25e4cb68b..074f1047d67 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -210,6 +210,7 @@ static bool compare_hostname(const acl_host_and_ip *host,const char *hostname, const char *ip); static my_bool acl_load(THD *thd, TABLE_LIST *tables); static my_bool grant_load(THD *thd, TABLE_LIST *tables); +static inline void get_grantor(THD *thd, char* grantor); /* Convert scrambled password to binary form, according to scramble type, @@ -1643,12 +1644,10 @@ bool change_password(THD *thd, const char *host, const char *user, result= 0; if (mysql_bin_log.is_open()) { - query_length= - my_sprintf(buff, - (buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'", - acl_user->user ? acl_user->user : "", - acl_user->host.hostname ? acl_user->host.hostname : "", - new_password)); + query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'", + acl_user->user ? acl_user->user : "", + acl_user->host.hostname ? acl_user->host.hostname : "", + new_password); thd->clear_error(); result= thd->binlog_query(THD::STMT_QUERY_TYPE, buff, query_length, FALSE, FALSE, FALSE, 0); @@ -2755,6 +2754,20 @@ end: DBUG_RETURN(result); } +static inline void get_grantor(THD *thd, char *grantor) +{ + const char *user= thd->security_ctx->user; + const char *host= thd->security_ctx->host_or_ip; + +#if defined(HAVE_REPLICATION) + if (thd->slave_thread && thd->has_invoker()) + { + user= thd->get_invoker_user().str; + host= thd->get_invoker_host().str; + } +#endif + strxmov(grantor, user, "@", host, NullS); +} static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, TABLE *table, const LEX_USER &combo, @@ -2769,9 +2782,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, uchar user_key[MAX_KEY_LENGTH]; DBUG_ENTER("replace_table_table"); - strxmov(grantor, thd->security_ctx->user, "@", - thd->security_ctx->host_or_ip, NullS); - + get_grantor(thd, grantor); /* The following should always succeed as new users are created before this function is called! @@ -2901,9 +2912,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, DBUG_RETURN(-1); } - strxmov(grantor, thd->security_ctx->user, "@", - thd->security_ctx->host_or_ip, NullS); - + get_grantor(thd, grantor); /* New users are created before this function is called. diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 0b3e5117c97..4b6756188dd 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -408,7 +408,7 @@ void field_real::add() if ((decs = decimals()) == NOT_FIXED_DEC) { - length= my_sprintf(buff, (buff, "%g", num)); + length= sprintf(buff, "%g", num); if (rint(num) != num) max_notzero_dec_len = 1; } @@ -419,7 +419,7 @@ void field_real::add() snprintf(buff, sizeof(buff)-1, "%-.*f", (int) decs, num); length = (uint) strlen(buff); #else - length= my_sprintf(buff, (buff, "%-.*f", (int) decs, num)); + length= sprintf(buff, "%-.*f", (int) decs, num); #endif // We never need to check further than this @@ -1006,9 +1006,9 @@ void field_decimal::get_opt_type(String *answer, my_decimal_set_zero(&zero); my_bool is_unsigned= (my_decimal_cmp(&zero, &min_arg) >= 0); - length= my_sprintf(buff, (buff, "DECIMAL(%d, %d)", - (int) (max_length - (item->decimals ? 1 : 0)), - item->decimals)); + length= my_snprintf(buff, sizeof(buff), "DECIMAL(%d, %d)", + (int) (max_length - (item->decimals ? 1 : 0)), + item->decimals); if (is_unsigned) length= (uint) (strmov(buff+length, " UNSIGNED")- buff); answer->append(buff, length); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c3e26bb665d..f746edef83f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8545,15 +8545,15 @@ my_bool mysql_rm_tmp_tables(void) (file->name[1] == '.' && !file->name[2]))) continue; - if (!bcmp((uchar*) file->name, (uchar*) tmp_file_prefix, - tmp_file_prefix_length)) + if (!memcmp(file->name, tmp_file_prefix, + tmp_file_prefix_length)) { char *ext= fn_ext(file->name); uint ext_len= strlen(ext); uint filePath_len= my_snprintf(filePath, sizeof(filePath), "%s%c%s", tmpdir, FN_LIBCHAR, file->name); - if (!bcmp((uchar*) reg_ext, (uchar*) ext, ext_len)) + if (!memcmp(reg_ext, ext, ext_len)) { handler *handler_file= 0; /* We should cut file extention before deleting of table */ diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 52ac34b7b60..6f59c3f51e1 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -52,9 +52,13 @@ void mysql_client_binlog_statement(THD* thd) if (check_global_access(thd, SUPER_ACL)) DBUG_VOID_RETURN; - size_t coded_len= thd->lex->comment.length + 1; + size_t coded_len= thd->lex->comment.length; + if (!coded_len) + { + my_error(ER_SYNTAX_ERROR, MYF(0)); + DBUG_VOID_RETURN; + } size_t decoded_len= base64_needed_decoded_length(coded_len); - DBUG_ASSERT(coded_len > 0); /* Allocation @@ -155,14 +159,16 @@ void mysql_client_binlog_statement(THD* thd) /* Checking that the first event in the buffer is not truncated. */ - ulong event_len= uint4korr(bufptr + EVENT_LEN_OFFSET); - DBUG_PRINT("info", ("event_len=%lu, bytes_decoded=%d", - event_len, bytes_decoded)); - if (bytes_decoded < EVENT_LEN_OFFSET || (uint) bytes_decoded < event_len) + ulong event_len; + if (bytes_decoded < EVENT_LEN_OFFSET + 4 || + (event_len= uint4korr(bufptr + EVENT_LEN_OFFSET)) > + (uint) bytes_decoded) { my_error(ER_SYNTAX_ERROR, MYF(0)); goto end; } + DBUG_PRINT("info", ("event_len=%lu, bytes_decoded=%d", + event_len, bytes_decoded)); /* If we have not seen any Format_description_event, then we must @@ -200,17 +206,6 @@ void mysql_client_binlog_statement(THD* thd) bufptr += event_len; DBUG_PRINT("info",("ev->get_type_code()=%d", ev->get_type_code())); -#ifndef HAVE_purify - /* - This debug printout should not be used for valgrind builds - since it will read from unassigned memory. - */ - DBUG_PRINT("info",("bufptr+EVENT_TYPE_OFFSET: 0x%lx", - (long) (bufptr+EVENT_TYPE_OFFSET))); - DBUG_PRINT("info", ("bytes_decoded: %d bufptr: 0x%lx buf[EVENT_LEN_OFFSET]: %lu", - bytes_decoded, (long) bufptr, - (ulong) uint4korr(bufptr+EVENT_LEN_OFFSET))); -#endif ev->thd= thd; /* We go directly to the application phase, since we don't need diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2fbdc2b58ac..eb4d353db81 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -628,6 +628,9 @@ THD::THD() thr_lock_owner_init(&main_lock_id, &lock_info); m_internal_handler= NULL; + current_user_used= FALSE; + memset(&invoker_user, 0, sizeof(invoker_user)); + memset(&invoker_host, 0, sizeof(invoker_host)); } @@ -1168,6 +1171,9 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) while (to != end) *(to++)+= *(from++); + + to_var->bytes_received+= from_var->bytes_received; + to_var->bytes_sent+= from_var->bytes_sent; } /* @@ -1193,6 +1199,9 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, while (to != end) *(to++)+= *(from++) - *(dec++); + + to_var->bytes_received+= from_var->bytes_received - dec_var->bytes_received;; + to_var->bytes_sent+= from_var->bytes_sent - dec_var->bytes_sent; } @@ -1344,6 +1353,7 @@ void THD::cleanup_after_query() where= THD::DEFAULT_WHERE; /* reset table map for multi-table update */ table_map_for_update= 0; + clean_current_user_used(); } @@ -3412,6 +3422,22 @@ void THD::leave_locked_tables_mode() mysql_ha_move_tickets_after_trans_sentinel(this); } +void THD::get_definer(LEX_USER *definer) +{ + set_current_user_used(); +#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) + if (slave_thread && has_invoker()) + { + definer->user = invoker_user; + definer->host= invoker_host; + definer->password.str= NULL; + definer->password.length= 0; + } + else +#endif + get_default_definer(this, definer); +} + /** Mark transaction to rollback and mark error as fatal to a sub-statement. diff --git a/sql/sql_class.h b/sql/sql_class.h index b73f830463e..c095fee6232 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -472,15 +472,18 @@ typedef struct system_variables my_bool sysdate_is_now; double long_query_time_double; + } SV; -/* per thread status variables */ +/** + Per thread status variables. + Must be long/ulong up to last_system_status_var so that + add_to_status/add_diff_to_status can work. +*/ typedef struct system_status_var { - ulonglong bytes_received; - ulonglong bytes_sent; ulong com_other; ulong com_stat[(uint) SQLCOM_END]; ulong created_tmp_disk_tables; @@ -536,13 +539,14 @@ typedef struct system_status_var Number of statements sent from the client */ ulong questions; + + ulonglong bytes_received; + ulonglong bytes_sent; /* IMPORTANT! SEE last_system_status_var DEFINITION BELOW. - Below 'last_system_status_var' are all variables which doesn't make any - sense to add to the /global/ status variable counter. - Status variables which it does not make sense to add to - global status variable counter + Below 'last_system_status_var' are all variables that cannot be handled + automatically by add_to_status()/add_diff_to_status(). */ double last_query_cost; } STATUS_VAR; @@ -2844,6 +2848,18 @@ public: } void leave_locked_tables_mode(); int decide_logging_format(TABLE_LIST *tables); + void set_current_user_used() { current_user_used= TRUE; } + bool is_current_user_used() { return current_user_used; } + void clean_current_user_used() { current_user_used= FALSE; } + void get_definer(LEX_USER *definer); + void set_invoker(const LEX_STRING *user, const LEX_STRING *host) + { + invoker_user= *user; + invoker_host= *host; + } + LEX_STRING get_invoker_user() { return invoker_user; } + LEX_STRING get_invoker_host() { return invoker_host; } + bool has_invoker() { return invoker_user.length > 0; } private: /** The current internal error handler for this thread, or NULL. */ @@ -2866,6 +2882,25 @@ private: MEM_ROOT main_mem_root; Warning_info main_warning_info; Diagnostics_area main_da; + + /** + It will be set TURE if CURRENT_USER() is called in account management + statements or default definer is set in CREATE/ALTER SP, SF, Event, + TRIGGER or VIEW statements. + + Current user will be binlogged into Query_log_event if current_user_used + is TRUE; It will be stored into invoker_host and invoker_user by SQL thread. + */ + bool current_user_used; + + /** + It points to the invoker in the Query_log_event. + SQL thread use it as the default definer in CREATE/ALTER SP, SF, Event, + TRIGGER or VIEW statements or current user in account management + statements if it is not NULL. + */ + LEX_STRING invoker_user; + LEX_STRING invoker_host; }; @@ -3420,6 +3455,9 @@ public: void reset(); bool walk(tree_walk_action action, void *walk_action_arg); + uint get_size() const { return size; } + ulonglong get_max_in_memory_size() const { return max_in_memory_size; } + friend int unique_write_to_file(uchar* key, element_count count, Unique *unique); friend int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique); }; diff --git a/sql/sql_list.h b/sql/sql_list.h index cc42fcae91b..5cd24236644 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -85,7 +85,7 @@ public: SQL_I_List() { empty(); } - SQL_I_List(const SQL_I_List &tmp) + SQL_I_List(const SQL_I_List &tmp) : Sql_alloc() { elements= tmp.elements; first= tmp.first; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index cbde8b9c982..b2a816a69dd 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1441,29 +1441,6 @@ int READ_INFO::read_field() while ( to < end_of_buff) { chr = GET; -#ifdef USE_MB - if ((my_mbcharlen(read_charset, chr) > 1) && - to+my_mbcharlen(read_charset, chr) <= end_of_buff) - { - uchar* p = (uchar*)to; - *to++ = chr; - int ml = my_mbcharlen(read_charset, chr); - int i; - for (i=1; i<ml; i++) { - chr = GET; - if (chr == my_b_EOF) - goto found_eof; - *to++ = chr; - } - if (my_ismbchar(read_charset, - (const char *)p, - (const char *)to)) - continue; - for (i=0; i<ml; i++) - PUSH((uchar) *--to); - chr = GET; - } -#endif if (chr == my_b_EOF) goto found_eof; if (chr == escape_char) @@ -1547,6 +1524,39 @@ int READ_INFO::read_field() return 0; } } +#ifdef USE_MB + if (my_mbcharlen(read_charset, chr) > 1 && + to + my_mbcharlen(read_charset, chr) <= end_of_buff) + { + uchar* p= (uchar*) to; + int ml, i; + *to++ = chr; + + ml= my_mbcharlen(read_charset, chr); + + for (i= 1; i < ml; i++) + { + chr= GET; + if (chr == my_b_EOF) + { + /* + Need to back up the bytes already ready from illformed + multi-byte char + */ + to-= i; + goto found_eof; + } + *to++ = chr; + } + if (my_ismbchar(read_charset, + (const char *)p, + (const char *)to)) + continue; + for (i= 0; i < ml; i++) + PUSH((uchar) *--to); + chr= GET; + } +#endif *to++ = (uchar) chr; } /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a7d538dd3e8..28a867cfcd8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7648,7 +7648,7 @@ LEX_USER *create_default_definer(THD *thd) if (! (definer= (LEX_USER*) thd->alloc(sizeof(LEX_USER)))) return 0; - get_default_definer(thd, definer); + thd->get_definer(definer); return definer; } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 09ae0acc6ad..089e751900e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -791,6 +791,19 @@ static void setup_one_conversion_function(THD *thd, Item_param *param, } #ifndef EMBEDDED_LIBRARY + +/** + Check whether this parameter data type is compatible with long data. + Used to detect whether a long data stream has been supplied to a + incompatible data type. +*/ +inline bool is_param_long_data_type(Item_param *param) +{ + return ((param->param_type >= MYSQL_TYPE_TINY_BLOB) && + (param->param_type <= MYSQL_TYPE_STRING)); +} + + /** Routines to assign parameters from data supplied by the client. @@ -860,6 +873,14 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array, DBUG_RETURN(1); } } + /* + A long data stream was supplied for this parameter marker. + This was done after prepare, prior to providing a placeholder + type (the types are supplied at execute). Check that the + supplied type of placeholder can accept a data stream. + */ + else if (!is_param_long_data_type(param)) + DBUG_RETURN(1); res= param->query_val_str(&str); if (param->convert_str_value(thd)) DBUG_RETURN(1); /* out of memory */ @@ -898,6 +919,14 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, DBUG_RETURN(1); } } + /* + A long data stream was supplied for this parameter marker. + This was done after prepare, prior to providing a placeholder + type (the types are supplied at execute). Check that the + supplied type of placeholder can accept a data stream. + */ + else if (is_param_long_data_type(param)) + DBUG_RETURN(1); if (param->convert_str_value(stmt->thd)) DBUG_RETURN(1); /* out of memory */ } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 787f9dcae2c..5f994c09d6d 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -257,8 +257,7 @@ bool log_in_use(const char* log_name) if ((linfo = tmp->current_linfo)) { mysql_mutex_lock(&linfo->lock); - result = !bcmp((uchar*) log_name, (uchar*) linfo->log_file_name, - log_name_len); + result = !memcmp(log_name, linfo->log_file_name, log_name_len); mysql_mutex_unlock(&linfo->lock); if (result) break; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 24d2a21147c..11378ac0d11 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -195,7 +195,8 @@ static bool test_if_cheaper_ordering(const JOIN_TAB *tab, ha_rows select_limit, int *new_key, int *new_key_direction, ha_rows *new_select_limit, - uint *new_used_key_parts= NULL); + uint *new_used_key_parts= NULL, + uint *saved_best_key_parts= NULL); static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order, ha_rows select_limit, bool no_changes, key_map *map); @@ -592,13 +593,21 @@ JOIN::prepare(Item ***rref_pointer_array, { Item *item= *ord->item; /* - Disregard sort order if there's only "{VAR}CHAR(0) NOT NULL" fields - there. Such fields don't contain any data to sort. + Disregard sort order if there's only + zero length NOT NULL fields (e.g. {VAR}CHAR(0) NOT NULL") or + zero length NOT NULL string functions there. + Such tuples don't contain any data to sort. */ if (!real_order && - (item->type() != Item::FIELD_ITEM || - ((Item_field *) item)->field->maybe_null() || - ((Item_field *) item)->field->sort_length())) + /* Not a zero length NOT NULL field */ + ((item->type() != Item::FIELD_ITEM || + ((Item_field *) item)->field->maybe_null() || + ((Item_field *) item)->field->sort_length()) && + /* AND not a zero length NOT NULL string function. */ + (item->type() != Item::FUNC_ITEM || + item->maybe_null || + item->result_type() != STRING_RESULT || + item->max_length))) real_order= TRUE; if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) @@ -1152,7 +1161,7 @@ JOIN::optimize() elements may be lost during further having condition transformation in JOIN::exec. */ - if (having && const_table_map) + if (having && const_table_map && !having->with_sum_func) { having->update_used_tables(); having= remove_eq_conds(thd, having, &having_value); @@ -7356,7 +7365,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, *simple_order=0; // Must do a temp table to sort else if (!(order_tables & not_const_tables)) { - if (order->item[0]->with_subselect) + if (order->item[0]->with_subselect && + !(join->select_lex->options & SELECT_DESCRIBE)) order->item[0]->val_str(&order->item[0]->str_value); DBUG_PRINT("info",("removing: %s", order->item[0]->full_name())); continue; // skip const item @@ -13694,6 +13704,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, } { uint best_key_parts= 0; + uint saved_best_key_parts= 0; int best_key_direction= 0; int best_key= -1; JOIN *join= tab->join; @@ -13702,7 +13713,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, test_if_cheaper_ordering(tab, order, table, usable_keys, ref_key, select_limit, &best_key, &best_key_direction, - &select_limit, &best_key_parts); + &select_limit, &best_key_parts, + &saved_best_key_parts); /* filesort() and join cache are usually faster than reading in @@ -13781,8 +13793,15 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ } } - used_key_parts= best_key_parts; order_direction= best_key_direction; + /* + saved_best_key_parts is actual number of used keyparts found by the + test_if_order_by_key function. It could differ from keyinfo->key_parts, + thus we have to restore it in case of desc order as it affects + QUICK_SELECT_DESC behaviour. + */ + used_key_parts= (order_direction == -1) ? + saved_best_key_parts : best_key_parts; } else DBUG_RETURN(0); @@ -17374,6 +17393,8 @@ void JOIN::cache_const_exprs() @param [out] new_used_key_parts NULL by default, otherwise return number of new_key prefix columns if success or undefined if the function fails + @param [out] saved_best_key_parts NULL by default, otherwise preserve the + value for further use in QUICK_SELECT_DESC @note This function takes into account table->quick_condition_rows statistic @@ -17388,7 +17409,8 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, key_map usable_keys, int ref_key, ha_rows select_limit, int *new_key, int *new_key_direction, - ha_rows *new_select_limit, uint *new_used_key_parts) + ha_rows *new_select_limit, uint *new_used_key_parts, + uint *saved_best_key_parts) { DBUG_ENTER("test_if_cheaper_ordering"); /* @@ -17567,6 +17589,8 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, { best_key= nr; best_key_parts= keyinfo->key_parts; + if (saved_best_key_parts) + *saved_best_key_parts= used_key_parts; best_records= quick_records; is_best_covering= is_covering; best_key_direction= direction; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index fc2f22f6f48..8a60dd730a3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2128,8 +2128,8 @@ static bool show_status_array(THD *thd, const char *wild, bool ucase_names, COND *cond) { - MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long); - char * const buff= (char *) &buff_data; + my_aligned_storage<SHOW_VAR_FUNC_BUFF_SIZE, MY_ALIGNOF(long)> buffer; + char * const buff= buffer.data; char *prefix_end; /* the variable name should not be longer than 64 characters */ char name_buffer[64]; @@ -2626,36 +2626,54 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, { LEX *lex= thd->lex; const char *wild= lex->wild ? lex->wild->ptr() : NullS; + bool rc= 0; + bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES)); switch (lex->sql_command) { case SQLCOM_SHOW_DATABASES: if (wild) { - lookup_field_values->db_value.str= (char*) wild; - lookup_field_values->db_value.length= strlen(wild); + thd->make_lex_string(&lookup_field_values->db_value, + wild, strlen(wild), 0); lookup_field_values->wild_db_value= 1; } - return 0; + break; case SQLCOM_SHOW_TABLES: case SQLCOM_SHOW_TABLE_STATUS: case SQLCOM_SHOW_TRIGGERS: case SQLCOM_SHOW_EVENTS: - lookup_field_values->db_value.str= lex->select_lex.db; - lookup_field_values->db_value.length=strlen(lex->select_lex.db); + thd->make_lex_string(&lookup_field_values->db_value, + lex->select_lex.db, strlen(lex->select_lex.db), 0); if (wild) { - lookup_field_values->table_value.str= (char*)wild; - lookup_field_values->table_value.length= strlen(wild); + thd->make_lex_string(&lookup_field_values->table_value, + wild, strlen(wild), 0); lookup_field_values->wild_table_value= 1; } - return 0; + break; default: /* The "default" is for queries over I_S. All previous cases handle SHOW commands. */ - return calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values); + rc= calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values); + break; } + + if (lower_case_table_names && !rc) + { + /* + We can safely do in-place upgrades here since all of the above cases + are allocating a new memory buffer for these strings. + */ + if (lookup_field_values->db_value.str && lookup_field_values->db_value.str[0]) + my_casedn_str(system_charset_info, lookup_field_values->db_value.str); + if (lookup_field_values->table_value.str && + lookup_field_values->table_value.str[0]) + my_casedn_str(system_charset_info, lookup_field_values->table_value.str); + } + + return rc; } @@ -2857,9 +2875,15 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex, { if (with_i_schema) { - if (find_schema_table(thd, lookup_field_vals->table_value.str)) + LEX_STRING *name; + ST_SCHEMA_TABLE *schema_table= + find_schema_table(thd, lookup_field_vals->table_value.str); + if (schema_table && !schema_table->hidden) { - if (table_names->push_back(&lookup_field_vals->table_value)) + if (!(name= + thd->make_lex_string(NULL, schema_table->table_name, + strlen(schema_table->table_name), TRUE)) || + table_names->push_back(name)) return 1; } } @@ -3439,6 +3463,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) error= 0; goto err; } + DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'", STR_OR_NIL(lookup_field_vals.db_value.str), STR_OR_NIL(lookup_field_vals.table_value.str))); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1c673f4ca42..3ba67368565 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1932,11 +1932,9 @@ master_def: { const char format[]= "%d seconds"; char buf[4*sizeof(SLAVE_MAX_HEARTBEAT_PERIOD) + sizeof(format)]; - my_sprintf(buf, (buf, format, SLAVE_MAX_HEARTBEAT_PERIOD)); + sprintf(buf, format, SLAVE_MAX_HEARTBEAT_PERIOD); my_error(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE, - MYF(0), - " is negative or exceeds the maximum ", - buf); + MYF(0), " is negative or exceeds the maximum ", buf); MYSQL_YYABORT; } if (Lex->mi.heartbeat_period > slave_net_timeout) diff --git a/sql/udf_example.c b/sql/udf_example.c index fa1b44178ac..284689d329f 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -146,7 +146,9 @@ typedef long long longlong; #ifdef HAVE_DLOPEN +#if !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_SOLARIS_STYLE_GETHOST) static pthread_mutex_t LOCK_hostname; +#endif /* These must be right or mysqld will not find the symbol! */ diff --git a/sql/unireg.h b/sql/unireg.h index dbbeea077a9..b897c887c89 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -77,8 +77,8 @@ typedef struct st_ha_create_information HA_CREATE_INFO; #define SPECIAL_LOG_QUERIES_NOT_USING_INDEXES 4096 /* Obsolete */ /* Extern defines */ -#define store_record(A,B) bmove_align((A)->B,(A)->record[0],(size_t) (A)->s->reclength) -#define restore_record(A,B) bmove_align((A)->record[0],(A)->B,(size_t) (A)->s->reclength) +#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength) +#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength) #define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength) #define empty_record(A) { \ restore_record((A),s->default_values); \ diff --git a/storage/archive/Makefile.am b/storage/archive/Makefile.am index adc11358df6..8b08105cef3 100644 --- a/storage/archive/Makefile.am +++ b/storage/archive/Makefile.am @@ -37,14 +37,14 @@ noinst_PROGRAMS = archive_test archive_reader EXTRA_LTLIBRARIES = ha_archive.la pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@ ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_archive_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_archive_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_archive_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_archive_la_SOURCES = ha_archive.cc azio.c EXTRA_LIBRARIES = libarchive.a noinst_LIBRARIES = @plugin_archive_static_target@ -libarchive_a_CXXFLAGS = $(AM_CFLAGS) +libarchive_a_CXXFLAGS = $(AM_CXXFLAGS) libarchive_a_CFLAGS = $(AM_CFLAGS) libarchive_a_SOURCES = ha_archive.cc azio.c diff --git a/storage/blackhole/Makefile.am b/storage/blackhole/Makefile.am index f3bdbdbd070..38c2f354844 100644 --- a/storage/blackhole/Makefile.am +++ b/storage/blackhole/Makefile.am @@ -35,14 +35,14 @@ noinst_HEADERS = ha_blackhole.h EXTRA_LTLIBRARIES = ha_blackhole.la pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@ ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir) -ha_blackhole_la_CXXFLAGS=$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_blackhole_la_CXXFLAGS=$(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_blackhole_la_CFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_blackhole_la_SOURCES=ha_blackhole.cc EXTRA_LIBRARIES = libblackhole.a noinst_LIBRARIES = @plugin_blackhole_static_target@ -libblackhole_a_CXXFLAGS=$(AM_CFLAGS) +libblackhole_a_CXXFLAGS=$(AM_CXXFLAGS) libblackhole_a_CFLAGS = $(AM_CFLAGS) libblackhole_a_SOURCES= ha_blackhole.cc diff --git a/storage/csv/Makefile.am b/storage/csv/Makefile.am index 36d6b464fcc..5e3587c893f 100644 --- a/storage/csv/Makefile.am +++ b/storage/csv/Makefile.am @@ -32,12 +32,12 @@ noinst_HEADERS = ha_tina.h transparent_file.h EXTRA_LTLIBRARIES = ha_csv.la pkglib_LTLIBRARIES = @plugin_csv_shared_target@ ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir) -ha_csv_la_CXXFLAGS = $(AM_CFLAGS) -DMYSQL_PLUGIN +ha_csv_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_PLUGIN ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc EXTRA_LIBRARIES = libcsv.a noinst_LIBRARIES = @plugin_csv_static_target@ -libcsv_a_CXXFLAGS = $(AM_CFLAGS) +libcsv_a_CXXFLAGS = $(AM_CXXFLAGS) libcsv_a_SOURCES = transparent_file.cc ha_tina.cc EXTRA_DIST = CMakeLists.txt plug.in diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am index 47d95d4663c..c79fbe97cc3 100644 --- a/storage/example/Makefile.am +++ b/storage/example/Makefile.am @@ -35,14 +35,14 @@ noinst_HEADERS = ha_example.h EXTRA_LTLIBRARIES = ha_example.la pkgplugin_LTLIBRARIES = @plugin_example_shared_target@ ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices -ha_example_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_example_la_SOURCES = ha_example.cc EXTRA_LIBRARIES = libexample.a noinst_LIBRARIES = @plugin_example_static_target@ -libexample_a_CXXFLAGS = $(AM_CFLAGS) +libexample_a_CXXFLAGS = $(AM_CXXFLAGS) libexample_a_CFLAGS = $(AM_CFLAGS) libexample_a_SOURCES= ha_example.cc diff --git a/storage/federated/Makefile.am b/storage/federated/Makefile.am index f4cd634567d..e07b0d95b97 100644 --- a/storage/federated/Makefile.am +++ b/storage/federated/Makefile.am @@ -36,14 +36,14 @@ noinst_HEADERS = ha_federated.h EXTRA_LTLIBRARIES = ha_federated.la pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@ ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_federated_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_federated_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_federated_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_federated_la_SOURCES = ha_federated.cc EXTRA_LIBRARIES = libfederated.a noinst_LIBRARIES = @plugin_federated_static_target@ -libfederated_a_CXXFLAGS = $(AM_CFLAGS) +libfederated_a_CXXFLAGS = $(AM_CXXFLAGS) libfederated_a_CFLAGS = $(AM_CFLAGS) libfederated_a_SOURCES= ha_federated.cc diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 5534c520604..d17b56bd4b1 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -594,7 +594,6 @@ static int parse_url_error(FEDERATED_SHARE *share, TABLE *table, int error_num) int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share) { int error_num= ER_FOREIGN_SERVER_DOESNT_EXIST; - char error_buffer[FEDERATED_QUERY_BUFFER_SIZE]; FOREIGN_SERVER *server, server_buffer; DBUG_ENTER("ha_federated::get_connection"); @@ -646,10 +645,8 @@ int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share) DBUG_RETURN(0); error: - my_sprintf(error_buffer, - (error_buffer, "server name: '%s' doesn't exist!", - share->connection_string)); - my_error(error_num, MYF(0), error_buffer); + my_printf_error(error_num, "server name: '%s' doesn't exist!", + MYF(0), share->connection_string); DBUG_RETURN(error_num); } @@ -2443,8 +2440,8 @@ int ha_federated::index_read_idx_with_result_set(uchar *buf, uint index, if (real_query(sql_query.ptr(), sql_query.length())) { - my_sprintf(error_buffer, (error_buffer, "error: %d '%s'", - mysql_errno(mysql), mysql_error(mysql))); + sprintf(error_buffer, "error: %d '%s'", + mysql_errno(mysql), mysql_error(mysql)); retval= ER_QUERY_ON_FOREIGN_DATA_SOURCE; goto error; } @@ -2841,7 +2838,6 @@ int ha_federated::rnd_pos(uchar *buf, uchar *pos) int ha_federated::info(uint flag) { - char error_buffer[FEDERATED_QUERY_BUFFER_SIZE]; char status_buf[FEDERATED_QUERY_BUFFER_SIZE]; int error; uint error_code; @@ -2925,9 +2921,8 @@ error: mysql_free_result(result); if (mysql) { - my_sprintf(error_buffer, (error_buffer, ": %d : %s", - mysql_errno(mysql), mysql_error(mysql))); - my_error(error_code, MYF(0), error_buffer); + my_printf_error(error_code, ": %d : %s", MYF(0), + mysql_errno(mysql), mysql_error(mysql)); } else if (remote_error_number != -1 /* error already reported */) diff --git a/storage/heap/CMakeLists.txt b/storage/heap/CMakeLists.txt index 2c0b65b0cc4..2c0b65b0cc4 100755..100644 --- a/storage/heap/CMakeLists.txt +++ b/storage/heap/CMakeLists.txt diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index aaaa0fe833f..f56df42aab3 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -577,7 +577,7 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2, } else { - if (bcmp(rec1+seg->start,rec2+seg->start,seg->length)) + if (memcmp(rec1+seg->start,rec2+seg->start,seg->length)) return 1; } } @@ -660,7 +660,7 @@ int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key) } else { - if (bcmp(rec+seg->start,key,seg->length)) + if (memcmp(rec+seg->start,key,seg->length)) return 1; } } diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index 5b0c8d8685d..1571fc98402 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -401,7 +401,7 @@ int main(int argc, char *argv[]) bmove(record2,record,reclength); if (heap_rsame(file,record,-1) || heap_rsame(file,record2,2)) goto err; - if (bcmp(record2,record,reclength)) + if (memcmp(record2,record,reclength)) { puts("heap_rsame didn't find right record"); goto end; @@ -410,7 +410,7 @@ int main(int argc, char *argv[]) puts("- Test of read through position"); if (heap_rrnd(file,record,position)) goto err; - if (bcmp(record3,record,reclength)) + if (memcmp(record3,record,reclength)) { puts("heap_frnd didn't find right record"); goto end; diff --git a/storage/ibmdb2i/Makefile.am b/storage/ibmdb2i/Makefile.am index 041bdc270e4..a9977de895d 100644 --- a/storage/ibmdb2i/Makefile.am +++ b/storage/ibmdb2i/Makefile.am @@ -34,7 +34,7 @@ EXTRA_LTLIBRARIES = ha_ibmdb2i.la pkgplugin_LTLIBRARIES = @plugin_ibmdb2i_shared_target@ ha_ibmdb2i_la_LIBADD = -liconv ha_ibmdb2i_la_LDFLAGS = -module -rpath $(MYSQLLIBdir) -ha_ibmdb2i_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_ibmdb2i_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_ibmdb2i_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_ibmdb2i_la_SOURCES = ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc \ db2i_blobCollection.cc db2i_file.cc db2i_charsetSupport.cc \ @@ -44,7 +44,7 @@ ha_ibmdb2i_la_SOURCES = ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc \ EXTRA_LIBRARIES = libibmdb2i.a noinst_LIBRARIES = @plugin_ibmdb2i_static_target@ -libibmdb2i_a_CXXFLAGS = $(AM_CFLAGS) +libibmdb2i_a_CXXFLAGS = $(AM_CXXFLAGS) libibmdb2i_a_CFLAGS = $(AM_CFLAGS) libibmdb2i_a_SOURCES= $(ha_ibmdb2i_la_SOURCES) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 90246aaa99d..b6399dcc478 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -95,7 +95,7 @@ IF(NOT CMAKE_CROSSCOMPILING) #include <pthread.h> #include <string.h> - int main(int argc, char** argv) { + int main() { pthread_t x1; pthread_t x2; pthread_t x3; diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index c15c46abaf0..7a6103d9e79 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -323,14 +323,14 @@ libinnobase_a_SOURCES= \ ut/ut0vec.c \ ut/ut0wqueue.c -libinnobase_a_CXXFLAGS= $(AM_CFLAGS) +libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS) libinnobase_a_CFLAGS= $(AM_CFLAGS) EXTRA_LTLIBRARIES= ha_innodb.la pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@ ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir) -ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES) diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt index b057a62a6dd..b057a62a6dd 100755..100644 --- a/storage/myisam/CMakeLists.txt +++ b/storage/myisam/CMakeLists.txt diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index c7ebf9ae220..24456e3d8fa 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -84,7 +84,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,info->buff, test(!(nextflag & SEARCH_SAVE_BUFF))))) goto err; - DBUG_DUMP("page",(uchar*) buff,mi_getint(buff)); + DBUG_DUMP("page", buff, mi_getint(buff)); flag=(*keyinfo->bin_search)(info,keyinfo,buff,key,key_len,nextflag, &keypos,lastkey, &last_key); @@ -819,7 +819,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long null packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(uchar*) *page_pos,16); + DBUG_DUMP("key", *page_pos, 16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; @@ -876,7 +876,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, { DBUG_PRINT("error",("Found too long packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(uchar*) *page_pos,16); + DBUG_DUMP("key", *page_pos, 16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Error */ @@ -948,7 +948,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long binary packed key: %u of %u at 0x%lx", length, keyinfo->maxlength, (long) *page_pos)); - DBUG_DUMP("key",(uchar*) *page_pos,16); + DBUG_DUMP("key", *page_pos, 16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); /* Wrong key */ diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 94936ab84ae..513b390ee68 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -412,7 +412,7 @@ int main(int argc, char *argv[]) } ant=0; while (mi_rprev(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys) { printf("prev: Found: %d records of %d\n",ant,dupp_keys); @@ -450,7 +450,7 @@ int main(int argc, char *argv[]) goto end; } if (mi_rlast(file,read_record2,0) || - bcmp(read_record2,read_record3,reclength)) + memcmp(read_record2,read_record3,reclength)) { printf("Can't find last record\n"); DBUG_DUMP("record2",(uchar*) read_record2,reclength); @@ -465,7 +465,7 @@ int main(int argc, char *argv[]) printf("prev: I found: %d records of %d\n",ant,write_count); goto end; } - if (bcmp(read_record,read_record3,reclength)) + if (memcmp(read_record,read_record3,reclength)) { printf("Can't find first record\n"); goto end; @@ -480,7 +480,7 @@ int main(int argc, char *argv[]) mi_rprev(file,read_record3,0) == 0 || mi_rnext(file,read_record3,0)) goto err; - if (bcmp(read_record,read_record3,reclength) != 0) + if (memcmp(read_record,read_record3,reclength) != 0) printf("Can't find first record\n"); if (!silent) @@ -492,7 +492,7 @@ int main(int argc, char *argv[]) mi_rnext(file,read_record3,0) == 0 || mi_rprev(file,read_record3,0)) goto err; - if (bcmp(read_record2,read_record3,reclength)) + if (memcmp(read_record2,read_record3,reclength)) printf("Can't find last record\n"); #ifdef NOT_ANYMORE if (!silent) @@ -506,7 +506,7 @@ int main(int argc, char *argv[]) bzero((char*) file->lastkey,file->s->base.max_key_length*2); if (mi_rkey(file,read_record,0,key2,(uint) i,HA_READ_PREFIX)) goto err; - if (bcmp(read_record+start,key,(uint) i)) + if (memcmp(read_record+start,key,(uint) i)) { puts("Didn't find right record"); goto end; @@ -525,7 +525,7 @@ int main(int argc, char *argv[]) opt_delete++; ant=1; while (mi_rnext(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-1) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-1); @@ -543,7 +543,7 @@ int main(int argc, char *argv[]) opt_delete++; ant=1; while (mi_rprev(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-2) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-2); @@ -563,7 +563,7 @@ int main(int argc, char *argv[]) if (mi_rnext(file,read_record,0)) goto err; /* Skall finnas poster */ while (mi_rnext(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-3) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-3); @@ -578,7 +578,7 @@ int main(int argc, char *argv[]) opt_delete++; ant=0; while (mi_rprev(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-4) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-4); @@ -601,7 +601,7 @@ int main(int argc, char *argv[]) for (i=min(2,keys) ; i-- > 0 ;) { if (mi_rsame(file,read_record2,(int) i)) goto err; - if (bcmp(read_record,read_record2,reclength) != 0) + if (memcmp(read_record,read_record2,reclength) != 0) { printf("is_rsame didn't find same record\n"); goto end; diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c index 02fcd9289dd..fdba84a2e67 100644 --- a/storage/myisam/mi_unique.c +++ b/storage/myisam/mi_unique.c @@ -56,7 +56,7 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, uchar *record, if (_mi_search_next(info,info->s->keyinfo+def->key, info->lastkey, MI_UNIQUE_HASH_LENGTH, SEARCH_BIGGER, info->s->state.key_root[def->key]) || - bcmp((char*) info->lastkey, (char*) key_buff, MI_UNIQUE_HASH_LENGTH)) + memcmp(info->lastkey, key_buff, MI_UNIQUE_HASH_LENGTH)) { info->page_changed=1; /* Can't optimize read next */ info->lastpos=lastpos; diff --git a/storage/myisammrg/CMakeLists.txt b/storage/myisammrg/CMakeLists.txt index 739bcd565bc..739bcd565bc 100755..100644 --- a/storage/myisammrg/CMakeLists.txt +++ b/storage/myisammrg/CMakeLists.txt diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index bf34bf538a1..bac8cb7a0b7 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -299,9 +299,8 @@ extern "C" int myisammrg_parent_open_callback(void *callback_param, if (! db || ! table_name) DBUG_RETURN(1); - DBUG_PRINT("myrg", ("open: '%.*s'.'%.*s'", db_length, db, - table_name_length, table_name)); - + DBUG_PRINT("myrg", ("open: '%.*s'.'%.*s'", (int) db_length, db, + (int) table_name_length, table_name)); /* Convert to lowercase if required. */ if (lower_case_table_names && table_name_length) diff --git a/storage/ndb/src/common/portlib/NdbMutex.c b/storage/ndb/src/common/portlib/NdbMutex.c index c9184e5d1f2..5595baba7c4 100644 --- a/storage/ndb/src/common/portlib/NdbMutex.c +++ b/storage/ndb/src/common/portlib/NdbMutex.c @@ -24,36 +24,31 @@ NdbMutex* NdbMutex_Create(void) { NdbMutex* pNdbMutex; int result; - DBUG_ENTER("NdbMutex_Create"); - + pNdbMutex = (NdbMutex*)NdbMem_Allocate(sizeof(NdbMutex)); - DBUG_PRINT("info",("NdbMem_Allocate 0x%lx", (long) pNdbMutex)); - + if (pNdbMutex == NULL) - DBUG_RETURN(NULL); - + return NULL; + result = pthread_mutex_init(pNdbMutex, NULL); assert(result == 0); - - DBUG_RETURN(pNdbMutex); + + return pNdbMutex; } int NdbMutex_Destroy(NdbMutex* p_mutex) { int result; - DBUG_ENTER("NdbMutex_Destroy"); if (p_mutex == NULL) - DBUG_RETURN(-1); + return -1; result = pthread_mutex_destroy(p_mutex); - DBUG_PRINT("info",("NdbMem_Free 0x%lx", (long) p_mutex)); NdbMem_Free(p_mutex); - - DBUG_RETURN(result); + return result; } diff --git a/storage/ndb/src/ndbapi/DictCache.cpp b/storage/ndb/src/ndbapi/DictCache.cpp index 04be3711847..9c66b2be9d2 100644 --- a/storage/ndb/src/ndbapi/DictCache.cpp +++ b/storage/ndb/src/ndbapi/DictCache.cpp @@ -20,8 +20,10 @@ #include <NdbCondition.h> #include <NdbSleep.h> -static NdbTableImpl f_invalid_table; -static NdbTableImpl f_altered_table; +static NdbTableImpl * f_invalid_table = 0; +static NdbTableImpl * f_altered_table = 0; + +static int ndb_dict_cache_count = 0; Ndb_local_table_info * Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz) @@ -93,11 +95,29 @@ GlobalDictCache::GlobalDictCache(){ DBUG_ENTER("GlobalDictCache::GlobalDictCache"); m_tableHash.createHashTable(); m_waitForTableCondition = NdbCondition_Create(); + if (f_invalid_table == NULL) + f_invalid_table = new NdbTableImpl(); + if (f_altered_table == NULL) + f_altered_table = new NdbTableImpl(); + ndb_dict_cache_count++; DBUG_VOID_RETURN; } GlobalDictCache::~GlobalDictCache(){ DBUG_ENTER("GlobalDictCache::~GlobalDictCache"); + if (--ndb_dict_cache_count == 0) + { + if (f_invalid_table) + { + delete f_invalid_table; + f_invalid_table = 0; + } + if (f_altered_table) + { + delete f_altered_table; + f_altered_table = 0; + } + } NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0); while(curr != 0){ Vector<TableVersion> * vers = curr->theData; @@ -254,7 +274,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) TableVersion & ver = vers->back(); if(ver.m_status != RETREIVING || !(ver.m_impl == 0 || - ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) || + ver.m_impl == f_invalid_table || ver.m_impl == f_altered_table) || ver.m_version != 0 || ver.m_refCount == 0){ abort(); @@ -271,7 +291,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) ver.m_version = tab->m_version; ver.m_status = OK; } - else if (ver.m_impl == &f_invalid_table) + else if (ver.m_impl == f_invalid_table) { DBUG_PRINT("info", ("Table DROPPED invalid")); ver.m_impl = tab; @@ -279,7 +299,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) ver.m_status = DROPPED; ver.m_impl->m_status = NdbDictionary::Object::Invalid; } - else if(ver.m_impl == &f_altered_table) + else if(ver.m_impl == f_altered_table) { DBUG_PRINT("info", ("Table DROPPED altered")); ver.m_impl = tab; @@ -440,7 +460,7 @@ GlobalDictCache::alter_table_rep(const char * name, if(i == sz - 1 && ver.m_status == RETREIVING) { - ver.m_impl = altered ? &f_altered_table : &f_invalid_table; + ver.m_impl = altered ? f_altered_table : f_invalid_table; DBUG_VOID_RETURN; } } diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index bb32f0d3f84..abc03302b64 100755..100644 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -15,7 +15,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -SET(STRINGS_SOURCES bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c +SET(STRINGS_SOURCES bchange.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c ctype-czech.c ctype-euc_kr.c ctype-eucjpms.c ctype-extra.c ctype-gb2312.c ctype-gbk.c ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c dtoa.c int2str.c diff --git a/strings/Makefile.am b/strings/Makefile.am index 9b32f42c49a..fd884a1296a 100644 --- a/strings/Makefile.am +++ b/strings/Makefile.am @@ -30,19 +30,19 @@ pkglib_LIBRARIES = libmystrings.a # Exact one of ASSEMBLER_X if ASSEMBLER_x86 ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s -CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c dtoa.c strmov.c +CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c dtoa.c strmov.c else if ASSEMBLER_sparc32 # These file MUST all be on the same line!! Otherwise automake # generats a very broken makefile ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s -CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c strmov.c +CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c strmov.c else #no assembler ASRCS = # These file MUST all be on the same line!! Otherwise automake # generats a very broken makefile -CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c +CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c endif endif @@ -66,7 +66,7 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc CHARSET_INFO.txt libmystrings_a_LIBADD= -conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c +conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c conf_to_src_LDADD= #force static linking of conf_to_src - essential when linking against #custom installation of libc diff --git a/strings/bcmp.c b/strings/bcmp.c deleted file mode 100644 index 1b6ed22fc22..00000000000 --- a/strings/bcmp.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - bcmp(s1, s2, len) returns 0 if the "len" bytes starting at "s1" are - identical to the "len" bytes starting at "s2", non-zero if they are - different. - Now only used with purify because purify gives wrong warnings when - comparing a shorter string with bcmp. -*/ - -#include <my_global.h> -#include "m_string.h" - -#ifdef HAVE_purify -#undef bcmp -#undef HAVE_BCMP -#endif - -#if !defined(bcmp) && !defined(HAVE_BCMP) - -#if defined(MC68000) && defined(DS90) - -int bcmp(s1,s2, len) -const char *s1; -const char *s2; -uint len; /* 0 <= len <= 65535 */ -{ - asm(" movl 12(a7),d0 "); - asm(" subqw #1,d0 "); - asm(" blt .L5 "); - asm(" movl 4(a7),a1 "); - asm(" movl 8(a7),a0 "); - asm(".L4: cmpmb (a0)+,(a1)+ "); - asm(" dbne d0,.L4 "); - asm(".L5: addqw #1,d0 "); -} - -#else - -#ifndef HAVE_purify -size_t bcmp(register const uchar *s1,register const uchar *s2, - register size_t len) -#else -size_t my_bcmp(register const uchar *s1,register const uchar *s2, - register size_t len) -#endif -{ - while (len-- != 0 && *s1++ == *s2++) ; - return len+1; -} - -#endif -#endif /* BSD_FUNCS */ diff --git a/strings/str_test.c b/strings/str_test.c index e4358196f27..0814647472c 100644 --- a/strings/str_test.c +++ b/strings/str_test.c @@ -50,10 +50,10 @@ int main(void) errors=tests=0; init_strings(); - test_arg("bcmp(from,to,5)",(long) my_test(bcmp(from,to,5)),1L); - test_arg("bcmp(from,from,5)",(long) bcmp(from,from,5),0L); + test_arg("memcmp(from,to,5)",(long) my_test(memcmp(from,to,5)),1L); + test_arg("memcmp(from,from,5)",(long) memcmp(from,from,5),0L); - test_arg("bcmp(from,to,0)",(long) bcmp(from,to,0),0L); + test_arg("memcmp(from,to,0)",(long) memcmp(from,to,0),0L); test_arg("strend(from)",(long) strend(from),(long) from+F_LEN); test_arg("strchr(v1,'M')",(long) strchr(v1,'M'),(long) v1); test_arg("strchr(v1,'y')",(long) strchr(v1,'y'),(long) v1+4); @@ -93,7 +93,7 @@ int main(void) test_strarg("bmove_upp(to+6,from+6,3)",(bmove_upp(to+6,from+6,3),0L),INT_MAX32, 3,T_CHAR,3,F_CHAR,0,0); test_strarg("bmove_upp(to,from,0)",(bmove_upp(to,from,0),0L),INT_MAX32,0,0); - test_strarg("bmove_align(to,from,8)",(bmove_align(to,from,8),0L),INT_MAX32, + test_strarg("memcpy(to,from,8)",(memcpy(to,from,8),0L),INT_MAX32, 8,F_CHAR,0,0); test_strarg("strappend(to,3,' ')",(strappend(to,3,' '),0L),INT_MAX32, 3,T_CHAR,1,0,T_LEN-4,T_CHAR,1,0,0,0); @@ -233,7 +233,7 @@ int compare_buff(const char *message, char * b1, char * b2, int length, { int i,error=0; - if (bcmp(b1,b2,length)) + if (memcmp(b1,b2,length)) { errors++; printf("func: '%s' Buffers differ\nIs: ",message); diff --git a/strings/xml.c b/strings/xml.c index 1b697ec6b26..f3cfaad54fa 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -123,16 +123,16 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) a->beg=p->cur; a->end=p->cur; - if ((p->end - p->cur > 3) && !bcmp(p->cur,"<!--",4)) + if ((p->end - p->cur > 3) && !memcmp(p->cur,"<!--",4)) { - for (; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++) + for (; (p->cur < p->end) && memcmp(p->cur, "-->", 3); p->cur++) {} - if (!bcmp(p->cur, "-->", 3)) + if (!memcmp(p->cur, "-->", 3)) p->cur+=3; a->end=p->cur; lex=MY_XML_COMMENT; } - else if (!bcmp(p->cur, "<![CDATA[",9)) + else if (!memcmp(p->cur, "<![CDATA[",9)) { p->cur+= 9; for (; p->cur < p->end - 2 ; p->cur++) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b0e3342b1bc..b0e3342b1bc 100755..100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 1fd2c45cb63..a3640077889 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -2270,7 +2270,7 @@ static void test_prepare() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 100; tiny_data++) { - length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); + length[1]= sprintf(str_data, "MySQL%d", int_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -2309,7 +2309,7 @@ static void test_prepare() /* now, execute the prepared statement to insert 10 records.. */ for (o_tiny_data= 0; o_tiny_data < 100; o_tiny_data++) { - len= my_sprintf(data, (data, "MySQL%d", o_int_data)); + len= sprintf(data, "MySQL%d", o_int_data); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); @@ -3675,7 +3675,7 @@ static void test_simple_update() my_bind[0].buffer= szData; /* string data */ my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= my_sprintf(szData, (szData, "updated-data")); + length[0]= sprintf(szData, "updated-data"); my_bind[1].buffer= (void *) &nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -3871,7 +3871,7 @@ static void test_long_data_str() DIE_UNLESS(rc == 1); mysql_free_result(result); - my_sprintf(data, (data, "%d", i*5)); + sprintf(data, "%d", i*5); verify_col_data("test_long_data_str", "LENGTH(longstr)", data); data[0]= '\0'; while (i--) @@ -3929,7 +3929,7 @@ static void test_long_data_str1() rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); - length= my_sprintf(data, (data, "MySQL AB")); + length= sprintf(data, "MySQL AB"); /* supply data in pieces */ for (i= 0; i < 3; i++) @@ -3969,10 +3969,10 @@ static void test_long_data_str1() DIE_UNLESS(rc == 1); mysql_free_result(result); - my_sprintf(data, (data, "%ld", (long)i*length)); + sprintf(data, "%ld", (long)i*length); verify_col_data("test_long_data_str", "length(longstr)", data); - my_sprintf(data, (data, "%d", i*2)); + sprintf(data, "%d", i*2); verify_col_data("test_long_data_str", "length(blb)", data); /* Test length of field->max_length */ @@ -4244,7 +4244,7 @@ static void test_update() my_bind[0].buffer= szData; my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= my_sprintf(szData, (szData, "inserted-data")); + length[0]= sprintf(szData, "inserted-data"); my_bind[1].buffer= (void *)&nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -4273,7 +4273,7 @@ static void test_update() my_bind[0].buffer= szData; my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= my_sprintf(szData, (szData, "updated-data")); + length[0]= sprintf(szData, "updated-data"); my_bind[1].buffer= (void *)&nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -4842,7 +4842,7 @@ static void bind_fetch(int row_count) /* CHAR */ { char buff[20]; - long len= my_sprintf(buff, (buff, "%d", rc)); + long len= sprintf(buff, "%d", rc); DIE_UNLESS(strcmp(s_data, buff) == 0); DIE_UNLESS(length[6] == (ulong) len); } @@ -5435,7 +5435,7 @@ static void test_insert() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 3; tiny_data++) { - length= my_sprintf(str_data, (str_data, "MySQL%d", tiny_data)); + length= sprintf(str_data, "MySQL%d", tiny_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } @@ -18097,7 +18097,7 @@ static void test_wl4166_1() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 10; tiny_data++) { - length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); + length[1]= sprintf(str_data, "MySQL%d", int_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -18120,7 +18120,7 @@ static void test_wl4166_1() for (tiny_data= 50; tiny_data < 60; tiny_data++) { - length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); + length[1]= sprintf(str_data, "MySQL%d", int_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -19060,6 +19060,63 @@ static void test_bug42373() } +/** + Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run +*/ + +static void test_bug54041() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_BIND bind; + + DBUG_ENTER("test_bug54041"); + myheader("test_bug54041"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a INT)"); + myquery(rc); + + stmt= mysql_simple_prepare(mysql, "INSERT INTO t1 (a) VALUES (?)"); + check_stmt(stmt); + verify_param_count(stmt, 1); + + memset(&bind, 0, sizeof(bind)); + + /* Any type that does not support long data handling. */ + bind.buffer_type= MYSQL_TYPE_LONG; + + rc= mysql_stmt_bind_param(stmt, &bind); + check_execute(stmt, rc); + + /* + Trick the client API into sending a long data packet for + the parameter. Long data is only supported for string and + binary types. + */ + stmt->params[0].buffer_type= MYSQL_TYPE_STRING; + + rc= mysql_stmt_send_long_data(stmt, 0, "data", 5); + check_execute(stmt, rc); + + /* Undo API violation. */ + stmt->params[0].buffer_type= MYSQL_TYPE_LONG; + + rc= mysql_stmt_execute(stmt); + /* Incorrect arguments. */ + check_execute_r(stmt, rc); + + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + + DBUG_VOID_RETURN; +} + + /* Bug#49972: Crash in prepared statements. @@ -19500,6 +19557,7 @@ static struct my_tests_st my_tests[]= { { "test_bug44495", test_bug44495 }, { "test_bug49972", test_bug49972 }, { "test_bug42373", test_bug42373 }, + { "test_bug54041", test_bug54041 }, { 0, 0 } }; diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt index dae2ed2bb2f..dae2ed2bb2f 100755..100644 --- a/vio/CMakeLists.txt +++ b/vio/CMakeLists.txt diff --git a/win/mysql_manifest.cmake b/win/mysql_manifest.cmake index 611553d68ac..611553d68ac 100755..100644 --- a/win/mysql_manifest.cmake +++ b/win/mysql_manifest.cmake diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 4be153bfdfa..4be153bfdfa 100755..100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt |