diff options
375 files changed, 7955 insertions, 4251 deletions
diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 589e609beeb..02d160158b3 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -82,8 +82,11 @@ path=`dirname $0` export AM_MAKEFLAGS AM_MAKEFLAGS="-j 4" -# SSL library to use. -SSL_LIBRARY=--with-yassl +# SSL library to use.--with-ssl will select our bundled yaSSL +# implementation of SSL. To use openSSl you will nee too point out +# the location of openSSL headers and lbs on your system. +# Ex --with-ssl=/usr +SSL_LIBRARY=--with-ssl if [ "x$warning_mode" != "xpedantic" ]; then # Both C and C++ warnings diff --git a/BUILD/autorun.sh b/BUILD/autorun.sh index 63bab3565c6..9ffe61b250a 100755 --- a/BUILD/autorun.sh +++ b/BUILD/autorun.sh @@ -3,19 +3,25 @@ die() { echo "$@"; exit 1; } +# Added glibtoolize reference to make native OSX autotools work +if [ -f /usr/bin/glibtoolize ] + then + LIBTOOLIZE=glibtoolize + else + LIBTOOLIZE=libtoolize +fi + +(cd storage/bdb/dist && sh s_all) +(cd storage/innobase && aclocal && autoheader && \ + $LIBTOOLIZE --automake --force --copy && \ + automake --force --add-missing --copy && autoconf) + aclocal || die "Can't execute aclocal" autoheader || die "Can't execute autoheader" # --force means overwrite ltmain.sh script if it already exists -# Added glibtoolize reference to make native OSX autotools work -if test -f /usr/bin/glibtoolize ; then - glibtoolize --automake --force || die "Can't execute glibtoolize" -else - libtoolize --automake --force || die "Can't execute libtoolize" -fi +$LIBTOOLIZE --automake --force || die "Can't execute libtoolize" # --add-missing instructs automake to install missing auxiliary files # and --force to overwrite them if they already exist automake --add-missing --force || die "Can't execute automake" autoconf || die "Can't execute autoconf" -(cd storage/bdb/dist && sh s_all) -(cd storage/innobase && aclocal && autoheader && aclocal && automake && autoconf) diff --git a/BUILD/compile-dist b/BUILD/compile-dist index dea29d4612b..326de19da13 100755 --- a/BUILD/compile-dist +++ b/BUILD/compile-dist @@ -7,13 +7,15 @@ # package" that is used as the basis for all other binary builds. # make distclean +(cd storage/bdb/dist && sh s_all) +(cd storage/innobase && aclocal && autoheader && \ + libtoolize --automake --force --copy && \ + automake --force --add-missing --copy && autoconf) aclocal autoheader libtoolize --automake --force --copy automake --force --add-missing --copy autoconf -(cd storage/bdb/dist && sh s_all) -(cd storage/innobase && aclocal && autoheader && aclocal && automake && autoconf) # Default to gcc for CC and CXX if test -z "$CXX" ; then @@ -52,7 +54,7 @@ fi --with-federated-storage-engine \ --with-berkeley-db \ --with-innodb \ - --with-yassl \ + --with-ssl \ --enable-thread-safe-client \ --with-extra-charsets=complex \ --with-ndbcluster \ diff --git a/BUILD/compile-pentium-debug-openssl b/BUILD/compile-pentium-debug-openssl index 91c3b448c7e..2e24dbfd2f1 100755 --- a/BUILD/compile-pentium-debug-openssl +++ b/BUILD/compile-pentium-debug-openssl @@ -6,6 +6,6 @@ path=`dirname $0` extra_flags="$pentium_cflags $debug_cflags" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-debug=full --with-openssl" +extra_configs="$extra_configs --with-debug=full --with-ssl=/usr" . "$path/FINISH.sh" diff --git a/BUILD/compile-pentium-debug-yassl b/BUILD/compile-pentium-debug-yassl index 84ca489903d..61ad2937c4a 100755 --- a/BUILD/compile-pentium-debug-yassl +++ b/BUILD/compile-pentium-debug-yassl @@ -6,6 +6,6 @@ path=`dirname $0` extra_flags="$pentium_cflags $debug_cflags" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-debug=full --with-yassl" +extra_configs="$extra_configs --with-debug=full --with-ssl" . "$path/FINISH.sh" diff --git a/cmakelists.txt b/CMakeLists.txt index 5edc33b9f5a..5edc33b9f5a 100644 --- a/cmakelists.txt +++ b/CMakeLists.txt diff --git a/Makefile.am b/Makefile.am index 8709fca34c3..dfa6c7f0f07 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,7 +20,7 @@ AUTOMAKE_OPTIONS = foreign # These are built from source in the Docs directory EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \ - README COPYING EXCEPTIONS-CLIENT cmakelists.txt + README COPYING EXCEPTIONS-CLIENT CMakeLists.txt SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ @readline_topdir@ sql-common \ @thread_dirs@ pstack \ diff --git a/client/cmakelists.txt b/client/CMakeLists.txt index 26cc36c7f6f..26cc36c7f6f 100644 --- a/client/cmakelists.txt +++ b/client/CMakeLists.txt diff --git a/client/Makefile.am b/client/Makefile.am index 0531d741764..aa78f825c87 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -77,7 +77,7 @@ strings_src=decimal.c DEFS = -DUNDEF_THREADS_HACK \ -DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \ -DDATADIR="\"$(localstatedir)\"" -EXTRA_DIST = get_password.c cmakelists.txt +EXTRA_DIST = get_password.c CMakeLists.txt link_sources: for f in $(sql_src) ; do \ diff --git a/client/client_priv.h b/client/client_priv.h index 625fbf24fa6..bcaa74d3228 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -58,5 +58,5 @@ enum options_client OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_CREATE_SLAP_SCHEMA, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID, - OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES + OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT }; diff --git a/client/client_priv.h.rej b/client/client_priv.h.rej new file mode 100644 index 00000000000..ac3818bb1e1 --- /dev/null +++ b/client/client_priv.h.rej @@ -0,0 +1,15 @@ +*************** +*** 50,55 **** + OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, + #endif + OPT_TRIGGERS, + OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, +! OPT_TZ_UTC, OPT_AUTO_CLOSE + }; +--- 50,55 ---- + OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, + #endif + OPT_TRIGGERS, + OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, +! OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT + }; diff --git a/client/mysql.cc b/client/mysql.cc index 80fee6f0995..96df1fafc3b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -448,6 +448,14 @@ int main(int argc,char *argv[]) MYF(MY_WME)); if (histfile) sprintf(histfile,"%s/.mysql_history",getenv("HOME")); + char link_name[FN_REFLEN]; + if (my_readlink(link_name, histfile, 0) == 0 && + strncmp(link_name, "/dev/null", 10) == 0) + { + /* The .mysql_history file is a symlink to /dev/null, don't use it */ + my_free(histfile, MYF(MY_ALLOW_ZERO_PTR)); + histfile= 0; + } } if (histfile) { @@ -484,7 +492,7 @@ sig_handler mysql_end(int sig) { mysql_close(&mysql); #ifdef HAVE_READLINE - if (!status.batch && !quick && !opt_html && !opt_xml) + if (!status.batch && !quick && !opt_html && !opt_xml && histfile) { /* write-history */ if (verbose) @@ -3143,6 +3151,8 @@ sql_real_connect(char *host,char *database,char *user,char *password, if (opt_use_ssl) mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher); + mysql_options(&mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 5b52d524f8e..57ab4e071fb 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -340,6 +340,8 @@ int main(int argc,char *argv[]) if (opt_use_ssl) mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher); + mysql_options(&mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 490a74e6035..4b2527c25ef 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -815,7 +815,8 @@ static void die(const char* fmt, ...) fprintf(stderr, "\n"); va_end(args); cleanup(); - my_end(0); + /* We cannot free DBUG, it is used in global destructors after exit(). */ + my_end(MY_DONT_FREE_DBUG); exit(1); } @@ -1487,7 +1488,8 @@ int main(int argc, char** argv) cleanup(); free_defaults(defaults_argv); my_free_open_file_info(); - my_end(0); + /* We cannot free DBUG, it is used in global destructors after exit(). */ + my_end(MY_DONT_FREE_DBUG); exit(exit_value); DBUG_RETURN(exit_value); // Keep compilers happy } diff --git a/client/mysqldump.c b/client/mysqldump.c index 82da5d990b9..58cd2342bd3 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -918,6 +918,8 @@ static int dbConnect(char *host, char *user,char *passwd) if (opt_use_ssl) mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher); + mysql_options(&mysql_connection,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 42d521a1412..ccd6932e25b 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -406,6 +406,8 @@ static MYSQL *db_connect(char *host, char *database, if (opt_use_ssl) mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher); + mysql_options(mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 504f0d9844b..d090495ff81 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -109,6 +109,8 @@ int main(int argc, char **argv) if (opt_use_ssl) mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher); + mysql_options(&mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqltest.c b/client/mysqltest.c index ce876708fbc..774cbac6e3f 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -87,14 +87,6 @@ #endif #define MAX_SERVER_ARGS 64 -/* - Sometimes in a test the client starts before - the server - to solve the problem, we try again - after some sleep if connection fails the first - time -*/ -#define CON_RETRY_SLEEP 2 -#define MAX_CON_TRIES 5 #define SLAVE_POLL_INTERVAL 300000 /* 0.3 of a sec */ #define DEFAULT_DELIMITER ";" @@ -108,7 +100,7 @@ enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC, OPT_SSL_SSL, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER,OPT_PS_PROTOCOL,OPT_SP_PROTOCOL,OPT_CURSOR_PROTOCOL, - OPT_VIEW_PROTOCOL}; + OPT_VIEW_PROTOCOL, OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES}; /* ************************************************************************ */ /* @@ -158,6 +150,7 @@ static char *db = 0, *pass=0; const char *user = 0, *host = 0, *unix_sock = 0, *opt_basedir="./"; const char *opt_include= 0; static int port = 0; +static int opt_max_connect_retries; static my_bool opt_big_test= 0, opt_compress= 0, silent= 0, verbose = 0; static my_bool tty_password= 0; static my_bool ps_protocol= 0, ps_protocol_enabled= 0; @@ -2501,9 +2494,16 @@ void init_manager() db, port, sock NOTE - This function will try to connect to the given server MAX_CON_TRIES - times and sleep CON_RETRY_SLEEP seconds between attempts before - finally giving up. This helps in situation when the client starts + + Sometimes in a test the client starts before + the server - to solve the problem, we try again + after some sleep if connection fails the first + time + + This function will try to connect to the given server + "opt_max_connect_retries" times and sleep "connection_retry_sleep" + seconds between attempts before finally giving up. + This helps in situation when the client starts before the server (which happens sometimes). It will ignore any errors during these retries. One should use connect_n_handle_errors() if he expects a connection error and wants @@ -2518,8 +2518,9 @@ int safe_connect(MYSQL* mysql, const char *host, const char *user, { int con_error= 1; my_bool reconnect= 1; + static int connection_retry_sleep= 2; /* Seconds */ int i; - for (i= 0; i < MAX_CON_TRIES; ++i) + for (i= 0; i < opt_max_connect_retries; i++) { if (mysql_real_connect(mysql, host,user, pass, db, port, sock, CLIENT_MULTI_STATEMENTS | CLIENT_REMEMBER_OPTIONS)) @@ -2527,7 +2528,7 @@ int safe_connect(MYSQL* mysql, const char *host, const char *user, con_error= 0; break; } - sleep(CON_RETRY_SLEEP); + sleep(connection_retry_sleep); } /* TODO: change this to 0 in future versions, but the 'kill' test relies on @@ -2755,8 +2756,12 @@ int do_connect(struct st_query *q) #ifdef HAVE_OPENSSL if (opt_use_ssl || con_ssl) + { mysql_ssl_set(&next_con->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher); + mysql_options(&next_con->mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + &opt_ssl_verify_server_cert); + } #endif if (con_sock && !free_con_sock && *con_sock && *con_sock != FN_LIBCHAR) con_sock=fn_format(buff, con_sock, TMPDIR, "",0); @@ -3290,6 +3295,10 @@ static struct my_option my_long_options[] = {"manager-wait-timeout", OPT_MANAGER_WAIT_TIMEOUT, "Undocumented: Used for debugging.", (gptr*) &manager_wait_timeout, (gptr*) &manager_wait_timeout, 0, GET_INT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0}, + {"max-connect-retries", OPT_MAX_CONNECT_RETRIES, + "Max number of connection attempts when connecting to server", + (gptr*) &opt_max_connect_retries, (gptr*) &opt_max_connect_retries, 0, + GET_INT, REQUIRED_ARG, 5, 1, 10, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection.", (gptr*) &port, @@ -5207,9 +5216,14 @@ int main(int argc, char **argv) mysql_options(&cur_con->mysql, MYSQL_SET_CHARSET_NAME, charset_name); #ifdef HAVE_OPENSSL + opt_ssl_verify_server_cert= TRUE; /* Always on in mysqltest */ if (opt_use_ssl) + { mysql_ssl_set(&cur_con->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, opt_ssl_capath, opt_ssl_cipher); + mysql_options(&cur_con->mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + &opt_ssl_verify_server_cert); + } #endif if (!(cur_con->name = my_strdup("default", MYF(MY_WME)))) diff --git a/config/ac-macros/openssl.m4 b/config/ac-macros/openssl.m4 deleted file mode 100644 index a23c46eed00..00000000000 --- a/config/ac-macros/openssl.m4 +++ /dev/null @@ -1,136 +0,0 @@ -AC_DEFUN([MYSQL_FIND_OPENSSL], [ - incs="$1" - libs="$2" - eval shrexts=\"$shrext_cmds\" - case "$incs---$libs" in - ---) - for d in /usr/ssl/include /usr/local/ssl/include /usr/include \ -/usr/include/ssl /opt/ssl/include /opt/openssl/include \ -/usr/local/ssl/include /usr/local/include /usr/freeware/include ; do - if test -f $d/openssl/ssl.h ; then - OPENSSL_INCLUDE=-I$d - fi - done - - for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \ -/usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib \ -/usr/freeware/lib32 /usr/local/lib/ ; do - # Just to be safe, we test for ".so" anyway - if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl$shrext ; then - OPENSSL_LIB=$d - fi - done - ;; - ---* | *---) - AC_MSG_ERROR([if either 'includes' or 'libs' is specified, both must be specified]) - ;; - * ) - if test -f $incs/openssl/ssl.h ; then - OPENSSL_INCLUDE=-I$incs - fi - # Just to be safe, we test for ".so" anyway - if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f $libs/libssl$shrext ; then - OPENSSL_LIB=$libs - fi - ;; - esac - - # On RedHat 9 we need kerberos to compile openssl - for d in /usr/kerberos/include - do - if test -f $d/krb5.h ; then - OPENSSL_KERBEROS_INCLUDE="$d" - fi - done - - - if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INCLUDE" ; then - echo "Could not find an installation of OpenSSL" - if test -n "$OPENSSL_LIB" ; then - if test "$TARGET_LINUX" = "true"; then - echo "Looks like you've forgotten to install OpenSSL development RPM" - fi - fi - exit 1 - fi - -]) - -AC_DEFUN([MYSQL_CHECK_OPENSSL], [ -AC_MSG_CHECKING(for OpenSSL) - AC_ARG_WITH([openssl], - [ --with-openssl[=DIR] Include the OpenSSL support], - [openssl="$withval"], - [openssl=no]) - - AC_ARG_WITH([openssl-includes], - [ - --with-openssl-includes=DIR - Find OpenSSL headers in DIR], - [openssl_includes="$withval"], - [openssl_includes=""]) - - AC_ARG_WITH([openssl-libs], - [ - --with-openssl-libs=DIR - Find OpenSSL libraries in DIR], - [openssl_libs="$withval"], - [openssl_libs=""]) - - if test "$openssl" != "no" - then - if test "$openssl" != "yes" - then - if test -z "$openssl_includes" - then - openssl_includes="$openssl/include" - fi - if test -z "$openssl_libs" - then - openssl_libs="$openssl/lib" - fi - fi - MYSQL_FIND_OPENSSL([$openssl_includes], [$openssl_libs]) - #force VIO use - AC_MSG_RESULT(yes) - openssl_libs="-L$OPENSSL_LIB -lssl -lcrypto" - # Don't set openssl_includes to /usr/include as this gives us a lot of - # compiler warnings when using gcc 3.x - openssl_includes="" - if test "$OPENSSL_INCLUDE" != "-I/usr/include" - then - openssl_includes="$OPENSSL_INCLUDE" - fi - if test "$OPENSSL_KERBEROS_INCLUDE" - then - openssl_includes="$openssl_includes -I$OPENSSL_KERBEROS_INCLUDE" - fi - AC_DEFINE([HAVE_OPENSSL], [1], [OpenSSL]) - - # openssl-devel-0.9.6 requires dlopen() and we can't link staticly - # on many platforms (We should actually test this here, but it's quite - # hard) to do as we are doing libtool for linking. - using_static="" - case "$CLIENT_EXTRA_LDFLAGS $MYSQLD_EXTRA_LDFLAGS" in - *-all-static*) using_static="yes" ;; - esac - if test "$using_static" = "yes" - then - echo "You can't use the --all-static link option when using openssl." - exit 1 - fi - NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs" - else - AC_MSG_RESULT(no) - if test ! -z "$openssl_includes" - then - AC_MSG_ERROR(Can't have --with-openssl-includes without --with-openssl); - fi - if test ! -z "$openssl_libs" - then - AC_MSG_ERROR(Can't have --with-openssl-libs without --with-openssl); - fi - fi - AC_SUBST(openssl_libs) - AC_SUBST(openssl_includes) -]) diff --git a/config/ac-macros/plugins.m4 b/config/ac-macros/plugins.m4 index aa28a611e9e..4bf9292547d 100644 --- a/config/ac-macros/plugins.m4 +++ b/config/ac-macros/plugins.m4 @@ -39,6 +39,10 @@ AC_DEFUN([_MYSQL_PLUGIN],[ m4_define([MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]), [$3]) m4_define([MYSQL_PLUGIN_DESC_]AS_TR_CPP([$1]), [$4]) _MYSQL_PLUGAPPEND_META([$1], $5) + ifelse(m4_bregexp(__mysql_include__,[/plug\.in$]),-1,[],[ + MYSQL_PLUGIN_DIRECTORY([$1], + m4_bregexp(__mysql_include__,[^\(.*\)/plug\.in$],[\1])) + ]) ]) ]) @@ -249,7 +253,6 @@ AC_DEFUN([MYSQL_PLUGIN_ACTIONS],[ ]) ]) - dnl --------------------------------------------------------------------------- dnl Macro: MYSQL_CONFIGURE_PLUGINS dnl @@ -267,6 +270,10 @@ AC_DEFUN([MYSQL_CONFIGURE_PLUGINS],[ AC_FATAL([cannot use [MYSQL_CONFIGURE_PLUGINS] multiple times]) ],[ m4_define([__mysql_plugin_configured__],[done]) + _MYSQL_INCLUDE_LIST( + m4_bpatsubst(m4_esyscmd([ls plugin/*/plug.in storage/*/plug.in 2>/dev/null]), +[[ +]],[,])) m4_ifdef([__mysql_plugin_list__],[ _MYSQL_CHECK_PLUGIN_ARGS([$1]) _MYSQL_CONFIGURE_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,])) @@ -397,11 +404,11 @@ dnl Although this is "pretty", it breaks libmysqld build m4_ifdef([$6],[ if test -n "$mysql_use_plugin_dir" ; then mysql_plugin_dirs="$mysql_plugin_dirs $6" - if test -f "$srcdir/$6/configure" ; then - other_configures="$other_configures $6/configure" - else - AC_CONFIG_FILES($6/Makefile) - fi + m4_syscmd(test -f "$6/configure") + ifelse(m4_sysval, 0, + [other_configures="$other_configures $6/configure"], + [AC_CONFIG_FILES($6/Makefile)] + ) ifelse(m4_substr($6, 0, 8), [storage/], [mysql_se_dirs="$mysql_se_dirs ]m4_substr($6, 8)", m4_substr($6, 0, 7), [plugin/], @@ -730,4 +737,26 @@ _MYSQL_EMIT_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,])) _MYSQL_EMIT_PLUGIN_DEPENDS(m4_bpatsubst(__mysql_plugin_list__, :, [,])) ]) +dnl --------------------------------------------------------------------------- +dnl Macro: _MYSQL_INCLUDE_LIST +dnl +dnl SYNOPSIS +dnl _MYSQL_INCLUDE_LIST([filename,filename...]) +dnl +dnl DESCRIPTION +dnl includes all files from the list +dnl +dnl --------------------------------------------------------------------------- +AC_DEFUN([_MYSQL_INCLUDE_LIST],[ + ifelse([$1], [], [], [ + m4_define([__mysql_include__],[$1]) + dnl We have to use builtin(), because sinclude would generate an error + dnl "file $1 does not exists" in aclocal-1.8 - which is a bug, clearly + dnl violating m4 specs, and which is fixed in aclocal-1.9 + builtin([include],$1) + m4_undefine([__mysql_include__]) + _MYSQL_INCLUDE_LIST(m4_shift($@)) + ]) +]) + dnl =========================================================================== diff --git a/config/ac-macros/ssl.m4 b/config/ac-macros/ssl.m4 new file mode 100644 index 00000000000..14f3dcc9bc8 --- /dev/null +++ b/config/ac-macros/ssl.m4 @@ -0,0 +1,200 @@ +dnl =========================================================================== +dnl Support for SSL +dnl =========================================================================== +dnl +dnl + +dnl --------------------------------------------------------------------------- +dnl Macro: MYSQL_USE_BUNDLED_YASSL +dnl +dnl SYNOPSIS +dnl MYSQL_USE_BUNDLED_YASSL() +dnl +dnl DESCRIPTION +dnl Add defines so yassl is built and linked with +dnl --------------------------------------------------------------------------- +AC_DEFUN([MYSQL_USE_BUNDLED_YASSL], [ + + AC_CONFIG_FILES(extra/yassl/Makefile dnl + extra/yassl/taocrypt/Makefile dnl + extra/yassl/taocrypt/benchmark/Makefile dnl + extra/yassl/taocrypt/src/Makefile dnl + extra/yassl/taocrypt/test/Makefile dnl + extra/yassl/src/Makefile dnl + extra/yassl/testsuite/Makefile) + + with_yassl="yes" + + yassl_dir="yassl" + AC_SUBST([yassl_dir]) + + yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt" + AC_SUBST(yassl_libs) + yassl_includes="-I\$(top_srcdir)/extra/yassl/include" + AC_SUBST(yassl_includes) + + AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for SSL.]) + AC_DEFINE([HAVE_YASSL], [1], [Defined by configure. Using yaSSL for SSL.]) + + # System specific checks + yassl_integer_extra_cxxflags="" + case $host_cpu--$CXX_VERSION in + sparc*--*Sun*C++*5.6*) + # Disable inlining when compiling taocrypt/src/ + yassl_taocrypt_extra_cxxflags="+d" + AC_MSG_NOTICE([disabling inlining for yassl/taocrypt/src/]) + ;; + esac + AC_SUBST([yassl_taocrypt_extra_cxxflags]) + + # Link extra/yassl/include/openssl subdir to include/ + yassl_h_ln_cmd="\$(LN) -s \$(top_srcdir)/extra/yassl/include/openssl openssl" + AC_SUBST(yassl_h_ln_cmd) + + AC_MSG_RESULT([using bundled yaSSL]) +]) + + +dnl --------------------------------------------------------------------------- +dnl Macro: MYSQL_CHECK_SSL_DIR +dnl +dnl SYNOPSIS +dnl MYSQL_CHECK_SSL_DIR(includes, libs) +dnl +dnl DESCRIPTION +dnl Auxiliary macro to check for ssl at given path +dnl +dnl --------------------------------------------------------------------------- + +AC_DEFUN([MYSQL_CHECK_SSL_DIR], [ +ssl_incs="$1" +ssl_libs="$2" +save_CPPFLAGS="$CPPFLAGS" +save_LIBS="$LIBS" +CPPFLAGS="$ssl_incs $CPPFLAGS" +LIBS="$LIBS $ssl_libs" +AC_TRY_LINK([#include <openssl/ssl.h>], + [return SSL_library_init();], + [mysql_ssl_found="yes"], + [mysql_ssl_found="no"]) +CPPFLAGS="$save_CPPFLAGS" +LIBS="$save_LIBS" +]) + + +dnl --------------------------------------------------------------------------- +dnl Macro: MYSQL_FIND_OPENSSL +dnl +dnl SYNOPSIS +dnl MYSQL_FIND_OPENSSL(location) +dnl +dnl DESCRIPTION +dnl Search the location for OpenSSL support +dnl +dnl --------------------------------------------------------------------------- +AC_DEFUN([MYSQL_FIND_OPENSSL], [ + location="$1" + + # + # Set include paths + # + openssl_include="$location/include" + openssl_includes="" + + # Don't set ssl_includes to /usr/include as this gives us a lot of + # compiler warnings when using gcc 3.x + if test "$openssl_include" != "/usr/include" + then + openssl_includes="-I$ssl_include" + fi + + # + # Try to link with openSSL libs in <location> + # + openssl_libs="-L$location/lib/ -lssl -lcrypto" + MYSQL_CHECK_SSL_DIR([$openssl_includes], [$openssl_libs]) + + if test "$mysql_ssl_found" == "no" + then + # + # BUG 764: Compile failure with OpenSSL on Red Hat Linux (krb5.h missing) + # Try to link with include paths to kerberos set + # + openssl_includes="$openssl_includes -I/usr/kerberos/include" + MYSQL_CHECK_SSL_DIR([$openssl_includes], [$openssl_libs]) + fi + + if test "$mysql_ssl_found" == "no" + then + AC_MSG_ERROR([Could not link with SSL libs at $location]) + fi + + # openssl-devel-0.9.6 requires dlopen() and we can't link staticly + # on many platforms (We should actually test this here, but it's quite + # hard to do as we are doing libtool for linking.) + case "$CLIENT_EXTRA_LDFLAGS $MYSQLD_EXTRA_LDFLAGS" in + *-all-static*) + AC_MSG_ERROR([You can't use the --all-static link option when using openssl.]) + ;; + esac + + AC_SUBST(openssl_includes) + AC_SUBST(openssl_libs) + + NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs" + + AC_DEFINE([HAVE_OPENSSL], [1], [OpenSSL]) + AC_MSG_RESULT([using openSSL from $location]) +]) + + + +dnl ------------------------------------------------------------------------ +dnl Macro: MYSQL_CHECK_SSL +dnl +dnl SYNOPSIS +dnl MYSQL_CHECK_SSL +dnl +dnl Provides the following configure options: +dnl --with-ssl=DIR +dnl Possible DIR values are: +dnl - no - the macro will disable use of ssl +dnl - bundled, empty or not specified - means use ssl lib +dnl bundled along with MySQL sources +dnl - ssl location prefix - given location prefix, the macro expects +dnl to find the header files in $prefix/include/, and libraries in +dnl $prefix/lib. If headers or libraries weren't found at $prefix, the +dnl macro bails out with error. +dnl +dnl ------------------------------------------------------------------------ +AC_DEFUN([MYSQL_CHECK_SSL], [ +AC_MSG_CHECKING(for SSL) + AC_ARG_WITH([ssl], + [ --with-ssl[=DIR] Include SSL support], + [mysql_ssl_dir="$withval"], + [mysql_ssl_dir=no]) + + case "$mysql_ssl_dir" in + "no") + # + # Don't include SSL support + # + AC_MSG_RESULT([disabled]) + ;; + + "bundled"|"yes") + # + # Use the bundled SSL implementation (yaSSL) + # + MYSQL_USE_BUNDLED_YASSL + ;; + + *) + # + # A location where to search for OpenSSL was specified + # + MYSQL_FIND_OPENSSL([$mysql_ssl_dir]) + ;; + esac + AM_CONDITIONAL([HAVE_YASSL], [ test "$with_yassl" = "yes" ]) +]) diff --git a/config/ac-macros/yassl.m4 b/config/ac-macros/yassl.m4 deleted file mode 100644 index f6eee32ff84..00000000000 --- a/config/ac-macros/yassl.m4 +++ /dev/null @@ -1,45 +0,0 @@ -AC_DEFUN([MYSQL_CHECK_YASSL], [ - AC_MSG_CHECKING(for yaSSL) - AC_ARG_WITH([yassl], [ --with-yassl Include the yaSSL support],,) - - if test "$with_yassl" = "yes" - then - if test "$openssl" != "no" - then - AC_MSG_ERROR([Cannot configure MySQL to use yaSSL and OpenSSL simultaneously.]) - fi - AC_MSG_RESULT([using bundled yaSSL]) - AC_CONFIG_FILES(extra/yassl/Makefile dnl - extra/yassl/taocrypt/Makefile dnl - extra/yassl/taocrypt/benchmark/Makefile dnl - extra/yassl/taocrypt/src/Makefile dnl - extra/yassl/taocrypt/test/Makefile dnl - extra/yassl/src/Makefile dnl - extra/yassl/testsuite/Makefile) - yassl_dir="yassl" - yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt" - yassl_includes="-I\$(top_srcdir)/extra/yassl/include" - AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for OpenSSL emulation.]) - AC_DEFINE([HAVE_YASSL], [1], [Defined by configure. Using yaSSL for OpenSSL emulation.]) - # System specific checks - yassl_integer_extra_cxxflags="" - case $host_cpu--$CXX_VERSION in - sparc*--*Sun*C++*5.6*) - # Disable inlining when compiling taocrypt/src/ - yassl_taocrypt_extra_cxxflags="+d" - AC_MSG_NOTICE([disabling inlining for yassl/taocrypt/src/]) - ;; - esac - AC_SUBST([yassl_taocrypt_extra_cxxflags]) - # Link extra/yassl/include/openssl subdir to include/ - yassl_h_ln_cmd="\$(LN) -s \$(top_srcdir)/extra/yassl/include/openssl openssl" - AC_SUBST(yassl_h_ln_cmd) - else - yassl_dir="" - AC_MSG_RESULT(no) - fi - AC_SUBST(yassl_libs) - AC_SUBST(yassl_includes) - AC_SUBST(yassl_dir) - AM_CONDITIONAL([HAVE_YASSL], [ test "$with_yassl" = "yes" ]) -]) diff --git a/config/ac-macros/zlib.m4 b/config/ac-macros/zlib.m4 index 713e7072c6f..17b951d4723 100644 --- a/config/ac-macros/zlib.m4 +++ b/config/ac-macros/zlib.m4 @@ -89,10 +89,11 @@ case $SYSTEM_TYPE in fi ;; *) - # Just to be safe, we test for ".so" anyway - eval shrexts=\"$shrext_cmds\" - if test \( -f "$mysql_zlib_dir/lib/libz.a" -o -f "$mysql_zlib_dir/lib/libz.so" -o \ - -f "$mysql_zlib_dir/lib/libz$shrext" \) \ + # Test for libz using all known library file endings + if test \( -f "$mysql_zlib_dir/lib/libz.a" -o \ + -f "$mysql_zlib_dir/lib/libz.so" -o \ + -f "$mysql_zlib_dir/lib/libz.sl" -o \ + -f "$mysql_zlib_dir/lib/libz.dylib" \) \ -a -f "$mysql_zlib_dir/include/zlib.h"; then ZLIB_INCLUDES="-I$mysql_zlib_dir/include" ZLIB_LIBS="-L$mysql_zlib_dir/lib -lz" diff --git a/configure.in b/configure.in index 71f6f9d89ab..64886892e2e 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.1.10-beta) +AM_INIT_AUTOMAKE(mysql, 5.1.11-beta) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -36,10 +36,9 @@ sinclude(config/ac-macros/ha_berkeley.m4) sinclude(config/ac-macros/ha_ndbcluster.m4) sinclude(config/ac-macros/large_file.m4) sinclude(config/ac-macros/misc.m4) -sinclude(config/ac-macros/openssl.m4) sinclude(config/ac-macros/readline.m4) sinclude(config/ac-macros/replication.m4) -sinclude(config/ac-macros/yassl.m4) +sinclude(config/ac-macros/ssl.m4) sinclude(config/ac-macros/zlib.m4) # Remember to add a directory sql/share/LANGUAGE @@ -2184,8 +2183,7 @@ MYSQL_CHECK_BIG_TABLES MYSQL_CHECK_MAX_INDEXES MYSQL_CHECK_REPLICATION MYSQL_CHECK_VIO -MYSQL_CHECK_OPENSSL -MYSQL_CHECK_YASSL +MYSQL_CHECK_SSL #-------------------------------------------------------------------- # Declare our plugin modules @@ -2193,12 +2191,6 @@ MYSQL_CHECK_YASSL # functions tested above #-------------------------------------------------------------------- -MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine], - [Archive Storage Engine], [max,max-no-ndb]) -MYSQL_PLUGIN_DIRECTORY(archive, [storage/archive]) -MYSQL_PLUGIN_STATIC(archive, [libarchive.a]) -MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la]) - MYSQL_STORAGE_ENGINE(berkeley, berkeley-db, [BerkeleyDB Storage Engine], [Transactional Tables using BerkeleyDB], [max,max-no-ndb]) MYSQL_PLUGIN_DIRECTORY(berkeley,[storage/bdb]) @@ -2217,12 +2209,6 @@ MYSQL_PLUGIN_DIRECTORY(csv, [storage/csv]) MYSQL_PLUGIN_STATIC(csv, [libcsv.a]) MYSQL_PLUGIN_MANDATORY(csv) dnl Used for logging -MYSQL_STORAGE_ENGINE(example,, [Example Storage Engine], - [Skeleton for Storage Engines for developers], [max,max-no-ndb]) -MYSQL_PLUGIN_DIRECTORY(example, [storage/example]) -MYSQL_PLUGIN_STATIC(example, [libexample.a]) -MYSQL_PLUGIN_DYNAMIC(example, [ha_example.la]) - MYSQL_STORAGE_ENGINE(federated,,[Federated Storage Engine], [Connects to tables on remote MySQL servers], [max,max-no-ndb]) diff --git a/dbug/cmakelists.txt b/dbug/CMakeLists.txt index fe20fdd3db6..fe20fdd3db6 100644 --- a/dbug/cmakelists.txt +++ b/dbug/CMakeLists.txt diff --git a/dbug/Makefile.am b/dbug/Makefile.am index b0c8862bede..60a95a82be5 100644 --- a/dbug/Makefile.am +++ b/dbug/Makefile.am @@ -20,7 +20,7 @@ LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a pkglib_LIBRARIES = libdbug.a noinst_HEADERS = dbug_long.h libdbug_a_SOURCES = dbug.c sanity.c -EXTRA_DIST = cmakelists.txt example1.c example2.c example3.c \ +EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \ user.r monty.doc dbug_add_tags.pl \ my_main.c main.c factorial.c dbug_analyze.c NROFF_INC = example1.r example2.r example3.r main.r \ diff --git a/dbug/dbug.c b/dbug/dbug.c index 52de4b4a92d..07f72a3e758 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -255,6 +255,8 @@ static void DBUGOpenFile(CODE_STATE *,const char *, const char *, int); static void DBUGCloseFile(CODE_STATE *cs, FILE *fp); /* Push current debug settings */ static void PushState(CODE_STATE *cs); + /* Free memory associated with debug state. */ +static void FreeState (CODE_STATE *cs, struct settings *state); /* Test for tracing enabled */ static BOOLEAN DoTrace(CODE_STATE *cs); @@ -742,19 +744,7 @@ void _db_pop_() if (discard->next != NULL) { cs->stack= discard->next; - if (!is_shared(discard, keywords)) - FreeList(discard->keywords); - if (!is_shared(discard, functions)) - FreeList(discard->functions); - if (!is_shared(discard, processes)) - FreeList(discard->processes); - if (!is_shared(discard, p_functions)) - FreeList(discard->p_functions); - if (!is_shared(discard, out_file)) - DBUGCloseFile(cs, discard->out_file); - if (discard->prof_file) - DBUGCloseFile(cs, discard->prof_file); - free((char *) discard); + FreeState(cs, discard); } } @@ -1425,6 +1415,74 @@ static void PushState(CODE_STATE *cs) cs->stack= new_malloc; } +/* + * FUNCTION + * + * FreeState Free memory associated with a struct state. + * + * SYNOPSIS + * + * static void FreeState (state) + * struct state *state; + * + * DESCRIPTION + * + * Deallocates the memory allocated for various information in a + * state. + * + */ +static void FreeState ( +CODE_STATE *cs, +struct settings *state) +{ + if (!is_shared(state, keywords)) + FreeList(state->keywords); + if (!is_shared(state, functions)) + FreeList(state->functions); + if (!is_shared(state, processes)) + FreeList(state->processes); + if (!is_shared(state, p_functions)) + FreeList(state->p_functions); + if (!is_shared(state, out_file)) + DBUGCloseFile(cs, state->out_file); + if (state->prof_file) + DBUGCloseFile(cs, state->prof_file); + free((char *) state); +} + + +/* + * FUNCTION + * + * _db_end_ End debugging, freeing state stack memory. + * + * SYNOPSIS + * + * static VOID _db_end_ () + * + * DESCRIPTION + * + * Ends debugging, de-allocating the memory allocated to the + * state stack. + * + * To be called at the very end of the program. + * + */ +void _db_end_ () +{ + struct settings *discard; + CODE_STATE *cs=0; + + get_code_state_or_return; + + while((discard= cs->stack) != NULL) { + if(discard == &init_settings) + break; + cs->stack= discard->next; + FreeState (cs, discard); + } +} + /* * FUNCTION diff --git a/extra/cmakelists.txt b/extra/CMakeLists.txt index 50e0f04eb14..50e0f04eb14 100644 --- a/extra/cmakelists.txt +++ b/extra/CMakeLists.txt diff --git a/extra/Makefile.am b/extra/Makefile.am index 4b483128439..de8e519e641 100644 --- a/extra/Makefile.am +++ b/extra/Makefile.am @@ -40,7 +40,7 @@ $(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \ resolve_stack_dump mysql_waitpid innochecksum noinst_PROGRAMS = charset2html -EXTRA_DIST = cmakelists.txt +EXTRA_DIST = CMakeLists.txt perror.o: perror.c $(COMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $< diff --git a/extra/yassl/cmakelists.txt b/extra/yassl/CMakeLists.txt index cafa3011e94..cafa3011e94 100644 --- a/extra/yassl/cmakelists.txt +++ b/extra/yassl/CMakeLists.txt diff --git a/extra/yassl/Makefile.am b/extra/yassl/Makefile.am index 60868f82add..e4a81019cd1 100644 --- a/extra/yassl/Makefile.am +++ b/extra/yassl/Makefile.am @@ -1,3 +1,3 @@ SUBDIRS = taocrypt src testsuite EXTRA_DIST = yassl.dsp yassl.dsw yassl.vcproj $(wildcard mySTL/*.hpp) \ - cmakelists.txt + CMakeLists.txt diff --git a/extra/yassl/README b/extra/yassl/README index ad59fe3965e..62209723f66 100644 --- a/extra/yassl/README +++ b/extra/yassl/README @@ -1,4 +1,37 @@ -yaSSL Release notes, version 1.2.2 (03/27/06) +yaSSL Release notes, version 1.3.0 (04/26/06) + + + This release of yaSSL contains minor bug fixes, portability enhancements, + and libcurl support. + +See normal build instructions below under 1.0.6. + + +--To build for libcurl on Linux, Solaris, *BSD, Mac OS X, or Cygwin: + + To build for libcurl the library needs to be built without C++ globals since + the linker will be called in a C context, also libcurl configure will expect + OpenSSL library names so some symbolic links are created. + + ./configure --enable-pure-c + make + make openssl-links + + (then go to your libcurl home and tell libcurl about yaSSL) + ./configure --with-ssl=/yaSSL-HomeDir + make + + +--To build for libcurl on Win32: + + Simply add the yaSSL project as a dependency to libcurl, add + yaSSL-Home\include and yaSSL-Home\include\openssl to the include list, and + define USE_SSLEAY and USE_OPENSSL + + please email todd@yassl.com if you have any questions. + + +*******************yaSSL Release notes, version 1.2.2 (03/27/06) This release of yaSSL contains minor bug fixes and portability enhancements. diff --git a/extra/yassl/certs/ca-cert.pem b/extra/yassl/certs/ca-cert.pem new file mode 100644 index 00000000000..981dd004fc6 --- /dev/null +++ b/extra/yassl/certs/ca-cert.pem @@ -0,0 +1,53 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 0 (0x0) + Signature Algorithm: md5WithRSAEncryption + Issuer: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com + Validity + Not Before: Jan 18 20:12:32 2005 GMT + Not After : Oct 15 20:12:32 2007 GMT + Subject: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:cf:2b:14:00:b0:3c:df:6f:9e:91:40:ec:c8:f6: + 90:b2:5b:b4:70:80:a5:a4:0a:73:c7:44:f3:2a:26: + c4:2f:f1:3a:f1:c3:c4:ac:fc:c3:d2:c3:bf:f5:d7: + 6a:38:42:ad:22:ab:c8:c4:4b:4c:1d:16:af:05:34: + 7d:79:97:5e:e1 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + CB:0F:1F:E9:A2:76:71:C9:E6:E8:23:A6:C1:18:B7:CC:44:CF:B9:84 + X509v3 Authority Key Identifier: + keyid:CB:0F:1F:E9:A2:76:71:C9:E6:E8:23:A6:C1:18:B7:CC:44:CF:B9:84 + DirName:/C=US/ST=Oregon/L=Portland/O=sawtooth/CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com + serial:00 + + X509v3 Basic Constraints: + CA:TRUE + Signature Algorithm: md5WithRSAEncryption + 27:f7:3d:fb:39:6f:73:a4:86:f3:a0:48:22:60:84:e9:5c:3d: + 28:36:05:16:44:98:07:87:e1:5d:b5:f3:a7:bc:33:5f:f4:29: + a9:5f:87:33:df:e6:8e:bd:e2:f3:0a:c8:00:69:ae:3d:41:47: + 03:ea:0b:4c:67:45:4b:ab:f3:39 +-----BEGIN CERTIFICATE----- +MIIC7zCCApmgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBiTELMAkGA1UEBhMCVVMx +DzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxhbmQxETAPBgNVBAoTCHNh +d3Rvb3RoMSQwIgYDVQQDExt3d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAb +BgkqhkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMB4XDTA1MDExODIwMTIzMloXDTA3 +MTAxNTIwMTIzMlowgYkxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZPcmVnb24xETAP +BgNVBAcTCFBvcnRsYW5kMREwDwYDVQQKEwhzYXd0b290aDEkMCIGA1UEAxMbd3d3 +LnNhd3Rvb3RoLWNvbnN1bHRpbmcuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlh +c3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDPKxQAsDzfb56RQOzI9pCy +W7RwgKWkCnPHRPMqJsQv8Trxw8Ss/MPSw7/112o4Qq0iq8jES0wdFq8FNH15l17h +AgMBAAGjgekwgeYwHQYDVR0OBBYEFMsPH+midnHJ5ugjpsEYt8xEz7mEMIG2BgNV +HSMEga4wgauAFMsPH+midnHJ5ugjpsEYt8xEz7mEoYGPpIGMMIGJMQswCQYDVQQG +EwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDERMA8GA1UE +ChMIc2F3dG9vdGgxJDAiBgNVBAMTG3d3dy5zYXd0b290aC1jb25zdWx0aW5nLmNv +bTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb22CAQAwDAYDVR0TBAUwAwEB +/zANBgkqhkiG9w0BAQQFAANBACf3Pfs5b3OkhvOgSCJghOlcPSg2BRZEmAeH4V21 +86e8M1/0KalfhzPf5o694vMKyABprj1BRwPqC0xnRUur8zk= +-----END CERTIFICATE----- diff --git a/extra/yassl/certs/client-cert.der b/extra/yassl/certs/client-cert.der Binary files differnew file mode 100644 index 00000000000..b28e2753376 --- /dev/null +++ b/extra/yassl/certs/client-cert.der diff --git a/extra/yassl/certs/client-cert.pem b/extra/yassl/certs/client-cert.pem new file mode 100644 index 00000000000..81110f17252 --- /dev/null +++ b/extra/yassl/certs/client-cert.pem @@ -0,0 +1,52 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 0 (0x0) + Signature Algorithm: md5WithRSAEncryption + Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, CN=www.yassl.com/emailAddress=info@yassl.com + Validity + Not Before: Jan 18 19:33:15 2005 GMT + Not After : Oct 15 19:33:15 2007 GMT + Subject: C=US, ST=Oregon, L=Portland, O=yaSSL, CN=www.yassl.com/emailAddress=info@yassl.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:cd:1f:78:47:f8:b8:d6:08:bf:bd:7c:23:61:86: + 36:28:ac:ee:3c:a8:9a:94:e6:d5:26:e8:71:50:b2: + 26:8b:1c:1e:3f:75:b2:d3:b3:67:95:0c:fd:76:28: + 65:d5:ce:12:82:9e:06:00:a2:09:dd:ce:3a:26:dd: + 46:2a:a0:45:71 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + AE:25:5E:FA:4D:A3:5B:2B:87:DE:F1:2A:F5:42:C0:FF:CE:B5:B4:AD + X509v3 Authority Key Identifier: + keyid:AE:25:5E:FA:4D:A3:5B:2B:87:DE:F1:2A:F5:42:C0:FF:CE:B5:B4:AD + DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/CN=www.yassl.com/emailAddress=info@yassl.com + serial:00 + + X509v3 Basic Constraints: + CA:TRUE + Signature Algorithm: md5WithRSAEncryption + c5:82:26:0c:1f:61:01:14:b0:ce:18:99:64:91:0e:f1:f8:90: + 3e:a3:0e:be:38:7c:97:ba:05:c9:2a:dc:dd:62:2d:12:61:79: + 7a:86:b1:97:5d:1e:e8:f7:e8:32:34:f7:8f:b1:08:3d:13:71: + a6:3c:15:91:85:12:35:6e:78:87 +-----BEGIN CERTIFICATE----- +MIICtzCCAmGgAwIBAgIBADANBgkqhkiG9w0BAQQFADB4MQswCQYDVQQGEwJVUzEP +MA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDEOMAwGA1UEChMFeWFT +U0wxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9A +eWFzc2wuY29tMB4XDTA1MDExODE5MzMxNVoXDTA3MTAxNTE5MzMxNVoweDELMAkG +A1UEBhMCVVMxDzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxhbmQxDjAM +BgNVBAoTBXlhU1NMMRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcN +AQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDNH3hH ++LjWCL+9fCNhhjYorO48qJqU5tUm6HFQsiaLHB4/dbLTs2eVDP12KGXVzhKCngYA +ogndzjom3UYqoEVxAgMBAAGjgdUwgdIwHQYDVR0OBBYEFK4lXvpNo1srh97xKvVC +wP/OtbStMIGiBgNVHSMEgZowgZeAFK4lXvpNo1srh97xKvVCwP/OtbStoXykejB4 +MQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFu +ZDEOMAwGA1UEChMFeWFTU0wxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkq +hkiG9w0BCQEWDmluZm9AeWFzc2wuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZI +hvcNAQEEBQADQQDFgiYMH2EBFLDOGJlkkQ7x+JA+ow6+OHyXugXJKtzdYi0SYXl6 +hrGXXR7o9+gyNPePsQg9E3GmPBWRhRI1bniH +-----END CERTIFICATE----- diff --git a/extra/yassl/certs/client-key.der b/extra/yassl/certs/client-key.der Binary files differnew file mode 100644 index 00000000000..6e8b432a07c --- /dev/null +++ b/extra/yassl/certs/client-key.der diff --git a/extra/yassl/certs/client-key.pem b/extra/yassl/certs/client-key.pem new file mode 100644 index 00000000000..6898b2796fa --- /dev/null +++ b/extra/yassl/certs/client-key.pem @@ -0,0 +1,9 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOgIBAAJBAM0feEf4uNYIv718I2GGNiis7jyompTm1SbocVCyJoscHj91stOz +Z5UM/XYoZdXOEoKeBgCiCd3OOibdRiqgRXECAwEAAQJAXwa6OVVvg7Bv63+MAI0l +n/hlMfLGEj9R9gFvJXwywPSEQhijOZmedpHALufFPNHtwba9dmbqMkBAw9JDaAgg +QQIhAO+mBaSmoG5AYVKYQZiASe/2wMZjaQSN+zFLyF97OX8ZAiEA2x5iRmXUkbOT +8Td/vx8R9mq9W5CJu+cN+SWGwTYhPBkCIGZFM6NQeKaUUvQshdHO7b66Twpa4jZP +YSNoc9pLe/4BAiB+jIvBkKo2A/rbg2waG32qTXdTXKTPiuA9Fnk/OV30cQIhANuA +uMdo+T+rYcNGJ1hCYKDe9JWBpNfSQ+H/A7sWuW8L +-----END RSA PRIVATE KEY----- diff --git a/extra/yassl/certs/dh1024.dat b/extra/yassl/certs/dh1024.dat new file mode 100644 index 00000000000..86a95518278 --- /dev/null +++ b/extra/yassl/certs/dh1024.dat @@ -0,0 +1 @@ +30818702818100DA9A18547FF03B385CC16508C173A7EF4EB61CB40EF8FEF3B31F145051676166BCDC3FE6B799FC394D08C26385F9413F896E09117E46209D6923602683CEA100924A6EE695281775C619DAA94EA8CB3691B4275B0183F1D39639EBC92995FE645D6C1BC28D409E585549BBD2C5DCDD6C208B04EADD8B7A6D997F72CBAD88390F020102
\ No newline at end of file diff --git a/extra/yassl/certs/dsa-cert.pem b/extra/yassl/certs/dsa-cert.pem new file mode 100644 index 00000000000..ecca18dae82 --- /dev/null +++ b/extra/yassl/certs/dsa-cert.pem @@ -0,0 +1,68 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 0 (0x0) + Signature Algorithm: dsaWithSHA1 + Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL DSA, CN=yaSSL DSA/emailAddress=info@yassl.com + Validity + Not Before: Jan 23 22:54:51 2005 GMT + Not After : Oct 20 22:54:51 2007 GMT + Subject: C=US, ST=Oregon, L=Portland, O=yaSSL DSA, CN=yaSSL DSA/emailAddress=info@yassl.com + Subject Public Key Info: + Public Key Algorithm: dsaEncryption + DSA Public Key: + pub: + 04:84:a0:26:31:72:0c:e8:4f:5d:53:17:62:b1:80: + ca:c0:16:5f:c3:1e:ea:c5:d9:98:38:f9:be:56:53: + 47:68:ce:08:22:57:1c:bb:0d:77:91:cf:5b:36:ed: + f3:24:82:90:8a:cd:90:7c:db:77:f9:17:2d:73:73: + ef:bb:b9:82 + P: + 00:99:29:69:80:c9:3c:98:68:45:a9:82:fe:67:eb: + 95:88:c5:b4:0c:d6:26:45:95:19:2c:a0:20:5b:7e: + df:69:e9:dc:c3:0f:f3:61:0a:25:9b:f2:21:01:6a: + cd:aa:8c:37:e7:ca:66:db:56:f4:0f:7d:7a:d1:18: + b9:42:fd:1b:11 + Q: + 00:ad:25:29:ab:0a:9f:09:1c:c1:ad:03:20:76:7f: + a6:b7:dd:4d:03:09 + G: + 12:88:99:da:e7:d0:0b:93:9b:e6:ee:3c:21:7f:9c: + b3:b4:8d:a5:8c:e2:37:80:3f:17:d1:81:4f:bd:f0: + 71:b6:32:08:54:dd:bf:01:e2:b3:77:06:64:75:8a: + 04:d6:79:39:b1:02:03:03:c6:06:74:e5:90:05:0a: + 10:46:19:31 + X509v3 extensions: + X509v3 Subject Key Identifier: + BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2 + X509v3 Authority Key Identifier: + keyid:BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2 + DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL DSA/CN=yaSSL DSA/emailAddress=info@yassl.com + serial:00 + + X509v3 Basic Constraints: + CA:TRUE + Signature Algorithm: dsaWithSHA1 + 30:2b:02:14:74:46:9f:91:7b:24:17:3b:ee:0f:10:e3:76:62: + f4:dc:81:e6:fd:fe:02:13:08:f4:87:0a:ab:ba:9c:de:3a:69: + 72:59:b8:ec:e9:57:f4:bf:37 +-----BEGIN CERTIFICATE----- +MIIDMTCCAvKgAwIBAgIBADAJBgcqhkjOOAQDMHgxCzAJBgNVBAYTAlVTMQ8wDQYD +VQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMRIwEAYDVQQKEwl5YVNTTCBE +U0ExEjAQBgNVBAMTCXlhU1NMIERTQTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNz +bC5jb20wHhcNMDUwMTIzMjI1NDUxWhcNMDcxMDIwMjI1NDUxWjB4MQswCQYDVQQG +EwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDESMBAGA1UE +ChMJeWFTU0wgRFNBMRIwEAYDVQQDEwl5YVNTTCBEU0ExHTAbBgkqhkiG9w0BCQEW +DmluZm9AeWFzc2wuY29tMIHwMIGoBgcqhkjOOAQBMIGcAkEAmSlpgMk8mGhFqYL+ +Z+uViMW0DNYmRZUZLKAgW37faencww/zYQolm/IhAWrNqow358pm21b0D3160Ri5 +Qv0bEQIVAK0lKasKnwkcwa0DIHZ/prfdTQMJAkASiJna59ALk5vm7jwhf5yztI2l +jOI3gD8X0YFPvfBxtjIIVN2/AeKzdwZkdYoE1nk5sQIDA8YGdOWQBQoQRhkxA0MA +AkAEhKAmMXIM6E9dUxdisYDKwBZfwx7qxdmYOPm+VlNHaM4IIlccuw13kc9bNu3z +JIKQis2QfNt3+Rctc3Pvu7mCo4HVMIHSMB0GA1UdDgQWBBS++Yxd1hy07oHdNlYK +IeRhRHPp4jCBogYDVR0jBIGaMIGXgBS++Yxd1hy07oHdNlYKIeRhRHPp4qF8pHow +eDELMAkGA1UEBhMCVVMxDzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxh +bmQxEjAQBgNVBAoTCXlhU1NMIERTQTESMBAGA1UEAxMJeWFTU0wgRFNBMR0wGwYJ +KoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbYIBADAMBgNVHRMEBTADAQH/MAkGByqG +SM44BAMDLgAwKwIUdEafkXskFzvuDxDjdmL03IHm/f4CEwj0hwqrupzeOmlyWbjs +6Vf0vzc= +-----END CERTIFICATE----- diff --git a/extra/yassl/certs/dsa512.der b/extra/yassl/certs/dsa512.der Binary files differnew file mode 100644 index 00000000000..fe79ccb612b --- /dev/null +++ b/extra/yassl/certs/dsa512.der diff --git a/extra/yassl/certs/dsa512.pem b/extra/yassl/certs/dsa512.pem new file mode 100644 index 00000000000..04a3dd94a77 --- /dev/null +++ b/extra/yassl/certs/dsa512.pem @@ -0,0 +1,8 @@ +-----BEGIN DSA PRIVATE KEY----- +MIH3AgEAAkEAmSlpgMk8mGhFqYL+Z+uViMW0DNYmRZUZLKAgW37faencww/zYQol +m/IhAWrNqow358pm21b0D3160Ri5Qv0bEQIVAK0lKasKnwkcwa0DIHZ/prfdTQMJ +AkASiJna59ALk5vm7jwhf5yztI2ljOI3gD8X0YFPvfBxtjIIVN2/AeKzdwZkdYoE +1nk5sQIDA8YGdOWQBQoQRhkxAkAEhKAmMXIM6E9dUxdisYDKwBZfwx7qxdmYOPm+ +VlNHaM4IIlccuw13kc9bNu3zJIKQis2QfNt3+Rctc3Pvu7mCAhQjg+e+aqykxwwc +E2V27tjDFY02uA== +-----END DSA PRIVATE KEY----- diff --git a/extra/yassl/certs/server-cert.pem b/extra/yassl/certs/server-cert.pem new file mode 100644 index 00000000000..403dabdf5fa --- /dev/null +++ b/extra/yassl/certs/server-cert.pem @@ -0,0 +1,38 @@ +Certificate: + Data: + Version: 1 (0x0) + Serial Number: 1 (0x1) + Signature Algorithm: md5WithRSAEncryption + Issuer: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com + Validity + Not Before: Jan 18 20:50:59 2005 GMT + Not After : Oct 15 20:50:59 2007 GMT + Subject: C=US, ST=Oregon, L=Portland, O=taoSoftDev, CN=www.taosoftdev.com/emailAddress=info@yassl.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:a4:68:bb:bc:b7:27:5f:3c:f5:78:c6:1a:af:b9: + 95:fc:7e:61:1f:a8:81:0a:ca:43:88:9a:03:e0:d0: + a6:79:70:16:34:b9:7c:75:54:ca:70:19:66:38:be: + 6e:28:7e:a5:ff:6b:3c:83:2f:39:42:c3:15:f3:bd: + f2:25:93:22:e7 + Exponent: 65537 (0x10001) + Signature Algorithm: md5WithRSAEncryption + 08:36:07:8c:3a:7f:f9:91:0a:82:d1:6a:c1:34:be:bc:2d:b2: + 20:98:dc:45:50:53:9c:66:e6:26:71:bd:fa:d2:b4:91:d3:53: + c0:20:05:c0:b6:84:9a:5f:3f:61:75:f5:fd:c6:ec:e2:f6:9f: + a2:13:17:a9:b7:83:60:cc:cb:eb +-----BEGIN CERTIFICATE----- +MIIB9zCCAaECAQEwDQYJKoZIhvcNAQEEBQAwgYkxCzAJBgNVBAYTAlVTMQ8wDQYD +VQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMREwDwYDVQQKEwhzYXd0b290 +aDEkMCIGA1UEAxMbd3d3LnNhd3Rvb3RoLWNvbnN1bHRpbmcuY29tMR0wGwYJKoZI +hvcNAQkBFg5pbmZvQHlhc3NsLmNvbTAeFw0wNTAxMTgyMDUwNTlaFw0wNzEwMTUy +MDUwNTlaMIGCMQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQH +EwhQb3J0bGFuZDETMBEGA1UEChMKdGFvU29mdERldjEbMBkGA1UEAxMSd3d3LnRh +b3NvZnRkZXYuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0G +CSqGSIb3DQEBAQUAA0sAMEgCQQCkaLu8tydfPPV4xhqvuZX8fmEfqIEKykOImgPg +0KZ5cBY0uXx1VMpwGWY4vm4ofqX/azyDLzlCwxXzvfIlkyLnAgMBAAEwDQYJKoZI +hvcNAQEEBQADQQAINgeMOn/5kQqC0WrBNL68LbIgmNxFUFOcZuYmcb360rSR01PA +IAXAtoSaXz9hdfX9xuzi9p+iExept4NgzMvr +-----END CERTIFICATE----- diff --git a/extra/yassl/certs/server-key.pem b/extra/yassl/certs/server-key.pem new file mode 100644 index 00000000000..d6055c4cfd8 --- /dev/null +++ b/extra/yassl/certs/server-key.pem @@ -0,0 +1,9 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIBOQIBAAJBAKRou7y3J1889XjGGq+5lfx+YR+ogQrKQ4iaA+DQpnlwFjS5fHVU +ynAZZji+bih+pf9rPIMvOULDFfO98iWTIucCAwEAAQJABLVvMw931DV1vljGKORC +1HF2LKbx0zJJzt7CX6z6J54vcE79K3NYXdU6o7/j1WTtfD47tFG+4ljGvSYPmrCI +2QIhANfiY6is6JUJGGgeMxyWeQRPXfaE9Yrk6OhxHhpYf5CTAiEAwvWraeLPy/NE +B+0w80mh8tCv2tpuKaYMOG53XpYX3N0CIDy/Bj3rUZLGOWjqvoUXzjupPY5lgVYw +7Vyin87YAiUjAiAgM8X5em5KSMc+6+2+8bWfTtsNMjEqDfRMyepLpE0SvQIgTSYL +WWfcZoRUPDM9GEuQ40nifVNjobzvjTW4aYyHCEI= +-----END RSA PRIVATE KEY----- diff --git a/extra/yassl/certs/taoCert.txt b/extra/yassl/certs/taoCert.txt new file mode 100644 index 00000000000..585293e4f2b --- /dev/null +++ b/extra/yassl/certs/taoCert.txt @@ -0,0 +1,50 @@ + +***** Create a self signed cert ************ + +1) openssl genrsa 512 > client-key.pem + +2) openssl req -new -x509 -nodes -md5 -days 1000 -key client-key.pem > client-cert.pem + +-- adding metadata to beginning + +3) openssl x509 -in client-cert.pem -text > tmp.pem + +4) mv tmp.pem client-cert.pem + + +***** Create a CA, signing authority ********** + +same as self signed, use ca prefix instead of client + + +***** Create a cert signed by CA ************** + +1) openssl req -newkey rsa:512 -md5 -days 1000 -nodes -keyout server-key.pem > server-req.pem + +2) copy ca-key.pem ca-cert.srl (why ????) + +3) openssl x509 -req -in server-req.pem -days 1000 -md5 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem + + + +***** To create a dsa cert ******************** + +1) openssl dsaparam 512 > dsa512.param # creates group params + +2) openssl gendsa dsa512.param > dsa512.pem # creates private key + +3) openssl req -new -x509 -nodes -days 1000 -key dsa512.pem > dsa-cert.pem + + + + +***** To convert from PEM to DER ************** + +a) openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER + +to convert rsa private PEM to DER : + +b) openssl rsa -in key.pem -outform DER -out key.der + + + diff --git a/extra/yassl/examples/client/client.cpp b/extra/yassl/examples/client/client.cpp index 704a8e76637..94bf753210b 100644 --- a/extra/yassl/examples/client/client.cpp +++ b/extra/yassl/examples/client/client.cpp @@ -33,10 +33,10 @@ void client_test(void* args) const char* cipher = 0; int index = 0; char list[1024]; - strcpy(list, "cipherlist"); + strncpy(list, "cipherlist", 11); while ( (cipher = SSL_get_cipher_list(ssl, index++)) ) { - strcat(list, ":"); - strcat(list, cipher); + strncat(list, ":", 2); + strncat(list, cipher, strlen(cipher) + 1); } printf("%s\n", list); printf("Using Cipher Suite %s\n", SSL_get_cipher(ssl)); @@ -89,6 +89,8 @@ void client_test(void* args) args.argv = argv; client_test(&args); + yaSSL_CleanUp(); + return args.return_code; } diff --git a/extra/yassl/examples/echoclient/echoclient.cpp b/extra/yassl/examples/echoclient/echoclient.cpp index ca557cca8af..fd3f7dd48a3 100644 --- a/extra/yassl/examples/echoclient/echoclient.cpp +++ b/extra/yassl/examples/echoclient/echoclient.cpp @@ -82,6 +82,7 @@ void echoclient_test(void* args) args.argv = argv; echoclient_test(&args); + yaSSL_CleanUp(); return args.return_code; } diff --git a/extra/yassl/examples/echoserver/echoserver.cpp b/extra/yassl/examples/echoserver/echoserver.cpp index 14a37a7e175..8e23ead20ab 100644 --- a/extra/yassl/examples/echoserver/echoserver.cpp +++ b/extra/yassl/examples/echoserver/echoserver.cpp @@ -15,6 +15,8 @@ args.argv = argv; echoserver_test(&args); + yaSSL_CleanUp(); + return args.return_code; } @@ -63,7 +65,8 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) while (!shutdown) { sockaddr_in client; socklen_t client_len = sizeof(client); - int clientfd = accept(sockfd, (sockaddr*)&client, &client_len); + int clientfd = accept(sockfd, (sockaddr*)&client, + (ACCEPT_THIRD_T)&client_len); if (clientfd == -1) err_sys("tcp accept failed"); SSL* ssl = SSL_new(ctx); diff --git a/extra/yassl/examples/server/server.cpp b/extra/yassl/examples/server/server.cpp index 4d3f121cf2c..73cff19e371 100644 --- a/extra/yassl/examples/server/server.cpp +++ b/extra/yassl/examples/server/server.cpp @@ -67,6 +67,8 @@ THREAD_RETURN YASSL_API server_test(void* args) args.argv = argv; server_test(&args); + yaSSL_CleanUp(); + return args.return_code; } diff --git a/extra/yassl/include/openssl/err.h b/extra/yassl/include/openssl/err.h index 054d0940509..45ac1ca2469 100644 --- a/extra/yassl/include/openssl/err.h +++ b/extra/yassl/include/openssl/err.h @@ -1,6 +1,6 @@ /* err.h for openssl */ -#ifndef ysSSL_err_h__ +#ifndef yaSSL_err_h__ #define yaSSL_err_h__ diff --git a/extra/yassl/include/openssl/md4.h b/extra/yassl/include/openssl/md4.h new file mode 100644 index 00000000000..2e99f977fca --- /dev/null +++ b/extra/yassl/include/openssl/md4.h @@ -0,0 +1 @@ +/* md4.h for libcurl */ diff --git a/extra/yassl/include/openssl/md5.h b/extra/yassl/include/openssl/md5.h index a1025b92782..dfaf9799c44 100644 --- a/extra/yassl/include/openssl/md5.h +++ b/extra/yassl/include/openssl/md5.h @@ -1 +1,4 @@ /* md5.h for openssl */ + +#include "ssl.h" /* in there for now */ + diff --git a/extra/yassl/include/openssl/pem.h b/extra/yassl/include/openssl/pem.h new file mode 100644 index 00000000000..b4c63d56a4d --- /dev/null +++ b/extra/yassl/include/openssl/pem.h @@ -0,0 +1 @@ +/* pem.h for libcurl */ diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index b6840d006df..23e48d2011f 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -29,8 +29,22 @@ #define yaSSL_openssl_h__ #include <stdio.h> /* ERR_print fp */ +#include "opensslv.h" /* for version number */ #include "rsa.h" +#if defined(__cplusplus) +extern "C" { +#endif + + void yaSSL_CleanUp(); /* call once at end of application use to + free static singleton memory holders, + not a leak per se, but helpful when + looking for them */ + +#if defined(__cplusplus) +} // extern +#endif + #if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE) namespace yaSSL { extern "C" { @@ -102,7 +116,6 @@ void X509_free(X509*); typedef struct BIO BIO; /* ASN stuff */ -typedef struct ASN1_TIME ASN1_TIME; @@ -260,6 +273,7 @@ int SSL_pending(SSL*); enum { /* ssl Constants */ + SSL_WOULD_BLOCK = -8, SSL_BAD_STAT = -7, SSL_BAD_PATH = -6, SSL_BAD_FILETYPE = -5, @@ -345,8 +359,8 @@ long SSL_CTX_sess_set_cache_size(SSL_CTX*, long); long SSL_CTX_set_tmp_dh(SSL_CTX*, DH*); void OpenSSL_add_all_algorithms(void); -void SSL_library_init(); -void SSLeay_add_ssl_algorithms(void); +int SSL_library_init(); +int SSLeay_add_ssl_algorithms(void); SSL_CIPHER* SSL_get_current_cipher(SSL*); @@ -371,6 +385,10 @@ typedef unsigned char DES_cblock[8]; typedef const DES_cblock const_DES_cblock; typedef DES_cblock DES_key_schedule; +enum { + DES_ENCRYPT = 1, + DES_DECRYPT = 0 +}; const EVP_MD* EVP_md5(void); const EVP_CIPHER* EVP_des_ede3_cbc(void); @@ -392,6 +410,108 @@ int RAND_write_file(const char*); int RAND_load_file(const char*, long); +/* for libcurl */ +int RAND_status(void); + +int DES_set_key(const_DES_cblock*, DES_key_schedule*); +void DES_set_odd_parity(DES_cblock*); +void DES_ecb_encrypt(DES_cblock*, DES_cblock*, DES_key_schedule*, int); + +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void* userdata); +void SSL_SESSION_free(SSL_SESSION* session); + +X509* SSL_get_certificate(SSL* ssl); +EVP_PKEY* SSL_get_privatekey(SSL* ssl); +EVP_PKEY* X509_get_pubkey(X509* x); + +int EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from); +void EVP_PKEY_free(EVP_PKEY* pkey); +void ERR_error_string_n(unsigned long e, char *buf, size_t len); +void ERR_free_strings(void); +void EVP_cleanup(void); + +void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx); + +#define GEN_IPADD 7 +#define NID_subject_alt_name 85 +#define STACK_OF(x) x + + +/* defined here because libcurl dereferences */ +typedef struct ASN1_STRING { + int type; + int length; + unsigned char* data; +} ASN1_STRING; + + +typedef struct GENERAL_NAME { + int type; + union { + ASN1_STRING* ia5; + } d; +} GENERAL_NAME; + +void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x); + +int sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x); +GENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i); + + +unsigned char* ASN1_STRING_data(ASN1_STRING* x); +int ASN1_STRING_length(ASN1_STRING* x); +int ASN1_STRING_type(ASN1_STRING *x); + +typedef ASN1_STRING X509_NAME_ENTRY; + +int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos); + +ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne); +X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc); + +#define OPENSSL_malloc(x) malloc(x) +#define OPENSSL_free(x) free(x) + +int ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in); + +SSL_METHOD* SSLv23_client_method(void); /* doesn't actually roll back */ +SSL_METHOD* SSLv2_client_method(void); /* will never work, no v 2 */ + + +SSL_SESSION* SSL_get1_session(SSL* ssl); /* what's ref count */ + + +#define CRYPTO_free(x) free(x) +#define ASN1_TIME ASN1_STRING + +ASN1_TIME* X509_get_notBefore(X509* x); +ASN1_TIME* X509_get_notAfter(X509* x); + + +#define ASN1_UTCTIME ASN1_STRING +#define NID_commonName 13 +#define V_ASN1_UTF8STRING 12 +#define GEN_DNS 2 + + +typedef struct MD4_CTX { + int buffer[32]; /* big enough to hold, check size in Init */ +} MD4_CTX; + +void MD4_Init(MD4_CTX*); +void MD4_Update(MD4_CTX*, const void*, unsigned long); +void MD4_Final(unsigned char*, MD4_CTX*); + + +typedef struct MD5_CTX { + int buffer[32]; /* big enough to hold, check size in Init */ +} MD5_CTX; + +void MD5_Init(MD5_CTX*); +void MD5_Update(MD5_CTX*, const void*, unsigned long); +void MD5_Final(unsigned char*, MD5_CTX*); + + #define SSL_DEFAULT_CIPHER_LIST "" /* default all */ diff --git a/extra/yassl/include/openssl/x509.h b/extra/yassl/include/openssl/x509.h new file mode 100644 index 00000000000..dcd847c0337 --- /dev/null +++ b/extra/yassl/include/openssl/x509.h @@ -0,0 +1 @@ +/* x509.h for libcurl */ diff --git a/extra/yassl/include/openssl/x509v3.h b/extra/yassl/include/openssl/x509v3.h new file mode 100644 index 00000000000..adf94af8f48 --- /dev/null +++ b/extra/yassl/include/openssl/x509v3.h @@ -0,0 +1 @@ +/* x509v3.h for libcurl */ diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp index d2258a93723..16db142b3a2 100644 --- a/extra/yassl/include/socket_wrapper.hpp +++ b/extra/yassl/include/socket_wrapper.hpp @@ -66,6 +66,7 @@ typedef unsigned char byte; // Wraps Windows Sockets and BSD Sockets class Socket { socket_t socket_; // underlying socket descriptor + bool wouldBlock_; // for non-blocking data public: explicit Socket(socket_t s = INVALID_SOCKET); ~Socket(); @@ -75,9 +76,10 @@ public: socket_t get_fd() const; uint send(const byte* buf, unsigned int len, int flags = 0) const; - uint receive(byte* buf, unsigned int len, int flags = 0) const; + uint receive(byte* buf, unsigned int len, int flags = 0); - bool wait() const; + bool wait(); + bool WouldBlock() const; void closeSocket(); void shutDown(int how = SD_SEND); diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 935bae582ea..97ae468d2f9 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -34,6 +34,7 @@ #include "cert_wrapper.hpp" #include "log.hpp" #include "lock.hpp" +#include "openssl/ssl.h" // ASN1_STRING and DH namespace yaSSL { @@ -126,32 +127,70 @@ private: }; +// hold add crypt references provided to callers +class CryptProvider { + mySTL::list<Digest*> digestList_; + mySTL::list<BulkCipher*> cipherList_; + CryptProvider() {} // only GetCryptProvider creates +public: + ~CryptProvider(); + + Digest* NewMd5(); + BulkCipher* NewDesEde(); + + friend CryptProvider& GetCryptProvider(); +private: + CryptProvider(const CryptProvider&); // hide copy + CryptProvider& operator=(const CryptProvider&); // and assign +}; + +CryptProvider& GetCryptProvider(); + #undef X509_NAME // wincrypt.h clash // openSSL X509 names class X509_NAME { char* name_; + size_t sz_; + ASN1_STRING entry_; public: X509_NAME(const char*, size_t sz); ~X509_NAME(); char* GetName(); + ASN1_STRING* GetEntry(int i); private: X509_NAME(const X509_NAME&); // hide copy X509_NAME& operator=(const X509_NAME&); // and assign }; +class StringHolder { + ASN1_STRING asnString_; +public: + StringHolder(const char* str, int sz); + ~StringHolder(); + + ASN1_STRING* GetString(); +}; + + // openSSL X509 class X509 { X509_NAME issuer_; X509_NAME subject_; + StringHolder beforeDate_; // not valid before + StringHolder afterDate_; // not valid after public: - X509(const char* i, size_t, const char* s, size_t); + X509(const char* i, size_t, const char* s, size_t, + const char* b, int, const char* a, int); ~X509() {} X509_NAME* GetIssuer(); X509_NAME* GetSubject(); + + ASN1_STRING* GetBefore(); + ASN1_STRING* GetAfter(); private: X509(const X509&); // hide copy X509& operator=(const X509&); // and assign diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index bfb6467182b..76c807cd05f 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -35,10 +35,6 @@ namespace yaSSL { -// Delete static singleton memory holders -void CleanUp(); - - #ifdef YASSL_PURE_C // library allocation diff --git a/extra/yassl/lib/dummy b/extra/yassl/lib/dummy new file mode 100644 index 00000000000..85c1efd587f --- /dev/null +++ b/extra/yassl/lib/dummy @@ -0,0 +1 @@ +// this is a dummy file diff --git a/extra/yassl/mySTL/helpers.hpp b/extra/yassl/mySTL/helpers.hpp index 5aa14d838b1..df79025197a 100644 --- a/extra/yassl/mySTL/helpers.hpp +++ b/extra/yassl/mySTL/helpers.hpp @@ -44,6 +44,11 @@ return static_cast<void*>(d); } + // for compilers that want matching delete + inline void operator delete(void* ptr, Dummy* d) + { + } + typedef Dummy* yassl_pointer; namespace mySTL { diff --git a/extra/yassl/mySTL/stdexcept.hpp b/extra/yassl/mySTL/stdexcept.hpp index 33ea43bf0e0..b50dd35edae 100644 --- a/extra/yassl/mySTL/stdexcept.hpp +++ b/extra/yassl/mySTL/stdexcept.hpp @@ -46,8 +46,10 @@ public: // for compiler generated call, never used static void operator delete(void*) { assert(0); } private: +#if defined(__hpux) // don't allow dynamic creation of exceptions static void* operator new(size_t); +#endif }; diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index b98c7faf1d0..ae609b510ba 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -271,10 +271,13 @@ int CertManager::Validate() else peerKeyType_ = dsa_sa_algo; - int iSz = cert.GetIssuer() ? strlen(cert.GetIssuer()) + 1 : 0; - int sSz = cert.GetCommonName() ? strlen(cert.GetCommonName()) + 1 : 0; + int iSz = strlen(cert.GetIssuer()) + 1; + int sSz = strlen(cert.GetCommonName()) + 1; + int bSz = strlen(cert.GetBeforeDate()) + 1; + int aSz = strlen(cert.GetAfterDate()) + 1; peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(), - sSz); + sSz, cert.GetBeforeDate(), bSz, + cert.GetAfterDate(), aSz); } return 0; } diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 2603365e41a..2b099af930c 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -656,7 +656,7 @@ mySTL::auto_ptr<input_buffer> DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered) { // wait for input if blocking - if (!ssl.getSocket().wait()) { + if (!ssl.useSocket().wait()) { ssl.SetError(receive_error); buffered.reset(0); return buffered; @@ -673,7 +673,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered) } // add new data - uint read = ssl.getSocket().receive(buffer.get_buffer() + buffSz, ready); + uint read = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready); buffer.add_size(read); uint offset = 0; const MessageFactory& mf = ssl.getFactory().getMessage(); @@ -858,6 +858,9 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) // send data int sendData(SSL& ssl, const void* buffer, int sz) { + if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ)) + ssl.SetError(no_error); + ssl.verfiyHandShakeComplete(); if (ssl.GetError()) return 0; int sent = 0; @@ -893,6 +896,9 @@ int sendAlert(SSL& ssl, const Alert& alert) // process input data int receiveData(SSL& ssl, Data& data) { + if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ)) + ssl.SetError(no_error); + ssl.verfiyHandShakeComplete(); if (ssl.GetError()) return 0; @@ -902,6 +908,11 @@ int receiveData(SSL& ssl, Data& data) ssl.useLog().ShowData(data.get_length()); if (ssl.GetError()) return 0; + + if (data.get_length() == 0 && ssl.getSocket().WouldBlock()) { + ssl.SetError(YasslError(SSL_ERROR_WANT_READ)); + return SSL_WOULD_BLOCK; + } return data.get_length(); } diff --git a/extra/yassl/src/make.bat b/extra/yassl/src/make.bat index 4c79a9c6406..148427a6f41 100644 --- a/extra/yassl/src/make.bat +++ b/extra/yassl/src/make.bat @@ -1,4 +1,4 @@ -# quick and dirty build file for testing different MSDEVs +REM quick and dirty build file for testing different MSDEVs setlocal set myFLAGS= /I../include /I../mySTL /I../taocrypt/include /W3 /c /ZI diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp index c6611803421..803f4b01249 100644 --- a/extra/yassl/src/socket_wrapper.cpp +++ b/extra/yassl/src/socket_wrapper.cpp @@ -58,7 +58,7 @@ namespace yaSSL { Socket::Socket(socket_t s) - : socket_(s) + : socket_(s), wouldBlock_(false) {} @@ -123,17 +123,21 @@ uint Socket::send(const byte* buf, unsigned int sz, int flags) const } -uint Socket::receive(byte* buf, unsigned int sz, int flags) const +uint Socket::receive(byte* buf, unsigned int sz, int flags) { assert(socket_ != INVALID_SOCKET); + wouldBlock_ = false; + int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags); // idea to seperate error from would block by arnetheduck@gmail.com if (recvd == -1) { if (get_lastError() == SOCKET_EWOULDBLOCK || - get_lastError() == SOCKET_EAGAIN) + get_lastError() == SOCKET_EAGAIN) { + wouldBlock_ = true; return 0; } + } else if (recvd == 0) return static_cast<uint>(-1); @@ -142,7 +146,7 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags) const // wait if blocking for input, return false for error -bool Socket::wait() const +bool Socket::wait() { byte b; return receive(&b, 1, MSG_PEEK) != static_cast<uint>(-1); @@ -166,6 +170,12 @@ int Socket::get_lastError() } +bool Socket::WouldBlock() const +{ + return wouldBlock_; +} + + void Socket::set_lastError(int errorCode) { #ifdef _WIN32 diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 1aab14009d3..747305730df 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -1,4 +1,4 @@ -/* ssl.cpp + /* ssl.cpp * * Copyright (C) 2003 Sawtooth Consulting Ltd. * @@ -36,6 +36,8 @@ #include "openssl/ssl.h" #include "handshake.hpp" #include "yassl_int.hpp" +#include "md5.hpp" // for TaoCrypt MD5 size assert +#include "md4.hpp" // for TaoCrypt MD4 size assert #include <stdio.h> #ifdef _WIN32 @@ -52,6 +54,53 @@ namespace yaSSL { using mySTL::min; +int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) +{ + if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM) + return SSL_BAD_FILETYPE; + + FILE* input = fopen(file, "rb"); + if (!input) + return SSL_BAD_FILE; + + if (type == CA) { + x509* ptr = PemToDer(file, Cert); + if (!ptr) { + fclose(input); + return SSL_BAD_FILE; + } + ctx->AddCA(ptr); // takes ownership + } + else { + x509*& x = (type == Cert) ? ctx->certificate_ : ctx->privateKey_; + + if (format == SSL_FILETYPE_ASN1) { + fseek(input, 0, SEEK_END); + long sz = ftell(input); + rewind(input); + x = NEW_YS x509(sz); // takes ownership + size_t bytes = fread(x->use_buffer(), sz, 1, input); + if (bytes != 1) { + fclose(input); + return SSL_BAD_FILE; + } + } + else { + x = PemToDer(file, type); + if (!x) { + fclose(input); + return SSL_BAD_FILE; + } + } + } + fclose(input); + return SSL_SUCCESS; +} + + +extern "C" { + + SSL_METHOD* SSLv3_method() { return SSLv3_client_method(); @@ -448,50 +497,6 @@ long SSL_CTX_set_tmp_dh(SSL_CTX* ctx, DH* dh) } -int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) -{ - if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM) - return SSL_BAD_FILETYPE; - - FILE* input = fopen(file, "rb"); - if (!input) - return SSL_BAD_FILE; - - if (type == CA) { - x509* ptr = PemToDer(file, Cert); - if (!ptr) { - fclose(input); - return SSL_BAD_FILE; - } - ctx->AddCA(ptr); // takes ownership - } - else { - x509*& x = (type == Cert) ? ctx->certificate_ : ctx->privateKey_; - - if (format == SSL_FILETYPE_ASN1) { - fseek(input, 0, SEEK_END); - long sz = ftell(input); - rewind(input); - x = NEW_YS x509(sz); // takes ownership - size_t bytes = fread(x->use_buffer(), sz, 1, input); - if (bytes != 1) { - fclose(input); - return SSL_BAD_FILE; - } - } - else { - x = PemToDer(file, type); - if (!x) { - fclose(input); - return SSL_BAD_FILE; - } - } - } - fclose(input); - return SSL_SUCCESS; -} - - int SSL_CTX_use_certificate_file(SSL_CTX* ctx, const char* file, int format) { return read_file(ctx, file, format, Cert); @@ -723,8 +728,10 @@ void OpenSSL_add_all_algorithms() // compatibility only {} -void SSL_library_init() // compatiblity only -{} +int SSL_library_init() // compatiblity only +{ + return 1; +} DH* DH_new(void) @@ -804,15 +811,13 @@ const char* X509_verify_cert_error_string(long /* error */) const EVP_MD* EVP_md5(void) { - // TODO: FIX add to some list for destruction - return NEW_YS MD5; + return GetCryptProvider().NewMd5(); } const EVP_CIPHER* EVP_des_ede3_cbc(void) { - // TODO: FIX add to some list for destruction - return NEW_YS DES_EDE; + return GetCryptProvider().NewDesEde(); } @@ -897,6 +902,284 @@ void DES_ede3_cbc_encrypt(const byte* input, byte* output, long sz, } +// functions for libcurl +int RAND_status() +{ + return 1; /* TaoCrypt provides enough seed */ +} + + +int DES_set_key(const_DES_cblock* key, DES_key_schedule* schedule) +{ + memcpy(schedule, key, sizeof(const_DES_cblock)); + return 1; +} + + +void DES_set_odd_parity(DES_cblock* key) +{ + // not needed now for TaoCrypt +} + + +void DES_ecb_encrypt(DES_cblock* input, DES_cblock* output, + DES_key_schedule* key, int enc) +{ + DES des; + + if (enc) { + des.set_encryptKey(*key, 0); + des.encrypt(*output, *input, DES_BLOCK); + } + else { + des.set_decryptKey(*key, 0); + des.decrypt(*output, *input, DES_BLOCK); + } +} + + +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void* userdata) +{ + // yaSSL doesn't support yet, unencrypt your PEM file with userdata + // before handing off to yaSSL +} + + +X509* SSL_get_certificate(SSL* ssl) +{ + // only used to pass to get_privatekey which isn't used + return 0; +} + + +EVP_PKEY* SSL_get_privatekey(SSL* ssl) +{ + // only called, not used + return 0; +} + + +void SSL_SESSION_free(SSL_SESSION* session) +{ + // managed by singleton +} + + + +EVP_PKEY* X509_get_pubkey(X509* x) +{ + // called, not used though + return 0; +} + + +int EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from) +{ + // called, not used though + return 0; +} + + +void EVP_PKEY_free(EVP_PKEY* pkey) +{ + // never allocated from above +} + + +void ERR_error_string_n(unsigned long e, char *buf, size_t len) +{ + if (len) ERR_error_string(e, buf); +} + + +void ERR_free_strings(void) +{ + // handled internally +} + + +void EVP_cleanup(void) +{ + // nothing to do yet +} + + +ASN1_TIME* X509_get_notBefore(X509* x) +{ + if (x) return x->GetBefore(); + return 0; +} + + +ASN1_TIME* X509_get_notAfter(X509* x) +{ + if (x) return x->GetAfter(); + return 0; +} + + +SSL_METHOD* SSLv23_client_method(void) /* doesn't actually roll back */ +{ + return SSLv3_client_method(); +} + + +SSL_METHOD* SSLv2_client_method(void) /* will never work, no v 2 */ +{ + return 0; +} + + +SSL_SESSION* SSL_get1_session(SSL* ssl) /* what's ref count */ +{ + return SSL_get_session(ssl); +} + + +void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x) +{ + // no extension names supported yet +} + + +int sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x) +{ + // no extension names supported yet + return 0; +} + + +GENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i) +{ + // no extension names supported yet + return 0; +} + + +unsigned char* ASN1_STRING_data(ASN1_STRING* x) +{ + if (x) return x->data; + return 0; +} + + +int ASN1_STRING_length(ASN1_STRING* x) +{ + if (x) return x->length; + return 0; +} + + +int ASN1_STRING_type(ASN1_STRING *x) +{ + if (x) return x->type; + return 0; +} + + +int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos) +{ + int idx = -1; // not found + const char* start = &name->GetName()[lastpos + 1]; + + switch (nid) { + case NID_commonName: + const char* found = strstr(start, "/CN="); + if (found) { + found += 4; // advance to str + idx = found - start + lastpos + 1; + } + break; + } + + return idx; +} + + +ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne) +{ + // the same in yaSSL + return ne; +} + + +X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc) +{ + return name->GetEntry(loc); +} + + +// already formatted, caller responsible for freeing *out +int ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in) +{ + if (!in) return 0; + + *out = (unsigned char*)malloc(in->length + 1); + if (*out) { + memcpy(*out, in->data, in->length); + (*out)[in->length] = 0; + } + return in->length; +} + + +void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx) +{ + // no extensions supported yet + return 0; +} + + +void MD4_Init(MD4_CTX* md4) +{ + // make sure we have a big enough buffer + typedef char ok[sizeof(md4->buffer) >= sizeof(TaoCrypt::MD4) ? 1 : -1]; + (void) sizeof(ok); + + // using TaoCrypt since no dynamic memory allocated + // and no destructor will be called + new (reinterpret_cast<yassl_pointer>(md4->buffer)) TaoCrypt::MD4(); +} + + +void MD4_Update(MD4_CTX* md4, const void* data, unsigned long sz) +{ + reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Update( + static_cast<const byte*>(data), static_cast<unsigned int>(sz)); +} + + +void MD4_Final(unsigned char* hash, MD4_CTX* md4) +{ + reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Final(hash); +} + + +void MD5_Init(MD5_CTX* md5) +{ + // make sure we have a big enough buffer + typedef char ok[sizeof(md5->buffer) >= sizeof(TaoCrypt::MD5) ? 1 : -1]; + (void) sizeof(ok); + + // using TaoCrypt since no dynamic memory allocated + // and no destructor will be called + new (reinterpret_cast<yassl_pointer>(md5->buffer)) TaoCrypt::MD5(); +} + + +void MD5_Update(MD5_CTX* md5, const void* data, unsigned long sz) +{ + reinterpret_cast<TaoCrypt::MD5*>(md5->buffer)->Update( + static_cast<const byte*>(data), static_cast<unsigned int>(sz)); +} + + +void MD5_Final(unsigned char* hash, MD5_CTX* md5) +{ + reinterpret_cast<TaoCrypt::MD5*>(md5->buffer)->Final(hash); +} + + // functions for stunnel void RAND_screen() @@ -1098,8 +1381,10 @@ void DES_ede3_cbc_encrypt(const byte* input, byte* output, long sz, } - void SSLeay_add_ssl_algorithms() // compatibility only - {} + int SSLeay_add_ssl_algorithms() // compatibility only + { + return 1; + } void ERR_remove_state(unsigned long) @@ -1129,4 +1414,5 @@ void DES_ede3_cbc_encrypt(const byte* input, byte* output, long sz, // end stunnel needs +} // extern "C" } // namespace diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp index 5782df213ea..134deb00c75 100644 --- a/extra/yassl/src/template_instnt.cpp +++ b/extra/yassl/src/template_instnt.cpp @@ -51,12 +51,16 @@ template class list<yaSSL::SSL_SESSION*>; template class list<yaSSL::input_buffer*>; template class list<yaSSL::output_buffer*>; template class list<yaSSL::x509*>; +template class list<yaSSL::Digest*>; +template class list<yaSSL::BulkCipher*>; template void destroy<mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*); template yaSSL::del_ptr_zero for_each<mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<TaoCrypt::Signer*>::iterator, mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::SSL_SESSION*>::iterator, mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero); template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::x509*>::iterator, mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::Digest*>::iterator, mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::BulkCipher*>::iterator, mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero); } namespace yaSSL { @@ -82,6 +86,7 @@ template void ysDelete<X509>(X509*); template void ysDelete<Message>(Message*); template void ysDelete<sslFactory>(sslFactory*); template void ysDelete<Sessions>(Sessions*); +template void ysDelete<CryptProvider>(CryptProvider*); template void ysArrayDelete<unsigned char>(unsigned char*); template void ysArrayDelete<char>(char*); } diff --git a/extra/yassl/src/timer.cpp b/extra/yassl/src/timer.cpp index 4fe0d3aa4f9..8b7d2d17a84 100644 --- a/extra/yassl/src/timer.cpp +++ b/extra/yassl/src/timer.cpp @@ -26,13 +26,17 @@ #include "runtime.hpp" #include "timer.hpp" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else +#include <sys/time.h> +#endif + namespace yaSSL { #ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - timer_d timer() { static bool init(false); @@ -57,8 +61,6 @@ namespace yaSSL { #else // _WIN32 - #include <sys/time.h> - timer_d timer() { struct timeval tv; diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index 59113d7438c..1973c54d781 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -26,6 +26,7 @@ #include "runtime.hpp" #include "yassl_error.hpp" #include "error.hpp" // TaoCrypt error numbers +#include "openssl/ssl.h" // SSL_ERROR_WANT_READ namespace yaSSL { @@ -117,6 +118,11 @@ void SetErrorString(YasslError error, char* buffer) strncpy(buffer, "unable to proccess cerificate", max); break; + // openssl errors + case SSL_ERROR_WANT_READ : + strncpy(buffer, "the read operation would block", max); + break; + // TaoCrypt errors case NO_ERROR : strncpy(buffer, "not in error state", max); diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 396461a6ed5..a715d32f282 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -28,7 +28,6 @@ #include "yassl_int.hpp" #include "handshake.hpp" #include "timer.hpp" -#include "openssl/ssl.h" // for DH #ifdef YASSL_PURE_C @@ -1375,18 +1374,44 @@ Sessions& GetSessions() static sslFactory* sslFactoryInstance = 0; -sslFactory& GetSSL_Factory(){ +sslFactory& GetSSL_Factory() +{ if (!sslFactoryInstance) sslFactoryInstance = NEW_YS sslFactory; return *sslFactoryInstance; } -void CleanUp() +static CryptProvider* cryptProviderInstance = 0; + +CryptProvider& GetCryptProvider() { - TaoCrypt::CleanUp(); - ysDelete(sslFactoryInstance); - ysDelete(sessionsInstance); + if (!cryptProviderInstance) + cryptProviderInstance = NEW_YS CryptProvider; + return *cryptProviderInstance; +} + + +CryptProvider::~CryptProvider() +{ + mySTL::for_each(digestList_.begin(), digestList_.end(), del_ptr_zero()); + mySTL::for_each(cipherList_.begin(), cipherList_.end(), del_ptr_zero()); +} + + +Digest* CryptProvider::NewMd5() +{ + Digest* ptr = NEW_YS MD5(); + digestList_.push_back(ptr); + return ptr; +} + + +BulkCipher* CryptProvider::NewDesEde() +{ + BulkCipher* ptr = NEW_YS DES_EDE(); + cipherList_.push_back(ptr); + return ptr; } @@ -1978,18 +2003,20 @@ void Security::set_resuming(bool b) X509_NAME::X509_NAME(const char* n, size_t sz) - : name_(0) + : name_(0), sz_(sz) { if (sz) { name_ = NEW_YS char[sz]; memcpy(name_, n, sz); } + entry_.data = 0; } X509_NAME::~X509_NAME() { ysArrayDelete(name_); + ysArrayDelete(entry_.data); } @@ -1999,8 +2026,10 @@ char* X509_NAME::GetName() } -X509::X509(const char* i, size_t iSz, const char* s, size_t sSz) - : issuer_(i, iSz), subject_(s, sSz) +X509::X509(const char* i, size_t iSz, const char* s, size_t sSz, + const char* b, int bSz, const char* a, int aSz) + : issuer_(i, iSz), subject_(s, sSz), + beforeDate_(b, bSz), afterDate_(a, aSz) {} @@ -2016,9 +2045,73 @@ X509_NAME* X509::GetSubject() } +ASN1_STRING* X509::GetBefore() +{ + return beforeDate_.GetString(); +} + + +ASN1_STRING* X509::GetAfter() +{ + return afterDate_.GetString(); +} + + +ASN1_STRING* X509_NAME::GetEntry(int i) +{ + if (i < 0 || i >= int(sz_)) + return 0; + + if (entry_.data) + ysArrayDelete(entry_.data); + entry_.data = NEW_YS byte[sz_]; // max size; + + memcpy(entry_.data, &name_[i], sz_ - i); + if (entry_.data[sz_ -i - 1]) { + entry_.data[sz_ - i] = 0; + entry_.length = sz_ - i; + } + else + entry_.length = sz_ - i - 1; + entry_.type = 0; + + return &entry_; +} + + +StringHolder::StringHolder(const char* str, int sz) +{ + asnString_.length = sz; + asnString_.data = NEW_YS byte[sz + 1]; + memcpy(asnString_.data, str, sz); + asnString_.type = 0; // not used for now +} + + +StringHolder::~StringHolder() +{ + ysArrayDelete(asnString_.data); +} + + +ASN1_STRING* StringHolder::GetString() +{ + return &asnString_; +} + } // namespace + +extern "C" void yaSSL_CleanUp() +{ + TaoCrypt::CleanUp(); + ysDelete(yaSSL::cryptProviderInstance); + ysDelete(yaSSL::sslFactoryInstance); + ysDelete(yaSSL::sessionsInstance); +} + + #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION namespace mySTL { template yaSSL::yassl_int_cpp_local1::SumData for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData); diff --git a/extra/yassl/taocrypt/cmakelists.txt b/extra/yassl/taocrypt/CMakeLists.txt index 3ad9195b372..3ad9195b372 100644 --- a/extra/yassl/taocrypt/cmakelists.txt +++ b/extra/yassl/taocrypt/CMakeLists.txt diff --git a/extra/yassl/taocrypt/Makefile.am b/extra/yassl/taocrypt/Makefile.am index 859c704e9d5..c242696b82f 100644 --- a/extra/yassl/taocrypt/Makefile.am +++ b/extra/yassl/taocrypt/Makefile.am @@ -1,2 +1,2 @@ SUBDIRS = src test benchmark -EXTRA_DIST = taocrypt.dsw taocrypt.dsp taocrypt.vcproj cmakelists.txt +EXTRA_DIST = taocrypt.dsw taocrypt.dsp taocrypt.vcproj CMakeLists.txt diff --git a/extra/yassl/taocrypt/benchmark/make.bat b/extra/yassl/taocrypt/benchmark/make.bat index 63391578cfa..4ebe4b32417 100644 --- a/extra/yassl/taocrypt/benchmark/make.bat +++ b/extra/yassl/taocrypt/benchmark/make.bat @@ -1,10 +1,9 @@ -# quick and dirty build file for testing different MSDEVs +REM quick and dirty build file for testing different MSDEVs setlocal set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2 -#set myFLAGS= /I../include /I../../mySTL /c /W3 cl %myFLAGS% benchmark.cpp -link.exe /out:benchmark.exe ../src/taocrypt.lib benchmark.obj +link.exe /out:benchmark.exe ../src/taocrypt.lib benchmark.obj advapi32.lib diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index 6a1163fbb1c..da4c0ce1349 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -79,20 +79,27 @@ enum ASNIdFlag enum DNTags { - COMMON_NAME = 0x03 + COMMON_NAME = 0x03, // CN + SUR_NAME = 0x04, // SN + COUNTRY_NAME = 0x06, // C + LOCALITY_NAME = 0x07, // L + STATE_NAME = 0x08, // ST + ORG_NAME = 0x0a, // O + ORGUNIT_NAME = 0x0b // OU }; enum Constants { MIN_DATE_SZ = 13, - MAX_DATE_SZ = 15, + MAX_DATE_SZ = 16, MAX_ALGO_SZ = 16, MAX_LENGTH_SZ = 5, MAX_SEQ_SZ = 5, // enum(seq|con) + length(4) MAX_ALGO_SIZE = 9, MAX_DIGEST_SZ = 25, // SHA + enum(Bit or Octet) + length(4) - DSA_SIG_SZ = 40 + DSA_SIG_SZ = 40, + NAME_MAX = 512 // max total of all included names }; @@ -205,14 +212,14 @@ enum { SHA_SIZE = 20 }; // A Signing Authority class Signer { PublicKey key_; - char* name_; + char name_[NAME_MAX]; byte hash_[SHA_SIZE]; public: Signer(const byte* k, word32 kSz, const char* n, const byte* h); ~Signer(); const PublicKey& GetPublicKey() const { return key_; } - const char* GetCommonName() const { return name_; } + const char* GetName() const { return name_; } const byte* GetHash() const { return hash_; } private: @@ -245,6 +252,8 @@ public: const char* GetIssuer() const { return issuer_; } const char* GetCommonName() const { return subject_; } const byte* GetHash() const { return subjectHash_; } + const char* GetBeforeDate() const { return beforeDate_; } + const char* GetAfterDate() const { return afterDate_; } void DecodeToKey(); private: @@ -257,8 +266,10 @@ private: byte subjectHash_[SHA_SIZE]; // hash of all Names byte issuerHash_[SHA_SIZE]; // hash of all Names byte* signature_; - char* issuer_; // CommonName - char* subject_; // CommonName + char issuer_[NAME_MAX]; // Names + char subject_[NAME_MAX]; // Names + char beforeDate_[MAX_DATE_SZ]; // valid before date + char afterDate_[MAX_DATE_SZ]; // valid after date bool verify_; // Default to yes, but could be off void ReadHeader(); diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index 4c262e1a540..76836615ce6 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -96,7 +96,7 @@ public: pointer allocate(size_type n, const void* = 0) { - CheckSize(n); + this->CheckSize(n); if (n == 0) return 0; return NEW_TC T[n]; diff --git a/extra/yassl/taocrypt/include/md4.hpp b/extra/yassl/taocrypt/include/md4.hpp new file mode 100644 index 00000000000..aac930d7498 --- /dev/null +++ b/extra/yassl/taocrypt/include/md4.hpp @@ -0,0 +1,65 @@ +/* md4.hpp + * + * Copyright (C) 2003 Sawtooth Consulting Ltd. + * + * This file is part of yaSSL. + * + * yaSSL 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; either version 2 of the License, or + * (at your option) any later version. + * + * yaSSL 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 + */ + +/* md4.hpp provides MD4 digest support + * WANRING: MD4 is considered insecure, only use if you have to, e.g., yaSSL + * libcurl supports needs this for NTLM authentication +*/ + +#ifndef TAO_CRYPT_MD4_HPP +#define TAO_CRYPT_MD4_HPP + +#include "hash.hpp" + +namespace TaoCrypt { + + +// MD4 digest +class MD4 : public HASHwithTransform { +public: + enum { BLOCK_SIZE = 64, DIGEST_SIZE = 16, PAD_SIZE = 56, + TAO_BYTE_ORDER = LittleEndianOrder }; // in Bytes + MD4() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE) + { Init(); } + ByteOrder getByteOrder() const { return ByteOrder(TAO_BYTE_ORDER); } + word32 getBlockSize() const { return BLOCK_SIZE; } + word32 getDigestSize() const { return DIGEST_SIZE; } + word32 getPadSize() const { return PAD_SIZE; } + + MD4(const MD4&); + MD4& operator= (const MD4&); + + void Init(); + void Swap(MD4&); +private: + void Transform(); +}; + +inline void swap(MD4& a, MD4& b) +{ + a.Swap(b); +} + + +} // namespace + +#endif // TAO_CRYPT_MD4_HPP + diff --git a/extra/yassl/taocrypt/src/Makefile.am b/extra/yassl/taocrypt/src/Makefile.am index d3e72346110..1110ed335b8 100644 --- a/extra/yassl/taocrypt/src/Makefile.am +++ b/extra/yassl/taocrypt/src/Makefile.am @@ -4,7 +4,7 @@ noinst_LTLIBRARIES = libtaocrypt.la libtaocrypt_la_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp \ asn.cpp bftables.cpp blowfish.cpp coding.cpp des.cpp dh.cpp \ - dsa.cpp file.cpp hash.cpp integer.cpp md2.cpp md5.cpp misc.cpp \ + dsa.cpp file.cpp hash.cpp integer.cpp md2.cpp md4.cpp md5.cpp misc.cpp \ random.cpp ripemd.cpp rsa.cpp sha.cpp template_instnt.cpp \ tftables.cpp twofish.cpp diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index 3efc26ab168..383fe65dea6 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -213,21 +213,17 @@ void PublicKey::AddToEnd(const byte* data, word32 len) Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h) - : key_(k, kSz), name_(0) + : key_(k, kSz) { - if (n) { int sz = strlen(n); - name_ = NEW_TC char[sz + 1]; memcpy(name_, n, sz); name_[sz] = 0; - } memcpy(hash_, h, SHA::DIGEST_SIZE); } Signer::~Signer() { - tcArrayDelete(name_); } @@ -424,17 +420,19 @@ void DH_Decoder::Decode(DH& key) CertDecoder::CertDecoder(Source& s, bool decode, SignerList* signers, bool noVerify, CertType ct) : BER_Decoder(s), certBegin_(0), sigIndex_(0), sigLength_(0), - signature_(0), issuer_(0), subject_(0), verify_(!noVerify) + signature_(0), verify_(!noVerify) { + issuer_[0] = 0; + subject_[0] = 0; + if (decode) Decode(signers, ct); + } CertDecoder::~CertDecoder() { - tcArrayDelete(subject_); - tcArrayDelete(issuer_); tcArrayDelete(signature_); } @@ -672,8 +670,12 @@ void CertDecoder::GetName(NameType nt) SHA sha; word32 length = GetSequence(); // length of all distinguished names + assert (length < NAME_MAX); length += source_.get_index(); + char* ptr = (nt == ISSUER) ? issuer_ : subject_; + word32 idx = 0; + while (source_.get_index() < length) { GetSet(); GetSequence(); @@ -694,13 +696,49 @@ void CertDecoder::GetName(NameType nt) byte id = source_.next(); b = source_.next(); // strType word32 strLen = GetLength(source_); + bool copy = false; if (id == COMMON_NAME) { - char*& ptr = (nt == ISSUER) ? issuer_ : subject_; - ptr = NEW_TC char[strLen + 1]; - memcpy(ptr, source_.get_current(), strLen); - ptr[strLen] = 0; + memcpy(&ptr[idx], "/CN=", 4); + idx += 4; + copy = true; + } + else if (id == SUR_NAME) { + memcpy(&ptr[idx], "/SN=", 4); + idx += 4; + copy = true; + } + else if (id == COUNTRY_NAME) { + memcpy(&ptr[idx], "/C=", 3); + idx += 3; + copy = true; + } + else if (id == LOCALITY_NAME) { + memcpy(&ptr[idx], "/L=", 3); + idx += 3; + copy = true; + } + else if (id == STATE_NAME) { + memcpy(&ptr[idx], "/ST=", 4); + idx += 4; + copy = true; } + else if (id == ORG_NAME) { + memcpy(&ptr[idx], "/O=", 3); + idx += 3; + copy = true; + } + else if (id == ORGUNIT_NAME) { + memcpy(&ptr[idx], "/OU=", 4); + idx += 4; + copy = true; + } + + if (copy) { + memcpy(&ptr[idx], source_.get_current(), strLen); + idx += strLen; + } + sha.Update(source_.get_current(), strLen); source_.advance(strLen); } @@ -711,6 +749,8 @@ void CertDecoder::GetName(NameType nt) source_.advance(length); } } + ptr[idx++] = 0; + if (nt == ISSUER) sha.Final(issuerHash_); else @@ -744,6 +784,16 @@ void CertDecoder::GetDate(DateType dt) source_.SetError(BEFORE_DATE_E); else source_.SetError(AFTER_DATE_E); + + // save for later use + if (dt == BEFORE) { + memcpy(beforeDate_, date, length); + beforeDate_[length] = 0; + } + else { // after + memcpy(afterDate_, date, length); + afterDate_[length] = 0; + } } diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 82a248ff7da..885ddfbf630 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -2428,7 +2428,7 @@ void PositiveMultiply(Integer& product, const Integer& a, const Integer& b) product.reg_.CleanNew(RoundupSize(aSize + bSize)); product.sign_ = Integer::POSITIVE; - WordBlock workspace(aSize + bSize); + AlignedWordBlock workspace(aSize + bSize); AsymmetricMultiply(product.reg_.get_buffer(), workspace.get_buffer(), a.reg_.get_buffer(), aSize, b.reg_.get_buffer(), bSize); } @@ -3375,7 +3375,7 @@ void PositiveDivide(Integer& remainder, Integer& quotient, quotient.reg_.CleanNew(RoundupSize(aSize-bSize+2)); quotient.sign_ = Integer::POSITIVE; - WordBlock T(aSize+2*bSize+4); + AlignedWordBlock T(aSize+2*bSize+4); Divide(remainder.reg_.get_buffer(), quotient.reg_.get_buffer(), T.get_buffer(), a.reg_.get_buffer(), aSize, b.reg_.get_buffer(), bSize); @@ -3595,7 +3595,7 @@ Integer Integer::InverseMod(const Integer &m) const return !u ? Zero() : (m*(*this-u)+1)/(*this); } - WordBlock T(m.reg_.size() * 4); + AlignedWordBlock T(m.reg_.size() * 4); Integer r((word)0, m.reg_.size()); unsigned k = AlmostInverse(r.reg_.get_buffer(), T.get_buffer(), reg_.get_buffer(), reg_.size(), diff --git a/extra/yassl/taocrypt/src/make.bat b/extra/yassl/taocrypt/src/make.bat index 5a2ae580b76..ecf7e8f8469 100644 --- a/extra/yassl/taocrypt/src/make.bat +++ b/extra/yassl/taocrypt/src/make.bat @@ -1,8 +1,7 @@ -# quick and dirty build file for testing different MSDEVs +REM quick and dirty build file for testing different MSDEVs setlocal set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2 -#set myFLAGS= /I../include /I../../mySTL /c /W3 /O1 cl %myFLAGS% aes.cpp cl %myFLAGS% aestables.cpp diff --git a/extra/yassl/taocrypt/src/md4.cpp b/extra/yassl/taocrypt/src/md4.cpp new file mode 100644 index 00000000000..dfc2b079141 --- /dev/null +++ b/extra/yassl/taocrypt/src/md4.cpp @@ -0,0 +1,154 @@ +/* md4.cpp + * + * Copyright (C) 2003 Sawtooth Consulting Ltd. + * + * This file is part of yaSSL. + * + * yaSSL 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; either version 2 of the License, or + * (at your option) any later version. + * + * yaSSL 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 + */ + + +/* based on Wei Dai's md4.cpp from CryptoPP */ + +#include "runtime.hpp" +#include "md4.hpp" +#include "algorithm.hpp" // mySTL::swap + + + +namespace TaoCrypt { + +void MD4::Init() +{ + digest_[0] = 0x67452301L; + digest_[1] = 0xefcdab89L; + digest_[2] = 0x98badcfeL; + digest_[3] = 0x10325476L; + + buffLen_ = 0; + loLen_ = 0; + hiLen_ = 0; +} + + +MD4::MD4(const MD4& that) : HASHwithTransform(DIGEST_SIZE / sizeof(word32), + BLOCK_SIZE) +{ + buffLen_ = that.buffLen_; + loLen_ = that.loLen_; + hiLen_ = that.hiLen_; + + memcpy(digest_, that.digest_, DIGEST_SIZE); + memcpy(buffer_, that.buffer_, BLOCK_SIZE); +} + +MD4& MD4::operator= (const MD4& that) +{ + MD4 tmp(that); + Swap(tmp); + + return *this; +} + + +void MD4::Swap(MD4& other) +{ + mySTL::swap(loLen_, other.loLen_); + mySTL::swap(hiLen_, other.hiLen_); + mySTL::swap(buffLen_, other.buffLen_); + + memcpy(digest_, other.digest_, DIGEST_SIZE); + memcpy(buffer_, other.buffer_, BLOCK_SIZE); +} + + +void MD4::Transform() +{ +#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) + + word32 A, B, C, D; + + A = digest_[0]; + B = digest_[1]; + C = digest_[2]; + D = digest_[3]; + +#define function(a,b,c,d,k,s) a=rotlFixed(a+F(b,c,d)+buffer_[k],s); + function(A,B,C,D, 0, 3); + function(D,A,B,C, 1, 7); + function(C,D,A,B, 2,11); + function(B,C,D,A, 3,19); + function(A,B,C,D, 4, 3); + function(D,A,B,C, 5, 7); + function(C,D,A,B, 6,11); + function(B,C,D,A, 7,19); + function(A,B,C,D, 8, 3); + function(D,A,B,C, 9, 7); + function(C,D,A,B,10,11); + function(B,C,D,A,11,19); + function(A,B,C,D,12, 3); + function(D,A,B,C,13, 7); + function(C,D,A,B,14,11); + function(B,C,D,A,15,19); + +#undef function +#define function(a,b,c,d,k,s) a=rotlFixed(a+G(b,c,d)+buffer_[k]+0x5a827999,s); + function(A,B,C,D, 0, 3); + function(D,A,B,C, 4, 5); + function(C,D,A,B, 8, 9); + function(B,C,D,A,12,13); + function(A,B,C,D, 1, 3); + function(D,A,B,C, 5, 5); + function(C,D,A,B, 9, 9); + function(B,C,D,A,13,13); + function(A,B,C,D, 2, 3); + function(D,A,B,C, 6, 5); + function(C,D,A,B,10, 9); + function(B,C,D,A,14,13); + function(A,B,C,D, 3, 3); + function(D,A,B,C, 7, 5); + function(C,D,A,B,11, 9); + function(B,C,D,A,15,13); + +#undef function +#define function(a,b,c,d,k,s) a=rotlFixed(a+H(b,c,d)+buffer_[k]+0x6ed9eba1,s); + function(A,B,C,D, 0, 3); + function(D,A,B,C, 8, 9); + function(C,D,A,B, 4,11); + function(B,C,D,A,12,15); + function(A,B,C,D, 2, 3); + function(D,A,B,C,10, 9); + function(C,D,A,B, 6,11); + function(B,C,D,A,14,15); + function(A,B,C,D, 1, 3); + function(D,A,B,C, 9, 9); + function(C,D,A,B, 5,11); + function(B,C,D,A,13,15); + function(A,B,C,D, 3, 3); + function(D,A,B,C,11, 9); + function(C,D,A,B, 7,11); + function(B,C,D,A,15,15); + + digest_[0] += A; + digest_[1] += B; + digest_[2] += C; + digest_[3] += D; +} + + +} // namespace + diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index 3d0539187a7..4ef163a7f5d 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -25,6 +25,15 @@ #include "runtime.hpp" #include "misc.hpp" + +extern "C" { + + // for libcurl configure test, these are the signatures they use + // locking handled internally by library + char CRYPTO_lock() { return 0;} + char CRYPTO_add_lock() { return 0;} +} // extern "C" + #ifdef YASSL_PURE_C void* operator new(size_t sz, TaoCrypt::new_t) diff --git a/extra/yassl/taocrypt/taocrypt.dsp b/extra/yassl/taocrypt/taocrypt.dsp index 13b9a07419b..19edf7b2f22 100644 --- a/extra/yassl/taocrypt/taocrypt.dsp +++ b/extra/yassl/taocrypt/taocrypt.dsp @@ -64,7 +64,8 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# SUBTRACT CPP /Fr # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -145,6 +146,10 @@ SOURCE=.\src\md2.cpp # End Source File # Begin Source File +SOURCE=.\src\md4.cpp +# End Source File +# Begin Source File + SOURCE=.\src\md5.cpp # End Source File # Begin Source File @@ -245,6 +250,10 @@ SOURCE=.\include\md2.hpp # End Source File # Begin Source File +SOURCE=.\include\md4.hpp +# End Source File +# Begin Source File + SOURCE=.\include\md5.hpp # End Source File # Begin Source File diff --git a/extra/yassl/taocrypt/test/make.bat b/extra/yassl/taocrypt/test/make.bat index e1a4cbce7cd..5f01db68d0d 100644 --- a/extra/yassl/taocrypt/test/make.bat +++ b/extra/yassl/taocrypt/test/make.bat @@ -1,4 +1,4 @@ -# quick and dirty build file for testing different MSDEVs +REM quick and dirty build file for testing different MSDEVs setlocal set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2 diff --git a/extra/yassl/taocrypt/test/test.cpp b/extra/yassl/taocrypt/test/test.cpp index b8618b18d47..28ef73dfac8 100644 --- a/extra/yassl/taocrypt/test/test.cpp +++ b/extra/yassl/taocrypt/test/test.cpp @@ -8,6 +8,7 @@ #include "sha.hpp" #include "md5.hpp" #include "md2.hpp" +#include "md4.hpp" #include "ripemd.hpp" #include "hmac.hpp" #include "arc4.hpp" @@ -30,6 +31,7 @@ using TaoCrypt::word32; using TaoCrypt::SHA; using TaoCrypt::MD5; using TaoCrypt::MD2; +using TaoCrypt::MD4; using TaoCrypt::RIPEMD160; using TaoCrypt::HMAC; using TaoCrypt::ARC4; @@ -89,6 +91,7 @@ void file_test(int, char**); int sha_test(); int md5_test(); int md2_test(); +int md4_test(); int ripemd_test(); int hmac_test(); int arc4_test(); @@ -165,6 +168,11 @@ void taocrypt_test(void* args) else printf( "MD2 test passed!\n"); + if ( (ret = md4_test()) ) + err_sys("MD4 test failed!\n", ret); + else + printf( "MD4 test passed!\n"); + if ( (ret = ripemd_test()) ) err_sys("RIPEMD test failed!\n", ret); else @@ -348,6 +356,51 @@ int md5_test() } +int md4_test() +{ + MD4 md4; + byte hash[MD4::DIGEST_SIZE]; + + testVector test_md4[] = + { + testVector("", + "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31\xb7\x3c\x59\xd7\xe0\xc0\x89" + "\xc0"), + testVector("a", + "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb" + "\x24"), + testVector("abc", + "\xa4\x48\x01\x7a\xaf\x21\xd8\x52\x5f\xc1\x0a\xe8\x7a\xa6\x72" + "\x9d"), + testVector("message digest", + "\xd9\x13\x0a\x81\x64\x54\x9f\xe8\x18\x87\x48\x06\xe1\xc7\x01" + "\x4b"), + testVector("abcdefghijklmnopqrstuvwxyz", + "\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd\xee\xa8\xed\x63\xdf\x41\x2d" + "\xa9"), + testVector("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345" + "6789", + "\x04\x3f\x85\x82\xf2\x41\xdb\x35\x1c\xe6\x27\xe1\x53\xe7\xf0" + "\xe4"), + testVector("1234567890123456789012345678901234567890123456789012345678" + "9012345678901234567890", + "\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19\x9c\x3e\x7b\x16\x4f\xcc\x05" + "\x36") + }; + + int times( sizeof(test_md4) / sizeof(testVector) ); + for (int i = 0; i < times; ++i) { + md4.Update(test_md4[i].input_, test_md4[i].inLen_); + md4.Final(hash); + + if (memcmp(hash, test_md4[i].output_, MD4::DIGEST_SIZE) != 0) + return -5 - i; + } + + return 0; +} + + int md2_test() { MD2 md5; diff --git a/extra/yassl/testsuite/make.bat b/extra/yassl/testsuite/make.bat index d8a55b0d3af..1bc7ce0513d 100644 --- a/extra/yassl/testsuite/make.bat +++ b/extra/yassl/testsuite/make.bat @@ -1,4 +1,4 @@ -# quick and dirty build file for testing different MSDEVs +REM quick and dirty build file for testing different MSDEVs setlocal set myFLAGS= /I../include /I../taocrypt/include /I../mySTL /c /W3 /G6 /O2 /MT /D"WIN32" /D"NO_MAIN_DRIVER" diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp index 79d02b63558..c80e3ad23da 100644 --- a/extra/yassl/testsuite/test.hpp +++ b/extra/yassl/testsuite/test.hpp @@ -27,16 +27,22 @@ #endif /* _WIN32 */ -#if defined(__MACH__) || defined(_WIN32) +#if !defined(_SOCKLEN_T) && (defined(__MACH__) || defined(_WIN32)) typedef int socklen_t; #endif // HPUX doesn't use socklent_t for third parameter to accept -#if !defined(__hpux__) +#if !defined(__hpux) typedef socklen_t* ACCEPT_THIRD_T; #else typedef int* ACCEPT_THIRD_T; + +// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented +#ifndef _POSIX_THREADS +#define _POSIX_THREADS +#endif + #endif @@ -305,8 +311,8 @@ inline void showPeer(SSL* ssl) char* subject = X509_NAME_oneline(X509_get_subject_name(peer), 0, 0); printf("peer's cert info:\n"); - printf("issuer is: %s\n", issuer); - printf("subject is: %s\n", subject); + printf("issuer : %s\n", issuer); + printf("subject: %s\n", subject); free(subject); free(issuer); diff --git a/extra/yassl/testsuite/testsuite.cpp b/extra/yassl/testsuite/testsuite.cpp index af988432a86..1cf6a78ebe7 100644 --- a/extra/yassl/testsuite/testsuite.cpp +++ b/extra/yassl/testsuite/testsuite.cpp @@ -91,6 +91,7 @@ int main(int argc, char** argv) assert(memcmp(input, output, sizeof(input)) == 0); printf("\nAll tests passed!\n"); + yaSSL_CleanUp(); return 0; } @@ -146,10 +147,10 @@ int test_openSSL_des() (byte*)key, iv); byte cipher[16]; - DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz, &key[0], &key[8], - &key[16], &iv, true); + DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz, &key[0], &key[1], + &key[2], &iv, true); byte plain[16]; - DES_ede3_cbc_encrypt(cipher, plain, 16, &key[0], &key[8], &key[16], + DES_ede3_cbc_encrypt(cipher, plain, 16, &key[0], &key[1], &key[2], &iv, false); return 0; } diff --git a/extra/yassl/testsuite/testsuite.dsp b/extra/yassl/testsuite/testsuite.dsp index f896aa7f020..24c325fa878 100644 --- a/extra/yassl/testsuite/testsuite.dsp +++ b/extra/yassl/testsuite/testsuite.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX- /O2 /I "../taocrypt/include" /I "../include" /I "../mySTL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "NO_MAIN_DRIVER" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../taocrypt/include" /I "../include" /I "../mySTL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "NO_MAIN_DRIVER" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX- /ZI /Od /I "../taocrypt/include" /I "../include" /I "../mySTL" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "NO_MAIN_DRIVER" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../taocrypt/include" /I "../include" /I "../mySTL" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "NO_MAIN_DRIVER" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/include/my_base.h b/include/my_base.h index e014f7c33b7..0390106880a 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -340,7 +340,7 @@ enum ha_base_keytype { #define HA_ERR_WRONG_COMMAND 131 /* Command not supported */ #define HA_ERR_OLD_FILE 132 /* old databasfile */ #define HA_ERR_NO_ACTIVE_RECORD 133 /* No record read in update() */ -#define HA_ERR_RECORD_DELETED 134 /* Intern error-code */ +#define HA_ERR_RECORD_DELETED 134 /* A record is not there */ #define HA_ERR_RECORD_FILE_FULL 135 /* No more room in file */ #define HA_ERR_INDEX_FILE_FULL 136 /* No more room in file */ #define HA_ERR_END_OF_FILE 137 /* end in next/prev/first/last */ diff --git a/include/my_dbug.h b/include/my_dbug.h index 65bb7b55d0d..a397861c1af 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -42,6 +42,7 @@ extern void _db_pargs_(uint _line_,const char *keyword); extern void _db_doprnt_ _VARARGS((const char *format,...)); extern void _db_dump_(uint _line_,const char *keyword,const char *memory, uint length); +extern void _db_end_(void); extern void _db_lock_file_(void); extern void _db_unlock_file_(void); extern FILE *_db_fp_(void); @@ -73,6 +74,7 @@ extern FILE *_db_fp_(void); #define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1)) #define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2)) #define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2) +#define DBUG_END() _db_end_ () #define DBUG_LOCK_FILE _db_lock_file_() #define DBUG_UNLOCK_FILE _db_unlock_file_() #define DBUG_ASSERT(A) assert(A) @@ -97,6 +99,7 @@ extern FILE *_db_fp_(void); #define DBUG_SETJMP(a1) setjmp(a1) #define DBUG_LONGJMP(a1) longjmp(a1) #define DBUG_DUMP(keyword,a1,a2) +#define DBUG_END() #define DBUG_ASSERT(A) #define DBUG_LOCK_FILE #define DBUG_FILE (stderr) diff --git a/include/my_pthread.h b/include/my_pthread.h index acd1d2b558b..0cb38d29be8 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -226,12 +226,14 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ we want to make sure that no such flags are set. */ #if defined(HAVE_SIGACTION) && !defined(my_sigset) -#define my_sigset(A,B) do { struct sigaction s; sigset_t set; \ +#define my_sigset(A,B) do { struct sigaction s; sigset_t set; int rc; \ + DBUG_ASSERT((A) != 0); \ sigemptyset(&set); \ s.sa_handler = (B); \ s.sa_mask = set; \ s.sa_flags = 0; \ - sigaction((A), &s, (struct sigaction *) NULL); \ + rc= sigaction((A), &s, (struct sigaction *) NULL);\ + DBUG_ASSERT(rc == 0); \ } while (0) #elif defined(HAVE_SIGSET) && !defined(my_sigset) #define my_sigset(A,B) sigset((A),(B)) diff --git a/include/my_sys.h b/include/my_sys.h index 1540d820777..0a4881e2082 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -75,6 +75,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_GIVE_INFO 2 /* Give time info about process*/ +#define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */ #define ME_HIGHBYTE 8 /* Shift for colours */ #define ME_NOCUR 1 /* Don't use curses message */ diff --git a/include/my_time.h b/include/my_time.h index 2b0dc4ac6ff..df500dc501b 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -38,7 +38,10 @@ typedef long my_time_t; #define MY_TIME_T_MAX LONG_MAX #define MY_TIME_T_MIN LONG_MIN +/* two-digit years < this are 20..; >= this are 19.. */ #define YY_PART_YEAR 70 +/* apply above magic to years < this */ +#define YY_MAGIC_BELOW 200 /* Flags to str_to_datetime */ #define TIME_FUZZY_DATE 1 diff --git a/include/mysql.h b/include/mysql.h index 6217ce631b5..3a71e47f414 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -149,7 +149,8 @@ enum mysql_option MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, - MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT + MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT, + MYSQL_OPT_SSL_VERIFY_SERVER_CERT }; struct st_mysql_options { @@ -164,6 +165,7 @@ struct st_mysql_options { char *ssl_ca; /* PEM CA file */ char *ssl_capath; /* PEM directory of CA-s? */ char *ssl_cipher; /* cipher to use */ + my_bool ssl_verify_server_cert; /* if to verify server cert */ char *shared_memory_base_name; unsigned long max_allowed_packet; my_bool use_ssl; /* if to use SSL or not */ diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index dc3b0922327..0435ddb815a 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -20,12 +20,6 @@ "Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl.", (gptr*) &opt_use_ssl, (gptr*) &opt_use_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).", - (gptr*) &opt_ssl_key, (gptr*) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, - 0, 0, 0, 0, 0, 0}, - {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl).", - (gptr*) &opt_ssl_cert, (gptr*) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, - 0, 0, 0, 0, 0, 0}, {"ssl-ca", OPT_SSL_CA, "CA file in PEM format (check OpenSSL docs, implies --ssl).", (gptr*) &opt_ssl_ca, (gptr*) &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, @@ -34,8 +28,19 @@ "CA directory (check OpenSSL docs, implies --ssl).", (gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl).", + (gptr*) &opt_ssl_cert, (gptr*) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl).", (gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - + {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).", + (gptr*) &opt_ssl_key, (gptr*) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, +#ifdef MYSQL_CLIENT + {"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT, + "Verify server's \"Common Name\" in its cert against hostname used when connecting. This option is disabled by default.", + (gptr*) &opt_ssl_verify_server_cert, (gptr*) &opt_ssl_verify_server_cert, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, +#endif #endif /* HAVE_OPENSSL */ diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h index 164cf541381..7204145fc28 100644 --- a/include/sslopt-vars.h +++ b/include/sslopt-vars.h @@ -15,10 +15,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_OPENSSL -static my_bool opt_use_ssl = 0; -static char *opt_ssl_key = 0; -static char *opt_ssl_cert = 0; -static char *opt_ssl_ca = 0; -static char *opt_ssl_capath = 0; -static char *opt_ssl_cipher = 0; +#ifdef SSL_VARS_NOT_STATIC +#define SSL_STATIC +#else +#define SSL_STATIC static +#endif +SSL_STATIC my_bool opt_use_ssl = 0; +SSL_STATIC char *opt_ssl_ca = 0; +SSL_STATIC char *opt_ssl_capath = 0; +SSL_STATIC char *opt_ssl_cert = 0; +SSL_STATIC char *opt_ssl_cipher = 0; +SSL_STATIC char *opt_ssl_key = 0; +#ifdef MYSQL_CLIENT +SSL_STATIC my_bool opt_ssl_verify_server_cert= 0; +#endif #endif diff --git a/include/violite.h b/include/violite.h index de2ae5386c0..4837ade64b4 100644 --- a/include/violite.h +++ b/include/violite.h @@ -105,34 +105,23 @@ void vio_timeout(Vio *vio,uint which, uint timeout); #include <openssl/ssl.h> #include <openssl/err.h> -struct st_VioSSLAcceptorFd +struct st_VioSSLFd { SSL_CTX *ssl_context; - SSL_METHOD *ssl_method; - struct st_VioSSLAcceptorFd *session_id_context; }; -/* One copy for client */ -struct st_VioSSLConnectorFd -{ - SSL_CTX *ssl_context; - /* function pointers which are only once for SSL client */ - SSL_METHOD *ssl_method; -}; - -int sslaccept(struct st_VioSSLAcceptorFd*, Vio *, long timeout); -int sslconnect(struct st_VioSSLConnectorFd*, Vio *, long timeout); +int sslaccept(struct st_VioSSLFd*, Vio *, long timeout); +int sslconnect(struct st_VioSSLFd*, Vio *, long timeout); -struct st_VioSSLConnectorFd +struct st_VioSSLFd *new_VioSSLConnectorFd(const char *key_file, const char *cert_file, const char *ca_file, const char *ca_path, const char *cipher); -struct st_VioSSLAcceptorFd +struct st_VioSSLFd *new_VioSSLAcceptorFd(const char *key_file, const char *cert_file, const char *ca_file,const char *ca_path, const char *cipher); -Vio *new_VioSSL(struct st_VioSSLAcceptorFd *fd, Vio *sd, int state); -void free_vio_ssl_acceptor_fd(struct st_VioSSLAcceptorFd *fd); +void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd); #endif /* HAVE_OPENSSL */ #ifdef HAVE_SMEM @@ -141,6 +130,8 @@ int vio_write_shared_memory(Vio *vio, const gptr buf, int size); int vio_close_shared_memory(Vio * vio); #endif +void vio_end(void); + #ifdef __cplusplus } #endif @@ -205,7 +196,9 @@ struct st_vio my_bool (*was_interrupted)(Vio*); int (*vioclose)(Vio*); void (*timeout)(Vio*, unsigned int which, unsigned int timeout); +#ifdef HAVE_OPENSSL void *ssl_arg; +#endif #ifdef HAVE_SMEM HANDLE handle_file_map; char *handle_map; diff --git a/libmysql/cmakelists.txt b/libmysql/CMakeLists.txt index 35795102082..35795102082 100644 --- a/libmysql/cmakelists.txt +++ b/libmysql/CMakeLists.txt diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 9a6f418fa49..787ffc51de7 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -31,7 +31,7 @@ include $(srcdir)/Makefile.shared libmysqlclient_la_SOURCES = $(target_sources) libmysqlclient_la_LIBADD = $(target_libadd) $(yassl_las) libmysqlclient_la_LDFLAGS = $(target_ldflags) -EXTRA_DIST = Makefile.shared libmysql.def dll.c mytest.c cmakelists.txt +EXTRA_DIST = Makefile.shared libmysql.def dll.c mytest.c CMakeLists.txt noinst_HEADERS = client_settings.h # This is called from the toplevel makefile diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index b750e9cc4b2..225b3926aa7 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -178,7 +178,7 @@ void STDCALL mysql_server_end() /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) { - my_end(0); + my_end(MY_DONT_FREE_DBUG); /* Remove TRACING, if enabled by mysql_debug() */ DBUG_POP(); } @@ -186,6 +186,7 @@ void STDCALL mysql_server_end() mysql_thread_end(); finish_client_errs(); free_charsets(); + vio_end(); mysql_client_init= org_my_init_done= 0; #ifdef EMBEDDED_SERVER if (stderror_file) diff --git a/libmysqld/cmakelists.txt b/libmysqld/CMakeLists.txt index 8bd0e0baa32..8bd0e0baa32 100644 --- a/libmysqld/cmakelists.txt +++ b/libmysqld/CMakeLists.txt diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 63e75c34a6d..a3af2d43bd5 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -88,11 +88,11 @@ INC_LIB= $(top_builddir)/regex/libregex.a \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/vio/libvio.a \ @mysql_plugin_libs@ \ - $(yassl_las) + $(yassl_inc_libs) if HAVE_YASSL -yassl_las = $(top_srcdir)/extra/yassl/src/libyassl.la \ - $(top_srcdir)/extra/yassl/taocrypt/src/libtaocrypt.la +yassl_inc_libs= $(top_srcdir)/extra/yassl/src/.libs/libyassl.a \ + $(top_srcdir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a endif # Storage engine specific compilation options @@ -135,12 +135,12 @@ else (for arc in ./libmysqld_int.a $(INC_LIB); do \ arpath=`echo $$arc|sed 's|[^/]*$$||'|sed 's|\.libs/$$||'`; \ artmp=`echo $$arc|sed 's|^.*/|tmp/lib-|'`; \ - for F in `$(AR) t $$arc`; do \ + for F in `$(AR) t $$arc | grep -v SYMDEF`; do \ if test -e "$$arpath/$$F" ; then echo "$$arpath/$$F"; else \ mkdir $$artmp; cd $$artmp > /dev/null; \ $(AR) x ../../$$arc; \ cd $$current_dir > /dev/null; \ - ls $$artmp/*; \ + ls $$artmp/* | grep -v SYMDEF; \ continue 2; fi; done; \ done; echo $(libmysqld_a_DEPENDENCIES) ) | sort -u | xargs $(AR) cq libmysqld.a ; \ $(RANLIB) libmysqld.a ; \ diff --git a/libmysqld/examples/cmakelists.txt b/libmysqld/examples/CMakeLists.txt index 5c58264a7e7..5c58264a7e7 100644 --- a/libmysqld/examples/cmakelists.txt +++ b/libmysqld/examples/CMakeLists.txt diff --git a/mysql-test/extra/binlog_tests/blackhole.test b/mysql-test/extra/binlog_tests/blackhole.test index 71aec90e9a0..97243015aba 100644 --- a/mysql-test/extra/binlog_tests/blackhole.test +++ b/mysql-test/extra/binlog_tests/blackhole.test @@ -147,3 +147,15 @@ set autocommit=1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; + +# +# BUG#10952 - alter table ... lost data without errors and warnings +# +drop table if exists t1; +create table t1 (c char(20)) engine=MyISAM; +insert into t1 values ("Monty"),("WAX"),("Walrus"); +--error 1031 +alter table t1 engine=blackhole; +drop table t1; + +# End of 5.0 tests diff --git a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test index cfa943228fa..7a097fd1eae 100644 --- a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test +++ b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test @@ -3,6 +3,8 @@ # RENAME TABLE work with MERGE tables on the slave. # Test of FLUSH NO_WRITE_TO_BINLOG by the way. # + + -- source include/master-slave.inc create table t1 (a int); diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test index 116bdd1028e..20ee7cd0d8f 100644 --- a/mysql-test/extra/rpl_tests/rpl_log.test +++ b/mysql-test/extra/rpl_tests/rpl_log.test @@ -77,11 +77,8 @@ connection slave; # to go into the relay log (the master always sends a fake one when replication # starts). start slave; -# -# This is timing out in pushbuild and should be changed to use -# wait_slave_status.inc -# -sleep 2; +let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%'; +--source include/wait_slave_status.inc sync_with_master; flush logs; stop slave; diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index a3fb7ec0183..d6fb9382b90 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -20,6 +20,7 @@ sub mtr_record_dead_children (); sub mtr_exit ($); sub sleep_until_file_created ($$$); sub mtr_kill_processes ($); +sub mtr_kill_process ($$$$); # static in C sub spawn_impl ($$$$$$$$); @@ -875,6 +876,25 @@ sub mtr_kill_processes ($) { } } + +sub mtr_kill_process ($$$$) { + my $pid= shift; + my $signal= shift; + my $retries= shift; + my $timeout= shift; + + while (1) + { + kill($signal, $pid); + + last unless kill (0, $pid) and $retries--; + + mtr_debug("Sleep $timeout second waiting for processes to die"); + + sleep($timeout); + } +} + ############################################################################## # # When we exit, we kill off all children diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 0087459e1dd..0591c24e914 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -134,7 +134,6 @@ our $glob_win32= 0; # OS and native Win32 executables our $glob_win32_perl= 0; # ActiveState Win32 Perl our $glob_cygwin_perl= 0; # Cygwin Perl our $glob_cygwin_shell= undef; -our $glob_use_libtool= 1; our $glob_mysql_test_dir= undef; our $glob_mysql_bench_dir= undef; our $glob_hostname= undef; @@ -192,6 +191,7 @@ our $exe_slave_mysqld; our $exe_im; our $exe_my_print_defaults; our $lib_udf_example; +our $exe_libtool; our $opt_bench= 0; our $opt_small_bench= 0; @@ -390,7 +390,6 @@ sub main () { check_ndbcluster_support(); # We check whether to actually use it later check_ssl_support(); - check_running_as_root(); environment_setup(); signal_setup(); @@ -458,12 +457,6 @@ sub initial_setup () { $glob_cygwin_perl= ($^O eq "cygwin"); $glob_win32= ($glob_win32_perl or $glob_cygwin_perl); - # Use libtool on all platforms except windows - if ( $glob_win32 ) - { - $glob_use_libtool= 0; - } - # We require that we are in the "mysql-test" directory # to run mysql-test-run @@ -936,6 +929,7 @@ sub command_line_setup () { path_err => "$opt_vardir/log/im.err", path_log => "$opt_vardir/log/im.log", path_pid => "$opt_vardir/run/im.pid", + path_angel_pid => "$opt_vardir/run/im.angel.pid", path_sock => "$sockdir/im.sock", port => $im_port, start_timeout => $master->[0]->{'start_timeout'}, @@ -1013,6 +1007,21 @@ sub snapshot_setup () { sub executable_setup () { + # + # Check if libtool is available in this distribution/clone + # we need it when valgrinding or debugging non installed binary + # Otherwise valgrind will valgrind the libtool wrapper or bash + # and gdb will not find the real executable to debug + # + if ( -x "../libtool") + { + $exe_libtool= "../libtool"; + if ($opt_valgrind or $glob_debugger) + { + mtr_report("Using \"$exe_libtool\" when running valgrind or debugger"); + } + } + if ( $opt_source_dist ) { if ( $glob_win32 ) @@ -1212,6 +1221,7 @@ sub environment_setup () { $ENV{'NDB_STATUS_OK'}= "YES"; $ENV{'IM_PATH_PID'}= $instance_manager->{path_pid}; + $ENV{'IM_PATH_ANGEL_PID'}= $instance_manager->{path_angel_pid}; $ENV{'IM_PORT'}= $instance_manager->{port}; $ENV{'IM_MYSQLD1_SOCK'}= $instance_manager->{instances}->[0]->{path_sock}; @@ -1375,7 +1385,7 @@ sub kill_and_cleanup () { sub check_running_as_root () { # Check if running as root # i.e a file can be read regardless what mode we set it to - my $test_file= "test_running_as_root.txt"; + my $test_file= "$opt_vardir/test_running_as_root.txt"; mtr_tofile($test_file, "MySQL"); chmod(oct("0000"), $test_file); @@ -1821,6 +1831,7 @@ sub initialize_servers () { save_installed_db(); } } + check_running_as_root(); } } @@ -1990,6 +2001,7 @@ sub im_create_defaults_file($) { [manager] pid-file = $instance_manager->{path_pid} +angel-pid-file = $instance_manager->{path_angel_pid} socket = $instance_manager->{path_sock} port = $instance_manager->{port} password-file = $instance_manager->{password_file} @@ -2014,7 +2026,7 @@ log-slow-queries = $instance->{path_datadir}/mysqld$server_id.slow.log language = $path_language character-sets-dir = $path_charsetsdir basedir = $path_my_basedir -server_id =$server_id +server_id = $server_id skip-stack-trace skip-innodb skip-bdb @@ -2869,6 +2881,15 @@ sub mysqld_start ($$$$$) { $exe= undef; } + if ($exe_libtool and $opt_valgrind) + { + # Add "libtool --mode-execute" + # if running in valgrind(to avoid valgrinding bash) + unshift(@$args, "--mode=execute", $exe); + $exe= $exe_libtool; + } + + if ( $type eq 'master' ) { if ( ! defined $exe or @@ -3043,6 +3064,18 @@ sub im_start($$) { sub im_stop($) { my $instance_manager = shift; + # Obtain mysqld-process pids before we start stopping IM (it can delete pid + # files). + + my @mysqld_pids = (); + my $instances = $instance_manager->{'instances'}; + + push(@mysqld_pids, mtr_get_pid_from_file($instances->[0]->{'path_pid'})) + if -r $instances->[0]->{'path_pid'}; + + push(@mysqld_pids, mtr_get_pid_from_file($instances->[1]->{'path_pid'})) + if -r $instances->[1]->{'path_pid'}; + # Re-read pid from the file, since during tests Instance Manager could have # been restarted, so its pid could have been changed. @@ -3050,34 +3083,79 @@ sub im_stop($) { mtr_get_pid_from_file($instance_manager->{'path_pid'}) if -f $instance_manager->{'path_pid'}; + if (-f $instance_manager->{'path_angel_pid'}) + { + $instance_manager->{'angel_pid'} = + mtr_get_pid_from_file($instance_manager->{'path_angel_pid'}) + } + else + { + $instance_manager->{'angel_pid'} = undef; + } + # Inspired from mtr_stop_mysqld_servers(). start_reap_all(); - # Create list of pids. We should stop Instance Manager and all started - # mysqld-instances. Some of them may be nonguarded, so IM will not stop them - # on shutdown. + # Try graceful shutdown. - my @pids = ( $instance_manager->{'pid'} ); - my $instances = $instance_manager->{'instances'}; + mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1); + + # Check that all processes died. - if ( -r $instances->[0]->{'path_pid'} ) + my $clean_shutdown= 0; + + while (1) { - push(@pids, mtr_get_pid_from_file($instances->[0]->{'path_pid'})); + last if kill (0, $instance_manager->{'pid'}); + + last if (defined $instance_manager->{'angel_pid'}) && + kill (0, $instance_manager->{'angel_pid'}); + + foreach my $pid (@mysqld_pids) + { + last if kill (0, $pid); + } + + $clean_shutdown= 1; + last; } - if ( -r $instances->[1]->{'path_pid'} ) + # Kill leftovers (the order is important). + + unless ($clean_shutdown) { - push(@pids, mtr_get_pid_from_file($instances->[1]->{'path_pid'})); - } + mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1) + if defined $instance_manager->{'angel_pid'}; + + mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1); + + # Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM + # will not stop them on shutdown. So, we should firstly try to end them + # legally. + + mtr_kill_processes(\@mysqld_pids); - # Kill processes. + # Complain in error log so that a warning will be shown. + + my $errlog= "$opt_vardir/log/mysql-test-run.pl.err"; + + open (ERRLOG, ">>$errlog") || + mtr_error("Can not open error log ($errlog)"); + + my $ts= localtime(); + print ERRLOG + "Warning: [$ts] Instance Manager did not shutdown gracefully.\n"; + + close ERRLOG; + } - mtr_kill_processes(\@pids); + # That's all. stop_reap_all(); $instance_manager->{'pid'} = undef; + $instance_manager->{'angel_pid'} = undef; } @@ -3403,12 +3481,12 @@ sub run_mysqltest ($) { debugger_arguments(\$args, \$exe, "client"); } - if ($glob_use_libtool and $opt_valgrind) + if ($exe_libtool and $opt_valgrind) { # Add "libtool --mode-execute" before the test to execute # if running in valgrind(to avoid valgrinding bash) unshift(@$args, "--mode=execute", $exe); - $exe= "libtool"; + $exe= $exe_libtool; } if ( $opt_check_testcases ) @@ -3478,9 +3556,9 @@ sub gdb_arguments { mtr_add_arg($$args, "$type"); mtr_add_arg($$args, "-e"); - if ( $glob_use_libtool ) + if ( $exe_libtool ) { - mtr_add_arg($$args, "libtool"); + mtr_add_arg($$args, $exe_libtool); mtr_add_arg($$args, "--mode=execute"); } @@ -3540,9 +3618,9 @@ sub ddd_arguments { my $save_exe= $$exe; $$args= []; - if ( $glob_use_libtool ) + if ( $exe_libtool ) { - $$exe= "libtool"; + $$exe= $exe_libtool; mtr_add_arg($$args, "--mode=execute"); mtr_add_arg($$args, "ddd"); } @@ -3563,6 +3641,8 @@ sub debugger_arguments { my $exe= shift; my $debugger= $opt_debugger || $opt_client_debugger; + # FIXME Need to change the below "eq"'s to + # "case unsensitive string contains" if ( $debugger eq "vcexpress" or $debugger eq "vc") { # vc[express] /debugexe exe arg1 .. argn diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 1ad9cd6d1e9..f4332ea9888 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -647,3 +647,13 @@ SELECT LENGTH(s) FROM t1; LENGTH(s) 10 DROP TABLE t1; +CREATE TABLE t1 (v VARCHAR(3), b INT); +INSERT INTO t1 VALUES ('abc', 5); +SELECT * FROM t1; +v b +abc 5 +ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4); +SELECT * FROM t1; +v b +abc 5 +DROP TABLE t1; diff --git a/mysql-test/r/ansi.result b/mysql-test/r/ansi.result index 00a526df8ea..527748e00d5 100644 --- a/mysql-test/r/ansi.result +++ b/mysql-test/r/ansi.result @@ -2,7 +2,7 @@ drop table if exists t1; set sql_mode="MySQL40"; select @@sql_mode; @@sql_mode -NO_FIELD_OPTIONS,MYSQL40,HIGH_NOT_PRECEDENCE +MYSQL40,HIGH_NOT_PRECEDENCE set @@sql_mode="ANSI"; select @@sql_mode; @@sql_mode @@ -17,3 +17,32 @@ SELECT id FROM t1 GROUP BY id2; id drop table t1; SET @@SQL_MODE=""; +CREATE TABLE t1 (i int auto_increment NOT NULL, PRIMARY KEY (i)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SET @@SQL_MODE="MYSQL323"; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`i`) +) TYPE=MyISAM +SET @@SQL_MODE="MYSQL40"; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`i`) +) TYPE=MyISAM +SET @@SQL_MODE="NO_FIELD_OPTIONS"; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) NOT NULL, + PRIMARY KEY (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 2fe4db859b5..525f64ea902 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -355,6 +355,30 @@ CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE IF EXISTS t1; +CREATE TABLE `t1` ( +t1_name VARCHAR(255) DEFAULT NULL, +t1_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +KEY (t1_name), +PRIMARY KEY (t1_id) +) AUTO_INCREMENT = 1000; +INSERT INTO t1 (t1_name) VALUES('MySQL'); +INSERT INTO t1 (t1_name) VALUES('MySQL'); +INSERT INTO t1 (t1_name) VALUES('MySQL'); +SELECT * from t1; +t1_name t1_id +MySQL 1000 +MySQL 1001 +MySQL 1002 +SHOW CREATE TABLE `t1`; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1_name` varchar(255) DEFAULT NULL, + `t1_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`t1_id`), + KEY `t1_name` (`t1_name`) +) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1 +DROP TABLE `t1`; +End of 4.1 tests CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)); insert into t1 (b) values (1); replace into t1 (b) values (2), (1), (3); diff --git a/mysql-test/r/binlog_row_blackhole.result b/mysql-test/r/binlog_row_blackhole.result index aa5c943de00..42bf7a10888 100644 --- a/mysql-test/r/binlog_row_blackhole.result +++ b/mysql-test/r/binlog_row_blackhole.result @@ -156,3 +156,9 @@ master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT +drop table if exists t1; +create table t1 (c char(20)) engine=MyISAM; +insert into t1 values ("Monty"),("WAX"),("Walrus"); +alter table t1 engine=blackhole; +ERROR HY000: Table storage engine for 't1' doesn't have this option +drop table t1; diff --git a/mysql-test/r/binlog_stm_blackhole.result b/mysql-test/r/binlog_stm_blackhole.result index 90eabc6fa66..64569993a7b 100644 --- a/mysql-test/r/binlog_stm_blackhole.result +++ b/mysql-test/r/binlog_stm_blackhole.result @@ -149,3 +149,9 @@ master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=blackho master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(1) master-bin.000001 # Query 1 # use `test`; COMMIT +drop table if exists t1; +create table t1 (c char(20)) engine=MyISAM; +insert into t1 values ("Monty"),("WAX"),("Walrus"); +alter table t1 engine=blackhole; +ERROR HY000: Table storage engine for 't1' doesn't have this option +drop table t1; diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 9d2706f64fa..1d2041432fe 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -103,8 +103,8 @@ t1 CREATE TABLE `t1` ( `c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '', `c3` varbinary(1) NOT NULL DEFAULT '', `c4` varbinary(1) NOT NULL DEFAULT '', - `c5` varbinary(3) NOT NULL DEFAULT '', - `c6` varbinary(3) NOT NULL DEFAULT '', + `c5` varbinary(4) NOT NULL DEFAULT '', + `c6` varbinary(4) NOT NULL DEFAULT '', `c7` decimal(2,1) NOT NULL DEFAULT '0.0', `c8` decimal(2,1) NOT NULL DEFAULT '0.0', `c9` decimal(2,1) DEFAULT NULL, @@ -152,11 +152,11 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `COALESCE(1)` int(1) NOT NULL DEFAULT '0', - `COALESCE(1.0)` decimal(2,1) unsigned NOT NULL DEFAULT '0.0', + `COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', `COALESCE('a')` varchar(1) NOT NULL DEFAULT '', `COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', `COALESCE(1,'1')` varbinary(1) NOT NULL DEFAULT '', - `COALESCE(1.1,'1')` varbinary(3) NOT NULL DEFAULT '', + `COALESCE(1.1,'1')` varbinary(4) NOT NULL DEFAULT '', `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 44f6945238c..1246c6f3d5d 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -412,7 +412,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) CHARACTER SET utf8 DEFAULT NULL, - UNIQUE KEY `a` USING HASH (`c`(1)) + UNIQUE KEY `a` (`c`(1)) USING HASH ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); @@ -448,7 +448,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) CHARACTER SET utf8 DEFAULT NULL, - UNIQUE KEY `a` USING BTREE (`c`(1)) + UNIQUE KEY `a` (`c`(1)) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); @@ -570,7 +570,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, - UNIQUE KEY `a` USING HASH (`c`(1)) + UNIQUE KEY `a` (`c`(1)) USING HASH ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); @@ -606,7 +606,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, - UNIQUE KEY `a` USING BTREE (`c`(1)) + UNIQUE KEY `a` (`c`(1)) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 214c9466c8c..ea4ae8a8438 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -515,3 +515,39 @@ NULL select str_to_date( 1, IF(1=1,NULL,NULL) ); str_to_date( 1, IF(1=1,NULL,NULL) ) NULL +SELECT TIME_FORMAT("24:00:00", '%r'); +TIME_FORMAT("24:00:00", '%r') +12:00:00 AM +SELECT TIME_FORMAT("00:00:00", '%r'); +TIME_FORMAT("00:00:00", '%r') +12:00:00 AM +SELECT TIME_FORMAT("12:00:00", '%r'); +TIME_FORMAT("12:00:00", '%r') +12:00:00 PM +SELECT TIME_FORMAT("15:00:00", '%r'); +TIME_FORMAT("15:00:00", '%r') +03:00:00 PM +SELECT TIME_FORMAT("01:00:00", '%r'); +TIME_FORMAT("01:00:00", '%r') +01:00:00 AM +SELECT TIME_FORMAT("25:00:00", '%r'); +TIME_FORMAT("25:00:00", '%r') +01:00:00 AM +SELECT TIME_FORMAT("00:00:00", '%l %p'); +TIME_FORMAT("00:00:00", '%l %p') +12 AM +SELECT TIME_FORMAT("01:00:00", '%l %p'); +TIME_FORMAT("01:00:00", '%l %p') +1 AM +SELECT TIME_FORMAT("12:00:00", '%l %p'); +TIME_FORMAT("12:00:00", '%l %p') +12 PM +SELECT TIME_FORMAT("23:00:00", '%l %p'); +TIME_FORMAT("23:00:00", '%l %p') +11 PM +SELECT TIME_FORMAT("24:00:00", '%l %p'); +TIME_FORMAT("24:00:00", '%l %p') +12 AM +SELECT TIME_FORMAT("25:00:00", '%l %p'); +TIME_FORMAT("25:00:00", '%l %p') +1 AM diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index a6ad95570f8..89b17d69f40 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -533,3 +533,15 @@ select count(distinct concat(x,y)) from t1; count(distinct concat(x,y)) 2 drop table t1; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (1, 101); +INSERT INTO t1 SELECT a + 1, a + 101 FROM t1; +INSERT INTO t1 SELECT a + 2, a + 102 FROM t1; +INSERT INTO t1 SELECT a + 4, a + 104 FROM t1; +INSERT INTO t1 SELECT a + 8, a + 108 FROM t1; +EXPLAIN SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 8 NULL 16 Using where; Using index +SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a; +a a +DROP TABLE t1; diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index d66dec741bd..75e1548cdee 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -53,3 +53,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE ÔÁ ref ÉÎÄ0,ÉÎÄ01 ÉÎÄ0 5 const 1 Using where; Using index drop table ÔÁÂ; set names latin1; +select 3 into @v1; +explain select 3 into @v1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 58bf3b36469..824edbbe3a6 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -821,144 +821,6 @@ SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; MAX(id) NULL DROP TABLE t1; -create table t1m (a int) engine=myisam; -create table t1i (a int) engine=innodb; -create table t2m (a int) engine=myisam; -create table t2i (a int) engine=innodb; -insert into t2m values (5); -insert into t2i values (5); -select min(a) from t1m; -min(a) -NULL -select min(7) from t1m; -min(7) -NULL -select min(7) from DUAL; -min(7) -NULL -explain select min(7) from t2m join t1m; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away -select min(7) from t2m join t1m; -min(7) -NULL -select max(a) from t1m; -max(a) -NULL -select max(7) from t1m; -max(7) -NULL -select max(7) from DUAL; -max(7) -NULL -explain select max(7) from t2m join t1m; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away -select max(7) from t2m join t1m; -max(7) -NULL -select 1, min(a) from t1m where a=99; -1 min(a) -1 NULL -select 1, min(a) from t1m where 1=99; -1 min(a) -1 NULL -select 1, min(1) from t1m where a=99; -1 min(1) -1 NULL -select 1, min(1) from t1m where 1=99; -1 min(1) -1 NULL -select 1, max(a) from t1m where a=99; -1 max(a) -1 NULL -select 1, max(a) from t1m where 1=99; -1 max(a) -1 NULL -select 1, max(1) from t1m where a=99; -1 max(1) -1 NULL -select 1, max(1) from t1m where 1=99; -1 max(1) -1 NULL -select min(a) from t1i; -min(a) -NULL -select min(7) from t1i; -min(7) -NULL -select min(7) from DUAL; -min(7) -NULL -explain select min(7) from t2i join t1i; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 -select min(7) from t2i join t1i; -min(7) -NULL -select max(a) from t1i; -max(a) -NULL -select max(7) from t1i; -max(7) -NULL -select max(7) from DUAL; -max(7) -NULL -explain select max(7) from t2i join t1i; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 -select max(7) from t2i join t1i; -max(7) -NULL -select 1, min(a) from t1i where a=99; -1 min(a) -1 NULL -select 1, min(a) from t1i where 1=99; -1 min(a) -1 NULL -select 1, min(1) from t1i where a=99; -1 min(1) -1 NULL -select 1, min(1) from t1i where 1=99; -1 min(1) -1 NULL -select 1, max(a) from t1i where a=99; -1 max(a) -1 NULL -select 1, max(a) from t1i where 1=99; -1 max(a) -1 NULL -select 1, max(1) from t1i where a=99; -1 max(1) -1 NULL -select 1, max(1) from t1i where 1=99; -1 max(1) -1 NULL -explain select count(*), min(7), max(7) from t1m, t1i; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 -select count(*), min(7), max(7) from t1m, t1i; -count(*) min(7) max(7) -0 NULL NULL -explain select count(*), min(7), max(7) from t1m, t2i; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 -select count(*), min(7), max(7) from t1m, t2i; -count(*) min(7) max(7) -0 NULL NULL -explain select count(*), min(7), max(7) from t2m, t1i; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2m system NULL NULL NULL NULL 1 -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 -select count(*), min(7), max(7) from t2m, t1i; -count(*) min(7) max(7) -0 NULL NULL -drop table t1m, t1i, t2m, t2i; create table t2 (ff double); insert into t2 values (2.2); select cast(sum(distinct ff) as decimal(5,2)) from t2; diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index e3257ce5fd0..e38e2624e19 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -326,3 +326,20 @@ deallocate prepare s; set @str=NULL; drop table t2; drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +drop table t1; diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 5e375472c5f..10d20c001f1 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -51,6 +51,42 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) ); a 2004-01-06 12:34:00 drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (conn CHAR(7), connection_id INT); +INSERT INTO t1 VALUES ('default', CONNECTION_ID()); +SELECT GET_LOCK('bug16501',600); +GET_LOCK('bug16501',600) +1 +INSERT INTO t1 VALUES ('con1', CONNECTION_ID()); +SELECT IS_USED_LOCK('bug16501') = connection_id +FROM t1 +WHERE conn = 'default'; +IS_USED_LOCK('bug16501') = connection_id +1 + SELECT GET_LOCK('bug16501',600); +SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID(); +IS_USED_LOCK('bug16501') = CONNECTION_ID() +1 +SELECT RELEASE_LOCK('bug16501'); +RELEASE_LOCK('bug16501') +1 +GET_LOCK('bug16501',600) +1 +SELECT IS_USED_LOCK('bug16501') = connection_id +FROM t1 +WHERE conn = 'con1'; +IS_USED_LOCK('bug16501') = connection_id +1 +SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID(); +IS_USED_LOCK('bug16501') = CONNECTION_ID() +1 +SELECT RELEASE_LOCK('bug16501'); +RELEASE_LOCK('bug16501') +1 +SELECT IS_USED_LOCK('bug16501'); +IS_USED_LOCK('bug16501') +NULL +DROP TABLE t1; create table t1 as select uuid(), length(uuid()); show create table t1; Table Create Table diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 0b706b24488..354c886b19b 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -1017,6 +1017,13 @@ t 1000000 1 drop table t1; +select load_file("lkjlkj"); +load_file("lkjlkj") +NULL +select ifnull(load_file("lkjlkj"),"it's null"); +ifnull(load_file("lkjlkj"),"it's null") +it's null +End of 4.1 tests create table t1 (d decimal default null); insert into t1 values (null); select format(d, 2) from t1; @@ -1039,4 +1046,10 @@ cast(ltrim(' 20.06 ') as decimal(19,2)) select cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2)); cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2)) 20.06 +select conv("18383815659218730760",10,10) + 0; +conv("18383815659218730760",10,10) + 0 +1.8383815659219e+19 +select "18383815659218730760" + 0; +"18383815659218730760" + 0 +1.8383815659219e+19 End of 5.0 tests diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index b5fd35d926f..516809b8906 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -732,12 +732,6 @@ SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAY count(*) 3 DROP TABLE t1; -explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, -timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used -Warnings: -Note 1003 select timestampdiff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2` select last_day('2005-00-00'); last_day('2005-00-00') NULL @@ -753,6 +747,17 @@ last_day('2005-01-00') NULL Warnings: Warning 1292 Incorrect datetime value: '2005-01-00' +select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')), +monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m')); +monthname(str_to_date(null, '%m')) monthname(str_to_date(null, '%m')) monthname(str_to_date(1, '%m')) monthname(str_to_date(0, '%m')) +NULL NULL January NULL +End of 4.1 tests +explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, +timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select timestampdiff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2` select time_format('100:00:00', '%H %k %h %I %l'); time_format('100:00:00', '%H %k %h %I %l') 100 100 04 04 4 @@ -872,3 +877,38 @@ id day id day 1 2005-06-01 3 2005-07-15 3 2005-07-01 3 2005-07-15 DROP TABLE t1,t2; +End of 5.0 tests +select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND) +NULL +select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND) +NULL +select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND); +date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND) +NULL +select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND) +0199-12-31 23:59:59 +select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND); +date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND) +0200-01-01 00:00:00 +select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND) +0199-12-31 23:59:59 +select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR); +date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR) +0001-01-01 23:59:59 +select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND) +2049-12-31 23:59:59 +select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND) +1989-12-31 23:59:59 +select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND) +NULL +select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND); +date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND) +NULL +End of 5.1 tests diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index bf4a10a0041..cd6a2510001 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -294,7 +294,7 @@ t2 CREATE TABLE `t2` ( `g` geometry NOT NULL, PRIMARY KEY (`fid`), SPATIAL KEY `g` (`g`(32)) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 +) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=latin1 SELECT count(*) FROM t2; count(*) 100 diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 6370f7699b3..f9b55cc6a7b 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2116,3 +2116,25 @@ COUNT(DISTINCT a) 1 DROP TABLE t1; DROP PROCEDURE a; +CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a)); +INSERT INTO t1 (a) VALUES +(''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'), +('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'), +('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN'); +EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL PRIMARY 66 NULL 12 Using index for group-by +SELECT DISTINCT a,a FROM t1 ORDER BY a; +a a + +CENTRAL CENTRAL +EASTERN EASTERN +GREATER LONDON GREATER LONDON +NORTH CENTRAL NORTH CENTRAL +NORTH EAST NORTH EAST +NORTH WEST NORTH WEST +SCOTLAND SCOTLAND +SOUTH EAST SOUTH EAST +SOUTH WEST SOUTH WEST +WESTERN WESTERN +DROP TABLE t1; diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index a37f260ff31..68b13b5fc0a 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -12,7 +12,7 @@ explain extended select count(a) as b from t1 where a=0 having b >=0; 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 Warnings: -Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (count(`test`.`t1`.`a`) >= 0) +Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (`b` >= 0) drop table t1; CREATE TABLE t1 ( raw_id int(10) NOT NULL default '0', diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index 5a2d07db5e6..2c0e8123667 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -556,9 +556,9 @@ t1 CREATE TABLE `t1` ( `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` varchar(50) DEFAULT NULL, - KEY `v` USING BTREE (`v`), - KEY `c` USING BTREE (`c`), - KEY `t` USING BTREE (`t`(10)) + KEY `v` (`v`) USING BTREE, + KEY `c` (`c`) USING BTREE, + KEY `t` (`t`(10)) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 select count(*) from t1; count(*) diff --git a/mysql-test/r/im_options_set.result b/mysql-test/r/im_options_set.result index 0d2fa699fc7..5e6c740624e 100644 --- a/mysql-test/r/im_options_set.result +++ b/mysql-test/r/im_options_set.result @@ -1,11 +1,11 @@ -server_id =1 -server_id =2 +server_id = 1 +server_id = 2 SHOW VARIABLES LIKE 'server_id'; Variable_name Value server_id 1 SET mysqld1.server_id = 11; server_id =11 -server_id =2 +server_id = 2 SHOW VARIABLES LIKE 'server_id'; Variable_name Value server_id 1 diff --git a/mysql-test/r/im_options_unset.result b/mysql-test/r/im_options_unset.result index 834152c35d2..bf54025edb7 100644 --- a/mysql-test/r/im_options_unset.result +++ b/mysql-test/r/im_options_unset.result @@ -1,10 +1,10 @@ -server_id =1 -server_id =2 +server_id = 1 +server_id = 2 SHOW VARIABLES LIKE 'server_id'; Variable_name Value server_id 1 UNSET mysqld1.server_id; -server_id =2 +server_id = 2 SHOW VARIABLES LIKE 'server_id'; Variable_name Value server_id 1 diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 898dd64b794..9aeaae6c6c1 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1129,11 +1129,6 @@ DROP TABLE t1; DROP VIEW v1; DROP FUNCTION func1; DROP FUNCTION func2; -create database mysqltest; -create table mysqltest.t1(a int); -select table_schema from information_schema.tables where table_schema='mysqltest'; -table_schema -drop database mysqltest; select column_type, group_concat(table_schema, '.', table_name), count(*) as num from information_schema.columns where table_schema='information_schema' and @@ -1142,6 +1137,23 @@ group by column_type order by num; column_type group_concat(table_schema, '.', table_name) num varchar(7) information_schema.ROUTINES,information_schema.VIEWS 2 varchar(20) information_schema.COLUMNS,information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS 6 +create table t1(f1 char(1) not null, f2 char(9) not null) +default character set utf8; +select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from +information_schema.columns where table_schema='test' and table_name = 't1'; +CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH +1 3 +9 27 +drop table t1; +use mysql; +INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL', +'NO','DEFINER','','','BEGIN\r\n \r\nEND','root@%','2006-03-02 18:40:03', +'2006-03-02 18:40:03','',''); +select routine_name from information_schema.routines; +routine_name + +delete from proc where name=''; +use test; select * from information_schema.engines WHERE ENGINE="MyISAM"; ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS MyISAM ENABLED Default engine as of MySQL 3.23 with great performance NO NO NO diff --git a/mysql-test/r/information_schema_chmod.result b/mysql-test/r/information_schema_chmod.result new file mode 100644 index 00000000000..36124559439 --- /dev/null +++ b/mysql-test/r/information_schema_chmod.result @@ -0,0 +1,5 @@ +create database mysqltest; +create table mysqltest.t1(a int); +select table_schema from information_schema.tables where table_schema='mysqltest'; +table_schema +drop database mysqltest; diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 878c5cb5451..bbd9550196f 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1 +1,194 @@ -drop table if exists t1; +drop table if exists t1,t2; +create table t1 ( +c_id int(11) not null default '0', +org_id int(11) default null, +unique key contacts$c_id (c_id), +key contacts$org_id (org_id) +) engine=innodb; +insert into t1 values +(2,null),(120,null),(141,null),(218,7), (128,1), +(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3), +(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4); +create table t2 ( +slai_id int(11) not null default '0', +owner_tbl int(11) default null, +owner_id int(11) default null, +sla_id int(11) default null, +inc_web int(11) default null, +inc_email int(11) default null, +inc_chat int(11) default null, +inc_csr int(11) default null, +inc_total int(11) default null, +time_billed int(11) default null, +activedate timestamp null default null, +expiredate timestamp null default null, +state int(11) default null, +sla_set int(11) default null, +unique key t2$slai_id (slai_id), +key t2$owner_id (owner_id), +key t2$sla_id (sla_id) +) engine=innodb; +insert into t2(slai_id, owner_tbl, owner_id, sla_id) values +(1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7), +(8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12); +flush tables; +select si.slai_id +from t1 c join t2 si on +((si.owner_tbl = 3 and si.owner_id = c.org_id) or +( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where +c.c_id = 218 and expiredate is null; +slai_id +12 +select * from t1 where org_id is null; +c_id org_id +2 NULL +120 NULL +141 NULL +select si.slai_id +from t1 c join t2 si on +((si.owner_tbl = 3 and si.owner_id = c.org_id) or +( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where +c.c_id = 218 and expiredate is null; +slai_id +12 +drop table t1, t2; +create table t1m (a int) engine=myisam; +create table t1i (a int) engine=innodb; +create table t2m (a int) engine=myisam; +create table t2i (a int) engine=innodb; +insert into t2m values (5); +insert into t2i values (5); +select min(a) from t1m; +min(a) +NULL +select min(7) from t1m; +min(7) +NULL +select min(7) from DUAL; +min(7) +NULL +explain select min(7) from t2m join t1m; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select min(7) from t2m join t1m; +min(7) +NULL +select max(a) from t1m; +max(a) +NULL +select max(7) from t1m; +max(7) +NULL +select max(7) from DUAL; +max(7) +NULL +explain select max(7) from t2m join t1m; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +select max(7) from t2m join t1m; +max(7) +NULL +select 1, min(a) from t1m where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1m where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1m where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1m where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1m where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1m where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1m where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1m where 1=99; +1 max(1) +1 NULL +select min(a) from t1i; +min(a) +NULL +select min(7) from t1i; +min(7) +NULL +select min(7) from DUAL; +min(7) +NULL +explain select min(7) from t2i join t1i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 +select min(7) from t2i join t1i; +min(7) +NULL +select max(a) from t1i; +max(a) +NULL +select max(7) from t1i; +max(7) +NULL +select max(7) from DUAL; +max(7) +NULL +explain select max(7) from t2i join t1i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 +select max(7) from t2i join t1i; +max(7) +NULL +select 1, min(a) from t1i where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1i where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1i where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1i where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1i where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1i where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1i where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1i where 1=99; +1 max(1) +1 NULL +explain select count(*), min(7), max(7) from t1m, t1i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 +select count(*), min(7), max(7) from t1m, t1i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t1m, t2i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 +select count(*), min(7), max(7) from t1m, t2i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t2m, t1i; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2m system NULL NULL NULL NULL 1 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 +select count(*), min(7), max(7) from t2m, t1i; +count(*) min(7) max(7) +0 NULL NULL +drop table t1m, t1i, t2m, t2i; diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index ecf76d477a0..86288caf398 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -700,8 +700,8 @@ ERROR 42S22: Unknown column 't1.b' in 'on clause' select * from information_schema.statistics join information_schema.columns using(table_name,column_name) where table_name='user'; TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT -user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 20 60 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references -user User NULL mysql 0 mysql PRIMARY 2 A 5 NULL NULL BTREE NULL mysql 2 NO char 5 16 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references +user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references +user User NULL mysql 0 mysql PRIMARY 2 A 5 NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references drop table t1; drop table t2; drop table t3; diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 8a30f3c18ec..f4ec997e50c 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1151,6 +1151,63 @@ EXPLAIN SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%' OR FALSE; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index -1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index +1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where +DROP TABLE t1,t2; +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; +SELECT v1.a, v2. b +FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) +GROUP BY v1.a; +a b +2 NULL +3 3 +SELECT v1.a, v2. b +FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } +GROUP BY v1.a; +a b +2 NULL +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); +a b +1 NULL +2 2 +3 3 +4 NULL DROP TABLE t1,t2; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 538f1fa1a20..2f5f382028a 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -771,3 +771,11 @@ Table Op Msg_type Msg_text test.t1 check status OK test.t2 check status OK drop table t1, t2, t3; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' +create table t1 (c char(20)) engine=MyISAM; +insert into t1 values ("Monty"),("WAX"),("Walrus"); +alter table t1 engine=MERGE; +ERROR HY000: Table storage engine for 't1' doesn't have this option +drop table t1; diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 0a170e16188..50b0b6ae294 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -2,7 +2,7 @@ drop table if exists t1,t2; select 1, 1.0, -1, "hello", NULL; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def 1 8 1 1 N 32897 0 63 -def 1.0 246 3 3 N 161 1 63 +def 1.0 246 4 3 N 129 1 63 def -1 8 2 2 N 32897 0 63 def hello 253 5 5 N 1 31 8 def NULL 6 0 0 Y 32896 0 63 diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 8976c98136b..3226351f966 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1421,15 +1421,6 @@ create table t3 (c1 int) engine=myisam pack_keys=default; create table t4 (c1 int) engine=myisam pack_keys=2; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1 drop table t1, t2, t3; -create table t1 (a int not null, key `a` key_block_size=1024 (a)); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - KEY `a` KEY_BLOCK_SIZE=1024 (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; -set @@new=1; create table t1 (a int not null, key `a` (a) key_block_size=1024); show create table t1; Table Create Table @@ -1574,4 +1565,5 @@ t1 CREATE TABLE `t1` ( drop table t1; create table t1 (a int not null, key key_block_size=1024 (a)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1024 (a))' at line 1 -set @@new=0; +create table t1 (a int not null, key `a` key_block_size=1024 (a)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key_block_size=1024 (a))' at line 1 diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index a067d3ad0f8..4b7084e813c 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -74,7 +74,7 @@ c_cp932 +----------------------+------------+--------+ | >a < | b | 123421 | | >a < | 0123456789 | 4 | -| >abcd< | NULL | 4 | +| >abcd< | | 4 | +----------------------+------------+--------+ +------+------+---------------------------+ | i | j | k | @@ -94,6 +94,14 @@ c_cp932 | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | i | int(11) | YES | | NULL | | -| j | int(11) | NO | | NULL | | +| j | int(11) | NO | | | | | k | int(11) | YES | | NULL | | +-------+---------+------+-----+---------+-------+ ++------+------+ +| i | s1 | ++------+------+ +| 1 | x | +| 2 | NULL | +| 3 | | ++------+------+ +End of 5.0 tests diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 50e4cc28d93..664833fab2a 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -189,4 +189,5 @@ HEX(f) select HEX(f) from t4; HEX(f) 835C +flush logs; drop table t1, t2, t03, t04, t3, t4; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 5da2be8da37..493e79d4136 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1701,6 +1701,44 @@ select * from t1; a b Osnabrück Köln drop table t1; +create table `t1` ( +t1_name varchar(255) default null, +t1_id int(10) unsigned not null auto_increment, +key (t1_name), +primary key (t1_id) +) auto_increment = 1000 default charset=latin1; +insert into t1 (t1_name) values('bla'); +insert into t1 (t1_name) values('bla'); +insert into t1 (t1_name) values('bla'); +select * from t1; +t1_name t1_id +bla 1000 +bla 1001 +bla 1002 +show create table `t1`; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1_name` varchar(255) DEFAULT NULL, + `t1_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`t1_id`), + KEY `t1_name` (`t1_name`) +) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1 +DROP TABLE `t1`; +select * from t1; +t1_name t1_id +bla 1000 +bla 1001 +bla 1002 +show create table `t1`; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1_name` varchar(255) DEFAULT NULL, + `t1_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`t1_id`), + KEY `t1_name` (`t1_name`) +) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1 +drop table `t1`; +End of 4.1 tests create table t1 (a binary(1), b blob); insert into t1 values ('',''); diff --git a/mysql-test/r/ndb_autodiscover3.result b/mysql-test/r/ndb_autodiscover3.result new file mode 100644 index 00000000000..86495ebb3eb --- /dev/null +++ b/mysql-test/r/ndb_autodiscover3.result @@ -0,0 +1,53 @@ +drop table if exists t1, t2; +create table t1 (a int key) engine=ndbcluster; +begin; +insert into t1 values (1); +insert into t1 values (2); +ERROR HY000: Got temporary error 4025 'Node failure caused abort of transaction' from NDBCLUSTER +commit; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +drop table t1; +create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster; +insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1); +select * from t2 order by a limit 3; +a b +1 1 +2 1 +3 1 +select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +show tables like 't2'; +Tables_in_test (t2) +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; +a +1 +2 +3 +select * from t2 order by a limit 3; +a +1 +2 +3 +reset master; +select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +show tables like 't2'; +Tables_in_test (t2) +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; +a +1 +2 +3 +select * from t2 order by a limit 3; +a +1 +2 +3 +reset master; +drop table t2; diff --git a/mysql-test/r/ndb_bitfield.result b/mysql-test/r/ndb_bitfield.result index 9a8c571cfba..59c4d420b22 100644 --- a/mysql-test/r/ndb_bitfield.result +++ b/mysql-test/r/ndb_bitfield.result @@ -9,7 +9,7 @@ t1 CREATE TABLE `t1` ( `pk1` int(11) NOT NULL, `b` bit(64) DEFAULT NULL, PRIMARY KEY (`pk1`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 insert into t1 values (0,b'1111111111111111111111111111111111111111111111111111111111111111'), (1,b'1000000000000000000000000000000000000000000000000000000000000000'), diff --git a/mysql-test/r/ndb_blob.result b/mysql-test/r/ndb_blob.result index 7a781ae3bde..829c67905bf 100644 --- a/mysql-test/r/ndb_blob.result +++ b/mysql-test/r/ndb_blob.result @@ -500,3 +500,69 @@ select count(*) from t1; count(*) 0 drop table t1; +create table t1 ( +a varchar(40) not null, +b mediumint not null, +t text, +c varchar(2) not null, +d bigint not null, +primary key (a,b,c), +key (c,a), +unique key (d) +) engine=ndb; +insert into t1 (a,b,c,d,t) values ('a',1110,'a',1,@v1); +insert into t1 (a,b,c,d,t) values ('b',1110,'a',2,@v2); +insert into t1 (a,b,c,d,t) values ('a',1110,'b',3,@v3); +insert into t1 (a,b,c,d,t) values ('b',1110,'b',4,@v4); +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 b238654911689bfb626a3ef9dba4a1ca074e6a5e +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 NULL +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='a'; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='b'; +a b c d sha1(t) +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +update t1 set t=@v4 where a='b' and b=1110 and c='a'; +update t1 set t=@v2 where a='b' and b=1110 and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 NULL +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 b238654911689bfb626a3ef9dba4a1ca074e6a5e +update t1 set t=@v2 where d=2; +update t1 set t=@v4 where d=4; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 b238654911689bfb626a3ef9dba4a1ca074e6a5e +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 NULL +update t1 set t=@v4 where a='b' and c='a'; +update t1 set t=@v2 where a='b' and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 NULL +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 b238654911689bfb626a3ef9dba4a1ca074e6a5e +update t1 set t=@v2 where b+d=1112; +update t1 set t=@v4 where b+d=1114; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 b238654911689bfb626a3ef9dba4a1ca074e6a5e +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 NULL +delete from t1 where a='a' and b=1110 and c='a'; +delete from t1 where a='b' and c='a'; +delete from t1 where d=3; +delete from t1 where b+d=1114; +select count(*) from t1; +count(*) +0 +drop table t1; diff --git a/mysql-test/r/ndb_blob_partition.result b/mysql-test/r/ndb_blob_partition.result deleted file mode 100644 index b08a91f0cdd..00000000000 --- a/mysql-test/r/ndb_blob_partition.result +++ /dev/null @@ -1,104 +0,0 @@ -drop table if exists t1; -create table t1 ( -a mediumint not null, -b text not null, -c int not null, -d longblob, -primary key using hash (a,c), -unique key (c) -) -engine=ndb -partition by range (c) -partitions 3 -( partition p1 values less than (200), -partition p2 values less than (300), -partition p3 values less than (400)); -insert into t1 values (1, @v1, 101, @v2); -insert into t1 values (1, @v2, 102, @v3); -insert into t1 values (1, @v3, 103, @v4); -insert into t1 values (2, @v4, 201, @v5); -insert into t1 values (2, @v5, 202, @v6); -insert into t1 values (2, @v6, 203, @v7); -insert into t1 values (3, @v7, 301, @v8); -insert into t1 values (3, @v8, 302, @v9); -insert into t1 values (3, @v9, 303, @v1); -select a, sha1(b), c, sha1(d) from t1 order by a; -a sha1(b) c sha1(d) -1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 -1 10d3c783026b310218d10b7188da96a2401648c6 102 a33549d9844092289a58ac348dd59f09fc28406a -1 a33549d9844092289a58ac348dd59f09fc28406a 103 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c -2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d -2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 202 090565c580809efed3d369481a4bbb168b20713e -2 090565c580809efed3d369481a4bbb168b20713e 203 1e0070bec426871a46291de27b9bd6e4255ab4e5 -3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e -3 acbaba01bc2e682f015f40e79d9cbe475db3002e 302 9ee30d99162574f79c66ae95cdf132dcf9cbc259 -3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 303 1d42dd9090cf78314a06665d4ea938c35cc760f4 -select a, sha1(b), c, sha1(d) from t1 where a = 1 and c = 101; -a sha1(b) c sha1(d) -1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 -select a, sha1(b), c, sha1(d) from t1 where a = 2 and c = 201; -a sha1(b) c sha1(d) -2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d -select a, sha1(b), c, sha1(d) from t1 where a = 3 and c = 301; -a sha1(b) c sha1(d) -3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e -update t1 set b = @v3, d = @v4 where a = 1 and c = 102; -update t1 set b = @v6, d = @v7 where a = 2 and c = 202; -update t1 set b = @v9, d = @v1 where a = 3 and c = 302; -select a, sha1(b), c, sha1(d) from t1 order by a; -a sha1(b) c sha1(d) -1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 -1 a33549d9844092289a58ac348dd59f09fc28406a 102 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c -1 a33549d9844092289a58ac348dd59f09fc28406a 103 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c -2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d -2 090565c580809efed3d369481a4bbb168b20713e 202 1e0070bec426871a46291de27b9bd6e4255ab4e5 -2 090565c580809efed3d369481a4bbb168b20713e 203 1e0070bec426871a46291de27b9bd6e4255ab4e5 -3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e -3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 302 1d42dd9090cf78314a06665d4ea938c35cc760f4 -3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 303 1d42dd9090cf78314a06665d4ea938c35cc760f4 -update t1 set b = @v4, d = @v5 where c = 103; -update t1 set b = @v7, d = @v8 where c = 203; -update t1 set b = @v1, d = @v2 where c = 303; -select a, sha1(b), c, sha1(d) from t1 order by a; -a sha1(b) c sha1(d) -1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 -1 a33549d9844092289a58ac348dd59f09fc28406a 102 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c -1 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 103 70fc9a7d08beebc522258bfb02000a30c77a8f1d -2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d -2 090565c580809efed3d369481a4bbb168b20713e 202 1e0070bec426871a46291de27b9bd6e4255ab4e5 -2 1e0070bec426871a46291de27b9bd6e4255ab4e5 203 acbaba01bc2e682f015f40e79d9cbe475db3002e -3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e -3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 302 1d42dd9090cf78314a06665d4ea938c35cc760f4 -3 1d42dd9090cf78314a06665d4ea938c35cc760f4 303 10d3c783026b310218d10b7188da96a2401648c6 -update t1 set b = @v5, d = @v6; -select a, sha1(b), c, sha1(d) from t1 order by a; -a sha1(b) c sha1(d) -1 70fc9a7d08beebc522258bfb02000a30c77a8f1d 101 090565c580809efed3d369481a4bbb168b20713e -1 70fc9a7d08beebc522258bfb02000a30c77a8f1d 102 090565c580809efed3d369481a4bbb168b20713e -1 70fc9a7d08beebc522258bfb02000a30c77a8f1d 103 090565c580809efed3d369481a4bbb168b20713e -2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 201 090565c580809efed3d369481a4bbb168b20713e -2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 202 090565c580809efed3d369481a4bbb168b20713e -2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 203 090565c580809efed3d369481a4bbb168b20713e -3 70fc9a7d08beebc522258bfb02000a30c77a8f1d 301 090565c580809efed3d369481a4bbb168b20713e -3 70fc9a7d08beebc522258bfb02000a30c77a8f1d 302 090565c580809efed3d369481a4bbb168b20713e -3 70fc9a7d08beebc522258bfb02000a30c77a8f1d 303 090565c580809efed3d369481a4bbb168b20713e -update t1 set b = @v1, d = @v2 where 100 < c and c < 200; -update t1 set b = @v4, d = @v5 where 200 < c and c < 300; -update t1 set b = @v7, d = @v8 where 300 < c and c < 400; -select a, sha1(b), c, sha1(d) from t1 order by a; -a sha1(b) c sha1(d) -1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 -1 1d42dd9090cf78314a06665d4ea938c35cc760f4 102 10d3c783026b310218d10b7188da96a2401648c6 -1 1d42dd9090cf78314a06665d4ea938c35cc760f4 103 10d3c783026b310218d10b7188da96a2401648c6 -2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d -2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 202 70fc9a7d08beebc522258bfb02000a30c77a8f1d -2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 203 70fc9a7d08beebc522258bfb02000a30c77a8f1d -3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e -3 1e0070bec426871a46291de27b9bd6e4255ab4e5 302 acbaba01bc2e682f015f40e79d9cbe475db3002e -3 1e0070bec426871a46291de27b9bd6e4255ab4e5 303 acbaba01bc2e682f015f40e79d9cbe475db3002e -delete from t1 where a = 1 and c = 101; -delete from t1 where c = 102; -delete from t1; -select a, sha1(b), c, sha1(d) from t1 order by a; -a sha1(b) c sha1(d) -drop table t1; diff --git a/mysql-test/r/ndb_condition_pushdown.result b/mysql-test/r/ndb_condition_pushdown.result index 24fe30604ae..140324a21d8 100644 --- a/mysql-test/r/ndb_condition_pushdown.result +++ b/mysql-test/r/ndb_condition_pushdown.result @@ -1782,5 +1782,65 @@ select * from t5 where b like '%jo%' order by a; a b 1 jonas 3 johan +drop table t1; +create table t1 (a int, b varchar(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc +drop table t1; +create table t1 (a int, b char(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc set engine_condition_pushdown = @old_ecpd; DROP TABLE t1,t2,t3,t4,t5; diff --git a/mysql-test/r/ndb_dd_basic.result b/mysql-test/r/ndb_dd_basic.result index ee1b717e6f1..008be3aa79f 100644 --- a/mysql-test/r/ndb_dd_basic.result +++ b/mysql-test/r/ndb_dd_basic.result @@ -49,7 +49,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`pk1`) -) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES (0, 0, 0); SELECT * FROM t1; pk1 b c diff --git a/mysql-test/r/ndb_dd_disk2memory.result b/mysql-test/r/ndb_dd_disk2memory.result index 80056b7269d..bd5bbda42f3 100644 --- a/mysql-test/r/ndb_dd_disk2memory.result +++ b/mysql-test/r/ndb_dd_disk2memory.result @@ -218,7 +218,7 @@ t2 CREATE TABLE `t2` ( `b2` int(11) NOT NULL, `c2` int(11) NOT NULL, PRIMARY KEY (`pk2`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 SHOW CREATE TABLE test.t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -226,7 +226,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`pk1`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; SHOW CREATE TABLE test.t2; @@ -236,7 +236,7 @@ t2 CREATE TABLE `t2` ( `b2` int(11) NOT NULL, `c2` int(11) NOT NULL, PRIMARY KEY (`pk2`) -) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) TABLESPACE table_space1 STORAGE DISK ENGINE=ndbcluster DEFAULT CHARSET=latin1 ALTER TABLE test.t1 ENGINE=NDBCLUSTER; SHOW CREATE TABLE test.t1; Table Create Table @@ -245,7 +245,7 @@ t1 CREATE TABLE `t1` ( `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`pk1`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 DROP TABLE test.t1; DROP TABLE test.t2; diff --git a/mysql-test/r/ndb_gis.result b/mysql-test/r/ndb_gis.result index f9b9ceb76a5..67447a69242 100644 --- a/mysql-test/r/ndb_gis.result +++ b/mysql-test/r/ndb_gis.result @@ -14,7 +14,7 @@ gis_point CREATE TABLE `gis_point` ( `fid` int(11) NOT NULL AUTO_INCREMENT, `g` point DEFAULT NULL, PRIMARY KEY (`fid`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 SHOW FIELDS FROM gis_point; Field Type Null Key Default Extra fid int(11) NO PRI NULL auto_increment @@ -476,7 +476,7 @@ gis_point CREATE TABLE `gis_point` ( `fid` int(11) NOT NULL AUTO_INCREMENT, `g` point DEFAULT NULL, PRIMARY KEY (`fid`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 SHOW FIELDS FROM gis_point; Field Type Null Key Default Extra fid int(11) NO PRI NULL auto_increment diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index 497ad973e8b..bd42595f060 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -99,7 +99,7 @@ CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, b int unsigned not null, c int unsigned not null, -UNIQUE USING HASH (b, c) +UNIQUE (b, c) USING HASH ) engine=ndbcluster; insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); select * from t2 where a = 3; @@ -142,14 +142,14 @@ CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, b int unsigned not null, c int unsigned, -UNIQUE USING HASH (b, c) +UNIQUE (b, c) USING HASH ) engine=ndbcluster; ERROR 42000: Column 'c' is used with UNIQUE or INDEX but is not defined as NOT NULL CREATE TABLE t3 ( a int unsigned NOT NULL, b int unsigned not null, c int unsigned, -PRIMARY KEY USING HASH (a, b) +PRIMARY KEY (a, b) USING HASH ) engine=ndbcluster; insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); select * from t3 where a = 3; diff --git a/mysql-test/r/ndb_partition_error.result b/mysql-test/r/ndb_partition_error.result deleted file mode 100644 index d86dc382185..00000000000 --- a/mysql-test/r/ndb_partition_error.result +++ /dev/null @@ -1,47 +0,0 @@ -drop table if exists t1; -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(a,b), -index (a)) -engine = ndb -partition by range (a) -partitions 3 -(partition x1 values less than (5) nodegroup 12, -partition x2 values less than (10) nodegroup 13, -partition x3 values less than (20) nodegroup 14); -ERROR HY000: Can't create table 'test.t1' (errno: 140) -show warnings; -Level Code Message -Error 1296 Got error 771 'Given NODEGROUP doesn't exist in this cluster' from NDB -Error 1005 Can't create table 'test.t1' (errno: 140) -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(a)) -engine = ndb -partition by range (a) -partitions 3 -(partition x1 values less than (5), -partition x2 values less than (10), -partition x3 values less than (20)); -drop table t1; -CREATE TABLE t1 (id INT) ENGINE=NDB -PARTITION BY LIST(id) -(PARTITION p0 VALUES IN (2, 4), -PARTITION p1 VALUES IN (42, 142)); -INSERT INTO t1 VALUES (2); -UPDATE t1 SET id=5 WHERE id=2; -ERROR HY000: Table has no partition for value 5 -DROP TABLE t1; -create table t1 (a int,b int, c int) -engine = ndb -partition by list(a) -partitions 2 -(partition x123 values in (11, 12), -partition x234 values in (5, 1)); -insert into t1 values (NULL,1,1); -ERROR HY000: Table has no partition for value NULL -drop table t1; diff --git a/mysql-test/r/ndb_partition_key.result b/mysql-test/r/ndb_partition_key.result deleted file mode 100644 index 503283df532..00000000000 --- a/mysql-test/r/ndb_partition_key.result +++ /dev/null @@ -1,199 +0,0 @@ -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b,c)) -ENGINE = NDB -PARTITION BY KEY (a,b); -insert into t1 values (1,1,1,1); -select * from t1; -a b c d -1 1 1 1 -update t1 set d = 2 where a = 1 and b = 1 and c = 1; -select * from t1; -a b c d -1 1 1 2 -delete from t1; -select * from t1; -a b c d -drop table t1; -CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b)) -ENGINE = NDB -PARTITION BY KEY (c); -ERROR HY000: A PRIMARY KEY need to include all fields in the partition function -CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b)) -ENGINE = NDB -PARTITION BY KEY (a); -insert into t1 values -(1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3), -(1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3); -select * from t1 order by b; -a b c -1 1 3 -1 2 3 -1 3 3 -1 4 3 -1 5 3 -1 6 3 -1 7 3 -1 8 3 -1 9 3 -1 10 3 -1 11 3 -1 12 3 -DROP TABLE t1; -CREATE TABLE t1 (a INT, b CHAR(10) COLLATE latin1_bin, c INT, d INT, -PRIMARY KEY USING HASH (a,b,c)) -ENGINE=NDB -DEFAULT CHARSET=latin1 -PARTITION BY KEY (b); -insert into t1 values (1,"a",1,1),(2,"a",1,1),(3,"a",1,1); --- t1 -- - -Fragment type: 5 -K Value: 6 -Min load factor: 78 -Max load factor: 80 -Temporary table: no -Number of attributes: 4 -Number of primary keys: 3 -Length of frm data: # -Row Checksum: 1 -Row GCI: 1 -TableStatus: Retrieved --- Attributes -- -a Int PRIMARY KEY AT=FIXED ST=MEMORY -b Char(10;latin1_bin) PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY -c Int PRIMARY KEY AT=FIXED ST=MEMORY -d Int NULL AT=FIXED ST=MEMORY - --- Indexes -- -PRIMARY KEY(a, b, c) - UniqueHashIndex - - -NDBT_ProgramExit: 0 - OK - -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL DEFAULT '0', - `b` char(10) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '', - `c` int(11) NOT NULL DEFAULT '0', - `d` int(11) DEFAULT NULL, - PRIMARY KEY USING HASH (`a`,`b`,`c`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (b) -DROP TABLE t1; -CREATE TABLE t1 (a int not null primary key) -PARTITION BY KEY(a) -(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); -drop table t1; -CREATE TABLE t1 (a int not null primary key); -ALTER TABLE t1 -PARTITION BY KEY(a) -(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); -drop table t1; -create table t1 (a int) -engine=ndb -partition by key(a) -(partition p0, partition p1); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) -alter table t1 engine=heap; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MEMORY DEFAULT CHARSET=latin1 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MEMORY, PARTITION p1 ENGINE = MEMORY) -alter table t1 engine=ndb; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) -alter table t1 engine=heap remove partitioning; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MEMORY DEFAULT CHARSET=latin1 -alter table t1 engine=ndb -partition by key(a) -(partition p0, partition p1 engine = ndb); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) -alter table t1 -partition by key (a) -(partition p0 engine=ndb, partition p1 engine=ndb); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) -alter table t1 remove partitioning; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () -alter table t1 -partition by key(a) -(partition p0 engine=ndb, partition p1); -ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MySQL -alter table t1 -engine=ndb -partition by key(a) -(partition p0 engine=ndb, partition p1 engine = ndb); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) -drop table t1; -CREATE TABLE t1 ( -c1 MEDIUMINT NOT NULL AUTO_INCREMENT, -c2 TEXT NOT NULL, -c3 INT NOT NULL, -c4 BIT NOT NULL, -c5 FLOAT, -c6 VARCHAR(255), -c7 TIMESTAMP, -PRIMARY KEY(c1,c3)) -ENGINE=NDB -PARTITION BY KEY(c3) PARTITIONS 5; -ALTER TABLE t1 COALESCE PARTITION 4; -DROP TABLE t1; -CREATE TABLE t1 (a int primary key) -ENGINE=NDB -PARTITION BY KEY(a); -ALTER TABLE t1 OPTIMIZE PARTITION p0; -ERROR HY000: Table storage engine for 't1' doesn't have this option -ALTER TABLE t1 CHECK PARTITION p0; -ERROR HY000: Table storage engine for 't1' doesn't have this option -ALTER TABLE t1 REPAIR PARTITION p0; -ERROR HY000: Table storage engine for 't1' doesn't have this option -ALTER TABLE t1 ANALYZE PARTITION p0; -ERROR HY000: Table storage engine for 't1' doesn't have this option -ALTER TABLE t1 REBUILD PARTITION p0; -ERROR HY000: Table storage engine for 't1' doesn't have this option -DROP TABLE t1; -CREATE TABLE t1 ( -c1 MEDIUMINT NOT NULL AUTO_INCREMENT, -c2 TEXT NOT NULL, -c3 INT NOT NULL, -PRIMARY KEY(c1,c3)) -ENGINE=NDB -PARTITION BY KEY(c3) PARTITIONS 5; -ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; -DROP TABLE t1; -CREATE TABLE t1 ( -c1 MEDIUMINT NOT NULL AUTO_INCREMENT, -c2 TEXT NOT NULL, -c3 INT NOT NULL, -PRIMARY KEY(c1,c3)) -ENGINE=NDB -PARTITION BY KEY(c3); -ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; -DROP TABLE t1; diff --git a/mysql-test/r/ndb_partition_list.result b/mysql-test/r/ndb_partition_list.result deleted file mode 100644 index ce2574ddcc4..00000000000 --- a/mysql-test/r/ndb_partition_list.result +++ /dev/null @@ -1,51 +0,0 @@ -drop table if exists t1; -CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL, -f_char1 CHAR(10), -f_char2 CHAR(10), f_charbig VARCHAR(1000), -PRIMARY KEY (f_int1,f_int2)) -ENGINE = NDB -PARTITION BY LIST(MOD(f_int1 + f_int2,4)) -(PARTITION part_3 VALUES IN (-3), -PARTITION part_2 VALUES IN (-2), -PARTITION part_1 VALUES IN (-1), -PARTITION part0 VALUES IN (0), -PARTITION part1 VALUES IN (1), -PARTITION part2 VALUES IN (2), -PARTITION part3 VALUES IN (3,4,5)); -INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; -INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -SELECT * FROM t1 ORDER BY f_int1; -f_int1 f_int2 f_char1 f_char2 f_charbig --2 20 20 20 ===20=== -1 1 1 1 ===1=== -2 1 1 1 ===1=== -3 1 1 1 ===1=== -4 1 1 1 ===1=== -5 1 1 1 ===1=== -20 1 1 1 ===1=== -DROP TABLE t1; -CREATE TABLE t1 ( f_int1 INTEGER, f_int2 INTEGER, f_char1 CHAR(10), -f_char2 CHAR(10), f_charbig VARCHAR(1000)) -ENGINE = NDB -PARTITION BY LIST(f_int1) -(PARTITION part_1 VALUES IN (-1), -PARTITION part0 VALUES IN (0,1), -PARTITION part1 VALUES IN (2)); -INSERT INTO t1 SET f_int1 = -1, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; -INSERT INTO t1 SET f_int1 = 0, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; -INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -ERROR HY000: Table has no partition for value 20 -SELECT * FROM t1 ORDER BY f_int1; -f_int1 f_int2 f_char1 f_char2 f_charbig --1 20 20 20 ===20=== -0 20 20 20 ===20=== -1 1 1 1 ===1=== -2 1 1 1 ===1=== -DROP TABLE t1; diff --git a/mysql-test/r/ndb_partition_range.result b/mysql-test/r/ndb_partition_range.result deleted file mode 100644 index cb79f04873e..00000000000 --- a/mysql-test/r/ndb_partition_range.result +++ /dev/null @@ -1,263 +0,0 @@ -drop table if exists t1; -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(a,b), -index (a)) -engine = ndb -partition by range (a) -partitions 3 -(partition x1 values less than (5), -partition x2 values less than (10), -partition x3 values less than (20)); -INSERT into t1 values (1, 1, 1); -INSERT into t1 values (6, 1, 1); -INSERT into t1 values (10, 1, 1); -INSERT into t1 values (15, 1, 1); -select * from information_schema.partitions where table_name= 't1'; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME -NULL test t1 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 0 0 # # NULL NULL default 0 default -NULL test t1 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 0 0 # # NULL NULL default 0 default -NULL test t1 x3 NULL 3 NULL RANGE NULL a NULL 20 0 0 0 # 0 0 # # NULL NULL default 0 default -select * from t1 order by a; -a b c -1 1 1 -6 1 1 -10 1 1 -15 1 1 -select * from t1 where a=1 order by a; -a b c -1 1 1 -select * from t1 where a=15 and b=1 order by a; -a b c -15 1 1 -select * from t1 where a=21 and b=1 order by a; -a b c -select * from t1 where a=21 order by a; -a b c -select * from t1 where a in (1,6,10,21) order by a; -a b c -1 1 1 -6 1 1 -10 1 1 -select * from t1 where b=1 and a in (1,6,10,21) order by a; -a b c -1 1 1 -6 1 1 -10 1 1 -drop table t1; -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(b), -unique (a)) -engine = ndb -partition by range (b) -partitions 3 -(partition x1 values less than (5), -partition x2 values less than (10), -partition x3 values less than (20)); -INSERT into t1 values (1, 1, 1); -INSERT into t1 values (2, 6, 1); -INSERT into t1 values (3, 10, 1); -INSERT into t1 values (4, 15, 1); -select * from t1 order by a; -a b c -1 1 1 -2 6 1 -3 10 1 -4 15 1 -UPDATE t1 set a = 5 WHERE b = 15; -select * from t1 order by a; -a b c -1 1 1 -2 6 1 -3 10 1 -5 15 1 -UPDATE t1 set a = 6 WHERE a = 5; -select * from t1 order by a; -a b c -1 1 1 -2 6 1 -3 10 1 -6 15 1 -select * from t1 where b=1 order by b; -a b c -1 1 1 -select * from t1 where b=15 and a=1 order by b; -a b c -select * from t1 where b=21 and a=1 order by b; -a b c -select * from t1 where b=21 order by b; -a b c -select * from t1 where b in (1,6,10,21) order by b; -a b c -1 1 1 -2 6 1 -3 10 1 -select * from t1 where a in (1,2,5,6) order by b; -a b c -1 1 1 -2 6 1 -6 15 1 -select * from t1 where a=1 and b in (1,6,10,21) order by b; -a b c -1 1 1 -DELETE from t1 WHERE b = 6; -DELETE from t1 WHERE a = 6; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL, - `c` int(11) NOT NULL, - PRIMARY KEY (`b`), - UNIQUE KEY `a` (`a`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (b) (PARTITION x1 VALUES LESS THAN (5) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (10) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (20) ENGINE = ndbcluster) -drop table t1; -CREATE TABLE t1 -(id MEDIUMINT NOT NULL, -b1 BIT(8), -vc VARCHAR(255), -bc CHAR(255), -d DECIMAL(10,4) DEFAULT 0, -f FLOAT DEFAULT 0, -total BIGINT UNSIGNED, -y YEAR, -t DATE) ENGINE=NDB -PARTITION BY RANGE (YEAR(t)) -(PARTITION p0 VALUES LESS THAN (1901), -PARTITION p1 VALUES LESS THAN (1946), -PARTITION p2 VALUES LESS THAN (1966), -PARTITION p3 VALUES LESS THAN (1986), -PARTITION p4 VALUES LESS THAN (2005), -PARTITION p5 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); -SELECT * FROM t1; -id b1 vc bc d f total y t -0 NULL NULL NULL NULL NULL NULL NULL NULL -ALTER TABLE t1 ENGINE=MYISAM; -SELECT * FROM t1; -id b1 vc bc d f total y t -0 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE t1; -CREATE LOGFILE GROUP lg1 -ADD UNDOFILE 'undofile.dat' - INITIAL_SIZE 16M -UNDO_BUFFER_SIZE=1M -ENGINE=NDB; -CREATE TABLESPACE ts1 -ADD DATAFILE 'datafile.dat' - USE LOGFILE GROUP lg1 -INITIAL_SIZE 12M -ENGINE NDB; -CREATE TABLE test.t1 ( -a1 INT, -a2 TEXT NOT NULL, -a3 BIT NOT NULL, -a4 DECIMAL(8,3), -a5 INT NOT NULL, -a6 INT, -PRIMARY KEY(a1)) -TABLESPACE ts1 STORAGE DISK ENGINE=NDB -PARTITION BY LIST (a1) -(PARTITION p0 VALUES IN (1,2,3,4,5), -PARTITION p1 VALUES IN (6,7,8,9, 10), -PARTITION p2 VALUES IN (11, 12, 13, 14, 15)); -ALTER TABLE test.t1 DROP COLUMN a6; -ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255); -SELECT COUNT(*) FROM test.t1; -COUNT(*) -15 -ALTER TABLE test.t1 DROP COLUMN a4; -SELECT COUNT(*) FROM test.t1; -COUNT(*) -15 -DROP TABLE t1; -CREATE TABLE test.t1 ( -a1 INT, -a2 TEXT NOT NULL, -a3 BIT NOT NULL, -a4 DECIMAL(8,3), -a5 INT NOT NULL, -a6 VARCHAR(255), -PRIMARY KEY(a1)) -TABLESPACE ts1 STORAGE DISK ENGINE=NDB -PARTITION BY HASH(a1) -PARTITIONS 4; -SELECT COUNT(*) FROM test.t1; -COUNT(*) -15 -ALTER TABLE test.t1 DROP COLUMN a4; -SELECT COUNT(*) FROM test.t1; -COUNT(*) -15 -DROP TABLE t1; -ALTER TABLESPACE ts1 -DROP DATAFILE 'datafile.dat' -ENGINE=NDB; -DROP TABLESPACE ts1 ENGINE=NDB; -DROP LOGFILE GROUP lg1 ENGINE=NDB; -CREATE TABLE t1 -(id MEDIUMINT NOT NULL, -b1 BIT(8), -vc VARCHAR(255), -bc CHAR(255), -d DECIMAL(10,4) DEFAULT 0, -f FLOAT DEFAULT 0, -total BIGINT UNSIGNED, -y YEAR, -t DATE) ENGINE=NDB -PARTITION BY LIST(id) -(PARTITION p0 VALUES IN (2, 4), -PARTITION p1 VALUES IN (42, 142)); -INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); -SELECT * FROM t1; -id b1 vc bc d f total y t -2 NULL NULL NULL NULL NULL NULL NULL NULL -ALTER TABLE t1 ADD PARTITION -(PARTITION p2 VALUES IN (412)); -SELECT * FROM t1; -id b1 vc bc d f total y t -2 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE t1; -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null) -partition by list(a) -partitions 2 -(partition x123 values in (1,5,6), -partition x234 values in (4,7,8)); -INSERT into t1 VALUES (5,1,1); -select * from t1; -a b c -5 1 1 -UPDATE t1 SET a=8 WHERE a=5 AND b=1; -select * from t1; -a b c -8 1 1 -drop table t1; -CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb -PARTITION BY RANGE(f1) -( PARTITION part1 VALUES LESS THAN (2), -PARTITION part2 VALUES LESS THAN (1000)); -INSERT INTO t1 VALUES(1, '---1---'); -INSERT INTO t1 VALUES(2, '---2---'); -select * from t1 order by f1; -f1 f2 -1 ---1--- -2 ---2--- -UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2; -select * from t1 order by f1; -f1 f2 -1 ---1--- -6 ---2--- -UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1; -select * from t1 order by f1; -f1 f2 -5 ---1--- -6 ---2--- -drop table t1; diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index 91382619b6c..1fcfb11525e 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -3,8 +3,8 @@ create table t1(f1 int); insert into t1 values (5); grant select on test.* to ssl_user1@localhost require SSL; grant select on test.* to ssl_user2@localhost require cipher "DHE-RSA-AES256-SHA"; -grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com"; -grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com"; +grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com"; +grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/emailAddress=abstract.mysql.developer@mysql.com"; flush privileges; SHOW STATUS LIKE 'Ssl_cipher'; Variable_name Value @@ -41,3 +41,10 @@ ERROR 42000: DELETE command denied to user 'ssl_user4'@'localhost' for table 't1 drop user ssl_user1@localhost, ssl_user2@localhost, ssl_user3@localhost, ssl_user4@localhost; drop table t1; +mysqltest: Could not open connection 'default': 2026 SSL connection error +mysqltest: Could not open connection 'default': 2026 SSL connection error +mysqltest: Could not open connection 'default': 2026 SSL connection error +Error when connection to server using SSL:Unable to get private key from '' +mysqltest: Could not open connection 'default': 2026 SSL connection error +Error when connection to server using SSL:Unable to get certificate from '' +mysqltest: Could not open connection 'default': 2026 SSL connection error diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result Binary files differindex ee8c3249c9d..040dff576f8 100644 --- a/mysql-test/r/outfile.result +++ b/mysql-test/r/outfile.result diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 0da071374ea..a4dd5f9a64e 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,4 +1,8 @@ drop table if exists t1; +create table t1 (a int) +partition by key(a) +(partition p0 engine = MEMORY); +drop table t1; CREATE TABLE t1 ( a int not null, b int not null, @@ -886,4 +890,36 @@ s1 2 3 drop table t1; +create table t1 (a int) engine=memory +partition by key(a); +insert into t1 values (1); +create index inx1 on t1(a); +drop table t1; +create table t1 (a varchar(1)) +partition by key (a) +as select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY (a) +drop table t1; +CREATE TABLE t1 (a int) ENGINE = MYISAM PARTITION BY KEY(a); +INSERT into t1 values (1), (2); +SHOW TABLE STATUS; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 2 7 14 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +DELETE from t1 where a = 1; +SHOW TABLE STATUS; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 14 14 0 0 7 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +ALTER TABLE t1 OPTIMIZE PARTITION p0; +SHOW TABLE STATUS; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 7 7 0 1024 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +DROP TABLE t1; +CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a); +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t1 ENABLE KEYS; +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index ffe2b4d6409..5ba601bf305 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1777,7 +1777,7 @@ Table Create Table t5 CREATE TABLE `t5` ( `const01` bigint(1) NOT NULL DEFAULT '0', `param01` bigint(20) DEFAULT NULL, - `const02` decimal(2,1) unsigned NOT NULL DEFAULT '0.0', + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', `param02` decimal(65,30) DEFAULT NULL, `const03` double NOT NULL DEFAULT '0', `param03` double DEFAULT NULL, @@ -1807,7 +1807,7 @@ select * from t5 ; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 -def test t5 t5 const02 const02 246 3 3 N 33 1 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 const03 const03 5 17 1 N 32769 31 63 def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 707e5ed681f..836fb7b58c2 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1760,7 +1760,7 @@ Table Create Table t5 CREATE TABLE `t5` ( `const01` bigint(1) NOT NULL DEFAULT '0', `param01` bigint(20) DEFAULT NULL, - `const02` decimal(2,1) unsigned NOT NULL DEFAULT '0.0', + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', `param02` decimal(65,30) DEFAULT NULL, `const03` double NOT NULL DEFAULT '0', `param03` double DEFAULT NULL, @@ -1790,7 +1790,7 @@ select * from t5 ; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 -def test t5 t5 const02 const02 246 3 3 N 33 1 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 const03 const03 5 17 1 N 32769 31 63 def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 06429f92580..150820d92f0 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1761,7 +1761,7 @@ Table Create Table t5 CREATE TABLE `t5` ( `const01` bigint(1) NOT NULL DEFAULT '0', `param01` bigint(20) DEFAULT NULL, - `const02` decimal(2,1) unsigned NOT NULL DEFAULT '0.0', + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', `param02` decimal(65,30) DEFAULT NULL, `const03` double NOT NULL DEFAULT '0', `param03` double DEFAULT NULL, @@ -1791,7 +1791,7 @@ select * from t5 ; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 -def test t5 t5 const02 const02 246 3 3 N 33 1 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 const03 const03 5 17 1 N 32769 31 63 def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index c1002970932..72573ce3294 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1697,7 +1697,7 @@ Table Create Table t5 CREATE TABLE `t5` ( `const01` bigint(1) NOT NULL DEFAULT '0', `param01` bigint(20) DEFAULT NULL, - `const02` decimal(2,1) unsigned NOT NULL DEFAULT '0.0', + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', `param02` decimal(65,30) DEFAULT NULL, `const03` double NOT NULL DEFAULT '0', `param03` double DEFAULT NULL, @@ -1727,7 +1727,7 @@ select * from t5 ; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 -def test t5 t5 const02 const02 246 3 3 N 33 1 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 const03 const03 5 17 1 N 32769 31 63 def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 @@ -4711,7 +4711,7 @@ Table Create Table t5 CREATE TABLE `t5` ( `const01` bigint(1) NOT NULL DEFAULT '0', `param01` bigint(20) DEFAULT NULL, - `const02` decimal(2,1) unsigned NOT NULL DEFAULT '0.0', + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', `param02` decimal(65,30) DEFAULT NULL, `const03` double NOT NULL DEFAULT '0', `param03` double DEFAULT NULL, @@ -4741,7 +4741,7 @@ select * from t5 ; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 -def test t5 t5 const02 const02 246 3 3 N 33 1 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 const03 const03 5 17 1 N 32769 31 63 def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index ea1212addf5..44b4ebf33d4 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -1760,7 +1760,7 @@ Table Create Table t5 CREATE TABLE `t5` ( `const01` bigint(1) NOT NULL DEFAULT '0', `param01` bigint(20) DEFAULT NULL, - `const02` decimal(2,1) unsigned NOT NULL DEFAULT '0.0', + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', `param02` decimal(65,30) DEFAULT NULL, `const03` double NOT NULL DEFAULT '0', `param03` double DEFAULT NULL, @@ -1790,7 +1790,7 @@ select * from t5 ; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 -def test t5 t5 const02 const02 246 3 3 N 33 1 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 const03 const03 5 17 1 N 32769 31 63 def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 65cf7c1f88c..543435e4cd9 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -1760,7 +1760,7 @@ Table Create Table t5 CREATE TABLE `t5` ( `const01` bigint(1) NOT NULL default '0', `param01` bigint(20) default NULL, - `const02` decimal(2,1) unsigned NOT NULL default '0.0', + `const02` decimal(2,1) NOT NULL default '0.0', `param02` decimal(65,30) default NULL, `const03` double NOT NULL default '0', `param03` double default NULL, @@ -1790,7 +1790,7 @@ select * from t5 ; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 -def test t5 t5 const02 const02 246 3 3 N 33 1 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 const03 const03 5 17 1 N 32769 31 63 def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 diff --git a/mysql-test/r/rpl_ndb_UUID.result b/mysql-test/r/rpl_ndb_UUID.result index c768779c49b..422379d4f55 100644 --- a/mysql-test/r/rpl_ndb_UUID.result +++ b/mysql-test/r/rpl_ndb_UUID.result @@ -33,7 +33,7 @@ t1 CREATE TABLE `t1` ( `blob_column` longblob, `vchar_column` varchar(100) DEFAULT NULL, PRIMARY KEY (`a`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 DROP PROCEDURE test.p1; DROP FUNCTION test.fn1; DROP TABLE test.t1; diff --git a/mysql-test/r/rpl_ndb_dd_advance.result b/mysql-test/r/rpl_ndb_dd_advance.result index ba89592b532..2cb1cce649b 100644 --- a/mysql-test/r/rpl_ndb_dd_advance.result +++ b/mysql-test/r/rpl_ndb_dd_advance.result @@ -69,7 +69,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`), KEY `c5` (`c5`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Show first set of ALTERs on SLAVE **** SHOW CREATE TABLE t1; Table Create Table @@ -82,7 +82,7 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`), KEY `c5` (`c5`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Second set of alters test 1 **** ALTER TABLE t1 RENAME t2; ALTER TABLE t2 DROP INDEX c5; @@ -101,7 +101,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Show second set of ALTERs on SLAVE **** SHOW CREATE TABLE t1; Table Create Table @@ -113,7 +113,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`,`c3`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 **** Third and last set of alters for test1 **** ALTER TABLE t1 CHANGE c1 c1 DOUBLE; ALTER TABLE t1 CHANGE c2 c2 DECIMAL(10,2); @@ -135,7 +135,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 SELECT * FROM t1 ORDER BY c1 LIMIT 5; c1 c2 c3 c5 1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL @@ -153,7 +153,7 @@ t1 CREATE TABLE `t1` ( `c5` double DEFAULT NULL, PRIMARY KEY (`c1`), KEY `t1_i` (`c2`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 SELECT * FROM t1 where c1 = 1; c1 c2 c3 c5 1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL diff --git a/mysql-test/r/rpl_row_log.result b/mysql-test/r/rpl_row_log.result index 12b573b8bf6..65e9ee9fb9f 100644 --- a/mysql-test/r/rpl_row_log.result +++ b/mysql-test/r/rpl_row_log.result @@ -39,6 +39,10 @@ master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F flush logs; create table t3 (a int)ENGINE=MyISAM; start slave; + +let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%' ; + +--source include/wait_slave_status.inc flush logs; stop slave; create table t2 (n int)ENGINE=MyISAM; diff --git a/mysql-test/r/rpl_row_log_innodb.result b/mysql-test/r/rpl_row_log_innodb.result index 48c79c9ab11..2c89ca5f8ff 100644 --- a/mysql-test/r/rpl_row_log_innodb.result +++ b/mysql-test/r/rpl_row_log_innodb.result @@ -41,6 +41,10 @@ master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F flush logs; create table t3 (a int)ENGINE=InnoDB; start slave; + +let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%' ; + +--source include/wait_slave_status.inc flush logs; stop slave; create table t2 (n int)ENGINE=InnoDB; diff --git a/mysql-test/r/rpl_sp004.result b/mysql-test/r/rpl_sp004.result index dfc672d4cd7..1c0ed3cc50a 100644 --- a/mysql-test/r/rpl_sp004.result +++ b/mysql-test/r/rpl_sp004.result @@ -26,25 +26,25 @@ DROP TABLE IF EXISTS test.t2; INSERT INTO test.t3 VALUES(NULL,11111111.233333,NOW()); END| CALL test.p1(); -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY a; a 1 2 3 12 -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a 1 2 3 8 -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY a; a 1 2 3 12 -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a 1 2 @@ -62,25 +62,25 @@ t3 CALL test.p1(); Warnings: Note 1050 Table 't3' already exists -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY a; a 1 2 3 12 -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a 1 2 3 8 -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY a; a 1 2 3 12 -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a 1 2 diff --git a/mysql-test/r/rpl_stm_log.result b/mysql-test/r/rpl_stm_log.result index af774c5075f..02a861ceb53 100644 --- a/mysql-test/r/rpl_stm_log.result +++ b/mysql-test/r/rpl_stm_log.result @@ -39,6 +39,10 @@ master-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) flush logs; create table t3 (a int)ENGINE=MyISAM; start slave; + +let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%' ; + +--source include/wait_slave_status.inc flush logs; stop slave; create table t2 (n int)ENGINE=MyISAM; diff --git a/mysql-test/r/rpl_stm_until.result b/mysql-test/r/rpl_stm_until.result index 11b69f55f82..e8e33b66864 100644 --- a/mysql-test/r/rpl_stm_until.result +++ b/mysql-test/r/rpl_stm_until.result @@ -19,9 +19,40 @@ n 2 3 4 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 780 slave-relay-bin.000004 # master-bin.000001 # No 0 0 323 # Master master-bin.000001 323 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 780 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running # +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 323 +Relay_Log_Space # +Until_Condition Master +Until_Log_File master-bin.000001 +Until_Log_Pos 323 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; select * from t1; n @@ -29,23 +60,116 @@ n 2 3 4 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 780 slave-relay-bin.000004 # master-bin.000001 # No 0 0 323 # Master master-no-such-bin.000001 291 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 780 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running # +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 323 +Relay_Log_Space # +Until_Condition Master +Until_Log_File master-no-such-bin.000001 +Until_Log_Pos 291 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746; select * from t2; n 1 2 -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 780 slave-relay-bin.000004 # master-bin.000001 # No 0 0 612 # Relay slave-relay-bin.000004 746 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 780 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running # +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 612 +Relay_Log_Space # +Until_Condition Relay +Until_Log_File slave-relay-bin.000004 +Until_Log_Pos 746 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=776; -show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 780 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 780 # Master master-bin.000001 776 No # +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 780 +Relay_Log_File slave-relay-bin.000004 +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 780 +Relay_Log_Space # +Until_Condition Master +Until_Log_File master-bin.000001 +Until_Log_Pos 776 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index 929dc33c447..01882c683a4 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -88,17 +88,23 @@ f 1 drop temporary table t4; drop table t5; -set @session.pseudo_thread_id=100; +set @@session.pseudo_thread_id=100; create temporary table t101 (id int); create temporary table t102 (id int); -set @session.pseudo_thread_id=200; +set @@session.pseudo_thread_id=200; create temporary table t201 (id int); -create temporary table `#not_user_table_prefixed_with_hash_sign_no_harm` (id int); -set @con1_id=connection_id(); -kill @con1_id; +create temporary table `#sql_not_user_table202` (id int); +set @@session.pseudo_thread_id=300; +create temporary table t301 (id int); +create temporary table t302 (id int); +create temporary table `#sql_not_user_table303` (id int); create table t1(f int); insert into t1 values (1); select * from t1 /* must be 1 */; f 1 drop table t1; +select * from t1; +a +1 +drop table t1; diff --git a/mysql-test/r/rpl_user_variables.result b/mysql-test/r/rpl_user_variables.result index b553d37a187..ed0d2782394 100644 --- a/mysql-test/r/rpl_user_variables.result +++ b/mysql-test/r/rpl_user_variables.result @@ -78,5 +78,6 @@ abcn1 abcn1n2 abc\def This is a test +insert into t1 select * FROM (select @var1 union select @var2) AS t2; drop table t1; stop slave; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index e9092fc8a69..f45e16f66c1 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3411,3 +3411,38 @@ SELECT * FROM t1; i 255 DROP TABLE t1; +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, c int, e int, primary key(a,b,c)); +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5 +and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE A range PRIMARY PRIMARY 12 NULL 3 Using where +1 SIMPLE B ref PRIMARY PRIMARY 8 const,test.A.e 10 +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where +1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where +1 SIMPLE t2 ref c c 5 test.t1.a 2 Using where +DROP TABLE t1, t2; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index a8af5c59b81..5dcb8b2afd6 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -460,7 +460,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `i` int(11) DEFAULT NULL, - KEY `i` USING HASH (`i`) + KEY `i` (`i`) USING HASH ) ENGINE=MEMORY DEFAULT CHARSET=latin1 DROP TABLE t1; CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MEMORY; @@ -468,7 +468,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `i` int(11) DEFAULT NULL, - KEY `i` USING BTREE (`i`) + KEY `i` (`i`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 DROP TABLE t1; CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM; @@ -484,7 +484,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `i` int(11) DEFAULT NULL, - KEY `i` USING BTREE (`i`) + KEY `i` (`i`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM; @@ -507,14 +507,14 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `i` int(11) DEFAULT NULL, - KEY `i` USING BTREE (`i`) + KEY `i` (`i`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ALTER TABLE t1 ENGINE=MEMORY; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `i` int(11) DEFAULT NULL, - KEY `i` USING BTREE (`i`) + KEY `i` (`i`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 DROP TABLE t1; CREATE TABLE t1( @@ -549,8 +549,8 @@ Table Create Table t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` int(11) NOT NULL, - PRIMARY KEY USING HASH (`c1`), - KEY `c2` USING BTREE (`c2`) + PRIMARY KEY (`c1`) USING HASH, + KEY `c2` (`c2`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; flush tables; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 931fa2ee402..fde273c55ee 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -282,9 +282,9 @@ select @tmp_x, @tmp_y, @tmp_z| @tmp_x @tmp_y @tmp_z 42 45 87 call p(42, 43, @tmp_z)| -ERROR 42000: OUT or INOUT argument 2 for routine test.p is not a variable +ERROR 42000: OUT or INOUT argument 2 for routine test.p is not a variable or NEW pseudo-variable in BEFORE trigger call p(42, @tmp_y, 43)| -ERROR 42000: OUT or INOUT argument 3 for routine test.p is not a variable +ERROR 42000: OUT or INOUT argument 3 for routine test.p is not a variable or NEW pseudo-variable in BEFORE trigger drop procedure p| create procedure p() begin end| lock table t1 read| diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 5aa984bfa4e..8330c391715 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4914,4 +4914,60 @@ schema_name select routine_name,routine_schema from information_schema.routines where routine_schema like 'bug18344%'| routine_name routine_schema +drop function if exists bug12472| +create function bug12472() returns int return (select count(*) from t1)| +create table t3 as select bug12472() as i| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t3| +i +0 +drop table t3| +create view v1 as select bug12472() as j| +create table t3 as select * from v1| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `j` bigint(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t3| +j +0 +drop table t3| +drop view v1| +drop function bug12472| +DROP FUNCTION IF EXISTS bug18589_f1| +DROP PROCEDURE IF EXISTS bug18589_p1| +DROP PROCEDURE IF EXISTS bug18589_p2| +CREATE FUNCTION bug18589_f1(arg TEXT) RETURNS TEXT +BEGIN +RETURN CONCAT(arg, ""); +END| +CREATE PROCEDURE bug18589_p1(arg TEXT, OUT ret TEXT) +BEGIN +SET ret = CONCAT(arg, ""); +END| +CREATE PROCEDURE bug18589_p2(arg TEXT) +BEGIN +DECLARE v TEXT; +CALL bug18589_p1(arg, v); +SELECT v; +END| +SELECT bug18589_f1(REPEAT("a", 767))| +bug18589_f1(REPEAT("a", 767)) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +SET @bug18589_v1 = ""| +CALL bug18589_p1(REPEAT("a", 767), @bug18589_v1)| +SELECT @bug18589_v1| +@bug18589_v1 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +CALL bug18589_p2(REPEAT("a", 767))| +v +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP FUNCTION bug18589_f1| +DROP PROCEDURE bug18589_p1| +DROP PROCEDURE bug18589_p2| drop table t1,t2; diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result index 31b67529f8d..3466282a4b1 100644 --- a/mysql-test/r/sql_mode.result +++ b/mysql-test/r/sql_mode.result @@ -18,7 +18,7 @@ t1 CREATE TABLE `t1` ( `pseudo` varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '', `email` varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '', PRIMARY KEY (`a`), - UNIQUE KEY `email` USING BTREE (`email`) + UNIQUE KEY `email` (`email`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC set @@sql_mode="ansi_quotes"; show variables like 'sql_mode'; @@ -31,7 +31,7 @@ t1 CREATE TABLE "t1" ( "pseudo" varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '', "email" varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '', PRIMARY KEY ("a"), - UNIQUE KEY "email" USING BTREE ("email") + UNIQUE KEY "email" ("email") USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC set @@sql_mode="no_table_options"; show variables like 'sql_mode'; @@ -44,7 +44,7 @@ t1 CREATE TABLE `t1` ( `pseudo` varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '', `email` varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '', PRIMARY KEY (`a`), - UNIQUE KEY `email` USING BTREE (`email`) + UNIQUE KEY `email` (`email`) USING BTREE ) set @@sql_mode="no_key_options"; show variables like 'sql_mode'; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 0a464d055c2..71a71a14ad2 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1480,7 +1480,7 @@ Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<e explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 Using index -2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 1 Using index; Using where +2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index; Using where Warnings: Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < _latin1'a2'))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; @@ -3169,3 +3169,17 @@ create table t2 (a int, b int); insert into t2 values (2, 1), (1, 0); delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1; drop table t1, t2; +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1); +ERROR 42S22: Unknown column 'no_such_column' in 'where clause' +CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1); +ERROR 42S22: Unknown column 'no_such_column' in 'where clause' +SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1); +ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery' +DROP TABLE t1; +create table t1 (i int, j bigint); +insert into t1 values (1, 2), (2, 2), (3, 2); +select * from (select min(i) from t1 where j=(select * from (select min(j) from t1) t2)) t3; +min(i) +1 +drop table t1; diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index b3cb244c735..3b24210dd5d 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` ( `b` char(16) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' +) ENGINE=MyISAM AUTO_INCREMENT=16725 DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' alter table t9 rename t8, add column d int not null; alter table t8 rename t7; rename table t7 to t9; @@ -53,7 +53,7 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL, `d` int(11) NOT NULL, PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' +) ENGINE=MyISAM AUTO_INCREMENT=16725 DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' Got one of the listed errors Got one of the listed errors Got one of the listed errors @@ -71,7 +71,7 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL, `d` int(11) NOT NULL, PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' +) ENGINE=MyISAM AUTO_INCREMENT=16725 DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' drop database mysqltest; create table t1 (a int not null) engine=myisam; show create table t1; diff --git a/mysql-test/r/trigger-grant.result b/mysql-test/r/trigger-grant.result index 10f1e08eded..fec5d4812d9 100644 --- a/mysql-test/r/trigger-grant.result +++ b/mysql-test/r/trigger-grant.result @@ -364,3 +364,87 @@ SELECT @mysqltest_var; Hello, world! DROP USER mysqltest_u1@localhost; DROP DATABASE mysqltest_db1; +DELETE FROM mysql.user WHERE User LIKE 'mysqltest_%'; +DELETE FROM mysql.db WHERE User LIKE 'mysqltest_%'; +DELETE FROM mysql.tables_priv WHERE User LIKE 'mysqltest_%'; +DELETE FROM mysql.columns_priv WHERE User LIKE 'mysqltest_%'; +FLUSH PRIVILEGES; +DROP DATABASE IF EXISTS mysqltest_db1; +CREATE DATABASE mysqltest_db1; +USE mysqltest_db1; +CREATE TABLE t1 (i1 INT); +CREATE TABLE t2 (i1 INT); +CREATE USER mysqltest_dfn@localhost; +CREATE USER mysqltest_inv@localhost; +GRANT EXECUTE, CREATE ROUTINE, TRIGGER ON *.* TO mysqltest_dfn@localhost; +GRANT INSERT ON mysqltest_db1.* TO mysqltest_inv@localhost; +CREATE PROCEDURE p1(OUT i INT) DETERMINISTIC NO SQL SET i = 3; +CREATE PROCEDURE p2(INOUT i INT) DETERMINISTIC NO SQL SET i = i * 5; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW +CALL p2(NEW.i1); +INSERT INTO t1 VALUES (7); +ERROR 42000: UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1' +INSERT INTO t2 VALUES (11); +ERROR 42000: SELECT,UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't2' +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; +GRANT SELECT ON mysqltest_db1.* TO mysqltest_dfn@localhost; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW +CALL p2(NEW.i1); +INSERT INTO t1 VALUES (13); +ERROR 42000: UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1' +INSERT INTO t2 VALUES (17); +ERROR 42000: UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't2' +REVOKE SELECT ON mysqltest_db1.* FROM mysqltest_dfn@localhost; +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; +GRANT UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW +CALL p2(NEW.i1); +INSERT INTO t1 VALUES (19); +INSERT INTO t2 VALUES (23); +ERROR 42000: SELECT command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't2' +REVOKE UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost; +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; +GRANT SELECT, UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW +CALL p2(NEW.i1); +INSERT INTO t1 VALUES (29); +INSERT INTO t2 VALUES (31); +REVOKE SELECT, UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost; +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; +DROP PROCEDURE p2; +DROP PROCEDURE p1; +GRANT UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; +CREATE PROCEDURE p1(OUT i INT) DETERMINISTIC NO SQL SET i = 37; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +CALL p1(NEW.i1); +INSERT INTO t1 VALUES (41); +DROP PROCEDURE p1; +CREATE PROCEDURE p1(IN i INT) DETERMINISTIC NO SQL SET @v1 = i + 43; +INSERT INTO t1 VALUES (47); +ERROR 42000: SELECT command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1' +DROP PROCEDURE p1; +CREATE PROCEDURE p1(INOUT i INT) DETERMINISTIC NO SQL SET i = i + 51; +INSERT INTO t1 VALUES (53); +ERROR 42000: SELECT command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1' +DROP PROCEDURE p1; +REVOKE UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost; +DROP TRIGGER t1_bi; +DROP USER mysqltest_inv@localhost; +DROP USER mysqltest_dfn@localhost; +DROP TABLE t2; +DROP TABLE t1; +DROP DATABASE mysqltest_db1; +USE test; +End of 5.0 tests. diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 5d5ea9511ba..24675f2cd66 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -949,9 +949,9 @@ insert into t1 values create function f2() returns int return (select max(b) from t2); insert into t2 select a, f2() from t1; load data infile '../std_data_ln/words.dat' into table t1 (a) set b:= f1(); -drop table t1, t2; drop function f1; drop function f2; +drop table t1, t2; create table t1(i int not null, j int not null, n numeric(15,2), primary key(i,j)); create table t2(i int not null, n numeric(15,2), primary key(i)); create trigger t1_ai after insert on t1 for each row @@ -998,3 +998,95 @@ SELECT * FROM t1 WHERE conn_id != trigger_conn_id; conn_id trigger_conn_id DROP TRIGGER t1_bi; DROP TABLE t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i1 INT); +SET @save_sql_mode=@@sql_mode; +SET SQL_MODE=''; +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +SET @x = 5/0; +SET SQL_MODE='traditional'; +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW +SET @x = 5/0; +SET @x=1; +INSERT INTO t1 VALUES (@x); +SELECT @x; +@x +NULL +SET @x=2; +UPDATE t1 SET i1 = @x; +ERROR 22012: Division by 0 +SELECT @x; +@x +2 +SET SQL_MODE=''; +SET @x=3; +INSERT INTO t1 VALUES (@x); +SELECT @x; +@x +NULL +SET @x=4; +UPDATE t1 SET i1 = @x; +ERROR 22012: Division by 0 +SELECT @x; +@x +4 +SET @@sql_mode=@save_sql_mode; +DROP TRIGGER t1_ai; +DROP TRIGGER t1_au; +DROP TABLE t1; +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +CREATE TABLE t1 (i1 INT); +INSERT INTO t1 VALUES (3); +CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET i1 = 5; +CREATE PROCEDURE p2(INOUT i1 INT) DETERMINISTIC NO SQL SET i1 = i1 * 7; +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +BEGIN +CALL p1(NEW.i1); +CALL p2(NEW.i1); +END// +UPDATE t1 SET i1 = 11 WHERE i1 = 3; +DROP TRIGGER t1_bu; +DROP PROCEDURE p2; +DROP PROCEDURE p1; +INSERT INTO t1 VALUES (13); +CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET @a = 17; +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +CALL p1(OLD.i1); +UPDATE t1 SET i1 = 19 WHERE i1 = 13; +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger +DROP TRIGGER t1_bu; +DROP PROCEDURE p1; +INSERT INTO t1 VALUES (23); +CREATE PROCEDURE p1(INOUT i1 INT) DETERMINISTIC NO SQL SET @a = i1 * 29; +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +CALL p1(OLD.i1); +UPDATE t1 SET i1 = 31 WHERE i1 = 23; +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger +DROP TRIGGER t1_bu; +DROP PROCEDURE p1; +INSERT INTO t1 VALUES (37); +CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET @a = 41; +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW +CALL p1(NEW.i1); +UPDATE t1 SET i1 = 43 WHERE i1 = 37; +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger +DROP TRIGGER t1_au; +DROP PROCEDURE p1; +INSERT INTO t1 VALUES (47); +CREATE PROCEDURE p1(INOUT i1 INT) DETERMINISTIC NO SQL SET @a = i1 * 49; +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW +CALL p1(NEW.i1); +UPDATE t1 SET i1 = 51 WHERE i1 = 47; +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger +DROP TRIGGER t1_au; +DROP PROCEDURE p1; +SELECT * FROM t1; +i1 +35 +13 +23 +43 +51 +DROP TABLE t1; diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index d3c80a7c80e..cfae61d5e91 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -245,22 +245,22 @@ show warnings; Level Code Message desc t1; Field Type Null Key Default Extra -x decimal(21,2) unsigned NO 0.00 +x decimal(21,2) NO 0.00 drop table t1; create table t1 select 0.0 x; desc t1; Field Type Null Key Default Extra -x decimal(2,1) unsigned NO 0.0 +x decimal(2,1) NO 0.0 create table t2 select 105213674794682365.00 y; desc t2; Field Type Null Key Default Extra -y decimal(20,2) unsigned NO 0.00 +y decimal(20,2) NO 0.00 create table t3 select x+y a from t1,t2; show warnings; Level Code Message desc t3; Field Type Null Key Default Extra -a decimal(21,2) unsigned NO 0.00 +a decimal(21,2) NO 0.00 drop table t1,t2,t3; create table t1 (s1 float(0,2)); ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1'). diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index f96d5e383f4..702b589c911 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -68,10 +68,10 @@ NULL 1.1 NULL NULL NULL 1 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `nullif(1.1, 1.1)` decimal(2,1) unsigned DEFAULT NULL, - `nullif(1.1, 1.2)` decimal(2,1) unsigned DEFAULT NULL, - `nullif(1.1, 0.11e1)` decimal(2,1) unsigned DEFAULT NULL, - `nullif(1.0, 1)` decimal(2,1) unsigned DEFAULT NULL, + `nullif(1.1, 1.1)` decimal(2,1) DEFAULT NULL, + `nullif(1.1, 1.2)` decimal(2,1) DEFAULT NULL, + `nullif(1.1, 0.11e1)` decimal(2,1) DEFAULT NULL, + `nullif(1.0, 1)` decimal(2,1) DEFAULT NULL, `nullif(1, 1.0)` int(1) DEFAULT NULL, `nullif(1, 1.1)` int(1) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 @@ -174,9 +174,9 @@ create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(- show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `round(15.4,-1)` decimal(3,0) unsigned NOT NULL DEFAULT '0', + `round(15.4,-1)` decimal(3,0) NOT NULL DEFAULT '0', `truncate(-5678.123451,-3)` decimal(4,0) NOT NULL DEFAULT '0', - `abs(-1.1)` decimal(2,1) NOT NULL DEFAULT '0.0', + `abs(-1.1)` decimal(3,1) NOT NULL DEFAULT '0.0', `-(-1.1)` decimal(2,1) NOT NULL DEFAULT '0.0' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; @@ -771,7 +771,7 @@ create table t1 as select 0.5; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `0.5` decimal(2,1) unsigned NOT NULL DEFAULT '0.0' + `0.5` decimal(2,1) NOT NULL DEFAULT '0.0' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select round(1.5),round(2.5); diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 43b32782c63..e4b3fc2c2e2 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1,4 +1,31 @@ drop table if exists t1,t2; +set @my_binlog_cache_size =@@global.binlog_cache_size; +set @my_connect_timeout =@@global.connect_timeout; +set @my_delayed_insert_timeout =@@global.delayed_insert_timeout; +set @my_delayed_queue_size =@@global.delayed_queue_size; +set @my_flush =@@global.flush; +set @my_flush_time =@@global.flush_time; +set @my_key_buffer_size =@@global.key_buffer_size; +set @my_max_binlog_cache_size =@@global.max_binlog_cache_size; +set @my_max_binlog_size =@@global.max_binlog_size; +set @my_max_connect_errors =@@global.max_connect_errors; +set @my_max_delayed_threads =@@global.max_delayed_threads; +set @my_max_heap_table_size =@@global.max_heap_table_size; +set @my_max_insert_delayed_threads=@@global.max_insert_delayed_threads; +set @my_max_join_size =@@global.max_join_size; +set @my_max_user_connections =@@global.max_user_connections; +set @my_max_write_lock_count =@@global.max_write_lock_count; +set @my_myisam_data_pointer_size =@@global.myisam_data_pointer_size; +set @my_net_buffer_length =@@global.net_buffer_length; +set @my_net_write_timeout =@@global.net_write_timeout; +set @my_net_read_timeout =@@global.net_read_timeout; +set @my_query_cache_limit =@@global.query_cache_limit; +set @my_query_cache_type =@@global.query_cache_type; +set @my_rpl_recovery_rank =@@global.rpl_recovery_rank; +set @my_server_id =@@global.server_id; +set @my_slow_launch_time =@@global.slow_launch_time; +set @my_storage_engine =@@global.storage_engine; +set @my_thread_cache_size =@@global.thread_cache_size; set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @test @`test` @TEST @`TEST` @"teSt" @@ -612,4 +639,59 @@ select @@version, @@version_comment, @@version_compile_machine, @@version_compile_os; @@version @@version_comment @@version_compile_machine @@version_compile_os # # # # +select @@basedir, @@datadir, @@tmpdir; +@@basedir @@datadir @@tmpdir +# # # +show variables like 'basedir'; +Variable_name Value +basedir # +show variables like 'datadir'; +Variable_name Value +datadir # +show variables like 'tmpdir'; +Variable_name Value +tmpdir # +select @@ssl_ca, @@ssl_capath, @@ssl_cert, @@ssl_cipher, @@ssl_key; +@@ssl_ca @@ssl_capath @@ssl_cert @@ssl_cipher @@ssl_key +# # # # # +show variables like 'ssl%'; +Variable_name Value +ssl_ca # +ssl_capath # +ssl_cert # +ssl_cipher # +ssl_key # +select @@log_queries_not_using_indexes; +@@log_queries_not_using_indexes +0 +show variables like 'log_queries_not_using_indexes'; +Variable_name Value +log_queries_not_using_indexes OFF End of 5.0 tests +set global binlog_cache_size =@my_binlog_cache_size; +set global connect_timeout =@my_connect_timeout; +set global delayed_insert_timeout =@my_delayed_insert_timeout; +set global delayed_queue_size =@my_delayed_queue_size; +set global flush =@my_flush; +set global flush_time =@my_flush_time; +set global key_buffer_size =@my_key_buffer_size; +set global max_binlog_cache_size =default; +set global max_binlog_size =@my_max_binlog_size; +set global max_connect_errors =@my_max_connect_errors; +set global max_delayed_threads =@my_max_delayed_threads; +set global max_heap_table_size =@my_max_heap_table_size; +set global max_insert_delayed_threads=@my_max_insert_delayed_threads; +set global max_join_size =@my_max_join_size; +set global max_user_connections =@my_max_user_connections; +set global max_write_lock_count =@my_max_write_lock_count; +set global myisam_data_pointer_size =@my_myisam_data_pointer_size; +set global net_buffer_length =@my_net_buffer_length; +set global net_write_timeout =@my_net_write_timeout; +set global net_read_timeout =@my_net_read_timeout; +set global query_cache_limit =@my_query_cache_limit; +set global query_cache_type =@my_query_cache_type; +set global rpl_recovery_rank =@my_rpl_recovery_rank; +set global server_id =@my_server_id; +set global slow_launch_time =@my_slow_launch_time; +set global storage_engine =@my_storage_engine; +set global thread_cache_size =@my_thread_cache_size; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index c5446ac314e..9dba51c26d9 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -706,7 +706,7 @@ create view v1 as select a from t1; create view v2 as select a from t2 where a in (select a from v1); show create view v2; View Create View -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `a` in (select `v1`.`a` AS `a` from `v1`) +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `t2`.`a` in (select `v1`.`a` AS `a` from `v1`) drop view v2, v1; drop table t1, t2; CREATE VIEW `v 1` AS select 5 AS `5`; @@ -2649,3 +2649,48 @@ ldt 2006-01-01 03:00:00 drop view v1, v2; drop table t1; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime); +CREATE VIEW v1 AS +SELECT id, date(d) + INTERVAL TIME_TO_SEC(d) SECOND AS t, COUNT(*) +FROM t1 GROUP BY id, t; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) AS `t`,count(0) AS `COUNT(*)` from `t1` group by `t1`.`id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) +SELECT * FROM v1; +id t COUNT(*) +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (i INT, j BIGINT); +INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); +CREATE VIEW v1 AS SELECT MIN(j) AS j FROM t1; +CREATE VIEW v2 AS SELECT MIN(i) FROM t1 WHERE j = ( SELECT * FROM v1 ); +SELECT * FROM v2; +MIN(i) +1 +DROP VIEW v2, v1; +DROP TABLE t1; +CREATE TABLE t1( +fName varchar(25) NOT NULL, +lName varchar(25) NOT NULL, +DOB date NOT NULL, +uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1(fName, lName, DOB) VALUES +('Hank', 'Hill', '1964-09-29'), +('Tom', 'Adams', '1908-02-14'), +('Homer', 'Simpson', '1968-03-05'); +CREATE VIEW v1 AS +SELECT (year(now())-year(DOB)) AS Age +FROM t1 HAVING Age < 75; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) +SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; +Age +42 +38 +SELECT * FROM v1; +Age +42 +38 +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/std_data/cacert.pem b/mysql-test/std_data/cacert.pem index a63dae57767..b445e77d7c4 100644 --- a/mysql-test/std_data/cacert.pem +++ b/mysql-test/std_data/cacert.pem @@ -1,21 +1,17 @@ -----BEGIN CERTIFICATE----- -MIIDcTCCAtqgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCU0Ux -EDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhB -YnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0 -Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wHhcNMDMwOTEyMTYxNDE2WhcNMTMw -OTA5MTYxNDE2WjCBiDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAP -BgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhBYnN0cmFjdCBNeVNRTCBEZXZlbG9w -ZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNx -bC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKrT7zp5tp5djXp+TEQs -5ZEds1XUglp/EQUQ1FMMb1Xe6gqJsQ62O+jsUe0nrUjXBrUCUy49k6mcnmQtZREj -l1pWKmzx1fgcYpxTwxaY7IKB2jik5IWprhVPmSQ+AWss43oolXMZWR+csKehqm3j -+YNZc9NsR4ydE71l0VEtJEQvAgMBAAGjgegwgeUwHQYDVR0OBBYEFIiYZdnz8osD -HWZgYSP6rXNt02iSMIG1BgNVHSMEga0wgaqAFIiYZdnz8osDHWZgYSP6rXNt02iS -oYGOpIGLMIGIMQswCQYDVQQGEwJTRTEQMA4GA1UEBxMHVXBwc2FsYTERMA8GA1UE -ChMITXlTUUwgQUIxITAfBgNVBAMTGEFic3RyYWN0IE15U1FMIERldmVsb3BlcjEx -MC8GCSqGSIb3DQEJARYiYWJzdHJhY3QubXlzcWwuZGV2ZWxvcGVyQG15c3FsLmNv -bYIBADAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4GBAGIL22MCIU/0sKDp -pZIhoabvNVDTfuhtene+WBCrzCzGXPZjB4+b/KAJJNvOR4zi43Kk7euu+PENs9M7 -nKpInMdhvT1RcCnUHJ3jBCvDDzXab2msqn3rxhwetWWbfE0OeEn/PoQcwiZCe7x5 -h+Zz+oUbvsEe4DjtDVgG4UH9nSSS +MIICrTCCAhagAwIBAgIJAIAO/Ybiptv1MA0GCSqGSIb3DQEBBAUAMEQxCzAJBgNV +BAYTAlNFMRAwDgYDVQQIEwdVcHBzYWxhMRAwDgYDVQQHEwdVcHBzYWxhMREwDwYD +VQQKEwhNeVNRTCBBQjAeFw0wNjA1MDMwODQ4NTRaFw0wOTAxMjcwODQ4NTRaMEQx +CzAJBgNVBAYTAlNFMRAwDgYDVQQIEwdVcHBzYWxhMRAwDgYDVQQHEwdVcHBzYWxh +MREwDwYDVQQKEwhNeVNRTCBBQjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA ++C46EQl1u7tQ6gb9eqc8V079gr8YmDPCEqtjO8bCIbchpjOpDITx0WZz36Sn9E72 +GPJwNip4FxLaPRIA3xNQHM5cE5U53qznlRx1Fc4O3hcWCvyCqNDl/vzPAh3pI6Bl +Ku9hfHXpp93W812smVPe9haShEXGgbEPYGzvOfVdu/MCAwEAAaOBpjCBozAdBgNV +HQ4EFgQUjIy/6OCTmqtPHBFha6/qzVk3yTcwdAYDVR0jBG0wa4AUjIy/6OCTmqtP +HBFha6/qzVk3yTehSKRGMEQxCzAJBgNVBAYTAlNFMRAwDgYDVQQIEwdVcHBzYWxh +MRAwDgYDVQQHEwdVcHBzYWxhMREwDwYDVQQKEwhNeVNRTCBBQoIJAIAO/Ybiptv1 +MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEA8lD9zyB820Oq1aj7ZafX +De/hbdt9RIl2tzgw2K3r1KZGdXJVL0vSt5fZ51Nq9lg7OPJy3iXf+caBJEp0IJpB +uf4Gfr6zfXw+UlY6ZthRtHQHoXKcbskECjH5/ps/Uaa+dpVQ9O+Ii1rPzmgo6ztM +s+xZ46ESBt4WiHXm8kwbU9Y= -----END CERTIFICATE----- diff --git a/mysql-test/std_data/client-cert.pem b/mysql-test/std_data/client-cert.pem index 4c81162c911..fdd5c86a23f 100644 --- a/mysql-test/std_data/client-cert.pem +++ b/mysql-test/std_data/client-cert.pem @@ -1,67 +1,42 @@ Certificate: Data: - Version: 3 (0x2) + Version: 1 (0x0) Serial Number: 1 (0x1) Signature Algorithm: md5WithRSAEncryption - Issuer: C=SE, L=Uppsala, O=MySQL AB, CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com + Issuer: C=SE, ST=Uppsala, L=Uppsala, O=MySQL AB Validity - Not Before: Sep 12 16:21:19 2003 GMT - Not After : Sep 9 16:21:19 2013 GMT - Subject: C=SE, L=Uppsala, O=MySQL AB, CN=MySQL Client/Email=abstract.mysql.developer@mysql.com + Not Before: May 3 08:55:39 2006 GMT + Not After : Jan 27 08:55:39 2009 GMT + Subject: C=SE, ST=Uppsala, L=Uppsala, O=MySQL AB/emailAddress=abstract.mysql.developer@mysql.com Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public Key: (1024 bit) - Modulus (1024 bit): - 00:c4:03:0a:ee:e3:b1:12:fc:ee:b4:19:f4:e1:60: - 1d:e0:28:c3:96:2d:df:82:69:cd:74:7c:54:58:d0: - ae:b3:59:3f:0c:19:1c:99:10:a6:12:c9:cf:3a:64: - 05:43:8e:bf:d2:65:36:80:91:0b:65:b0:27:26:38: - c9:23:d8:36:a2:4a:f0:f7:c0:2f:68:38:70:01:27: - 29:ff:b2:c5:52:e1:6b:f1:c8:d7:c3:5c:ee:f0:37: - 6c:2a:9b:96:1a:05:9e:eb:33:a2:39:5a:77:66:62: - 27:75:1f:2f:6f:38:da:e5:9f:78:af:ca:6b:22:3f: - 57:2b:bc:a6:8f:47:d1:99:6f + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:d8:db:68:28:49:84:4d:d6:0f:5c:bc:3d:9a:ab: + 70:d5:3e:f5:b5:17:ba:ef:e1:f8:87:54:30:22:1f: + 81:07:bf:f9:24:7f:8a:54:10:e9:5f:e6:99:50:04: + d4:3b:55:a9:f1:52:ad:12:2b:5a:da:5c:be:8c:3e: + 5b:9e:b0:5a:19 Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Netscape Comment: - OpenSSL Generated Certificate - X509v3 Subject Key Identifier: - 80:81:A9:22:EB:AB:D6:CA:7E:3F:8D:BB:D1:AC:2A:F4:87:9D:13:29 - X509v3 Authority Key Identifier: - keyid:88:98:65:D9:F3:F2:8B:03:1D:66:60:61:23:FA:AD:73:6D:D3:68:92 - DirName:/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com - serial:00 - Signature Algorithm: md5WithRSAEncryption - 86:17:1c:f3:9f:10:1b:75:47:03:ca:54:ea:ef:f7:15:54:8d: - 8f:58:c9:64:7d:de:2e:bf:ea:a6:5d:72:56:c9:81:be:bb:1c: - 78:a5:91:d6:f8:77:df:9d:d2:cb:94:d9:06:61:4f:05:21:22: - 2a:ea:9e:c3:8b:4d:fe:94:c7:98:61:cd:7e:88:19:c9:92:01: - 1f:10:5b:c6:16:95:99:9b:32:01:3a:89:df:fa:0a:89:ac:fa: - b5:40:55:7a:ca:0a:bd:5d:8b:06:d8:7e:e1:44:8c:70:c8:63: - c7:77:6a:37:3d:a4:ac:57:dc:00:c1:c1:f3:72:17:5b:50:95: - ee:b7 + 07:57:bf:07:92:c2:8e:86:24:6b:0a:bf:e5:31:21:44:c3:60: + 02:a6:ac:9e:f7:db:7a:6e:fc:4f:d4:7b:54:18:80:47:d2:4a: + 63:0e:e3:f8:af:6e:58:e3:97:5a:2b:82:5d:76:20:d1:33:a0: + f5:43:a1:d1:51:f4:ca:c8:b3:1a:66:4e:0e:55:df:d2:e8:fa: + 83:18:42:f5:ec:66:40:f0:39:e8:f9:d7:cf:f6:dd:e4:7b:69: + dd:0c:92:d8:52:95:43:6f:29:3d:f0:8d:4c:dd:52:ea:6b:a0: + 39:0f:dc:59:a7:5c:37:6b:8b:05:44:b7:69:ea:a3:58:e0:4e: + ce:d6 -----BEGIN CERTIFICATE----- -MIIDkTCCAvqgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCU0Ux -EDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhB -YnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0 -Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wHhcNMDMwOTEyMTYyMTE5WhcNMTMw -OTA5MTYyMTE5WjB8MQswCQYDVQQGEwJTRTEQMA4GA1UEBxMHVXBwc2FsYTERMA8G -A1UEChMITXlTUUwgQUIxFTATBgNVBAMTDE15U1FMIENsaWVudDExMC8GCSqGSIb3 -DQEJARYiYWJzdHJhY3QubXlzcWwuZGV2ZWxvcGVyQG15c3FsLmNvbTCBnzANBgkq -hkiG9w0BAQEFAAOBjQAwgYkCgYEAxAMK7uOxEvzutBn04WAd4CjDli3fgmnNdHxU -WNCus1k/DBkcmRCmEsnPOmQFQ46/0mU2gJELZbAnJjjJI9g2okrw98AvaDhwAScp -/7LFUuFr8cjXw1zu8DdsKpuWGgWe6zOiOVp3ZmIndR8vbzja5Z94r8prIj9XK7ym -j0fRmW8CAwEAAaOCARQwggEQMAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9w -ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBSAgaki66vWyn4/ -jbvRrCr0h50TKTCBtQYDVR0jBIGtMIGqgBSImGXZ8/KLAx1mYGEj+q1zbdNokqGB -jqSBizCBiDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoT -CE15U1FMIEFCMSEwHwYDVQQDExhBYnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAv -BgkqhkiG9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb22C -AQAwDQYJKoZIhvcNAQEEBQADgYEAhhcc858QG3VHA8pU6u/3FVSNj1jJZH3eLr/q -pl1yVsmBvrsceKWR1vh3353Sy5TZBmFPBSEiKuqew4tN/pTHmGHNfogZyZIBHxBb -xhaVmZsyATqJ3/oKiaz6tUBVesoKvV2LBth+4USMcMhjx3dqNz2krFfcAMHB83IX -W1CV7rc= +MIIB5jCCAU8CAQEwDQYJKoZIhvcNAQEEBQAwRDELMAkGA1UEBhMCU0UxEDAOBgNV +BAgTB1VwcHNhbGExEDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFC +MB4XDTA2MDUwMzA4NTUzOVoXDTA5MDEyNzA4NTUzOVowdzELMAkGA1UEBhMCU0Ux +EDAOBgNVBAgTB1VwcHNhbGExEDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15 +U1FMIEFCMTEwLwYJKoZIhvcNAQkBFiJhYnN0cmFjdC5teXNxbC5kZXZlbG9wZXJA +bXlzcWwuY29tMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANjbaChJhE3WD1y8PZqr +cNU+9bUXuu/h+IdUMCIfgQe/+SR/ilQQ6V/mmVAE1DtVqfFSrRIrWtpcvow+W56w +WhkCAwEAATANBgkqhkiG9w0BAQQFAAOBgQAHV78HksKOhiRrCr/lMSFEw2ACpqye +99t6bvxP1HtUGIBH0kpjDuP4r25Y45daK4JddiDRM6D1Q6HRUfTKyLMaZk4OVd/S +6PqDGEL17GZA8Dno+dfP9t3ke2ndDJLYUpVDbyk98I1M3VLqa6A5D9xZp1w3a4sF +RLdp6qNY4E7O1g== -----END CERTIFICATE----- diff --git a/mysql-test/std_data/client-key.pem b/mysql-test/std_data/client-key.pem index 58fa805e620..22f8e23ab2a 100644 --- a/mysql-test/std_data/client-key.pem +++ b/mysql-test/std_data/client-key.pem @@ -1,15 +1,9 @@ -----BEGIN RSA PRIVATE KEY----- -MIICXQIBAAKBgQDEAwru47ES/O60GfThYB3gKMOWLd+Cac10fFRY0K6zWT8MGRyZ -EKYSyc86ZAVDjr/SZTaAkQtlsCcmOMkj2DaiSvD3wC9oOHABJyn/ssVS4WvxyNfD -XO7wN2wqm5YaBZ7rM6I5WndmYid1Hy9vONrln3ivymsiP1crvKaPR9GZbwIDAQAB -AoGAcR7IaoGhKbIrGGl6d67+zuT3q24h9aOV3Mn7653TlNHGnvbHGFcRYPpyy+H5 -X7m8XnHm+F+80hzNGzPecP9Q12oPOyoZgeQn6bTK73OFkNcX7FAkNdyH4xVhf2aK -YOzTcQfq3gRCqXtVIg4qBShTMjJLE31R8H430Or62XmJgFECQQDjP+Kz+ecQwuTB -HADLm+GQgceIB1kLgdQoZ3deUxGvqtVImuDRViSM0F2srfJ4GfkEDhc27UI5f6ir -ZTOw4ww7AkEA3M9wCPgWNtbOXbYjaNA0IzHcjMDxQDVvJAmb3EiZlKQp4EfrESxR -ly/u08TyfwrK6q5WS7xE0ad8+95G1af4XQJBAI9+3ME20SB1YItMCniHYwSj3oHX -2fN5NKWax/Zoz+c0IV+qZMHq+kNso2oRoOUTyXk1CJWndcTnBnPMALr2c9cCQQCZ -VL7Cq6uZVx6kemcqUHH0AprZbt3YLYLI7pc5p3xmeHzPzoEQQstBhjp8+aU+zPrN -blRkcQ8E2x5yNA7SLLrNAkAhzkA+EK8hc0f9W3ncy+py0Rn0i5Ay0N3T715vkThf -CfOHE3L91dLlmYpL5xVqOpugY/2sHyxwctv97DgS6tHZ +MIIBOgIBAAJBANjbaChJhE3WD1y8PZqrcNU+9bUXuu/h+IdUMCIfgQe/+SR/ilQQ +6V/mmVAE1DtVqfFSrRIrWtpcvow+W56wWhkCAwEAAQJAK27WT6tZylUjQomZNQ89 +TBiOEbUtBbqWklQ0R8FTkH9uKV+8KYQ+k+tMkoAEGFfChB0YfofNQ2KZYWWw4yOB +WQIhAPXXDQt73aou10s+cmKM3C3WzLmIZtrvm9wNBXWDGxgTAiEA4dG4cXrZfa1M +TTbjzNU1/Jf50/M8SvZDWMPQWxJ8oqMCIH6zBpYUkHlVCsBMvsbrsc4uFfTIx7mu +I7WVQGr/1sbhAiBf4uFirjtztgZUMx5/d3k5DH80lG/hlLf8FQl/4lWx6QIhAPHw +CXfPUbUFl4r/i9Br5+exGol50qX4F3aP5Sh5EnZT -----END RSA PRIVATE KEY----- diff --git a/mysql-test/std_data/server-cert.pem b/mysql-test/std_data/server-cert.pem index debf7026e3c..f420b4f3124 100644 --- a/mysql-test/std_data/server-cert.pem +++ b/mysql-test/std_data/server-cert.pem @@ -1,67 +1,42 @@ Certificate: Data: - Version: 3 (0x2) - Serial Number: 2 (0x2) + Version: 1 (0x0) + Serial Number: 1 (0x1) Signature Algorithm: md5WithRSAEncryption - Issuer: C=SE, L=Uppsala, O=MySQL AB, CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com + Issuer: C=SE, ST=Uppsala, L=Uppsala, O=MySQL AB Validity - Not Before: Sep 12 16:22:06 2003 GMT - Not After : Sep 9 16:22:06 2013 GMT - Subject: C=SE, L=Uppsala, O=MySQL AB, CN=MySQL Server/Email=abstract.mysql.developer@mysql.com + Not Before: May 3 08:54:13 2006 GMT + Not After : Jan 27 08:54:13 2009 GMT + Subject: C=SE, ST=Uppsala, L=Uppsala, O=MySQL AB, CN=localhost/emailAddress=abstract.mysql.developer@mysql.com Subject Public Key Info: Public Key Algorithm: rsaEncryption - RSA Public Key: (1024 bit) - Modulus (1024 bit): - 00:e9:86:7a:55:84:88:4c:be:a4:f8:92:73:30:12: - 49:0b:7a:85:87:39:34:39:0d:7d:0b:8d:18:c2:17: - 95:13:52:d2:3f:55:10:57:c8:3f:5a:f5:b2:fa:8b: - d0:67:49:cc:aa:82:fc:9f:ce:00:b4:73:f3:36:d2: - 3a:d3:c2:b0:0e:14:c3:d4:b2:21:74:a1:f0:31:81: - 60:87:98:73:5c:10:c1:b1:1a:4d:f1:f3:b0:98:3f: - f0:d7:97:9b:2b:fd:d5:21:79:b2:2f:eb:64:15:c9: - 9b:9d:fc:9e:2d:d4:f8:04:5b:ea:a9:75:4b:42:c3: - 3d:0e:4d:2a:a8:b8:ca:99:8d + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:d9:fd:da:b3:fb:7c:e0:b0:03:be:97:c6:a4:36: + ac:71:af:bb:2d:e5:84:ed:f3:8f:2b:eb:11:e5:aa: + 66:ed:bf:62:6b:e3:ce:fa:80:ed:90:ff:b9:4a:39: + 20:40:b6:f2:99:bf:2f:33:b5:f2:ec:3a:90:60:1d: + 9e:94:7e:a4:1b Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Netscape Comment: - OpenSSL Generated Certificate - X509v3 Subject Key Identifier: - 6E:E4:9B:6A:C5:EA:E4:E6:C7:EF:D7:1E:C8:63:45:60:2B:1B:D4:D4 - X509v3 Authority Key Identifier: - keyid:88:98:65:D9:F3:F2:8B:03:1D:66:60:61:23:FA:AD:73:6D:D3:68:92 - DirName:/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com - serial:00 - Signature Algorithm: md5WithRSAEncryption - 31:77:69:b9:bd:ab:29:f3:fc:5a:09:16:6f:5d:42:ea:ba:01: - 55:69:e3:75:cf:b8:d1:b7:b9:bf:da:63:85:8c:48:92:06:60: - 76:97:e0:00:78:4b:ad:da:ab:6a:90:6d:8b:03:a8:b1:e9:09: - 78:e1:29:98:56:12:60:6b:42:fe:e8:a7:c4:f8:d6:15:07:e8: - 2b:c2:d8:8a:e5:1b:2e:51:08:9b:56:e3:b3:7a:4c:3e:e5:be: - 4a:4d:f8:65:7b:a8:21:e0:ca:fe:8b:ab:d7:ec:f2:2d:f7:d0: - bf:d7:c5:23:1c:08:d8:aa:57:c7:f3:5f:ba:33:3f:78:d1:f4: - 8e:5e + de:5e:35:cd:7b:11:e6:7c:c5:7c:d6:27:4e:72:12:49:42:eb: + 6f:2c:96:f3:f4:00:78:a7:4f:9f:2d:7b:d7:30:39:af:49:4d: + df:b1:55:0d:30:be:23:6f:06:67:fd:dd:ba:98:66:36:c6:32: + b7:ed:63:fc:aa:49:cd:4f:72:98:3b:13:0e:f6:28:d7:d4:eb: + 04:6b:dc:e8:c7:04:80:92:e4:04:86:0b:ed:32:25:76:1d:a9: + 5c:a9:2c:18:2c:bd:bc:15:ed:e1:76:96:4d:bb:0d:41:44:06: + 2c:ad:45:bb:db:61:ad:17:11:cb:49:70:67:eb:c6:27:d3:91: + c8:f2 -----BEGIN CERTIFICATE----- -MIIDkTCCAvqgAwIBAgIBAjANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCU0Ux -EDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhB -YnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0 -Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wHhcNMDMwOTEyMTYyMjA2WhcNMTMw -OTA5MTYyMjA2WjB8MQswCQYDVQQGEwJTRTEQMA4GA1UEBxMHVXBwc2FsYTERMA8G -A1UEChMITXlTUUwgQUIxFTATBgNVBAMTDE15U1FMIFNlcnZlcjExMC8GCSqGSIb3 -DQEJARYiYWJzdHJhY3QubXlzcWwuZGV2ZWxvcGVyQG15c3FsLmNvbTCBnzANBgkq -hkiG9w0BAQEFAAOBjQAwgYkCgYEA6YZ6VYSITL6k+JJzMBJJC3qFhzk0OQ19C40Y -wheVE1LSP1UQV8g/WvWy+ovQZ0nMqoL8n84AtHPzNtI608KwDhTD1LIhdKHwMYFg -h5hzXBDBsRpN8fOwmD/w15ebK/3VIXmyL+tkFcmbnfyeLdT4BFvqqXVLQsM9Dk0q -qLjKmY0CAwEAAaOCARQwggEQMAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9w -ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBRu5Jtqxerk5sfv -1x7IY0VgKxvU1DCBtQYDVR0jBIGtMIGqgBSImGXZ8/KLAx1mYGEj+q1zbdNokqGB -jqSBizCBiDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoT -CE15U1FMIEFCMSEwHwYDVQQDExhBYnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAv -BgkqhkiG9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb22C -AQAwDQYJKoZIhvcNAQEEBQADgYEAMXdpub2rKfP8WgkWb11C6roBVWnjdc+40be5 -v9pjhYxIkgZgdpfgAHhLrdqrapBtiwOosekJeOEpmFYSYGtC/uinxPjWFQfoK8LY -iuUbLlEIm1bjs3pMPuW+Sk34ZXuoIeDK/our1+zyLffQv9fFIxwI2KpXx/NfujM/ -eNH0jl4= +MIIB+zCCAWQCAQEwDQYJKoZIhvcNAQEEBQAwRDELMAkGA1UEBhMCU0UxEDAOBgNV +BAgTB1VwcHNhbGExEDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFC +MB4XDTA2MDUwMzA4NTQxM1oXDTA5MDEyNzA4NTQxM1owgYsxCzAJBgNVBAYTAlNF +MRAwDgYDVQQIEwdVcHBzYWxhMRAwDgYDVQQHEwdVcHBzYWxhMREwDwYDVQQKEwhN +eVNRTCBBQjESMBAGA1UEAxMJbG9jYWxob3N0MTEwLwYJKoZIhvcNAQkBFiJhYnN0 +cmFjdC5teXNxbC5kZXZlbG9wZXJAbXlzcWwuY29tMFwwDQYJKoZIhvcNAQEBBQAD +SwAwSAJBANn92rP7fOCwA76XxqQ2rHGvuy3lhO3zjyvrEeWqZu2/YmvjzvqA7ZD/ +uUo5IEC28pm/LzO18uw6kGAdnpR+pBsCAwEAATANBgkqhkiG9w0BAQQFAAOBgQDe +XjXNexHmfMV81idOchJJQutvLJbz9AB4p0+fLXvXMDmvSU3fsVUNML4jbwZn/d26 +mGY2xjK37WP8qknNT3KYOxMO9ijX1OsEa9zoxwSAkuQEhgvtMiV2HalcqSwYLL28 +Fe3hdpZNuw1BRAYsrUW722GtFxHLSXBn68Yn05HI8g== -----END CERTIFICATE----- diff --git a/mysql-test/std_data/server-key.pem b/mysql-test/std_data/server-key.pem index 4292dc79929..a4842624c0c 100644 --- a/mysql-test/std_data/server-key.pem +++ b/mysql-test/std_data/server-key.pem @@ -1,15 +1,9 @@ -----BEGIN RSA PRIVATE KEY----- -MIICXgIBAAKBgQDphnpVhIhMvqT4knMwEkkLeoWHOTQ5DX0LjRjCF5UTUtI/VRBX -yD9a9bL6i9BnScyqgvyfzgC0c/M20jrTwrAOFMPUsiF0ofAxgWCHmHNcEMGxGk3x -87CYP/DXl5sr/dUhebIv62QVyZud/J4t1PgEW+qpdUtCwz0OTSqouMqZjQIDAQAB -AoGBALTq11nrjIEQbdSZ+R1z/R0kddB2U+wjdA3/6P9tr7PBxVsFdtzbKaI5mcib -iwCKX0J2qmrP+SHUdsexBZxLR4KV/Z55v9Pym99Dy+DxDA95zURyCMKRBIzlU5uN -F7USEQoltLUCsmZwNWdit0gfxSWdddkHNuI0uxTzHwuDcUlNAkEA/76zVremngNL -DlekM9NPn/8E/TXBHN1b1jdUKd7WymSJykdcm3viU98dFNZFWF8B0jiTcuBKXgpR -vTShNab/swJBAOnCGp554BLhioTyyk8qjRLt3xEsjsDljJULHVLYWcUqIkMf97GL -VLBhl6ZEI9i0WduqvgZ+Bacd0uHqIHz1Yb8CQQDm1CjqTDiGxlIoT9JVNJTZxEOs -h6gVdXY+kxHT+N3FL5luiZp8fAR7zxVgiUVtzdLG+2madfapiobcT3RyCJkhAkBI -64AaR7KasTjg2Ew7/e4cJZAcb2XozrLYG6t+GHeIhehCQEqoW+qDSy5fc4orI7eU -SuMUa2OgCjGqv7p6wKFJAkEAznmum/MbVOBpC4FsdnIGkxyFKIbh2OLY2aUb2KkK -Ouf4S8Y5Ldgszi0fnDPRaxWJzewwZKvcff2zj+mYZeAXbA== +MIIBOgIBAAJBANn92rP7fOCwA76XxqQ2rHGvuy3lhO3zjyvrEeWqZu2/YmvjzvqA +7ZD/uUo5IEC28pm/LzO18uw6kGAdnpR+pBsCAwEAAQJBAMieYdpmRoUaODf9wqh6 +ULXH/sG8i1vaXRcUHcJ50oRVfVK8/tGGvUuTDu6MeINTdahNDlYfjwOjKWVXys1w +h6ECIQDs6s7DfczK2bKCLt0zqg24mZL3rOpGmDU+TatwN1yVgwIhAOuMzdVTX39p +328+5WxJvBOFfxmSmqdDhIFpnRMvgguJAiByvKjT/km+970+1OllyvaIL0AA2OpA +tBgdC0p6tyUMdwIgKuHAWzTJbu28UolVxQgLaFZmVCZ/ZzIAfnrWsLZ2a1kCIBq/ +ywJ2cpyFlgazu8AH6KCQa0ok9s70ElaB6FEC85Al -----END RSA PRIVATE KEY----- diff --git a/mysql-test/std_data/untrusted-cacert.pem b/mysql-test/std_data/untrusted-cacert.pem new file mode 100644 index 00000000000..981dd004fc6 --- /dev/null +++ b/mysql-test/std_data/untrusted-cacert.pem @@ -0,0 +1,53 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 0 (0x0) + Signature Algorithm: md5WithRSAEncryption + Issuer: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com + Validity + Not Before: Jan 18 20:12:32 2005 GMT + Not After : Oct 15 20:12:32 2007 GMT + Subject: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (512 bit) + Modulus (512 bit): + 00:cf:2b:14:00:b0:3c:df:6f:9e:91:40:ec:c8:f6: + 90:b2:5b:b4:70:80:a5:a4:0a:73:c7:44:f3:2a:26: + c4:2f:f1:3a:f1:c3:c4:ac:fc:c3:d2:c3:bf:f5:d7: + 6a:38:42:ad:22:ab:c8:c4:4b:4c:1d:16:af:05:34: + 7d:79:97:5e:e1 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + CB:0F:1F:E9:A2:76:71:C9:E6:E8:23:A6:C1:18:B7:CC:44:CF:B9:84 + X509v3 Authority Key Identifier: + keyid:CB:0F:1F:E9:A2:76:71:C9:E6:E8:23:A6:C1:18:B7:CC:44:CF:B9:84 + DirName:/C=US/ST=Oregon/L=Portland/O=sawtooth/CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com + serial:00 + + X509v3 Basic Constraints: + CA:TRUE + Signature Algorithm: md5WithRSAEncryption + 27:f7:3d:fb:39:6f:73:a4:86:f3:a0:48:22:60:84:e9:5c:3d: + 28:36:05:16:44:98:07:87:e1:5d:b5:f3:a7:bc:33:5f:f4:29: + a9:5f:87:33:df:e6:8e:bd:e2:f3:0a:c8:00:69:ae:3d:41:47: + 03:ea:0b:4c:67:45:4b:ab:f3:39 +-----BEGIN CERTIFICATE----- +MIIC7zCCApmgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBiTELMAkGA1UEBhMCVVMx +DzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxhbmQxETAPBgNVBAoTCHNh +d3Rvb3RoMSQwIgYDVQQDExt3d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAb +BgkqhkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMB4XDTA1MDExODIwMTIzMloXDTA3 +MTAxNTIwMTIzMlowgYkxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZPcmVnb24xETAP +BgNVBAcTCFBvcnRsYW5kMREwDwYDVQQKEwhzYXd0b290aDEkMCIGA1UEAxMbd3d3 +LnNhd3Rvb3RoLWNvbnN1bHRpbmcuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlh +c3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDPKxQAsDzfb56RQOzI9pCy +W7RwgKWkCnPHRPMqJsQv8Trxw8Ss/MPSw7/112o4Qq0iq8jES0wdFq8FNH15l17h +AgMBAAGjgekwgeYwHQYDVR0OBBYEFMsPH+midnHJ5ugjpsEYt8xEz7mEMIG2BgNV +HSMEga4wgauAFMsPH+midnHJ5ugjpsEYt8xEz7mEoYGPpIGMMIGJMQswCQYDVQQG +EwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDERMA8GA1UE +ChMIc2F3dG9vdGgxJDAiBgNVBAMTG3d3dy5zYXd0b290aC1jb25zdWx0aW5nLmNv +bTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb22CAQAwDAYDVR0TBAUwAwEB +/zANBgkqhkiG9w0BAQQFAANBACf3Pfs5b3OkhvOgSCJghOlcPSg2BRZEmAeH4V21 +86e8M1/0KalfhzPf5o694vMKyABprj1BRwPqC0xnRUur8zk= +-----END CERTIFICATE----- diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 7cddb8bafa9..efe58579785 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -469,3 +469,16 @@ ALTER TABLE t1 MODIFY s BINARY(10); SELECT HEX(s) FROM t1; SELECT LENGTH(s) FROM t1; DROP TABLE t1; + +# +# Bug#19386: Multiple alter causes crashed table +# The trailing column would get corrupted data, or server could not even read +# it. +# + +CREATE TABLE t1 (v VARCHAR(3), b INT); +INSERT INTO t1 VALUES ('abc', 5); +SELECT * FROM t1; +ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/ansi.test b/mysql-test/t/ansi.test index 444bf982b8a..fa7f999954e 100644 --- a/mysql-test/t/ansi.test +++ b/mysql-test/t/ansi.test @@ -26,4 +26,16 @@ drop table t1; SET @@SQL_MODE=""; +# Bug#14515 + +CREATE TABLE t1 (i int auto_increment NOT NULL, PRIMARY KEY (i)); +SHOW CREATE TABLE t1; +SET @@SQL_MODE="MYSQL323"; +SHOW CREATE TABLE t1; +SET @@SQL_MODE="MYSQL40"; +SHOW CREATE TABLE t1; +SET @@SQL_MODE="NO_FIELD_OPTIONS"; +SHOW CREATE TABLE t1; +DROP TABLE t1; + # End of 4.1 tests diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index b20fe80303d..26b103b0107 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -219,7 +219,26 @@ INSERT INTO t1 (b) VALUES ('bbbb'); CHECK TABLE t1; DROP TABLE IF EXISTS t1; -# End of 4.1 tests +# BUG #19025: + +CREATE TABLE `t1` ( + t1_name VARCHAR(255) DEFAULT NULL, + t1_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + KEY (t1_name), + PRIMARY KEY (t1_id) +) AUTO_INCREMENT = 1000; + +INSERT INTO t1 (t1_name) VALUES('MySQL'); +INSERT INTO t1 (t1_name) VALUES('MySQL'); +INSERT INTO t1 (t1_name) VALUES('MySQL'); + +SELECT * from t1; + +SHOW CREATE TABLE `t1`; + +DROP TABLE `t1`; + +--echo End of 4.1 tests # # Bug #11080 & #11005 Multi-row REPLACE fails on a duplicate key error diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 2e1af51efa7..39a530ba733 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -280,3 +280,33 @@ select str_to_date( 1, NULL ); select str_to_date( NULL, 1 ); select str_to_date( 1, IF(1=1,NULL,NULL) ); # End of 4.1 tests + +# +# Bug#11326 +# TIME_FORMAT using "%r" returns wrong hour using 24:00:00 in TIME column +# +# This tests that 24:00:00 does not return PM, when it should be AM. +# Some other values are being tested same time. +# + +SELECT TIME_FORMAT("24:00:00", '%r'); +SELECT TIME_FORMAT("00:00:00", '%r'); +SELECT TIME_FORMAT("12:00:00", '%r'); +SELECT TIME_FORMAT("15:00:00", '%r'); +SELECT TIME_FORMAT("01:00:00", '%r'); +SELECT TIME_FORMAT("25:00:00", '%r'); + +# +# Bug#11324 +# TIME_FORMAT using "%l:%i" returns 36:00 with 24:00:00 in TIME column +# +# This tests that 24:00:00 does not change to "36:00 AM". Testing +# some other values same time. +# + +SELECT TIME_FORMAT("00:00:00", '%l %p'); +SELECT TIME_FORMAT("01:00:00", '%l %p'); +SELECT TIME_FORMAT("12:00:00", '%l %p'); +SELECT TIME_FORMAT("23:00:00", '%l %p'); +SELECT TIME_FORMAT("24:00:00", '%l %p'); +SELECT TIME_FORMAT("25:00:00", '%l %p'); diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index e29e51b8c2c..d6083ab8bfe 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -15,7 +15,7 @@ #events_scheduling : BUG#19170 2006-04-26 andrey Test case of 19170 fails on some platforms. Has to be checked. ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog -ndb_binlog_discover : BUG#19395 2006-04-28 tomas/knielsen mysqld does not always detect cluster shutdown +#ndb_binlog_discover : BUG#19395 2006-04-28 tomas/knielsen mysqld does not always detect cluster shutdown #ndb_cache2 : BUG#18597 2006-03-28 brian simultaneous drop table and ndb statistics update triggers node failure #ndb_cache_multi2 : BUG#18597 2006-04-10 kent simultaneous drop table and ndb statistics update triggers node failure ndb_load : BUG#17233 2006-05-04 tomas failed load data from infile causes mysqld dbug_assert, binlog not flushed @@ -35,7 +35,6 @@ rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed rpl_row_inexist_tbl : BUG#18948 2006-03-09 mats Disabled since patch makes this test wait forever rpl_sp : BUG#16456 2006-02-16 jmiller -udf : BUG#18564 2006-03-27 ian (Permission by Brian) # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open #ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 45bd0c7a51c..09f07c2852f 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -382,3 +382,19 @@ INSERT INTO t1 VALUES select count(distinct x,y) from t1; select count(distinct concat(x,y)) from t1; drop table t1; + +# +# Bug #18068: SELECT DISTINCT +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b)); + +INSERT INTO t1 VALUES (1, 101); +INSERT INTO t1 SELECT a + 1, a + 101 FROM t1; +INSERT INTO t1 SELECT a + 2, a + 102 FROM t1; +INSERT INTO t1 SELECT a + 4, a + 104 FROM t1; +INSERT INTO t1 SELECT a + 8, a + 108 FROM t1; + +EXPLAIN SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a; +SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a; + +DROP TABLE t1; diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 2a3a23c5f96..a38771db233 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -43,3 +43,12 @@ drop table ÔÁÂ; set names latin1; # End of 4.1 tests + + +# +# Bug#15463: EXPLAIN SELECT..INTO hangs the client (QB, command line) +# +select 3 into @v1; +explain select 3 into @v1; + +# End of 5.0 tests. diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index c667f90940c..fb9470c16dd 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -539,77 +539,6 @@ INSERT INTO t1 VALUES SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; DROP TABLE t1; -# -# Bug #12882 min/max inconsistent on empty table -# - ---disable_warnings -create table t1m (a int) engine=myisam; -create table t1i (a int) engine=innodb; -create table t2m (a int) engine=myisam; -create table t2i (a int) engine=innodb; ---enable_warnings -insert into t2m values (5); -insert into t2i values (5); - -# test with MyISAM -select min(a) from t1m; -select min(7) from t1m; -select min(7) from DUAL; -explain select min(7) from t2m join t1m; -select min(7) from t2m join t1m; - -select max(a) from t1m; -select max(7) from t1m; -select max(7) from DUAL; -explain select max(7) from t2m join t1m; -select max(7) from t2m join t1m; - -select 1, min(a) from t1m where a=99; -select 1, min(a) from t1m where 1=99; -select 1, min(1) from t1m where a=99; -select 1, min(1) from t1m where 1=99; - -select 1, max(a) from t1m where a=99; -select 1, max(a) from t1m where 1=99; -select 1, max(1) from t1m where a=99; -select 1, max(1) from t1m where 1=99; - -# test with InnoDB -select min(a) from t1i; -select min(7) from t1i; -select min(7) from DUAL; -explain select min(7) from t2i join t1i; -select min(7) from t2i join t1i; - -select max(a) from t1i; -select max(7) from t1i; -select max(7) from DUAL; -explain select max(7) from t2i join t1i; -select max(7) from t2i join t1i; - -select 1, min(a) from t1i where a=99; -select 1, min(a) from t1i where 1=99; -select 1, min(1) from t1i where a=99; -select 1, min(1) from t1i where 1=99; - -select 1, max(a) from t1i where a=99; -select 1, max(a) from t1i where 1=99; -select 1, max(1) from t1i where a=99; -select 1, max(1) from t1i where 1=99; - -# mixed MyISAM/InnoDB test -explain select count(*), min(7), max(7) from t1m, t1i; -select count(*), min(7), max(7) from t1m, t1i; - -explain select count(*), min(7), max(7) from t1m, t2i; -select count(*), min(7), max(7) from t1m, t2i; - -explain select count(*), min(7), max(7) from t2m, t1i; -select count(*), min(7), max(7) from t2m, t1i; - -drop table t1m, t1i, t2m, t2i; - # End of 4.1 tests # diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 351d1fc2c92..8ddf1fbe314 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -220,3 +220,15 @@ set @str=NULL; drop table t2; drop table t1; +# BUG#19618: Crash in range optimizer for +# "unsigned_keypart NOT IN(negative_number,...)" +# (introduced in fix BUG#15872) +create table t1 ( + some_id smallint(5) unsigned, + key (some_id) +); +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +select some_id from t1 where some_id not in(-4,-1,-4); +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +drop table t1; diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 4a618a56483..0475dd4bdb6 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -38,6 +38,46 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) ); drop table t1; + +# +# Bug#16501: IS_USED_LOCK does not appear to work +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (conn CHAR(7), connection_id INT); +INSERT INTO t1 VALUES ('default', CONNECTION_ID()); + +SELECT GET_LOCK('bug16501',600); + +connect (con1,localhost,root,,); +INSERT INTO t1 VALUES ('con1', CONNECTION_ID()); +SELECT IS_USED_LOCK('bug16501') = connection_id +FROM t1 +WHERE conn = 'default'; +send SELECT GET_LOCK('bug16501',600); + +connection default; +SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID(); +SELECT RELEASE_LOCK('bug16501'); +connection con1; +reap; +connection default; +SELECT IS_USED_LOCK('bug16501') = connection_id +FROM t1 +WHERE conn = 'con1'; + +connection con1; +SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID(); +SELECT RELEASE_LOCK('bug16501'); +SELECT IS_USED_LOCK('bug16501'); + +disconnect con1; +connection default; + +DROP TABLE t1; + # End of 4.1 tests # diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 85cedee0f4a..7f809dbc4a1 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -666,7 +666,14 @@ select rpad(i, 7, ' ') as t from t1; --disable_metadata drop table t1; -# End of 4.1 tests +# +# Bug #10418: LOAD_FILE does not behave like in manual if file does not exist +# + +select load_file("lkjlkj"); +select ifnull(load_file("lkjlkj"),"it's null"); + +--echo End of 4.1 tests # # Bug #13361: SELECT FORMAT(<decimal field with null>, 2) crashes @@ -691,4 +698,10 @@ select cast(rtrim(' 20.06 ') as decimal(19,2)); select cast(ltrim(' 20.06 ') as decimal(19,2)); select cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2)); +# +# Bug #13975: "same string" + 0 has 2 different results +# +select conv("18383815659218730760",10,10) + 0; +select "18383815659218730760" + 0; + --echo End of 5.0 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 4e4fb8f777a..5c993028cb4 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -352,12 +352,6 @@ INSERT INTO t1 VALUES (NOW()); SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAYS(@TMP)+1); DROP TABLE t1; - -# End of 4.1 tests - -explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, - timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; - # # Bug #10568 # @@ -367,6 +361,18 @@ select last_day('2005-00-01'); select last_day('2005-01-00'); # +# Bug #18501: monthname and NULLs +# + +select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')), + monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m')); + +--echo End of 4.1 tests + +explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, + timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; + +# # Bug #10590: %h, %I, and %l format specifies should all return results in # the 0-11 range # @@ -468,4 +474,23 @@ SELECT * FROM t1, t2 DROP TABLE t1,t2; -# End of 5.0 tests +--echo End of 5.0 tests + +# +# Bug #18997 +# + +select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND); +select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND); +select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND); +select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND); +select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR); +select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND); + + +--echo End of 5.1 tests diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index bff07366ec2..d9836ccc8df 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -782,3 +782,19 @@ SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0; DROP TABLE t1; DROP PROCEDURE a; + +# +# Bug #18068: SELECT DISTINCT +# + +CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a)); + +INSERT INTO t1 (a) VALUES + (''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'), + ('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'), + ('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN'); + +EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a; +SELECT DISTINCT a,a FROM t1 ORDER BY a; + +DROP TABLE t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index b7151b03ae1..274b4eae71f 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -797,15 +797,6 @@ DROP VIEW v1; DROP FUNCTION func1; DROP FUNCTION func2; -# -# Bug #15851 Unlistable directories yield no info from information_schema -# -create database mysqltest; -create table mysqltest.t1(a int); ---exec chmod -r $MYSQLTEST_VARDIR/master-data/mysqltest -select table_schema from information_schema.tables where table_schema='mysqltest'; ---exec chmod +r $MYSQLTEST_VARDIR/master-data/mysqltest -drop database mysqltest; # # Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema @@ -817,6 +808,26 @@ table_schema='information_schema' and group by column_type order by num; # +# Bug#19236 bad COLUMNS.CHARACTER_MAXIMUM_LENGHT and CHARACTER_OCTET_LENGTH +# +create table t1(f1 char(1) not null, f2 char(9) not null) +default character set utf8; +select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from +information_schema.columns where table_schema='test' and table_name = 't1'; +drop table t1; + +# +# Bug#18177 any access to INFORMATION_SCHEMA.ROUTINES crashes +# +use mysql; +INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL', +'NO','DEFINER','','','BEGIN\r\n \r\nEND','root@%','2006-03-02 18:40:03', +'2006-03-02 18:40:03','',''); +select routine_name from information_schema.routines; +delete from proc where name=''; +use test; + +# # End of 5.0 tests. # # Show engines diff --git a/mysql-test/t/information_schema_chmod.test b/mysql-test/t/information_schema_chmod.test new file mode 100644 index 00000000000..fb850b8e38d --- /dev/null +++ b/mysql-test/t/information_schema_chmod.test @@ -0,0 +1,20 @@ +# +# Due to "Bug#18474 Unlistable directories yield no info from +# information_schema, part2" this test can't be run on Window with our +# current test framework. When "chmod -r" is done within cygwin the +# MySQL Server can still read the directory. +# Manual testing shows the functionalty to skip unlistable directories +# works on windows +# +--source include/not_windows.inc + + +# +# Bug #15851 Unlistable directories yield no info from information_schema +# +create database mysqltest; +create table mysqltest.t1(a int); +--exec chmod -r $MYSQLTEST_VARDIR/master-data/mysqltest +select table_schema from information_schema.tables where table_schema='mysqltest'; +--exec chmod +r $MYSQLTEST_VARDIR/master-data/mysqltest +drop database mysqltest; diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index b942b9fbc0d..3de55e1c403 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -1,5 +1,131 @@ -- source include/have_innodb.inc --disable_warnings -drop table if exists t1; +drop table if exists t1,t2; --enable_warnings + +# BUG#16798: Uninitialized row buffer reads in ref-or-null optimizer +# (repeatable only w/innodb). +create table t1 ( + c_id int(11) not null default '0', + org_id int(11) default null, + unique key contacts$c_id (c_id), + key contacts$org_id (org_id) +) engine=innodb; +insert into t1 values + (2,null),(120,null),(141,null),(218,7), (128,1), + (151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3), + (246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4); + +create table t2 ( + slai_id int(11) not null default '0', + owner_tbl int(11) default null, + owner_id int(11) default null, + sla_id int(11) default null, + inc_web int(11) default null, + inc_email int(11) default null, + inc_chat int(11) default null, + inc_csr int(11) default null, + inc_total int(11) default null, + time_billed int(11) default null, + activedate timestamp null default null, + expiredate timestamp null default null, + state int(11) default null, + sla_set int(11) default null, + unique key t2$slai_id (slai_id), + key t2$owner_id (owner_id), + key t2$sla_id (sla_id) +) engine=innodb; +insert into t2(slai_id, owner_tbl, owner_id, sla_id) values + (1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7), + (8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12); + +flush tables; +select si.slai_id +from t1 c join t2 si on + ((si.owner_tbl = 3 and si.owner_id = c.org_id) or + ( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where + c.c_id = 218 and expiredate is null; + +select * from t1 where org_id is null; +select si.slai_id +from t1 c join t2 si on + ((si.owner_tbl = 3 and si.owner_id = c.org_id) or + ( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where + c.c_id = 218 and expiredate is null; + +drop table t1, t2; + +# +# Bug #12882 min/max inconsistent on empty table +# + +--disable_warnings +create table t1m (a int) engine=myisam; +create table t1i (a int) engine=innodb; +create table t2m (a int) engine=myisam; +create table t2i (a int) engine=innodb; +--enable_warnings +insert into t2m values (5); +insert into t2i values (5); + +# test with MyISAM +select min(a) from t1m; +select min(7) from t1m; +select min(7) from DUAL; +explain select min(7) from t2m join t1m; +select min(7) from t2m join t1m; + +select max(a) from t1m; +select max(7) from t1m; +select max(7) from DUAL; +explain select max(7) from t2m join t1m; +select max(7) from t2m join t1m; + +select 1, min(a) from t1m where a=99; +select 1, min(a) from t1m where 1=99; +select 1, min(1) from t1m where a=99; +select 1, min(1) from t1m where 1=99; + +select 1, max(a) from t1m where a=99; +select 1, max(a) from t1m where 1=99; +select 1, max(1) from t1m where a=99; +select 1, max(1) from t1m where 1=99; + +# test with InnoDB +select min(a) from t1i; +select min(7) from t1i; +select min(7) from DUAL; +explain select min(7) from t2i join t1i; +select min(7) from t2i join t1i; + +select max(a) from t1i; +select max(7) from t1i; +select max(7) from DUAL; +explain select max(7) from t2i join t1i; +select max(7) from t2i join t1i; + +select 1, min(a) from t1i where a=99; +select 1, min(a) from t1i where 1=99; +select 1, min(1) from t1i where a=99; +select 1, min(1) from t1i where 1=99; + +select 1, max(a) from t1i where a=99; +select 1, max(a) from t1i where 1=99; +select 1, max(1) from t1i where a=99; +select 1, max(1) from t1i where 1=99; + +# mixed MyISAM/InnoDB test +explain select count(*), min(7), max(7) from t1m, t1i; +select count(*), min(7), max(7) from t1m, t1i; + +explain select count(*), min(7), max(7) from t1m, t2i; +select count(*), min(7), max(7) from t1m, t2i; + +explain select count(*), min(7), max(7) from t2m, t1i; +select count(*), min(7), max(7) from t2m, t1i; + +drop table t1m, t1i, t2m, t2i; + diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index c194213e0c9..dc4e240750c 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -779,3 +779,47 @@ SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%' OR FALSE; DROP TABLE t1,t2; + +# +# Bug 19396: LEFT OUTER JOIN over views in curly braces +# +--disable_warnings +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +--enable_warnings + +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); + +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; + +SELECT v1.a, v2. b + FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) + GROUP BY v1.a; +SELECT v1.a, v2. b + FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } + GROUP BY v1.a; + +DROP VIEW v1,v2; +DROP TABLE t1,t2; + +# +# Bug 19816: LEFT OUTER JOIN with constant ORed predicates in WHERE clause +# + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); + +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); + +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); + +DROP TABLE t1,t2; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 9fe7bb787cb..9fee4a03b81 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -382,3 +382,15 @@ check table t1, t2; drop table t1, t2, t3; # End of 4.1 tests + +# +# BUG#10952 - alter table ... lost data without errors and warnings +# +drop table if exists t1; +create table t1 (c char(20)) engine=MyISAM; +insert into t1 values ("Monty"),("WAX"),("Walrus"); +--error 1031 +alter table t1 engine=MERGE; +drop table t1; + +# End of 5.0 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 87a00399c23..a77537f3ff5 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -811,13 +811,6 @@ drop table t1, t2, t3; # Test of key_block_size # -# Old format, to be obsolete in 5.3 -create table t1 (a int not null, key `a` key_block_size=1024 (a)); -show create table t1; -drop table t1; - -set @@new=1; - create table t1 (a int not null, key `a` (a) key_block_size=1024); show create table t1; drop table t1; @@ -874,5 +867,6 @@ drop table t1; --error 1064 create table t1 (a int not null, key key_block_size=1024 (a)); +--error 1064 +create table t1 (a int not null, key `a` key_block_size=1024 (a)); -set @@new=0; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index e76553f42e7..ac4c323f51e 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -72,3 +72,11 @@ drop table t1; # --exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;" +# +# Bug#19564: mysql displays NULL instead of space +# +--exec $MYSQL -t test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;" + +--echo End of 5.0 tests + + diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 1bede1d5c9a..b76a5103120 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -124,9 +124,22 @@ select HEX(f) from t3; select HEX(f) from t04; select HEX(f) from t4; +# +# BUG#14157: utf8 encoding in binlog without set character_set_client +# +# BUG: +# This test only works on the MySQL-internal rpl machines. +# Needs to be fixed. Problem is that koi8r is not installed +# on many machines. +# +flush logs; +# --exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=koi8r test -e 'create table if not exists t5 (a int); set names koi8r; create temporary table `ÑÝÉË` (a int); insert into `ÑÝÉË` values (1); insert into t5 select * from `ÑÝÉË`' +# resulted log is client charset insensitive (latin1 not koi8r) as it must be +# --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 | $MYSQL --default-character-set=latin1 +#select * from t5 /* must be (1),(1) */; # clean up drop table t1, t2, t03, t04, t3, t4; -# End of 4.1 tests +# End of 5.0 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index c5c3f88d8c8..732a3ce89da 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -713,6 +713,35 @@ select * from t1; drop table t1; # +# BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]" +# +create table `t1` ( + t1_name varchar(255) default null, + t1_id int(10) unsigned not null auto_increment, + key (t1_name), + primary key (t1_id) +) auto_increment = 1000 default charset=latin1; + +insert into t1 (t1_name) values('bla'); +insert into t1 (t1_name) values('bla'); +insert into t1 (t1_name) values('bla'); + +select * from t1; + +show create table `t1`; + +--exec $MYSQL_DUMP --skip-comments test t1 > $MYSQLTEST_VARDIR/tmp/bug19025.sql +DROP TABLE `t1`; + +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug19025.sql + +select * from t1; + +show create table `t1`; + +drop table `t1`; + +--echo End of 4.1 tests # Bug #13318: Bad result with empty field and --hex-blob # create table t1 (a binary(1), b blob); @@ -721,7 +750,6 @@ insert into t1 values ('',''); --exec $MYSQL_DUMP --skip-comments --hex-blob test t1 drop table t1; -# End of 4.1 tests # # dump of view @@ -1158,7 +1186,7 @@ select * from words2; # Drop table "words" and run with threads, should fail drop table words; ---replace_regex /.*mysqlimport/mysql-import/ +--replace_regex /.*mysqlimport(\.exe)*/mysql-import/ --error 1 --exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data_ln/words.dat $MYSQLTEST_VARDIR/std_data_ln/words2.dat 2>&1 diff --git a/mysql-test/t/ndb_autodiscover3.test b/mysql-test/t/ndb_autodiscover3.test new file mode 100644 index 00000000000..ed75c89cdd1 --- /dev/null +++ b/mysql-test/t/ndb_autodiscover3.test @@ -0,0 +1,76 @@ +-- source include/have_ndb.inc +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +# +# Transaction ongoing while cluster is restarted +# +--connection server1 +create table t1 (a int key) engine=ndbcluster; + +begin; +insert into t1 values (1); + +--exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT + +--error 1297 +insert into t1 values (2); +--error 1296 +commit; + +drop table t1; + +# +# Stale cache after restart -i +# +--connection server1 +create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster; +insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1); +select * from t2 order by a limit 3; + +--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT +# to ensure mysqld has connected again, and recreated system tables +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -r 30 -d cluster apply_status >> $NDB_TOOLS_OUTPUT + +--connection server2 +--error ER_NO_SUCH_TABLE +select * from t2; +show tables like 't2'; +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; + +# server 1 should have a stale cache, and in this case wrong frm, transaction must be retried +--connection server1 +select * from t2 order by a limit 3; +reset master; + +--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT +# to ensure mysqld has connected again, and recreated system tables +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -r 30 -d cluster apply_status >> $NDB_TOOLS_OUTPUT + +--connection server1 +--error ER_NO_SUCH_TABLE +select * from t2; +show tables like 't2'; +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; + +# server 2 should have a stale cache, but with right frm, transaction need not be retried +--connection server2 +select * from t2 order by a limit 3; +reset master; + +drop table t2; +# End of 4.1 tests diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index bf82a793049..d6e0edc89f0 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -428,4 +428,60 @@ truncate t1; select count(*) from t1; drop table t1; +# -- bug#19956 - var* key, complex key + +create table t1 ( + a varchar(40) not null, + b mediumint not null, + t text, + c varchar(2) not null, + d bigint not null, + primary key (a,b,c), + key (c,a), + unique key (d) +) engine=ndb; + +--disable_query_log +set @s1 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau'; +set @s2 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz'; +set @s3 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah'; +set @v1 = repeat(@s1,123); +set @v2 = repeat(@s2,234); +set @v3 = repeat(@s3,345); +set @v4 = NULL; +--enable_query_log + +insert into t1 (a,b,c,d,t) values ('a',1110,'a',1,@v1); +insert into t1 (a,b,c,d,t) values ('b',1110,'a',2,@v2); +insert into t1 (a,b,c,d,t) values ('a',1110,'b',3,@v3); +insert into t1 (a,b,c,d,t) values ('b',1110,'b',4,@v4); +select a,b,c,d,sha1(t) from t1 order by c,a; + +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='a'; +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='b'; + +update t1 set t=@v4 where a='b' and b=1110 and c='a'; +update t1 set t=@v2 where a='b' and b=1110 and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; + +update t1 set t=@v2 where d=2; +update t1 set t=@v4 where d=4; +select a,b,c,d,sha1(t) from t1 order by c,a; + +update t1 set t=@v4 where a='b' and c='a'; +update t1 set t=@v2 where a='b' and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; + +update t1 set t=@v2 where b+d=1112; +update t1 set t=@v4 where b+d=1114; +select a,b,c,d,sha1(t) from t1 order by c,a; + +delete from t1 where a='a' and b=1110 and c='a'; +delete from t1 where a='b' and c='a'; +delete from t1 where d=3; +delete from t1 where b+d=1114; +select count(*) from t1; + +drop table t1; + # End of 4.1 tests diff --git a/mysql-test/t/ndb_blob_partition.test b/mysql-test/t/ndb_blob_partition.test deleted file mode 100644 index a3948cc9491..00000000000 --- a/mysql-test/t/ndb_blob_partition.test +++ /dev/null @@ -1,93 +0,0 @@ ---source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# -# Minimal NDB blobs test with range partitions. -# - -create table t1 ( - a mediumint not null, - b text not null, - c int not null, - d longblob, - primary key using hash (a,c), - unique key (c) -) - engine=ndb - partition by range (c) - partitions 3 - ( partition p1 values less than (200), - partition p2 values less than (300), - partition p3 values less than (400)); - ---disable_query_log -sleep 1; - -# length 61 -set @s0 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau'; -set @s1 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz'; -set @s2 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah'; - -set @v1 = repeat(@s0, 100); -- 1d42dd9090cf78314a06665d4ea938c35cc760f4 -set @v2 = repeat(@s1, 200); -- 10d3c783026b310218d10b7188da96a2401648c6 -set @v3 = repeat(@s2, 300); -- a33549d9844092289a58ac348dd59f09fc28406a -set @v4 = repeat(@s0, 400); -- daa61c6de36a0526f0d47dc29d6b9de7e6d2630c -set @v5 = repeat(@s1, 500); -- 70fc9a7d08beebc522258bfb02000a30c77a8f1d -set @v6 = repeat(@s2, 600); -- 090565c580809efed3d369481a4bbb168b20713e -set @v7 = repeat(@s0, 700); -- 1e0070bec426871a46291de27b9bd6e4255ab4e5 -set @v8 = repeat(@s1, 800); -- acbaba01bc2e682f015f40e79d9cbe475db3002e -set @v9 = repeat(@s2, 900); -- 9ee30d99162574f79c66ae95cdf132dcf9cbc259 ---enable_query_log - -# -- insert -- -insert into t1 values (1, @v1, 101, @v2); -insert into t1 values (1, @v2, 102, @v3); -insert into t1 values (1, @v3, 103, @v4); -insert into t1 values (2, @v4, 201, @v5); -insert into t1 values (2, @v5, 202, @v6); -insert into t1 values (2, @v6, 203, @v7); -insert into t1 values (3, @v7, 301, @v8); -insert into t1 values (3, @v8, 302, @v9); -insert into t1 values (3, @v9, 303, @v1); -select a, sha1(b), c, sha1(d) from t1 order by a; - -# -- pk read -- -select a, sha1(b), c, sha1(d) from t1 where a = 1 and c = 101; -select a, sha1(b), c, sha1(d) from t1 where a = 2 and c = 201; -select a, sha1(b), c, sha1(d) from t1 where a = 3 and c = 301; - -# -- pk update -- -update t1 set b = @v3, d = @v4 where a = 1 and c = 102; -update t1 set b = @v6, d = @v7 where a = 2 and c = 202; -update t1 set b = @v9, d = @v1 where a = 3 and c = 302; -select a, sha1(b), c, sha1(d) from t1 order by a; - -# -- hash index update -- -update t1 set b = @v4, d = @v5 where c = 103; -update t1 set b = @v7, d = @v8 where c = 203; -update t1 set b = @v1, d = @v2 where c = 303; -select a, sha1(b), c, sha1(d) from t1 order by a; - -# -- full scan update -- -update t1 set b = @v5, d = @v6; -select a, sha1(b), c, sha1(d) from t1 order by a; - -# -- range scan update -update t1 set b = @v1, d = @v2 where 100 < c and c < 200; -update t1 set b = @v4, d = @v5 where 200 < c and c < 300; -update t1 set b = @v7, d = @v8 where 300 < c and c < 400; -select a, sha1(b), c, sha1(d) from t1 order by a; - -# -- delete -- -delete from t1 where a = 1 and c = 101; -delete from t1 where c = 102; -# delete from t1 where c < 300; # XXX coredump -delete from t1; -select a, sha1(b), c, sha1(d) from t1 order by a; - -# -- clean up -- -drop table t1; diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test index 44740c1a486..3b53f7b3431 100644 --- a/mysql-test/t/ndb_condition_pushdown.test +++ b/mysql-test/t/ndb_condition_pushdown.test @@ -1649,5 +1649,42 @@ set engine_condition_pushdown = on; explain select * from t5 where b like '%jo%'; select * from t5 where b like '%jo%' order by a; +# bug#17421 -1 +drop table t1; +create table t1 (a int, b varchar(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +# in TUP the constants 'ab' 'abc' were expected in varchar format +# "like" returned error which became "false" +# scan filter negates "or" which exposes the bug +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; + +# bug#17421 -2 +drop table t1; +create table t1 (a int, b char(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +# test that incorrect MySQL behaviour is preserved +# 'ab ' LIKE 'ab' is true in MySQL +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; + set engine_condition_pushdown = @old_ecpd; DROP TABLE t1,t2,t3,t4,t5; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 700ff55c2d5..a40efc8a40c 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -72,7 +72,7 @@ CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, b int unsigned not null, c int unsigned not null, - UNIQUE USING HASH (b, c) + UNIQUE (b, c) USING HASH ) engine=ndbcluster; insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); @@ -96,7 +96,7 @@ CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, b int unsigned not null, c int unsigned, - UNIQUE USING HASH (b, c) + UNIQUE (b, c) USING HASH ) engine=ndbcluster; # @@ -107,7 +107,7 @@ CREATE TABLE t3 ( a int unsigned NOT NULL, b int unsigned not null, c int unsigned, - PRIMARY KEY USING HASH (a, b) + PRIMARY KEY (a, b) USING HASH ) engine=ndbcluster; insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); diff --git a/mysql-test/t/ndb_partition_error.test b/mysql-test/t/ndb_partition_error.test deleted file mode 100644 index 06581f1270f..00000000000 --- a/mysql-test/t/ndb_partition_error.test +++ /dev/null @@ -1,71 +0,0 @@ --- source include/have_ndb.inc -#--disable_abort_on_error -# -# Simple test for the partition storage engine -# Focuses on range partitioning tests -# -#-- source include/have_partition.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# -# Partition by range, generate node group error -# ---error 1005 -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(a,b), -index (a)) -engine = ndb -partition by range (a) -partitions 3 -(partition x1 values less than (5) nodegroup 12, - partition x2 values less than (10) nodegroup 13, - partition x3 values less than (20) nodegroup 14); -show warnings; - -# -# Partition by range, create normal valid table -# -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(a)) -engine = ndb -partition by range (a) -partitions 3 -(partition x1 values less than (5), - partition x2 values less than (10), - partition x3 values less than (20)); - -drop table t1; - -# -# Bug #17763 mysqld cores with list partitioning if update to missing partition -# -CREATE TABLE t1 (id INT) ENGINE=NDB - PARTITION BY LIST(id) - (PARTITION p0 VALUES IN (2, 4), - PARTITION p1 VALUES IN (42, 142)); -INSERT INTO t1 VALUES (2); ---error ER_NO_PARTITION_FOR_GIVEN_VALUE -UPDATE t1 SET id=5 WHERE id=2; -DROP TABLE t1; - -# -# NULL for LIST partition -# -create table t1 (a int,b int, c int) -engine = ndb -partition by list(a) -partitions 2 -(partition x123 values in (11, 12), - partition x234 values in (5, 1)); ---error ER_NO_PARTITION_FOR_GIVEN_VALUE -insert into t1 values (NULL,1,1); -drop table t1; diff --git a/mysql-test/t/ndb_partition_key.test b/mysql-test/t/ndb_partition_key.test deleted file mode 100644 index ce939663ab8..00000000000 --- a/mysql-test/t/ndb_partition_key.test +++ /dev/null @@ -1,198 +0,0 @@ --- source include/have_ndb.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -# -# Basic syntax test -# - -# Support for partition key verified -CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b,c)) - ENGINE = NDB - PARTITION BY KEY (a,b); - -insert into t1 values (1,1,1,1); -select * from t1; -update t1 set d = 2 where a = 1 and b = 1 and c = 1; -select * from t1; -delete from t1; -select * from t1; - -drop table t1; - -# only support for partition key on primary key ---error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF -CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b)) - ENGINE = NDB - PARTITION BY KEY (c); - -CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b)) - ENGINE = NDB - PARTITION BY KEY (a); - -insert into t1 values - (1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3), - (1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3); - -select * from t1 order by b; - -DROP TABLE t1; - -# -# Test partition and char support -# - -CREATE TABLE t1 (a INT, b CHAR(10) COLLATE latin1_bin, c INT, d INT, - PRIMARY KEY USING HASH (a,b,c)) - ENGINE=NDB - DEFAULT CHARSET=latin1 - PARTITION BY KEY (b); - -insert into t1 values (1,"a",1,1),(2,"a",1,1),(3,"a",1,1); - -# should show only one attribute with DISTRIBUTION KEY ---exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | sed 's/Version: [0-9]*//' | sed 's/\(Length of frm data: \)[0-9]*/\1#/' - -# -# Test that explicit partition info is not shown in show create table -# result should not contain (PARTITION P0 ... etc) since this is what shows up in -# mysqldump, and we don't want that info there -# -show create table t1; - -DROP TABLE t1; - -# -# Bug #13155: Problem in Create Table using SHOW CREATE TABLE syntax -# -CREATE TABLE t1 (a int not null primary key) -PARTITION BY KEY(a) -(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); - -drop table t1; - -CREATE TABLE t1 (a int not null primary key); -ALTER TABLE t1 -PARTITION BY KEY(a) -(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); - -drop table t1; - -# -# Bug #17754 Improper handling of removal of partitioning in ALTER TABLE -# Also added a number of general test cases in the same area -# -create table t1 (a int) -engine=ndb -partition by key(a) -(partition p0, partition p1); -show create table t1; - -alter table t1 engine=heap; -show create table t1; - -alter table t1 engine=ndb; -show create table t1; - -alter table t1 engine=heap remove partitioning; -show create table t1; - -alter table t1 engine=ndb -partition by key(a) -(partition p0, partition p1 engine = ndb); -show create table t1; - -alter table t1 -partition by key (a) -(partition p0 engine=ndb, partition p1 engine=ndb); -show create table t1; - -alter table t1 remove partitioning; -show create table t1; - ---error ER_MIX_HANDLER_ERROR -alter table t1 -partition by key(a) -(partition p0 engine=ndb, partition p1); - -alter table t1 -engine=ndb -partition by key(a) -(partition p0 engine=ndb, partition p1 engine = ndb); -show create table t1; - -drop table t1; - -# -# BUG 16810 Out of memory when coalesce partition -# -CREATE TABLE t1 ( - c1 MEDIUMINT NOT NULL AUTO_INCREMENT, - c2 TEXT NOT NULL, - c3 INT NOT NULL, - c4 BIT NOT NULL, - c5 FLOAT, - c6 VARCHAR(255), - c7 TIMESTAMP, - PRIMARY KEY(c1,c3)) - ENGINE=NDB - PARTITION BY KEY(c3) PARTITIONS 5; - -let $j= 11; ---disable_query_log -while ($j) -{ - eval INSERT INTO t1 VALUES (NULL, "Tested Remotely from Texas, USA", $j, -b'0', - $j.00,"By JBM $j","2006-01-26"); - dec $j; -} ---enable_query_log -ALTER TABLE t1 COALESCE PARTITION 4; - -DROP TABLE t1; - -# -# Bug 16822: OPTIMIZE TABLE hangs test -# -CREATE TABLE t1 (a int primary key) -ENGINE=NDB -PARTITION BY KEY(a); ---error 1031 -ALTER TABLE t1 OPTIMIZE PARTITION p0; ---error 1031 -ALTER TABLE t1 CHECK PARTITION p0; ---error 1031 -ALTER TABLE t1 REPAIR PARTITION p0; ---error 1031 -ALTER TABLE t1 ANALYZE PARTITION p0; ---error 1031 -ALTER TABLE t1 REBUILD PARTITION p0; -DROP TABLE t1; - -# -# BUG 16806: ALTER TABLE fails -# -CREATE TABLE t1 ( - c1 MEDIUMINT NOT NULL AUTO_INCREMENT, - c2 TEXT NOT NULL, - c3 INT NOT NULL, - PRIMARY KEY(c1,c3)) - ENGINE=NDB - PARTITION BY KEY(c3) PARTITIONS 5; - -ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; -DROP TABLE t1; - -CREATE TABLE t1 ( - c1 MEDIUMINT NOT NULL AUTO_INCREMENT, - c2 TEXT NOT NULL, - c3 INT NOT NULL, - PRIMARY KEY(c1,c3)) - ENGINE=NDB - PARTITION BY KEY(c3); - -ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; -DROP TABLE t1; diff --git a/mysql-test/t/ndb_partition_list.test b/mysql-test/t/ndb_partition_list.test deleted file mode 100644 index 2ad37b8768c..00000000000 --- a/mysql-test/t/ndb_partition_list.test +++ /dev/null @@ -1,64 +0,0 @@ ---source include/have_ndb.inc -# -# Simple test for the partition storage engine -# Focuses on range partitioning tests -# -#-- source include/have_partition.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# -# Partition by list, basic -# - -CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL, - f_char1 CHAR(10), - f_char2 CHAR(10), f_charbig VARCHAR(1000), -PRIMARY KEY (f_int1,f_int2)) -ENGINE = NDB -PARTITION BY LIST(MOD(f_int1 + f_int2,4)) -(PARTITION part_3 VALUES IN (-3), - PARTITION part_2 VALUES IN (-2), - PARTITION part_1 VALUES IN (-1), - PARTITION part0 VALUES IN (0), - PARTITION part1 VALUES IN (1), - PARTITION part2 VALUES IN (2), - PARTITION part3 VALUES IN (3,4,5)); - -INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; -INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; - -SELECT * FROM t1 ORDER BY f_int1; - -DROP TABLE t1; - -# -# Partition by list, no pk -# - -CREATE TABLE t1 ( f_int1 INTEGER, f_int2 INTEGER, f_char1 CHAR(10), - f_char2 CHAR(10), f_charbig VARCHAR(1000)) -ENGINE = NDB -PARTITION BY LIST(f_int1) -(PARTITION part_1 VALUES IN (-1), - PARTITION part0 VALUES IN (0,1), - PARTITION part1 VALUES IN (2)); - -INSERT INTO t1 SET f_int1 = -1, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; -INSERT INTO t1 SET f_int1 = 0, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; -INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; -INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; ---error ER_NO_PARTITION_FOR_GIVEN_VALUE -INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; - -SELECT * FROM t1 ORDER BY f_int1; - -DROP TABLE t1; - diff --git a/mysql-test/t/ndb_partition_range.test b/mysql-test/t/ndb_partition_range.test deleted file mode 100644 index 981467d4055..00000000000 --- a/mysql-test/t/ndb_partition_range.test +++ /dev/null @@ -1,260 +0,0 @@ --- source include/have_ndb.inc -#--disable_abort_on_error -# -# Simple test for the partition storage engine -# Focuses on range partitioning tests -# -#-- source include/have_partition.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# -# Partition by range, basic -# -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(a,b), -index (a)) -engine = ndb -partition by range (a) -partitions 3 -(partition x1 values less than (5), - partition x2 values less than (10), - partition x3 values less than (20)); - -# Simple insert and verify test -INSERT into t1 values (1, 1, 1); -INSERT into t1 values (6, 1, 1); -INSERT into t1 values (10, 1, 1); -INSERT into t1 values (15, 1, 1); - ---replace_column 16 # 19 # 20 # -select * from information_schema.partitions where table_name= 't1'; - -select * from t1 order by a; - -select * from t1 where a=1 order by a; -select * from t1 where a=15 and b=1 order by a; -select * from t1 where a=21 and b=1 order by a; -select * from t1 where a=21 order by a; -select * from t1 where a in (1,6,10,21) order by a; -select * from t1 where b=1 and a in (1,6,10,21) order by a; - -drop table t1; - -# -# Partition by range, basic -# -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null, -primary key(b), -unique (a)) -engine = ndb -partition by range (b) -partitions 3 -(partition x1 values less than (5), - partition x2 values less than (10), - partition x3 values less than (20)); - -# Simple insert and verify test -INSERT into t1 values (1, 1, 1); -INSERT into t1 values (2, 6, 1); -INSERT into t1 values (3, 10, 1); -INSERT into t1 values (4, 15, 1); - -select * from t1 order by a; -UPDATE t1 set a = 5 WHERE b = 15; -select * from t1 order by a; -UPDATE t1 set a = 6 WHERE a = 5; -select * from t1 order by a; - -select * from t1 where b=1 order by b; -select * from t1 where b=15 and a=1 order by b; -select * from t1 where b=21 and a=1 order by b; -select * from t1 where b=21 order by b; -select * from t1 where b in (1,6,10,21) order by b; -select * from t1 where a in (1,2,5,6) order by b; -select * from t1 where a=1 and b in (1,6,10,21) order by b; - -DELETE from t1 WHERE b = 6; -DELETE from t1 WHERE a = 6; - -# -# Test that explicit partition info _is_ shown in show create table -# result _should_ contain (PARTITION x1 ... etc) -# -show create table t1; - -drop table t1; - -# -# Bug #17499, #17687 -# Alter partitioned NDB table causes mysqld to core -# - -CREATE TABLE t1 - (id MEDIUMINT NOT NULL, - b1 BIT(8), - vc VARCHAR(255), - bc CHAR(255), - d DECIMAL(10,4) DEFAULT 0, - f FLOAT DEFAULT 0, - total BIGINT UNSIGNED, - y YEAR, - t DATE) ENGINE=NDB - PARTITION BY RANGE (YEAR(t)) - (PARTITION p0 VALUES LESS THAN (1901), - PARTITION p1 VALUES LESS THAN (1946), - PARTITION p2 VALUES LESS THAN (1966), - PARTITION p3 VALUES LESS THAN (1986), - PARTITION p4 VALUES LESS THAN (2005), - PARTITION p5 VALUES LESS THAN MAXVALUE); - -INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); -SELECT * FROM t1; -ALTER TABLE t1 ENGINE=MYISAM; -SELECT * FROM t1; -DROP TABLE t1; - -CREATE LOGFILE GROUP lg1 - ADD UNDOFILE 'undofile.dat' - INITIAL_SIZE 16M - UNDO_BUFFER_SIZE=1M - ENGINE=NDB; - -CREATE TABLESPACE ts1 - ADD DATAFILE 'datafile.dat' - USE LOGFILE GROUP lg1 - INITIAL_SIZE 12M - ENGINE NDB; - -CREATE TABLE test.t1 ( - a1 INT, - a2 TEXT NOT NULL, - a3 BIT NOT NULL, - a4 DECIMAL(8,3), - a5 INT NOT NULL, - a6 INT, - PRIMARY KEY(a1)) - TABLESPACE ts1 STORAGE DISK ENGINE=NDB - PARTITION BY LIST (a1) - (PARTITION p0 VALUES IN (1,2,3,4,5), - PARTITION p1 VALUES IN (6,7,8,9, 10), - PARTITION p2 VALUES IN (11, 12, 13, 14, 15)); - -# Alter table directly without any statements inbetween -ALTER TABLE test.t1 DROP COLUMN a6; -ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255); - -let $j= 15; ---disable_query_log -while ($j) -{ -eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA", -b'1',$j.00,$j+1,"By NIK $j"); -dec $j; -} ---enable_query_log -SELECT COUNT(*) FROM test.t1; - -ALTER TABLE test.t1 DROP COLUMN a4; -SELECT COUNT(*) FROM test.t1; - -DROP TABLE t1; - -CREATE TABLE test.t1 ( - a1 INT, - a2 TEXT NOT NULL, - a3 BIT NOT NULL, - a4 DECIMAL(8,3), - a5 INT NOT NULL, - a6 VARCHAR(255), - PRIMARY KEY(a1)) - TABLESPACE ts1 STORAGE DISK ENGINE=NDB - PARTITION BY HASH(a1) - PARTITIONS 4; - -let $j= 15; ---disable_query_log -while ($j) -{ -eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA", -b'1',$j.00,$j+1,"By NIK $j"); -dec $j; -} ---enable_query_log -SELECT COUNT(*) FROM test.t1; - -ALTER TABLE test.t1 DROP COLUMN a4; -SELECT COUNT(*) FROM test.t1; - -DROP TABLE t1; - -ALTER TABLESPACE ts1 - DROP DATAFILE 'datafile.dat' - ENGINE=NDB; -DROP TABLESPACE ts1 ENGINE=NDB; -DROP LOGFILE GROUP lg1 ENGINE=NDB; - - -# -# Bug #17701 ALTER TABLE t1 ADD PARTITION for PARTITION BY LIST hangs test -# - -CREATE TABLE t1 - (id MEDIUMINT NOT NULL, - b1 BIT(8), - vc VARCHAR(255), - bc CHAR(255), - d DECIMAL(10,4) DEFAULT 0, - f FLOAT DEFAULT 0, - total BIGINT UNSIGNED, - y YEAR, - t DATE) ENGINE=NDB - PARTITION BY LIST(id) - (PARTITION p0 VALUES IN (2, 4), - PARTITION p1 VALUES IN (42, 142)); - -INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); -SELECT * FROM t1; -ALTER TABLE t1 ADD PARTITION - (PARTITION p2 VALUES IN (412)); -SELECT * FROM t1; -DROP TABLE t1; - -# -# Bug #17806 Update on NDB table with list partition causes mysqld to core -# Bug #16385 Partitions: crash when updating a range partitioned NDB table -# -CREATE TABLE t1 ( -a int not null, -b int not null, -c int not null) -partition by list(a) -partitions 2 -(partition x123 values in (1,5,6), - partition x234 values in (4,7,8)); -INSERT into t1 VALUES (5,1,1); -select * from t1; -UPDATE t1 SET a=8 WHERE a=5 AND b=1; -select * from t1; -drop table t1; - -CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb -PARTITION BY RANGE(f1) -( PARTITION part1 VALUES LESS THAN (2), -PARTITION part2 VALUES LESS THAN (1000)); -INSERT INTO t1 VALUES(1, '---1---'); -INSERT INTO t1 VALUES(2, '---2---'); -select * from t1 order by f1; -UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2; -select * from t1 order by f1; -UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1; -select * from t1 order by f1; -drop table t1; diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 4cc9113048f..afee381f5b7 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -10,8 +10,8 @@ insert into t1 values (5); grant select on test.* to ssl_user1@localhost require SSL; grant select on test.* to ssl_user2@localhost require cipher "DHE-RSA-AES256-SHA"; -grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com"; -grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com"; +grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com"; +grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/emailAddress=abstract.mysql.developer@mysql.com"; flush privileges; connect (con1,localhost,ssl_user1,,,,,SSL); @@ -54,3 +54,41 @@ ssl_user3@localhost, ssl_user4@localhost; drop table t1; # End of 4.1 tests + +# +# Test that we can't open connection to server if we are using +# a different cacert +# +--exec echo "this query should not execute;" > $MYSQLTEST_VARDIR/tmp/test.sql +--error 1 +--exec $MYSQL_TEST --ssl-ca=$MYSQL_TEST_DIR/std_data/untrusted-cacert.pem --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 + +# +# Test that we can't open connection to server if we are using +# a blank ca +# +--error 1 +--exec $MYSQL_TEST --ssl-ca= --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 + +# +# Test that we can't open connection to server if we are using +# a nonexistent ca file +# +--error 1 +--exec $MYSQL_TEST --ssl-ca=nonexisting_file.pem --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 + +# +# Test that we can't open connection to server if we are using +# a blank client-key +# +--error 1 +--exec $MYSQL_TEST --ssl-key= --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 + +# +# Test that we can't open connection to server if we are using +# a blank client-cert +# +--error 1 +--exec $MYSQL_TEST --ssl-cert= --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 + + diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test index d404a6fff9f..c48e6c9730d 100644 --- a/mysql-test/t/outfile.test +++ b/mysql-test/t/outfile.test @@ -40,7 +40,6 @@ eval select * into dumpfile "../tmp/outfile-test.2" from t1; --error 1086 eval select * into dumpfile "../tmp/outfile-test.3" from t1; enable_query_log; ---error 13,2 select load_file(concat(@tmpdir,"/outfile-test.not-exist")); --exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.1 --exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.2 diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 272cdc27af6..1a64537b6fc 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -9,6 +9,11 @@ drop table if exists t1; --enable_warnings +create table t1 (a int) +partition by key(a) +(partition p0 engine = MEMORY); +drop table t1; + # # Partition by key no partition defined => OK # @@ -1009,4 +1014,46 @@ select auto_increment from information_schema.tables where table_name='t1'; select * from t1; drop table t1; +# +# BUG 19140 Partitions: Create index for partitioned table crashes +# +create table t1 (a int) engine=memory +partition by key(a); +insert into t1 values (1); +create index inx1 on t1(a); +drop table t1; + +# +# BUG 19062 Partition clause ignored if CREATE TABLE ... AS SELECT ...; +# +create table t1 (a varchar(1)) +partition by key (a) +as select 'a'; + +show create table t1; +drop table t1; + +# +# BUG 19501 Partitions: SHOW TABLE STATUS shows wrong Data_free +# +CREATE TABLE t1 (a int) ENGINE = MYISAM PARTITION BY KEY(a); +INSERT into t1 values (1), (2); +--replace_column 9 0 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +DELETE from t1 where a = 1; +--replace_column 9 0 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +ALTER TABLE t1 OPTIMIZE PARTITION p0; +--replace_column 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +DROP TABLE t1; + +# +# BUG 19502: ENABLE/DISABLE Keys don't work for partitioned tables +# +CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a); +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t1 ENABLE KEYS; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test index 5caecef176e..86e4b6eed0a 100644 --- a/mysql-test/t/rename.test +++ b/mysql-test/t/rename.test @@ -61,9 +61,15 @@ connection con2; sleep 1; show tables; UNLOCK TABLES; -sleep 1; +connection con1; +reap; +connection con2; show tables; drop table t2, t4; +disconnect con2; +disconnect con1; +connection default; + # End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_engine.test b/mysql-test/t/rpl_multi_engine.test index 3f7b7b11c0d..10780c765f7 100644 --- a/mysql-test/t/rpl_multi_engine.test +++ b/mysql-test/t/rpl_multi_engine.test @@ -1,5 +1,9 @@ # See if replication between MyISAM, MEMORY and InnoDB works. +#This test case is not written for NDB, result files do not +#match when NDB is the default engine +-- source include/not_ndb_default.inc + -- source include/master-slave.inc connection slave; diff --git a/mysql-test/t/rpl_row_basic_11bugs.test b/mysql-test/t/rpl_row_basic_11bugs.test index d098723644f..3a686ea6b3d 100644 --- a/mysql-test/t/rpl_row_basic_11bugs.test +++ b/mysql-test/t/rpl_row_basic_11bugs.test @@ -1,5 +1,11 @@ --source include/have_row_based.inc --source include/have_binlog_format_row.inc + + +#This test case is not written for NDB, the result files +#will not match when NDB is the default engine +-- source include/not_ndb_default.inc + --source include/master-slave.inc # Bug#15942 (RBR ignores --binlog_ignore_db and tries to map to table diff --git a/mysql-test/t/rpl_row_flsh_tbls.test b/mysql-test/t/rpl_row_flsh_tbls.test index 1a81da39896..9e8efc1ac9c 100644 --- a/mysql-test/t/rpl_row_flsh_tbls.test +++ b/mysql-test/t/rpl_row_flsh_tbls.test @@ -6,6 +6,11 @@ let $rename_event_pos= 615; # Bug#18326: Do not lock table for writing during prepare of statement # The use of the ps protocol causes extra table maps in the binlog, so # we disable the ps-protocol for this statement. + +# Merge tables are not supported in NDB +-- source include/not_ndb_default.inc + + --disable_ps_protocol -- source extra/rpl_tests/rpl_flsh_tbls.test --enable_ps_protocol diff --git a/mysql-test/t/rpl_sp004.test b/mysql-test/t/rpl_sp004.test index 335a17c7af0..055a13cc157 100644 --- a/mysql-test/t/rpl_sp004.test +++ b/mysql-test/t/rpl_sp004.test @@ -44,13 +44,13 @@ END| delimiter ;| CALL test.p1(); -SELECT * FROM test.t1; -SELECT * FROM test.t2; +SELECT * FROM test.t1 ORDER BY a; +SELECT * FROM test.t2 ORDER BY a; save_master_pos; connection slave; sync_with_master; -SELECT * FROM test.t1; -SELECT * FROM test.t2; +SELECT * FROM test.t1 ORDER BY a; +SELECT * FROM test.t2 ORDER BY a; connection master; CALL test.p2(); @@ -66,14 +66,14 @@ SHOW TABLES; connection master; CALL test.p1(); -SELECT * FROM test.t1; -SELECT * FROM test.t2; +SELECT * FROM test.t1 ORDER BY a; +SELECT * FROM test.t2 ORDER BY a; #SELECT * FROM test.t3; save_master_pos; connection slave; sync_with_master; -SELECT * FROM test.t1; -SELECT * FROM test.t2; +SELECT * FROM test.t1 ORDER BY a; +SELECT * FROM test.t2 ORDER BY a; #SELECT * FROM test.t3; --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp004_master.sql diff --git a/mysql-test/t/rpl_stm_until.test b/mysql-test/t/rpl_stm_until.test index 1bd87db88cb..9a4e4471fe1 100644 --- a/mysql-test/t/rpl_stm_until.test +++ b/mysql-test/t/rpl_stm_until.test @@ -32,7 +32,7 @@ wait_for_slave_to_stop; select * from t1; --replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 9 # 11 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS # this should fail right after start start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; @@ -42,7 +42,7 @@ sleep 2; wait_for_slave_to_stop; --replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 9 # 11 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS # try replicate all up to and not including the second insert to t2; start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746; @@ -51,7 +51,7 @@ wait_for_slave_to_stop; select * from t2; --replace_result $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 9 # 11 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS # clean up start slave; @@ -68,7 +68,7 @@ wait_for_slave_to_stop; # here the sql slave thread should be stopped --replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004 --replace_column 1 # 9 # 23 # 33 # -show slave status; +--query_vertical SHOW SLAVE STATUS #testing various error conditions --error 1277 diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 612ab54dff1..0d91a9f8e91 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -165,14 +165,19 @@ drop table t5; # value was set up at the moment of temp table creation # connection con1; -set @session.pseudo_thread_id=100; +set @@session.pseudo_thread_id=100; create temporary table t101 (id int); create temporary table t102 (id int); -set @session.pseudo_thread_id=200; +set @@session.pseudo_thread_id=200; create temporary table t201 (id int); -create temporary table `#not_user_table_prefixed_with_hash_sign_no_harm` (id int); -set @con1_id=connection_id(); -kill @con1_id; +#create temporary table `t``201` (id int); +# emulate internal temp table not to come to binlog +create temporary table `#sql_not_user_table202` (id int); +set @@session.pseudo_thread_id=300; +create temporary table t301 (id int); +create temporary table t302 (id int); +create temporary table `#sql_not_user_table303` (id int); +disconnect con1; #now do something to show that slave is ok after DROP temp tables connection master; @@ -185,4 +190,17 @@ select * from t1 /* must be 1 */; connection master; drop table t1; -# End of 5.1 tests + +# +#14157: utf8 encoding in binlog without set character_set_client +# +--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=latin1 test -e 'create table t1 (a int); set names latin1; create temporary table `äöüÄÖÜ` (a int); insert into `äöüÄÖÜ` values (1); insert into t1 select * from `äöüÄÖÜ`' + +sync_slave_with_master; +#connection slave; +select * from t1; + +connection master; +drop table t1; + +# End of 5.0 tests diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test index cb2a1e1d853..08717fce114 100644 --- a/mysql-test/t/rpl_user_variables.test +++ b/mysql-test/t/rpl_user_variables.test @@ -1,8 +1,4 @@ ################################### -# Change Author: JBM -# Change Date: 2006-01-17 -# Change: Added order by -################################### # # Test of replicating user variables # @@ -55,6 +51,7 @@ SELECT * FROM t1 ORDER BY n; sync_slave_with_master; SELECT * FROM t1 ORDER BY n; connection master; +insert into t1 select * FROM (select @var1 union select @var2) AS t2; drop table t1; sync_slave_with_master; stop slave; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 8e3c5847846..4b6ae921b9b 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2886,3 +2886,37 @@ SELECT * FROM t1; UPDATE t1 SET i = i - 1; SELECT * FROM t1; DROP TABLE t1; + +# BUG#17379 + +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, c int, e int, primary key(a,b,c)); +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C; +analyze table t2; +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; + +explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5 + and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5); +drop table t1, t2; + +# +#Bug #18940: selection of optimal execution plan caused by equality +# propagation (the bug was fixed by the patch for bug #17379) + +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), + (3,1), (5,1), (8,9), (2,2), (0,9); + +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES + (1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), + (5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), + (0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); + +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; + +DROP TABLE t1, t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 8ccd954eeea..90d43bf7cc0 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -5780,6 +5780,76 @@ select routine_name,routine_schema from information_schema.routines where # +# BUG#12472/BUG#15137 'CREATE TABLE ... SELECT ... which explicitly or +# implicitly uses stored function gives "Table not locked" error'. +# +--disable_warnings +drop function if exists bug12472| +--enable_warnings +create function bug12472() returns int return (select count(*) from t1)| +# Check case when function is used directly +create table t3 as select bug12472() as i| +show create table t3| +select * from t3| +drop table t3| +# Check case when function is used indirectly through view +create view v1 as select bug12472() as j| +create table t3 as select * from v1| +show create table t3| +select * from t3| +drop table t3| +drop view v1| +drop function bug12472| + + +# +# BUG#18587: Function that accepts and returns TEXT garbles data if longer than +# 766 chars +# + +# Prepare. + +--disable_warnings +DROP FUNCTION IF EXISTS bug18589_f1| +DROP PROCEDURE IF EXISTS bug18589_p1| +DROP PROCEDURE IF EXISTS bug18589_p2| +--enable_warnings + +CREATE FUNCTION bug18589_f1(arg TEXT) RETURNS TEXT +BEGIN + RETURN CONCAT(arg, ""); +END| + +CREATE PROCEDURE bug18589_p1(arg TEXT, OUT ret TEXT) +BEGIN + SET ret = CONCAT(arg, ""); +END| + +CREATE PROCEDURE bug18589_p2(arg TEXT) +BEGIN + DECLARE v TEXT; + CALL bug18589_p1(arg, v); + SELECT v; +END| + +# Test case. + +SELECT bug18589_f1(REPEAT("a", 767))| + +SET @bug18589_v1 = ""| +CALL bug18589_p1(REPEAT("a", 767), @bug18589_v1)| +SELECT @bug18589_v1| + +CALL bug18589_p2(REPEAT("a", 767))| + +# Cleanup. + +DROP FUNCTION bug18589_f1| +DROP PROCEDURE bug18589_p1| +DROP PROCEDURE bug18589_p2| + + +# # BUG#NNNN: New bug synopsis # #--disable_warnings diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 1ef80bdd7ac..3f48b648f40 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2085,3 +2085,27 @@ create table t2 (a int, b int); insert into t2 values (2, 1), (1, 0); delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1; drop table t1, t2; + +# +# Bug #7549: Missing error message for invalid view selection with subquery +# + +CREATE TABLE t1 (a INT); + +--error 1054 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1); +--error 1054 +CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1); +--error 1054 +SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1); + +DROP TABLE t1; + +# +# Bug#19077: A nested materialized derived table is used before being populated. +# +create table t1 (i int, j bigint); +insert into t1 values (1, 2), (2, 2), (3, 2); +select * from (select min(i) from t1 where j=(select * from (select min(j) from t1) t2)) t3; +drop table t1; + diff --git a/mysql-test/t/trigger-grant.test b/mysql-test/t/trigger-grant.test index 67aec1496dd..8ca8ffe904b 100644 --- a/mysql-test/t/trigger-grant.test +++ b/mysql-test/t/trigger-grant.test @@ -690,3 +690,176 @@ SELECT @mysqltest_var; DROP USER mysqltest_u1@localhost; DROP DATABASE mysqltest_db1; + + +# +# Test for bug #14635 Accept NEW.x as INOUT parameters to stored +# procedures from within triggers +# +# We require UPDATE privilege when NEW.x passed as OUT parameter, and +# SELECT and UPDATE when NEW.x passed as INOUT parameter. +# +DELETE FROM mysql.user WHERE User LIKE 'mysqltest_%'; +DELETE FROM mysql.db WHERE User LIKE 'mysqltest_%'; +DELETE FROM mysql.tables_priv WHERE User LIKE 'mysqltest_%'; +DELETE FROM mysql.columns_priv WHERE User LIKE 'mysqltest_%'; +FLUSH PRIVILEGES; + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest_db1; +--enable_warnings + +CREATE DATABASE mysqltest_db1; +USE mysqltest_db1; + +CREATE TABLE t1 (i1 INT); +CREATE TABLE t2 (i1 INT); + +CREATE USER mysqltest_dfn@localhost; +CREATE USER mysqltest_inv@localhost; + +GRANT EXECUTE, CREATE ROUTINE, TRIGGER ON *.* TO mysqltest_dfn@localhost; +GRANT INSERT ON mysqltest_db1.* TO mysqltest_inv@localhost; + +connect (definer,localhost,mysqltest_dfn,,mysqltest_db1); +connect (invoker,localhost,mysqltest_inv,,mysqltest_db1); + +connection definer; +CREATE PROCEDURE p1(OUT i INT) DETERMINISTIC NO SQL SET i = 3; +CREATE PROCEDURE p2(INOUT i INT) DETERMINISTIC NO SQL SET i = i * 5; + +# Check that having no privilege won't work. +connection definer; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW + CALL p2(NEW.i1); + +connection invoker; +--error ER_COLUMNACCESS_DENIED_ERROR +INSERT INTO t1 VALUES (7); +--error ER_COLUMNACCESS_DENIED_ERROR +INSERT INTO t2 VALUES (11); + +connection definer; +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; + +# Check that having only SELECT privilege is not enough. +connection default; +GRANT SELECT ON mysqltest_db1.* TO mysqltest_dfn@localhost; + +connection definer; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW + CALL p2(NEW.i1); + +connection invoker; +--error ER_COLUMNACCESS_DENIED_ERROR +INSERT INTO t1 VALUES (13); +--error ER_COLUMNACCESS_DENIED_ERROR +INSERT INTO t2 VALUES (17); + +connection default; +REVOKE SELECT ON mysqltest_db1.* FROM mysqltest_dfn@localhost; + +connection definer; +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; + +# Check that having only UPDATE privilege is enough for OUT parameter, +# but not for INOUT parameter. +connection default; +GRANT UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; + +connection definer; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW + CALL p2(NEW.i1); + +connection invoker; +INSERT INTO t1 VALUES (19); +--error ER_COLUMNACCESS_DENIED_ERROR +INSERT INTO t2 VALUES (23); + +connection default; +REVOKE UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost; + +connection definer; +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; + +# Check that having SELECT and UPDATE privileges is enough. +connection default; +GRANT SELECT, UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; + +connection definer; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + CALL p1(NEW.i1); +CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW + CALL p2(NEW.i1); + +connection invoker; +INSERT INTO t1 VALUES (29); +INSERT INTO t2 VALUES (31); + +connection default; +REVOKE SELECT, UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost; + +connection definer; +DROP TRIGGER t2_bi; +DROP TRIGGER t1_bi; + +connection default; +DROP PROCEDURE p2; +DROP PROCEDURE p1; + +# Check that late procedure redefining won't open a security hole. +connection default; +GRANT UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; + +connection definer; +CREATE PROCEDURE p1(OUT i INT) DETERMINISTIC NO SQL SET i = 37; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + CALL p1(NEW.i1); + +connection invoker; +INSERT INTO t1 VALUES (41); + +connection definer; +DROP PROCEDURE p1; +CREATE PROCEDURE p1(IN i INT) DETERMINISTIC NO SQL SET @v1 = i + 43; + +connection invoker; +--error ER_COLUMNACCESS_DENIED_ERROR +INSERT INTO t1 VALUES (47); + +connection definer; +DROP PROCEDURE p1; +CREATE PROCEDURE p1(INOUT i INT) DETERMINISTIC NO SQL SET i = i + 51; + +connection invoker; +--error ER_COLUMNACCESS_DENIED_ERROR +INSERT INTO t1 VALUES (53); + +connection default; +DROP PROCEDURE p1; +REVOKE UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost; + +connection definer; +DROP TRIGGER t1_bi; + +# Cleanup. +disconnect definer; +disconnect invoker; +connection default; +DROP USER mysqltest_inv@localhost; +DROP USER mysqltest_dfn@localhost; +DROP TABLE t2; +DROP TABLE t1; +DROP DATABASE mysqltest_db1; +USE test; + +--echo End of 5.0 tests. diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 00c85a650d1..a87f289e94e 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1111,9 +1111,9 @@ insert into t1 values create function f2() returns int return (select max(b) from t2); insert into t2 select a, f2() from t1; load data infile '../std_data_ln/words.dat' into table t1 (a) set b:= f1(); -drop table t1, t2; drop function f1; drop function f2; +drop table t1, t2; # # Test for bug #16021 "Wrong index given to function in trigger" which @@ -1165,4 +1165,126 @@ SELECT * FROM t1 WHERE conn_id != trigger_conn_id; DROP TRIGGER t1_bi; DROP TABLE t1; + +# +# Bug#6951: Triggers/Traditional: SET @ result wrong +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (i1 INT); + +SET @save_sql_mode=@@sql_mode; + +SET SQL_MODE=''; + +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW + SET @x = 5/0; + +SET SQL_MODE='traditional'; + +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW + SET @x = 5/0; + +SET @x=1; +INSERT INTO t1 VALUES (@x); +SELECT @x; + +SET @x=2; +--error 1365 +UPDATE t1 SET i1 = @x; +SELECT @x; + +SET SQL_MODE=''; + +SET @x=3; +INSERT INTO t1 VALUES (@x); +SELECT @x; + +SET @x=4; +--error 1365 +UPDATE t1 SET i1 = @x; +SELECT @x; + +SET @@sql_mode=@save_sql_mode; + +DROP TRIGGER t1_ai; +DROP TRIGGER t1_au; +DROP TABLE t1; + + +# +# Test for bug #14635 Accept NEW.x as INOUT parameters to stored +# procedures from within triggers +# +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +--enable_warnings + +CREATE TABLE t1 (i1 INT); + +# Check that NEW.x pseudo variable is accepted as INOUT and OUT +# parameter to stored routine. +INSERT INTO t1 VALUES (3); +CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET i1 = 5; +CREATE PROCEDURE p2(INOUT i1 INT) DETERMINISTIC NO SQL SET i1 = i1 * 7; +delimiter //; +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +BEGIN + CALL p1(NEW.i1); + CALL p2(NEW.i1); +END// +delimiter ;// +UPDATE t1 SET i1 = 11 WHERE i1 = 3; +DROP TRIGGER t1_bu; +DROP PROCEDURE p2; +DROP PROCEDURE p1; + +# Check that OLD.x pseudo variable is not accepted as INOUT and OUT +# parameter to stored routine. +INSERT INTO t1 VALUES (13); +CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET @a = 17; +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW + CALL p1(OLD.i1); +--error ER_SP_NOT_VAR_ARG +UPDATE t1 SET i1 = 19 WHERE i1 = 13; +DROP TRIGGER t1_bu; +DROP PROCEDURE p1; + +INSERT INTO t1 VALUES (23); +CREATE PROCEDURE p1(INOUT i1 INT) DETERMINISTIC NO SQL SET @a = i1 * 29; +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW + CALL p1(OLD.i1); +--error ER_SP_NOT_VAR_ARG +UPDATE t1 SET i1 = 31 WHERE i1 = 23; +DROP TRIGGER t1_bu; +DROP PROCEDURE p1; + +# Check that NEW.x pseudo variable is read-only in the AFTER TRIGGER. +INSERT INTO t1 VALUES (37); +CREATE PROCEDURE p1(OUT i1 INT) DETERMINISTIC NO SQL SET @a = 41; +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW + CALL p1(NEW.i1); +--error ER_SP_NOT_VAR_ARG +UPDATE t1 SET i1 = 43 WHERE i1 = 37; +DROP TRIGGER t1_au; +DROP PROCEDURE p1; + +INSERT INTO t1 VALUES (47); +CREATE PROCEDURE p1(INOUT i1 INT) DETERMINISTIC NO SQL SET @a = i1 * 49; +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW + CALL p1(NEW.i1); +--error ER_SP_NOT_VAR_ARG +UPDATE t1 SET i1 = 51 WHERE i1 = 47; +DROP TRIGGER t1_au; +DROP PROCEDURE p1; + +# Post requisite. +SELECT * FROM t1; + +DROP TABLE t1; + # End of 5.0 tests diff --git a/mysql-test/t/variables-master.opt b/mysql-test/t/variables-master.opt deleted file mode 100644 index abd826bc7fa..00000000000 --- a/mysql-test/t/variables-master.opt +++ /dev/null @@ -1 +0,0 @@ ---max_join_size=100 diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 018337f2631..7aa79f0eb40 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -5,6 +5,37 @@ drop table if exists t1,t2; --enable_warnings +# +# Bug #19263: variables.test doesn't clean up after itself (I/II -- save) +# +set @my_binlog_cache_size =@@global.binlog_cache_size; +set @my_connect_timeout =@@global.connect_timeout; +set @my_delayed_insert_timeout =@@global.delayed_insert_timeout; +set @my_delayed_queue_size =@@global.delayed_queue_size; +set @my_flush =@@global.flush; +set @my_flush_time =@@global.flush_time; +set @my_key_buffer_size =@@global.key_buffer_size; +set @my_max_binlog_cache_size =@@global.max_binlog_cache_size; +set @my_max_binlog_size =@@global.max_binlog_size; +set @my_max_connect_errors =@@global.max_connect_errors; +set @my_max_delayed_threads =@@global.max_delayed_threads; +set @my_max_heap_table_size =@@global.max_heap_table_size; +set @my_max_insert_delayed_threads=@@global.max_insert_delayed_threads; +set @my_max_join_size =@@global.max_join_size; +set @my_max_user_connections =@@global.max_user_connections; +set @my_max_write_lock_count =@@global.max_write_lock_count; +set @my_myisam_data_pointer_size =@@global.myisam_data_pointer_size; +set @my_net_buffer_length =@@global.net_buffer_length; +set @my_net_write_timeout =@@global.net_write_timeout; +set @my_net_read_timeout =@@global.net_read_timeout; +set @my_query_cache_limit =@@global.query_cache_limit; +set @my_query_cache_type =@@global.query_cache_type; +set @my_rpl_recovery_rank =@@global.rpl_recovery_rank; +set @my_server_id =@@global.server_id; +set @my_slow_launch_time =@@global.slow_launch_time; +set @my_storage_engine =@@global.storage_engine; +set @my_thread_cache_size =@@global.thread_cache_size; + # case insensitivity tests (new in 5.0) set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @@ -508,4 +539,68 @@ select @@system_time_zone; select @@version, @@version_comment, @@version_compile_machine, @@version_compile_os; +# +# Bug #1039: make tmpdir and datadir available as @@variables (also included +# basedir) +# +# Don't actually output, since it depends on the system +--replace_column 1 # 2 # 3 # +select @@basedir, @@datadir, @@tmpdir; +--replace_column 2 # +show variables like 'basedir'; +--replace_column 2 # +show variables like 'datadir'; +--replace_column 2 # +show variables like 'tmpdir'; + +# +# Bug #19606: make ssl settings available via SHOW VARIABLES and @@variables +# +# Don't actually output, since it depends on the system +--replace_column 1 # 2 # 3 # 4 # 5 # +select @@ssl_ca, @@ssl_capath, @@ssl_cert, @@ssl_cipher, @@ssl_key; +--replace_column 2 # +show variables like 'ssl%'; + +# +# Bug #19616: make log_queries_not_using_indexes available in SHOW VARIABLES +# and as @@log_queries_not_using_indexes +# +select @@log_queries_not_using_indexes; +show variables like 'log_queries_not_using_indexes'; + --echo End of 5.0 tests + +# This is at the very after the versioned tests, since it involves doing +# cleanup +# +# Bug #19263: variables.test doesn't clean up after itself (II/II -- +# restore) +# +set global binlog_cache_size =@my_binlog_cache_size; +set global connect_timeout =@my_connect_timeout; +set global delayed_insert_timeout =@my_delayed_insert_timeout; +set global delayed_queue_size =@my_delayed_queue_size; +set global flush =@my_flush; +set global flush_time =@my_flush_time; +set global key_buffer_size =@my_key_buffer_size; +set global max_binlog_cache_size =default; #@my_max_binlog_cache_size; +set global max_binlog_size =@my_max_binlog_size; +set global max_connect_errors =@my_max_connect_errors; +set global max_delayed_threads =@my_max_delayed_threads; +set global max_heap_table_size =@my_max_heap_table_size; +set global max_insert_delayed_threads=@my_max_insert_delayed_threads; +set global max_join_size =@my_max_join_size; +set global max_user_connections =@my_max_user_connections; +set global max_write_lock_count =@my_max_write_lock_count; +set global myisam_data_pointer_size =@my_myisam_data_pointer_size; +set global net_buffer_length =@my_net_buffer_length; +set global net_write_timeout =@my_net_write_timeout; +set global net_read_timeout =@my_net_read_timeout; +set global query_cache_limit =@my_query_cache_limit; +set global query_cache_type =@my_query_cache_type; +set global rpl_recovery_rank =@my_rpl_recovery_rank; +set global server_id =@my_server_id; +set global slow_launch_time =@my_slow_launch_time; +set global storage_engine =@my_storage_engine; +set global thread_cache_size =@my_thread_cache_size; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 6094382c094..ae633b2cc38 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2517,3 +2517,58 @@ create view v2 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from v1; select * from v2; drop view v1, v2; drop table t1; + +# +# Bug #19490: usage of view specified by a query with GROUP BY +# an expression containing non-constant interval + +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime); + +CREATE VIEW v1 AS +SELECT id, date(d) + INTERVAL TIME_TO_SEC(d) SECOND AS t, COUNT(*) + FROM t1 GROUP BY id, t; + +SHOW CREATE VIEW v1; +SELECT * FROM v1; + +DROP VIEW v1; +DROP TABLE t1; + +# +# Bug#19077: A nested materialized view is used before being populated. +# +CREATE TABLE t1 (i INT, j BIGINT); +INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); +CREATE VIEW v1 AS SELECT MIN(j) AS j FROM t1; +CREATE VIEW v2 AS SELECT MIN(i) FROM t1 WHERE j = ( SELECT * FROM v1 ); +SELECT * FROM v2; +DROP VIEW v2, v1; +DROP TABLE t1; + +# +# Bug #19573: VIEW with HAVING that refers an alias name +# + +CREATE TABLE t1( + fName varchar(25) NOT NULL, + lName varchar(25) NOT NULL, + DOB date NOT NULL, + uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); + +INSERT INTO t1(fName, lName, DOB) VALUES + ('Hank', 'Hill', '1964-09-29'), + ('Tom', 'Adams', '1908-02-14'), + ('Homer', 'Simpson', '1968-03-05'); + +CREATE VIEW v1 AS + SELECT (year(now())-year(DOB)) AS Age + FROM t1 HAVING Age < 75; +SHOW CREATE VIEW v1; + +SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; +SELECT * FROM v1; + +DROP VIEW v1; +DROP TABLE t1; + + diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index e1c67386744..6939dd489cd 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -11,7 +11,7 @@ fun:calloc fun:_dl_allocate_tls fun:allocate_stack - fun:pthread_create@@GLIBC_2.1 + fun:pthread_create* } { @@ -82,15 +82,6 @@ } { - pthread allocate_dtv memory loss second - Memcheck:Leak - fun:calloc - fun:allocate_dtv - fun:_dl_allocate_tls - fun:pthread_create* -} - -{ pthread memalign memory loss Memcheck:Leak fun:memalign @@ -255,3 +246,162 @@ Memcheck:Cond fun:_dl_relocate_object } + +# +# Leaks reported in _dl_* internal functions on Linux amd64 / glibc2.3.2. +# + +{ + _dl_start invalid write8 + Memcheck:Addr8 + fun:_dl_start +} + +{ + _dl_start invalid write4 + Memcheck:Addr4 + fun:_dl_start +} + +{ + _dl_start/_dl_setup_hash invalid read8 + Memcheck:Addr8 + fun:_dl_setup_hash + fun:_dl_start +} + +{ + _dl_sysdep_start invalid write8 + Memcheck:Addr8 + fun:_dl_sysdep_start +} + +{ + _dl_init invalid write8 + Memcheck:Addr8 + fun:_dl_init +} + +{ + _dl_init invalid write4 + Memcheck:Addr4 + fun:_dl_init +} + +{ + _dl_init/_dl_init invalid read8 + Memcheck:Addr8 + fun:_dl_debug_initialize + fun:_dl_init +} + +{ + _dl_init/_dl_debug_state invalid read8 + Memcheck:Addr8 + fun:_dl_debug_state + fun:_dl_init +} + +{ + init invalid write8 + Memcheck:Addr8 + fun:init +} + +{ + fixup invalid write8 + Memcheck:Addr8 + fun:fixup +} + +{ + fixup/_dl_lookup_versioned_symbol invalid read8 + Memcheck:Addr8 + fun:_dl_lookup_versioned_symbol + fun:fixup +} + +{ + _dl_runtime_resolve invalid read8 + Memcheck:Addr8 + fun:_dl_runtime_resolve +} + +{ + __libc_start_main invalid write8 + Memcheck:Addr8 + fun:__libc_start_main +} + +{ + __libc_start_main/__sigjmp_save invalid write4 + Memcheck:Addr4 + fun:__sigjmp_save + fun:__libc_start_main +} + +# +# These seem to be libc threading stuff, not related to MySQL code (allocations +# during pthread_exit()). Googling shows other projects also using these +# suppressions. +# +# Note that these all stem from pthread_exit() deeper in the call stack, but +# Valgrind only allows the top four calls in the suppressions. +# + +{ + libc pthread_exit 1 + Memcheck:Leak + fun:malloc + fun:_dl_new_object + fun:_dl_map_object_from_fd + fun:_dl_map_object +} + +{ + libc pthread_exit 2 + Memcheck:Leak + fun:malloc + fun:_dl_map_object + fun:dl_open_worker + fun:_dl_catch_error +} + +{ + libc pthread_exit 3 + Memcheck:Leak + fun:malloc + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error +} + +{ + libc pthread_exit 4 + Memcheck:Leak + fun:calloc + fun:_dl_check_map_versions + fun:dl_open_worker + fun:_dl_catch_error +} + +{ + libc pthread_exit 5 + Memcheck:Leak + fun:calloc + fun:_dl_new_object + fun:_dl_map_object_from_fd + fun:_dl_map_object +} + + +# +# This is seen internally in the system libraries on 64-bit RHAS3. +# + +{ + __lll_mutex_unlock_wake uninitialized + Memcheck:Param + futex(utime) + fun:__lll_mutex_unlock_wake +} diff --git a/mysys/cmakelists.txt b/mysys/CMakeLists.txt index 4aa99a70121..4aa99a70121 100644 --- a/mysys/cmakelists.txt +++ b/mysys/CMakeLists.txt diff --git a/mysys/Makefile.am b/mysys/Makefile.am index abc5cc142f5..1241e8cdded 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -57,7 +57,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ my_windac.c my_access.c base64.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ thr_mutex.c thr_rwlock.c \ - cmakelists.txt mf_soundex.c \ + CMakeLists.txt mf_soundex.c \ my_conio.c my_wincond.c my_winsem.c my_winthread.c libmysys_a_LIBADD = @THREAD_LOBJECTS@ # test_dir_DEPENDENCIES= $(LIBRARIES) diff --git a/mysys/my_init.c b/mysys/my_init.c index 4d7299c7cb1..9efe0a0c20e 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -197,8 +197,10 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", _CrtDumpMemoryLeaks(); #endif } + + if (!(infoflag & MY_DONT_FREE_DBUG)) + DBUG_END(); /* Must be done before my_thread_end */ #ifdef THREAD - DBUG_POP(); /* Must be done before my_thread_end */ my_thread_end(); my_thread_global_end(); #if defined(SAFE_MUTEX) diff --git a/regex/cmakelists.txt b/regex/CMakeLists.txt index e00f339b3b9..e00f339b3b9 100644 --- a/regex/cmakelists.txt +++ b/regex/CMakeLists.txt diff --git a/regex/Makefile.am b/regex/Makefile.am index 6fd5b1b57a2..1f496fcec62 100644 --- a/regex/Makefile.am +++ b/regex/Makefile.am @@ -25,7 +25,7 @@ re_SOURCES = split.c debug.c main.c re_LDFLAGS= @NOINST_LDFLAGS@ EXTRA_DIST = tests CHANGES COPYRIGHT WHATSNEW regexp.c \ debug.ih engine.ih main.ih regcomp.ih regerror.ih \ - regex.3 regex.7 cmakelists.txt + regex.3 regex.7 CMakeLists.txt test: re tests ./re < tests diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 83bc8ce8954..744a4791307 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -31,7 +31,6 @@ Usage: $0 [OPTIONS] --defaults-file=FILE Use the specified defaults file --defaults-extra-file=FILE Also use defaults from the specified file --ledir=DIRECTORY Look for mysqld in the specified directory - --log-error=FILE Log errors to the specified log file --open-files-limit=LIMIT Limit the number of open files --core-file-size=LIMIT Limit core files to the specified size --timezone=TZ Set the system timezone @@ -46,6 +45,11 @@ EOF exit 1 } +shell_quote_string() { + # This sed command makes sure that any special chars are quoted, + # so the arg gets passed exactly to the server. + echo "$1" | sed -e 's,\([^a-zA-Z0-9/_.=-]\),\\\1,g' +} parse_arguments() { # We only need to pass arguments through to the server if we don't @@ -69,14 +73,14 @@ parse_arguments() { --pid-file=*) pid_file=`echo "$arg" | sed -e "s;--pid-file=;;"` ;; --user=*) user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 ;; - # these two might have been set in a [mysqld_safe] section of my.cnf + # these might have been set in a [mysqld_safe] section of my.cnf # they are added to mysqld command line to override settings from my.cnf + --log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;; --socket=*) mysql_unix_port=`echo "$arg" | sed -e "s;--socket=;;"` ;; --port=*) mysql_tcp_port=`echo "$arg" | sed -e "s;--port=;;"` ;; # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;; - --log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;; --open-files-limit=*) open_files=`echo "$arg" | sed -e "s;--open-files-limit=;;"` ;; --core-file-size=*) core_file_size=`echo "$arg" | sed -e "s;--core-file-size=;;"` ;; --timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;; @@ -97,9 +101,7 @@ parse_arguments() { *) if test -n "$pick_args" then - # This sed command makes sure that any special chars are quoted, - # so the arg gets passed exactly to the server. - args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'` + append_arg_to_args "$arg" fi ;; esac @@ -194,6 +196,10 @@ else print_defaults="my_print_defaults" fi +append_arg_to_args () { + args="$args "`shell_quote_string "$1"` +} + args= SET_USER=2 parse_arguments `$print_defaults $defaults --loose-verbose mysqld server` @@ -239,15 +245,39 @@ else * ) pid_file="$DATADIR/$pid_file" ;; esac fi -test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err +append_arg_to_args "--pid-file=$pid_file" + +if [ -n "$err_log" ] +then + # mysqld adds ".err" if there is no extension on the --log-err + # argument; must match that here, or mysqld_safe will write to a + # different log file than mysqld + + # mysqld does not add ".err" to "--log-error=foo."; it considers a + # trailing "." as an extension + if expr "$err_log" : '.*\.[^/]*$' > /dev/null + then + : + else + err_log="$err_log".err + fi + + case "$err_log" in + /* ) ;; + * ) err_log="$DATADIR/$err_log" ;; + esac +else + err_log=$DATADIR/`@HOSTNAME@`.err +fi +append_arg_to_args "--log-error=$err_log" if test -n "$mysql_unix_port" then - args="--socket=$mysql_unix_port $args" + append_arg_to_args "--socket=$mysql_unix_port" fi if test -n "$mysql_tcp_port" then - args="--port=$mysql_tcp_port $args" + append_arg_to_args "--port=$mysql_tcp_port" fi if test $niceness -eq 0 @@ -314,7 +344,7 @@ then if test -n "$open_files" then ulimit -n $open_files - args="--open-files-limit=$open_files $args" + append_arg_to_args "--open-files-limit=$open_files" fi if test -n "$core_file_size" then @@ -372,12 +402,18 @@ echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log while true do rm -f $safe_mysql_unix_port $pid_file # Some extra safety - if test -z "$args" - then - $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1 - else - eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1" - fi + + cmd="$NOHUP_NICENESS" + + for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ + "--datadir=$DATADIR" "$USER_OPTION" + do + cmd="$cmd "`shell_quote_string "$i"` + done + cmd="$cmd $args >> "`shell_quote_string "$err_log"`" 2>&1" + #echo "Running mysqld: [$cmd]" + eval "$cmd" + if test ! -f $pid_file # This is removed if normal shutdown then echo "STOPPING server from pid file $pid_file" diff --git a/server-tools/instance-manager/cmakelists.txt b/server-tools/instance-manager/CMakeLists.txt index c20b9c7f9df..c20b9c7f9df 100644 --- a/server-tools/instance-manager/cmakelists.txt +++ b/server-tools/instance-manager/CMakeLists.txt diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am index 462d7984aa4..6ab5c3d1bfc 100644 --- a/server-tools/instance-manager/Makefile.am +++ b/server-tools/instance-manager/Makefile.am @@ -88,7 +88,7 @@ mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \ @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@ EXTRA_DIST = WindowsService.cpp WindowsService.h IMService.cpp \ - IMService.h cmakelists.txt + IMService.h CMakeLists.txt tags: ctags -R *.h *.cc diff --git a/server-tools/instance-manager/manager.cc b/server-tools/instance-manager/manager.cc index 95f9029f648..90d9d04cd36 100644 --- a/server-tools/instance-manager/manager.cc +++ b/server-tools/instance-manager/manager.cc @@ -35,12 +35,12 @@ #endif -static int create_pid_file(const char *pid_file_name) +int create_pid_file(const char *pid_file_name, int pid) { if (FILE *pid_file= my_fopen(pid_file_name, O_WRONLY | O_CREAT | O_BINARY, MYF(0))) { - fprintf(pid_file, "%d\n", (int) getpid()); + fprintf(pid_file, "%d\n", (int) pid); my_fclose(pid_file, MYF(0)); return 0; } @@ -138,8 +138,13 @@ void manager(const Options &options) if (user_map.load(options.password_file_name)) return; - /* write pid file */ - if (create_pid_file(options.pid_file_name)) + /* write Instance Manager pid file */ + + log_info("IM pid file: '%s'; PID: %d.", + (const char *) options.pid_file_name, + (int) manager_pid); + + if (create_pid_file(options.pid_file_name, manager_pid)) return; sigset_t mask; diff --git a/server-tools/instance-manager/manager.h b/server-tools/instance-manager/manager.h index 12ed6b3b1ff..3ddf292132e 100644 --- a/server-tools/instance-manager/manager.h +++ b/server-tools/instance-manager/manager.h @@ -20,4 +20,6 @@ struct Options; void manager(const Options &options); +int create_pid_file(const char *pid_file_name, int pid); + #endif // INCLUDES_MYSQL_INSTANCE_MANAGER_MANAGER_H diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc index d0b2cf2666c..ef714099de7 100644 --- a/server-tools/instance-manager/mysqlmanager.cc +++ b/server-tools/instance-manager/mysqlmanager.cc @@ -338,6 +338,14 @@ spawn: /* Here we return to main, and fall into manager */ break; default: // parent, success + pid= getpid(); /* Get our pid. */ + + log_info("Angel pid file: '%s'; PID: %d.", + (const char *) options.angel_pid_file_name, + (int) pid); + + create_pid_file(Options::angel_pid_file_name, pid); + while (child_status == CHILD_OK && is_terminated == 0) sigsuspend(&zeromask); diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index 85fea76c079..8de592f59b6 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -44,6 +44,7 @@ const char *Options::user= 0; /* No default value */ const char *default_password_file_name= QUOTE(DEFAULT_PASSWORD_FILE_NAME); const char *default_log_file_name= QUOTE(DEFAULT_LOG_FILE_NAME); const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE); +const char *Options::angel_pid_file_name= NULL; #endif const char *Options::log_file_name= default_log_file_name; const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME); @@ -61,6 +62,9 @@ bool Options::is_forced_default_file= 0; const char *Options::default_dbug_option= "d:t:i:O,im.trace"; #endif +static const char * const ANGEL_PID_FILE_SUFFIX= ".angel.pid"; +static const int ANGEL_PID_FILE_SUFFIX_LEN= strlen(ANGEL_PID_FILE_SUFFIX); + /* List of options, accepted by the instance manager. List must be closed with empty option. @@ -75,6 +79,7 @@ enum options { #ifndef __WIN__ OPT_RUN_AS_SERVICE, OPT_USER, + OPT_ANGEL_PID_FILE, #else OPT_INSTALL_SERVICE, OPT_REMOVE_SERVICE, @@ -91,6 +96,13 @@ static struct my_option my_long_options[] = { "help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, +#ifndef __WIN__ + { "angel-pid-file", OPT_ANGEL_PID_FILE, "Pid file for angel process.", + (gptr *) &Options::angel_pid_file_name, + (gptr *) &Options::angel_pid_file_name, + 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, +#endif + { "bind-address", OPT_BIND_ADDRESS, "Bind address to use for connection.", (gptr *) &Options::bind_address, (gptr *) &Options::bind_address, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, @@ -312,6 +324,46 @@ int Options::load(int argc, char **argv) get_one_option)) != 0) goto err; +#ifndef __WIN__ + if (Options::run_as_service) + { + if (Options::angel_pid_file_name == NULL) + { + /* + Calculate angel pid file on the IM pid file basis: replace the + extension (everything after the last dot) of the pid file basename to + '.angel.pid'. + */ + + char *angel_pid_file_name; + char *base_name_ptr; + char *ext_ptr; + + angel_pid_file_name= (char *) malloc(strlen(Options::pid_file_name) + + ANGEL_PID_FILE_SUFFIX_LEN); + + strcpy(angel_pid_file_name, Options::pid_file_name); + + base_name_ptr= strrchr(angel_pid_file_name, '/'); + + if (!base_name_ptr) + base_name_ptr= angel_pid_file_name + 1; + + ext_ptr= strrchr(base_name_ptr, '.'); + if (ext_ptr) + *ext_ptr= 0; + + strcat(angel_pid_file_name, ANGEL_PID_FILE_SUFFIX); + + Options::angel_pid_file_name= angel_pid_file_name; + } + else + { + Options::angel_pid_file_name= strdup(Options::angel_pid_file_name); + } + } +#endif + return 0; err: @@ -323,6 +375,11 @@ void Options::cleanup() /* free_defaults returns nothing */ if (Options::saved_argv != NULL) free_defaults(Options::saved_argv); + +#ifndef __WIN__ + if (Options::run_as_service) + free((void *) Options::angel_pid_file_name); +#endif } #ifdef __WIN__ diff --git a/server-tools/instance-manager/options.h b/server-tools/instance-manager/options.h index 06818288606..00a50a2acdb 100644 --- a/server-tools/instance-manager/options.h +++ b/server-tools/instance-manager/options.h @@ -35,6 +35,7 @@ struct Options #else static char run_as_service; /* handle_options doesn't support bool */ static const char *user; + static const char *angel_pid_file_name; #endif static bool is_forced_default_file; static const char *log_file_name; diff --git a/sql-common/client.c b/sql-common/client.c index 32672ce1201..08d87f9d083 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1495,6 +1495,7 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , mysql->options.ssl_ca= strdup_if_not_null(ca); mysql->options.ssl_capath= strdup_if_not_null(capath); mysql->options.ssl_cipher= strdup_if_not_null(cipher); + mysql->options.ssl_verify_server_cert= FALSE; /* Off by default */ #endif /* HAVE_OPENSSL */ DBUG_RETURN(0); } @@ -1509,17 +1510,16 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , static void mysql_ssl_free(MYSQL *mysql __attribute__((unused))) { - struct st_VioSSLConnectorFd *st= - (struct st_VioSSLConnectorFd*) mysql->connector_fd; + struct st_VioSSLFd *ssl_fd= (struct st_VioSSLFd*) mysql->connector_fd; DBUG_ENTER("mysql_ssl_free"); my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR)); - my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR)); - if (st) - SSL_CTX_free(st->ssl_context); + my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR)); + if (ssl_fd) + SSL_CTX_free(ssl_fd->ssl_context); my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR)); mysql->options.ssl_key = 0; mysql->options.ssl_cert = 0; @@ -1551,6 +1551,77 @@ mysql_get_ssl_cipher(MYSQL *mysql) DBUG_RETURN(NULL); } + +/* + Check the server's (subject) Common Name against the + hostname we connected to + + SYNOPSIS + ssl_verify_server_cert() + vio pointer to a SSL connected vio + server_hostname name of the server that we connected to + + RETURN VALUES + 0 Success + 1 Failed to validate server + + */ +static int ssl_verify_server_cert(Vio *vio, const char* server_hostname) +{ + SSL *ssl; + X509 *server_cert; + char *cp1, *cp2; + char buf[256]; + DBUG_ENTER("ssl_verify_server_cert"); + DBUG_PRINT("enter", ("server_hostname: %s", server_hostname)); + + if (!(ssl= (SSL*)vio->ssl_arg)) + { + DBUG_PRINT("error", ("No SSL pointer found")); + DBUG_RETURN(1); + } + + if (!server_hostname) + { + DBUG_PRINT("error", ("No server hostname supplied")); + DBUG_RETURN(1); + } + + if (!(server_cert= SSL_get_peer_certificate(ssl))) + { + DBUG_PRINT("error", ("Could not get server certificate")); + DBUG_RETURN(1); + } + + /* + We already know that the certificate exchanged was valid; the SSL library + handled that. Now we need to verify that the contents of the certificate + are what we expect. + */ + + X509_NAME_oneline(X509_get_subject_name(server_cert), buf, sizeof(buf)); + X509_free (server_cert); + + DBUG_PRINT("info", ("hostname in cert: %s", buf)); + cp1= strstr(buf, "/CN="); + if (cp1) + { + cp1+= 4; /* Skip the "/CN=" that we found */ + /* Search for next / which might be the delimiter for email */ + cp2= strchr(cp1, '/'); + if (cp2) + *cp2= '\0'; + DBUG_PRINT("info", ("Server hostname in cert: %s", cp1)); + if (!strcmp(cp1, server_hostname)) + { + /* Success */ + DBUG_RETURN(0); + } + } + DBUG_PRINT("error", ("SSL certificate validation failure")); + DBUG_RETURN(1); +} + #endif /* HAVE_OPENSSL */ @@ -1584,7 +1655,6 @@ static MYSQL_METHODS client_methods= #endif }; - MYSQL * CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, @@ -2029,37 +2099,52 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, mysql->client_flag=client_flag; #ifdef HAVE_OPENSSL - /* - Oops.. are we careful enough to not send ANY information without - encryption? - */ if (client_flag & CLIENT_SSL) { + /* Do the SSL layering. */ struct st_mysql_options *options= &mysql->options; + struct st_VioSSLFd *ssl_fd; + + /* + Send client_flag, max_packet_size - unencrypted otherwise + the server does not know we want to do SSL + */ if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net)) { set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate); goto error; } - /* Do the SSL layering. */ - if (!(mysql->connector_fd= - (gptr) new_VioSSLConnectorFd(options->ssl_key, - options->ssl_cert, - options->ssl_ca, - options->ssl_capath, - options->ssl_cipher))) + + /* Create the VioSSLConnectorFd - init SSL and load certs */ + if (!(ssl_fd= new_VioSSLConnectorFd(options->ssl_key, + options->ssl_cert, + options->ssl_ca, + options->ssl_capath, + options->ssl_cipher))) { set_mysql_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate); goto error; } + mysql->connector_fd= (void*)ssl_fd; + + /* Connect to the server */ DBUG_PRINT("info", ("IO layer change in progress...")); - if (sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd), - mysql->net.vio, (long) (mysql->options.connect_timeout))) + if (sslconnect(ssl_fd, mysql->net.vio, + (long) (mysql->options.connect_timeout))) { set_mysql_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate); goto error; } DBUG_PRINT("info", ("IO layer change done!")); + + /* Verify server cert */ + if (mysql->options.ssl_verify_server_cert && + ssl_verify_server_cert(mysql->net.vio, mysql->host)) + { + set_mysql_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate); + goto error; + } + } #endif /* HAVE_OPENSSL */ @@ -2799,6 +2884,9 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) case MYSQL_OPT_RECONNECT: mysql->reconnect= *(my_bool *) arg; break; + case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: + mysql->options.ssl_verify_server_cert= *(my_bool *) arg; + break; default: DBUG_RETURN(1); } diff --git a/sql-common/my_time.c b/sql-common/my_time.c index c9d39260761..f75298e4f5d 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -689,7 +689,7 @@ long calc_daynr(uint year,uint month,uint day) if (year == 0 && month == 0 && day == 0) DBUG_RETURN(0); /* Skip errors */ - if (year < 200) + if (year < YY_MAGIC_BELOW) { if ((year=year+1900) < 1900+YY_PART_YEAR) year+=100; diff --git a/sql/cmakelists.txt b/sql/CMakeLists.txt index 2b44fbdcc79..2b44fbdcc79 100644 --- a/sql/cmakelists.txt +++ b/sql/CMakeLists.txt diff --git a/sql/Makefile.am b/sql/Makefile.am index 8f051b61e74..eec7209bf50 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -122,7 +122,7 @@ DEFS = -DMYSQL_SERVER \ BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h EXTRA_DIST = udf_example.cc $(BUILT_SOURCES) \ - nt_servc.cc nt_servc.h message.mc cmakelists.txt + nt_servc.cc nt_servc.h message.mc CMakeLists.txt CLEANFILES = lex_hash.h sql_yacc.cc sql_yacc.h AM_YFLAGS = -d diff --git a/sql/field_conv.cc b/sql/field_conv.cc index f718a3d778c..3eab782d167 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -641,7 +641,8 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) void field_conv(Field *to,Field *from) { - if (to->real_type() == from->real_type()) + if (to->real_type() == from->real_type() && + !(to->type() == FIELD_TYPE_BLOB && to->table->copy_blobs)) { if (to->pack_length() == from->pack_length() && !(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) && diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 786d45a4966..40081c975c8 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1786,7 +1786,8 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *info, if (info->auto_increment_value != auto_increment_value || info->data_file_name != data_file_name || info->index_file_name != index_file_name || - table_changes == IS_EQUAL_NO) + table_changes == IS_EQUAL_NO || + table_changes & IS_EQUAL_PACK_LENGTH) // Not implemented yet return COMPATIBLE_DATA_NO; if ((options & (HA_OPTION_PACK_RECORD | HA_OPTION_CHECKSUM | diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 1cde37644bc..f4a052cea8a 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -74,7 +74,7 @@ handlerton myisammrg_hton= { NULL, /* Alter table flags */ NULL, /* Alter Tablespace */ NULL, /* Fill Files Table */ - HTON_CAN_RECREATE, + HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE, NULL, /* binlog_func */ NULL, /* binlog_log_query */ NULL /* release_temporary_latches */ diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5a1d4f48c9b..f46a5eccabf 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -182,6 +182,8 @@ static const char * ndb_connected_host= 0; static long ndb_connected_port= 0; static long ndb_number_of_replicas= 0; long ndb_number_of_storage_nodes= 0; +long ndb_number_of_ready_storage_nodes= 0; +long ndb_connect_count= 0; static int update_status_variables(Ndb_cluster_connection *c) { @@ -190,6 +192,8 @@ static int update_status_variables(Ndb_cluster_connection *c) ndb_connected_host= c->get_connected_host(); ndb_number_of_replicas= 0; ndb_number_of_storage_nodes= c->no_db_nodes(); + ndb_number_of_ready_storage_nodes= c->get_no_ready(); + ndb_connect_count= c->get_connect_count(); return 0; } @@ -7128,10 +7132,6 @@ void ndbcluster_real_free_share(NDB_SHARE **share) #ifndef DBUG_OFF bzero((gptr)(*share)->table_share, sizeof(*(*share)->table_share)); bzero((gptr)(*share)->table, sizeof(*(*share)->table)); -#endif - my_free((gptr) (*share)->table_share, MYF(0)); - my_free((gptr) (*share)->table, MYF(0)); -#ifndef DBUG_OFF (*share)->table_share= 0; (*share)->table= 0; #endif @@ -9361,11 +9361,15 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print, "cluster_node_id=%u, " "connected_host=%s, " "connected_port=%u, " - "number_of_storage_nodes=%u", + "number_of_storage_nodes=%u, " + "number_of_ready_storage_nodes=%u, " + "connect_count=%u", ndb_cluster_node_id, ndb_connected_host, ndb_connected_port, - ndb_number_of_storage_nodes); + ndb_number_of_storage_nodes, + ndb_number_of_ready_storage_nodes, + ndb_connect_count); if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name), "connection", strlen("connection"), buf, buflen)) diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index f407cb0090f..78c9ec765bb 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -113,6 +113,7 @@ typedef struct st_ndbcluster_share { char *old_names; // for rename table TABLE_SHARE *table_share; TABLE *table; + byte *record[2]; // pointer to allocated records for receiving data NdbValue *ndb_value[2]; MY_BITMAP *subscriber_bitmap; #endif diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index e358c87b378..144c073d565 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -25,6 +25,7 @@ #include "slave.h" #include "ha_ndbcluster_binlog.h" #include "NdbDictionary.hpp" +#include <util/NdbAutoPtr.hpp> #ifdef ndb_dynamite #undef assert @@ -265,7 +266,8 @@ ndbcluster_binlog_close_table(THD *thd, NDB_SHARE *share) static int ndbcluster_binlog_open_table(THD *thd, NDB_SHARE *share, - TABLE_SHARE *table_share, TABLE *table) + TABLE_SHARE *table_share, TABLE *table, + int reopen) { int error; DBUG_ENTER("ndbcluster_binlog_open_table"); @@ -278,27 +280,34 @@ ndbcluster_binlog_open_table(THD *thd, NDB_SHARE *share, share->key, error); DBUG_PRINT("error", ("open_table_def failed %d", error)); free_table_share(table_share); - my_free((gptr) table_share, MYF(0)); - my_free((gptr) table, MYF(0)); DBUG_RETURN(error); } - if ((error= open_table_from_share(thd, table_share, "", 0, + if ((error= open_table_from_share(thd, table_share, "", 0 /* fon't allocate buffers */, (uint) READ_ALL, 0, table, FALSE))) { sql_print_error("Unable to open table for %s, error=%d(%d)", share->key, error, my_errno); DBUG_PRINT("error", ("open_table_from_share failed %d", error)); free_table_share(table_share); - my_free((gptr) table_share, MYF(0)); - my_free((gptr) table, MYF(0)); DBUG_RETURN(error); } assign_new_table_id(table_share); - if (!table->record[1] || table->record[1] == table->record[0]) + + if (!reopen) + { + // allocate memory on ndb share so it can be reused after online alter table + share->record[0]= (byte*) alloc_root(&share->mem_root, table->s->rec_buff_length); + share->record[1]= (byte*) alloc_root(&share->mem_root, table->s->rec_buff_length); + } { - table->record[1]= alloc_root(&table->mem_root, - table->s->rec_buff_length); + my_ptrdiff_t row_offset= share->record[0] - table->record[0]; + Field **p_field; + for (p_field= table->field; *p_field; p_field++) + (*p_field)->move_field_offset(row_offset); + table->record[0]= share->record[0]; + table->record[1]= share->record[1]; } + table->in_use= injector_thd; table->s->db.str= share->db; @@ -366,10 +375,9 @@ void ndbcluster_binlog_init_share(NDB_SHARE *share, TABLE *_table) while (1) { int error; - TABLE_SHARE *table_share= - (TABLE_SHARE *) my_malloc(sizeof(*table_share), MYF(MY_WME)); - TABLE *table= (TABLE*) my_malloc(sizeof(*table), MYF(MY_WME)); - if ((error= ndbcluster_binlog_open_table(thd, share, table_share, table))) + TABLE_SHARE *table_share= (TABLE_SHARE *) alloc_root(mem_root, sizeof(*table_share)); + TABLE *table= (TABLE*) alloc_root(mem_root, sizeof(*table)); + if ((error= ndbcluster_binlog_open_table(thd, share, table_share, table, 0))) break; /* ! do not touch the contents of the table @@ -1535,6 +1543,10 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, sql_print_information("NDB: Failed write frm for %s.%s, error %d", dbname, tabname, error); } + + // copy names as memory will be freed + NdbAutoPtr<char> a1((char *)(dbname= strdup(dbname))); + NdbAutoPtr<char> a2((char *)(tabname= strdup(tabname))); ndbcluster_binlog_close_table(thd, share); TABLE_LIST table_list; @@ -1543,10 +1555,16 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, table_list.alias= table_list.table_name= (char *)tabname; close_cached_tables(thd, 0, &table_list, TRUE); - if ((error= ndbcluster_binlog_open_table(thd, share, - table_share, table))) + if ((error= ndbcluster_binlog_open_table(thd, share, + table_share, table, 1))) sql_print_information("NDB: Failed to re-open table %s.%s", dbname, tabname); + + table= share->table; + table_share= share->table_share; + dbname= table_share->db.str; + tabname= table_share->table_name.str; + pthread_mutex_unlock(&LOCK_open); } my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); @@ -1775,6 +1793,9 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, // skip break; case NDBEVENT::TE_CLUSTER_FAILURE: + if (ndb_extra_logging) + sql_print_information("NDB Binlog: cluster failure for %s at epoch %u.", + schema_share->key, (unsigned) pOp->getGCI()); // fall through case NDBEVENT::TE_DROP: if (ndb_extra_logging && @@ -1783,7 +1804,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, "read only on reconnect."); free_share(&schema_share); schema_share= 0; - ndb_binlog_tables_inited= FALSE; + close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0, FALSE); // fall through case NDBEVENT::TE_ALTER: ndb_handle_schema_change(thd, ndb, pOp, tmp_share); @@ -2101,7 +2122,14 @@ add_binlog_index_err: Functions for start, stop, wait for ndbcluster binlog thread *********************************************************************/ -static int do_ndbcluster_binlog_close_connection= 0; +enum Binlog_thread_state +{ + BCCC_running= 0, + BCCC_exit= 1, + BCCC_restart= 2 +}; + +static enum Binlog_thread_state do_ndbcluster_binlog_close_connection= BCCC_restart; int ndbcluster_binlog_start() { @@ -2139,7 +2167,7 @@ static void ndbcluster_binlog_close_connection(THD *thd) DBUG_ENTER("ndbcluster_binlog_close_connection"); const char *save_info= thd->proc_info; thd->proc_info= "ndbcluster_binlog_close_connection"; - do_ndbcluster_binlog_close_connection= 1; + do_ndbcluster_binlog_close_connection= BCCC_exit; while (ndb_binlog_thread_running > 0) sleep(1); thd->proc_info= save_info; @@ -2819,7 +2847,8 @@ ndb_binlog_thread_handle_non_data_event(THD *thd, Ndb *ndb, { case NDBEVENT::TE_CLUSTER_FAILURE: if (ndb_extra_logging) - sql_print_information("NDB Binlog: cluster failure for %s.", share->key); + sql_print_information("NDB Binlog: cluster failure for %s at epoch %u.", + share->key, (unsigned) pOp->getGCI()); if (apply_status_share == share) { if (ndb_extra_logging && @@ -2828,7 +2857,6 @@ ndb_binlog_thread_handle_non_data_event(THD *thd, Ndb *ndb, "read only on reconnect."); free_share(&apply_status_share); apply_status_share= 0; - ndb_binlog_tables_inited= FALSE; } DBUG_PRINT("info", ("CLUSTER FAILURE EVENT: " "%s received share: 0x%lx op: %lx share op: %lx " @@ -2844,7 +2872,6 @@ ndb_binlog_thread_handle_non_data_event(THD *thd, Ndb *ndb, "read only on reconnect."); free_share(&apply_status_share); apply_status_share= 0; - ndb_binlog_tables_inited= FALSE; } /* ToDo: remove printout */ if (ndb_extra_logging) @@ -3257,37 +3284,73 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) pthread_mutex_unlock(&injector_mutex); pthread_cond_signal(&injector_cond); - thd->proc_info= "Waiting for ndbcluster to start"; - - pthread_mutex_lock(&injector_mutex); - while (!schema_share || - (ndb_binlog_running && !apply_status_share)) +restart: + /* + Main NDB Injector loop + */ { - /* ndb not connected yet */ - struct timespec abstime; - set_timespec(abstime, 1); - pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime); - if (abort_loop) + thd->proc_info= "Waiting for ndbcluster to start"; + + pthread_mutex_lock(&injector_mutex); + while (!schema_share || + (ndb_binlog_running && !apply_status_share)) { - pthread_mutex_unlock(&injector_mutex); - goto err; + /* ndb not connected yet */ + struct timespec abstime; + set_timespec(abstime, 1); + pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime); + if (abort_loop) + { + pthread_mutex_unlock(&injector_mutex); + goto err; + } } - } - pthread_mutex_unlock(&injector_mutex); + pthread_mutex_unlock(&injector_mutex); - /* - Main NDB Injector loop - */ + if (thd_ndb == NULL) + { + DBUG_ASSERT(ndbcluster_hton.slot != ~(uint)0); + if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb())) + { + sql_print_error("Could not allocate Thd_ndb object"); + goto err; + } + set_thd_ndb(thd, thd_ndb); + thd_ndb->options|= TNO_NO_LOG_SCHEMA_OP; + thd->query_id= 0; // to keep valgrind quiet + } + } - DBUG_ASSERT(ndbcluster_hton.slot != ~(uint)0); - if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb())) { - sql_print_error("Could not allocate Thd_ndb object"); - goto err; + // wait for the first event + thd->proc_info= "Waiting for first event from ndbcluster"; + DBUG_PRINT("info", ("Waiting for the first event")); + int schema_res= 0; + Uint64 schema_gci= 0; + while (schema_res == 0 && !abort_loop) + { + schema_res= s_ndb->pollEvents(100, &schema_gci); + } + // now check that we have epochs consistant with what we had before the restart + DBUG_PRINT("info", ("schema_res: %d schema_gci: %d", schema_res, schema_gci)); + if (schema_res > 0) + { + i_ndb->pollEvents(0); + i_ndb->flushIncompleteEvents(schema_gci); + s_ndb->flushIncompleteEvents(schema_gci); + if (schema_gci < ndb_latest_handled_binlog_epoch) + { + sql_print_error("NDB Binlog: cluster has been restarted --initial or with older filesystem. " + "ndb_latest_handled_binlog_epoch: %u, while current epoch: %u. " + "RESET MASTER should be issued. Resetting ndb_latest_handled_binlog_epoch.", + (unsigned) ndb_latest_handled_binlog_epoch, (unsigned) schema_gci); + g_latest_trans_gci= 0; + ndb_latest_handled_binlog_epoch= 0; + ndb_latest_applied_binlog_epoch= 0; + ndb_latest_received_binlog_epoch= 0; + } + } } - set_thd_ndb(thd, thd_ndb); - thd_ndb->options|= TNO_NO_LOG_SCHEMA_OP; - thd->query_id= 0; // to keep valgrind quiet { static char db[]= ""; thd->db= db; @@ -3295,11 +3358,20 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) open_binlog_index(thd, &binlog_tables, &binlog_index); thd->db= db; } - + do_ndbcluster_binlog_close_connection= BCCC_running; for ( ; !((abort_loop || do_ndbcluster_binlog_close_connection) && - ndb_latest_handled_binlog_epoch >= g_latest_trans_gci); ) + ndb_latest_handled_binlog_epoch >= g_latest_trans_gci) && + do_ndbcluster_binlog_close_connection != BCCC_restart; ) { - +#ifndef DBUG_OFF + if (do_ndbcluster_binlog_close_connection) + { + DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection: %d, " + "ndb_latest_handled_binlog_epoch: %llu, " + "g_latest_trans_gci: %llu", do_ndbcluster_binlog_close_connection, + ndb_latest_handled_binlog_epoch, g_latest_trans_gci)); + } +#endif #ifdef RUN_NDB_BINLOG_TIMER main_timer.stop(); sql_print_information("main_timer %ld ms", main_timer.elapsed_ms()); @@ -3324,7 +3396,13 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) ndb_latest_received_binlog_epoch= gci; while (gci > schema_gci && schema_res >= 0) + { + static char buf[64]; + thd->proc_info= "Waiting for schema epoch"; + my_snprintf(buf, sizeof(buf), "%s %u(%u)", thd->proc_info, (unsigned) schema_gci, (unsigned) gci); + thd->proc_info= buf; schema_res= s_ndb->pollEvents(10, &schema_gci); + } if ((abort_loop || do_ndbcluster_binlog_close_connection) && (ndb_latest_handled_binlog_epoch >= g_latest_trans_gci || @@ -3360,10 +3438,31 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) while (pOp != NULL) { if (!pOp->hasError()) + { ndb_binlog_thread_handle_schema_event(thd, s_ndb, pOp, &post_epoch_log_list, &post_epoch_unlock_list, &mem_root); + DBUG_PRINT("info", ("s_ndb first: %s", s_ndb->getEventOperation() ? + s_ndb->getEventOperation()->getEvent()->getTable()->getName() : + "<empty>")); + DBUG_PRINT("info", ("i_ndb first: %s", i_ndb->getEventOperation() ? + i_ndb->getEventOperation()->getEvent()->getTable()->getName() : + "<empty>")); + if (i_ndb->getEventOperation() == NULL && + s_ndb->getEventOperation() == NULL && + do_ndbcluster_binlog_close_connection == BCCC_running) + { + DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart")); + do_ndbcluster_binlog_close_connection= BCCC_restart; + if (ndb_latest_received_binlog_epoch < g_latest_trans_gci && ndb_binlog_running) + { + sql_print_error("NDB Binlog: latest transaction in epoch %lld not in binlog " + "as latest received epoch is %lld", + g_latest_trans_gci, ndb_latest_received_binlog_epoch); + } + } + } else sql_print_error("NDB: error %lu (%s) on handling " "binlog schema event", @@ -3532,6 +3631,25 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) ndb_binlog_thread_handle_non_data_event(thd, i_ndb, pOp, row); // reset to catch errors i_ndb->setDatabaseName(""); + DBUG_PRINT("info", ("s_ndb first: %s", s_ndb->getEventOperation() ? + s_ndb->getEventOperation()->getEvent()->getTable()->getName() : + "<empty>")); + DBUG_PRINT("info", ("i_ndb first: %s", i_ndb->getEventOperation() ? + i_ndb->getEventOperation()->getEvent()->getTable()->getName() : + "<empty>")); + if (i_ndb->getEventOperation() == NULL && + s_ndb->getEventOperation() == NULL && + do_ndbcluster_binlog_close_connection == BCCC_running) + { + DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart")); + do_ndbcluster_binlog_close_connection= BCCC_restart; + if (ndb_latest_received_binlog_epoch < g_latest_trans_gci && ndb_binlog_running) + { + sql_print_error("NDB Binlog: latest transaction in epoch %lld not in binlog " + "as latest received epoch is %lld", + g_latest_trans_gci, ndb_latest_received_binlog_epoch); + } + } } pOp= i_ndb->nextEvent(); @@ -3587,6 +3705,13 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) *root_ptr= old_root; ndb_latest_handled_binlog_epoch= ndb_latest_received_binlog_epoch; } + if (do_ndbcluster_binlog_close_connection == BCCC_restart) + { + ndb_binlog_tables_inited= FALSE; + close_thread_tables(thd); + binlog_index= 0; + goto restart; + } err: DBUG_PRINT("info",("Shutting down cluster binlog thread")); thd->proc_info= "Shutting down"; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index b1a5a447b6f..7b9dd00ed56 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4175,6 +4175,8 @@ void ha_partition::info(uint flag) index_file_length: Length of index file, in principle bytes in indexes in the table We report sum + delete_length: Length of free space easily used by new records in table + We report sum mean_record_length:Mean record length in the table We calculate this check_time: Time of last check (only applicable to MyISAM) @@ -4184,6 +4186,7 @@ void ha_partition::info(uint flag) deleted= 0; data_file_length= 0; index_file_length= 0; + delete_length= 0; check_time= 0; file_array= m_file; do @@ -4196,6 +4199,7 @@ void ha_partition::info(uint flag) deleted+= file->deleted; data_file_length+= file->data_file_length; index_file_length+= file->index_file_length; + delete_length+= file->delete_length; if (file->check_time > check_time) check_time= file->check_time; } @@ -5325,6 +5329,82 @@ void ha_partition::init_table_handle_for_HANDLER() /**************************************************************************** + MODULE enable/disable indexes +****************************************************************************/ + +/* + Disable indexes for a while + SYNOPSIS + disable_indexes() + mode Mode + RETURN VALUES + 0 Success + != 0 Error +*/ + +int ha_partition::disable_indexes(uint mode) +{ + handler **file; + int error= 0; + + for (file= m_file; *file; file++) + { + if ((error= (*file)->disable_indexes(mode))) + break; + } + return error; +} + + +/* + Enable indexes again + SYNOPSIS + enable_indexes() + mode Mode + RETURN VALUES + 0 Success + != 0 Error +*/ + +int ha_partition::enable_indexes(uint mode) +{ + handler **file; + int error= 0; + + for (file= m_file; *file; file++) + { + if ((error= (*file)->enable_indexes(mode))) + break; + } + return error; +} + + +/* + Check if indexes are disabled + SYNOPSIS + indexes_are_disabled() + + RETURN VALUES + 0 Indexes are enabled + != 0 Indexes are disabled +*/ + +int ha_partition::indexes_are_disabled(void) +{ + handler **file; + int error= 0; + + for (file= m_file; *file; file++) + { + if ((error= (*file)->indexes_are_disabled())) + break; + } + return error; +} + + +/**************************************************************************** MODULE Partition Share ****************************************************************************/ /* diff --git a/sql/ha_partition.h b/sql/ha_partition.h index b31b9af28a3..1443a20133c 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -938,17 +938,18 @@ public: virtual uint checksum() const; virtual bool is_crashed() const; virtual bool auto_repair() const; + */ + /* ------------------------------------------------------------------------- MODULE enable/disable indexes ------------------------------------------------------------------------- - Enable/Disable Indexes are not supported currently (Heap, MyISAM) - This means that the following methods are not implemented: + Enable/Disable Indexes are only supported by HEAP and MyISAM. ------------------------------------------------------------------------- + */ virtual int disable_indexes(uint mode); virtual int enable_indexes(uint mode); virtual int indexes_are_disabled(void); - */ /* ------------------------------------------------------------------------- diff --git a/sql/handler.h b/sql/handler.h index d988e46b236..afee6bb9f8d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -603,6 +603,7 @@ struct show_table_alias_st { #define HTON_FLUSH_AFTER_RENAME (1 << 4) #define HTON_NOT_USER_SELECTABLE (1 << 5) #define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported +#define HTON_ALTER_CANNOT_CREATE (1 << 7) //Cannot use alter to create typedef struct st_thd_trans { diff --git a/sql/item.cc b/sql/item.cc index f778f0cb38e..d596699dd30 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -304,6 +304,7 @@ Item::Item(): marker= 0; maybe_null=null_value=with_sum_func=unsigned_flag=0; decimals= 0; max_length= 0; + with_subselect= 0; /* Put item in free list so that we can free all items at end */ THD *thd= current_thd; @@ -961,6 +962,12 @@ void Item_splocal::print(String *str) } +bool Item_splocal::set_value(THD *thd, sp_rcontext *ctx, Item **it) +{ + return ctx->set_variable(thd, get_var_idx(), it); +} + + /***************************************************************************** Item_case_expr methods *****************************************************************************/ @@ -1890,7 +1897,6 @@ Item_decimal::Item_decimal(const char *str_arg, uint length, name= (char*) str_arg; decimals= (uint8) decimal_value.frac; fixed= 1; - unsigned_flag= !decimal_value.sign(); max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, decimals, unsigned_flag); } @@ -1900,7 +1906,6 @@ Item_decimal::Item_decimal(longlong val, bool unsig) int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value); decimals= (uint8) decimal_value.frac; fixed= 1; - unsigned_flag= !decimal_value.sign(); max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, decimals, unsigned_flag); } @@ -1911,7 +1916,6 @@ Item_decimal::Item_decimal(double val, int precision, int scale) double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value); decimals= (uint8) decimal_value.frac; fixed= 1; - unsigned_flag= !decimal_value.sign(); max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, decimals, unsigned_flag); } @@ -1924,7 +1928,6 @@ Item_decimal::Item_decimal(const char *str, const my_decimal *val_arg, name= (char*) str; decimals= (uint8) decimal_par; max_length= length; - unsigned_flag= !decimal_value.sign(); fixed= 1; } @@ -1934,7 +1937,6 @@ Item_decimal::Item_decimal(my_decimal *value_par) my_decimal2decimal(value_par, &decimal_value); decimals= (uint8) decimal_value.frac; fixed= 1; - unsigned_flag= !decimal_value.sign(); max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, decimals, unsigned_flag); } @@ -1946,7 +1948,6 @@ Item_decimal::Item_decimal(const char *bin, int precision, int scale) &decimal_value, precision, scale); decimals= (uint8) decimal_value.frac; fixed= 1; - unsigned_flag= !decimal_value.sign(); max_length= my_decimal_precision_to_length(precision, decimals, unsigned_flag); } @@ -4881,7 +4882,16 @@ void Item_ref::cleanup() void Item_ref::print(String *str) { if (ref) - (*ref)->print(str); + { + if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF && + name && alias_name_used) + { + THD *thd= current_thd; + append_identifier(thd, str, name, (uint) strlen(name)); + } + else + (*ref)->print(str); + } else Item_ident::print(str); } @@ -5413,6 +5423,25 @@ bool Item_trigger_field::eq(const Item *item, bool binary_cmp) const } +void Item_trigger_field::set_required_privilege(bool rw) +{ + /* + Require SELECT and UPDATE privilege if this field will be read and + set, and only UPDATE privilege for setting the field. + */ + want_privilege= (rw ? SELECT_ACL | UPDATE_ACL : UPDATE_ACL); +} + + +bool Item_trigger_field::set_value(THD *thd, sp_rcontext */*ctx*/, Item **it) +{ + Item *item= sp_prepare_func_item(thd, it); + + return (!item || (!fixed && fix_fields(thd, 0)) || + (item->save_in_field(field, 0) < 0)); +} + + bool Item_trigger_field::fix_fields(THD *thd, Item **items) { /* @@ -5435,8 +5464,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items) if (table_grants) { - table_grants->want_privilege= - access_type == AT_READ ? SELECT_ACL : UPDATE_ACL; + table_grants->want_privilege= want_privilege; if (check_grant_column(thd, table_grants, triggers->table->s->db.str, triggers->table->s->table_name.str, field_name, @@ -5468,6 +5496,7 @@ void Item_trigger_field::print(String *str) void Item_trigger_field::cleanup() { + want_privilege= original_privilege; /* Since special nature of Item_trigger_field we should not do most of things from Item_field::cleanup() or Item_ident::cleanup() here. diff --git a/sql/item.h b/sql/item.h index f73017563dd..2f99034130a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -401,6 +401,42 @@ typedef enum monotonicity_info /*************************************************************************/ +class sp_rcontext; + + +class Settable_routine_parameter +{ +public: + /* + Set required privileges for accessing the parameter. + + SYNOPSIS + set_required_privilege() + rw if 'rw' is true then we are going to read and set the + parameter, so SELECT and UPDATE privileges might be + required, otherwise we only reading it and SELECT + privilege might be required. + */ + virtual void set_required_privilege(bool rw) {}; + + /* + Set parameter value. + + SYNOPSIS + set_value() + thd thread handle + ctx context to which parameter belongs (if it is local + variable). + it item which represents new value + + RETURN + FALSE if parameter value has been set, + TRUE if error has occured. + */ + virtual bool set_value(THD *thd, sp_rcontext *ctx, Item **it)= 0; +}; + + typedef bool (Item::*Item_processor)(byte *arg); typedef Item* (Item::*Item_transformer) (byte *arg); typedef void (*Cond_traverser) (const Item *item, void *arg); @@ -454,6 +490,9 @@ public: my_bool is_autogenerated_name; /* indicate was name of this Item autogenerated or set by user */ DTCollation collation; + my_bool with_subselect; /* If this item is a subselect or some + of its arguments is or contains a + subselect */ // alloc & destruct is done as start of select using sql_alloc Item(); @@ -784,6 +823,15 @@ public: } virtual bool is_splocal() { return 0; } /* Needed for error checking */ + + /* + Return Settable_routine_parameter interface of the Item. Return 0 + if this Item is not Settable_routine_parameter. + */ + virtual Settable_routine_parameter *get_settable_routine_parameter() + { + return 0; + } }; @@ -882,7 +930,8 @@ inline bool Item_sp_variable::send(Protocol *protocol, String *str) runtime. *****************************************************************************/ -class Item_splocal :public Item_sp_variable +class Item_splocal :public Item_sp_variable, + private Settable_routine_parameter { uint m_var_idx; @@ -920,6 +969,15 @@ public: inline enum Type type() const; inline Item_result result_type() const; + +private: + bool set_value(THD *thd, sp_rcontext *ctx, Item **it); + +public: + Settable_routine_parameter *get_settable_routine_parameter() + { + return this; + } }; /***************************************************************************** @@ -2146,14 +2204,13 @@ class Table_triggers_list; two Field instances representing either OLD or NEW version of this field. */ -class Item_trigger_field : public Item_field +class Item_trigger_field : public Item_field, + private Settable_routine_parameter { public: /* Is this item represents row from NEW or OLD row ? */ enum row_version_type {OLD_ROW, NEW_ROW}; row_version_type row_version; - /* Is this item used for reading or updating the value? */ - enum access_types { AT_READ = 0x1, AT_UPDATE = 0x2 }; /* Next in list of all Item_trigger_field's in trigger */ Item_trigger_field *next_trg_field; /* Index of the field in the TABLE::field array */ @@ -2164,11 +2221,11 @@ public: Item_trigger_field(Name_resolution_context *context_arg, row_version_type row_ver_arg, const char *field_name_arg, - access_types access_type_arg) + ulong priv, const bool ro) :Item_field(context_arg, (const char *)NULL, (const char *)NULL, field_name_arg), - row_version(row_ver_arg), field_idx((uint)-1), - access_type(access_type_arg), table_grants(NULL) + row_version(row_ver_arg), field_idx((uint)-1), original_privilege(priv), + want_privilege(priv), table_grants(NULL), read_only (ro) {} void setup_field(THD *thd, TABLE *table, GRANT_INFO *table_grant_info); enum Type type() const { return TRIGGER_FIELD_ITEM; } @@ -2179,8 +2236,39 @@ public: void cleanup(); private: - access_types access_type; + void set_required_privilege(bool rw); + bool set_value(THD *thd, sp_rcontext *ctx, Item **it); + +public: + Settable_routine_parameter *get_settable_routine_parameter() + { + return (read_only ? 0 : this); + } + + bool set_value(THD *thd, Item **it) + { + return set_value(thd, NULL, it); + } + +private: + /* + 'want_privilege' holds privileges required to perform operation on + this trigger field (SELECT_ACL if we are going to read it and + UPDATE_ACL if we are going to update it). It is initialized at + parse time but can be updated later if this trigger field is used + as OUT or INOUT parameter of stored routine (in this case + set_required_privilege() is called to appropriately update + want_privilege and cleanup() is responsible for restoring of + original want_privilege once parameter's value is updated). + */ + ulong original_privilege; + ulong want_privilege; GRANT_INFO *table_grants; + /* + Trigger field is read-only unless it belongs to the NEW row in a + BEFORE INSERT of BEFORE UPDATE trigger. + */ + bool read_only; }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index eb26f7ff960..0552e8b6336 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -204,10 +204,28 @@ longlong Item_func_nop_all::val_int() /* - Convert a constant expression or string to an integer. - This is done when comparing DATE's of different formats and - also when comparing bigint to strings (in which case the string - is converted once to a bigint). + Convert a constant item to an int and replace the original item + + SYNOPSIS + convert_constant_item() + thd thread handle + field item will be converted using the type of this field + item [in/out] reference to the item to convert + + DESCRIPTION + The function converts a constant expression or string to an integer. + On successful conversion the original item is substituted for the + result of the item evaluation. + This is done when comparing DATE/TIME of different formats and + also when comparing bigint to strings (in which case strings + are converted to bigints). + + NOTES + This function is called only at prepare stage. + As all derived tables are filled only after all derived tables + are prepared we do not evaluate items with subselects here because + they can contain derived tables and thus we may attempt to use a + table that has not been populated yet. RESULT VALUES 0 Can't convert item @@ -216,7 +234,7 @@ longlong Item_func_nop_all::val_int() static bool convert_constant_item(THD *thd, Field *field, Item **item) { - if ((*item)->const_item()) + if (!(*item)->with_subselect && (*item)->const_item()) { /* For comparison purposes allow invalid dates like 2000-01-32 */ ulong orig_sql_mode= field->table->in_use->variables.sql_mode; @@ -2570,7 +2588,9 @@ Item_cond::fix_fields(THD *thd, Item **ref) (item= *li.ref())->check_cols(1)) return TRUE; /* purecov: inspected */ used_tables_cache|= item->used_tables(); - if (!item->const_item()) + if (item->const_item()) + and_tables_cache= (table_map) 0; + else { tmp_table_map= item->not_null_tables(); not_null_tables_cache|= tmp_table_map; @@ -2578,6 +2598,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) const_item_cache= FALSE; } with_sum_func= with_sum_func || item->with_sum_func; + with_subselect|= item->with_subselect; if (item->maybe_null) maybe_null=1; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 9281a8a1ddf..acdaa4b246d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -184,6 +184,7 @@ Item_func::fix_fields(THD *thd, Item **ref) used_tables_cache|= item->used_tables(); not_null_tables_cache|= item->not_null_tables(); const_item_cache&= item->const_item(); + with_subselect|= item->with_subselect; } } fix_length_and_dec(); @@ -2736,9 +2737,10 @@ String *udf_handler::val_str(String *str,String *save_str) { uchar is_null_tmp=0; ulong res_length; + DBUG_ENTER("udf_handler::val_str"); if (get_arguments()) - return 0; + DBUG_RETURN(0); char * (*func)(UDF_INIT *, UDF_ARGS *, char *, ulong *, uchar *, uchar *)= (char* (*)(UDF_INIT *, UDF_ARGS *, char *, ulong *, uchar *, uchar *)) u_d->func; @@ -2748,22 +2750,26 @@ String *udf_handler::val_str(String *str,String *save_str) if (str->alloc(MAX_FIELD_WIDTH)) { error=1; - return 0; + DBUG_RETURN(0); } } char *res=func(&initid, &f_args, (char*) str->ptr(), &res_length, &is_null_tmp, &error); + DBUG_PRINT("info", ("udf func returned, res_length: %lu", res_length)); if (is_null_tmp || !res || error) // The !res is for safety { - return 0; + DBUG_PRINT("info", ("Null or error")); + DBUG_RETURN(0); } if (res == str->ptr()) { str->length(res_length); - return str; + DBUG_PRINT("exit", ("str: %s", str->ptr())); + DBUG_RETURN(str); } save_str->set(res, res_length, str->charset()); - return save_str; + DBUG_PRINT("exit", ("save_str: %s", save_str->ptr())); + DBUG_RETURN(save_str); } @@ -3013,6 +3019,7 @@ void item_user_lock_free(void) void item_user_lock_release(User_level_lock *ull) { ull->locked=0; + ull->thread_id= 0; if (--ull->count) pthread_cond_signal(&ull->cond); else @@ -3220,6 +3227,7 @@ longlong Item_func_get_lock::val_int() { ull->locked=1; ull->thread=thd->real_id; + ull->thread_id= thd->thread_id; thd->ull=ull; error=0; } @@ -3946,14 +3954,24 @@ int get_var_with_binlog(THD *thd, enum_sql_command sql_command, sql_set_variables(), we could instead manually call check() and update(); this would save memory and time; but calling sql_set_variables() makes one unique place to maintain (sql_set_variables()). + + Manipulation with lex is necessary since free_underlaid_joins + is going to release memory belonging to the main query. */ List<set_var_base> tmp_var_list; + LEX *sav_lex= thd->lex, lex_tmp; + thd->lex= &lex_tmp; + lex_start(thd, NULL, 0); tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(name, new Item_null()))); /* Create the variable */ if (sql_set_variables(thd, &tmp_var_list)) + { + thd->lex= sav_lex; goto err; + } + thd->lex= sav_lex; if (!(var_entry= get_variable(&thd->user_vars, name, 0))) goto err; } @@ -4105,6 +4123,18 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const } +bool Item_func_get_user_var::set_value(THD *thd, + sp_rcontext */*ctx*/, Item **it) +{ + Item_func_set_user_var *suv= new Item_func_set_user_var(get_name(), *it); + /* + Item_func_set_user_var is not fixed after construction, call + fix_fields(). + */ + return (!suv || suv->fix_fields(thd, it) || suv->check() || suv->update()); +} + + bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); @@ -4737,6 +4767,7 @@ Item_func_sp::sp_result_field(void) const dummy_table->alias= empty_name; dummy_table->maybe_null= maybe_null; dummy_table->in_use= current_thd; + dummy_table->copy_blobs= TRUE; dummy_table->s->table_cache_key.str = empty_name; dummy_table->s->table_name.str= empty_name; dummy_table->s->db.str= empty_name; diff --git a/sql/item_func.h b/sql/item_func.h index a91d93be8c6..1d8a1bd5e22 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1179,7 +1179,8 @@ public: }; -class Item_func_get_user_var :public Item_func +class Item_func_get_user_var :public Item_func, + private Settable_routine_parameter { user_var_entry *var_entry; @@ -1206,6 +1207,15 @@ public: table_map used_tables() const { return const_item() ? 0 : RAND_TABLE_BIT; } bool eq(const Item *item, bool binary_cmp) const; + +private: + bool set_value(THD *thd, sp_rcontext *ctx, Item **it); + +public: + Settable_routine_parameter *get_settable_routine_parameter() + { + return this; + } }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 1e483f32b02..eb1fbf4855d 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2579,7 +2579,7 @@ String *Item_load_file::val_str(String *str) (void) fn_format(path, file_name->c_ptr(), mysql_real_data_home, "", MY_RELATIVE_PATH | MY_UNPACK_FILENAME); - if (!my_stat(path, &stat_info, MYF(MY_WME))) + if (!my_stat(path, &stat_info, MYF(0))) goto err; if (!(stat_info.st_mode & S_IROTH)) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 7d7b62df0dc..90d421a2c68 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -542,7 +542,7 @@ public: void fix_length_and_dec() { collation.set(default_charset()); - decimals=0; max_length=64; + max_length= 64; } }; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 6c2ff19825f..5280dbf6813 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -39,6 +39,7 @@ Item_subselect::Item_subselect(): engine(0), old_engine(0), used_tables_cache(0), have_to_be_excluded(0), const_item_cache(1), engine_changed(0), changed(0) { + with_subselect= 1; reset(); /* item value is NULL if select_subselect not changed this value @@ -1354,6 +1355,17 @@ void Item_in_subselect::print(String *str) } +bool Item_in_subselect::fix_fields(THD *thd, Item **ref) +{ + bool result = 0; + + if(thd->lex->view_prepare_mode && left_expr && !left_expr->fixed) + result = left_expr->fix_fields(thd, &left_expr); + + return result || Item_subselect::fix_fields(thd, ref); +} + + Item_subselect::trans_res Item_allany_subselect::select_transformer(JOIN *join) { diff --git a/sql/item_subselect.h b/sql/item_subselect.h index a4dac5bda87..293408dc09e 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -258,6 +258,7 @@ public: void top_level_item() { abort_on_null=1; } bool test_limit(st_select_lex_unit *unit); void print(String *str); + bool fix_fields(THD *thd, Item **ref); friend class Item_ref_null_helper; friend class Item_is_not_null_test; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 34e8b585dcc..9d98e446c84 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -631,7 +631,8 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, case 'r': length= my_sprintf(intbuff, (intbuff, - (l_time->hour < 12) ? "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM", + ((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)); @@ -869,9 +870,9 @@ String* Item_func_monthname::val_str(String* str) { DBUG_ASSERT(fixed == 1); const char *month_name; - uint month=(uint) Item_func_month::val_int(); + uint month= (uint) val_int(); - if (!month) // This is also true for NULL + if (null_value || !month) { null_value=1; return (String*) 0; @@ -1962,6 +1963,9 @@ bool Item_date_add_interval::get_date(TIME *ltime, uint fuzzy_date) if (date_sub_interval) interval.neg = !interval.neg; + if (ltime->year < YY_MAGIC_BELOW) + return (null_value=1); + return (null_value= date_add_interval(ltime, int_type, interval)); } @@ -2020,8 +2024,13 @@ bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const Item_date_add_interval *other= (Item_date_add_interval*) item; if ((int_type != other->int_type) || - (!args[0]->eq(other->args[0], binary_cmp)) || - (get_interval_value(args[1], int_type, &val, &interval))) + (!args[0]->eq(other->args[0], binary_cmp))) + return FALSE; + + if (!args[1]->const_item() || !other->args[1]->const_item()) + return (args[1]->eq(other->args[1], binary_cmp)); + + if (get_interval_value(args[1], int_type, &val, &interval)) return FALSE; val= other->value; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4da098f4b48..e4fd4c0da05 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -862,13 +862,6 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, List<create_field> &fields, List<Key> &keys, bool tmp_table, uint select_field_count); -TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, - TABLE_LIST *create_table, - List<create_field> *extra_fields, - List<Key> *keys, - List<Item> *items, - MYSQL_LOCK **lock, - TABLEOP_HOOKS *hooks); bool mysql_alter_table(THD *thd, char *new_db, char *new_name, HA_CREATE_INFO *create_info, TABLE_LIST *table_list, @@ -1509,6 +1502,7 @@ extern my_bool locked_in_memory; extern bool opt_using_transactions, mysqld_embedded; extern bool using_update_log, opt_large_files, server_id_supplied; extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log; +extern my_bool opt_log_queries_not_using_indexes; extern bool opt_disable_networking, opt_skip_show_db; extern my_bool opt_character_set_client_handshake; extern bool volatile abort_loop, shutdown_in_progress, grant_option; @@ -1648,15 +1642,16 @@ extern pthread_t signal_thread; #endif #ifdef HAVE_OPENSSL -extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd; +extern struct st_VioSSLFd * ssl_acceptor_fd; #endif /* HAVE_OPENSSL */ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags, bool *need_reopen); -/* mysql_lock_tables() flags bits */ +/* mysql_lock_tables() and open_table() flags bits */ #define MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001 #define MYSQL_LOCK_IGNORE_FLUSH 0x0002 #define MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004 +#define MYSQL_OPEN_IGNORE_LOCKED_TABLES 0x0008 void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); @@ -1946,7 +1941,6 @@ inline int hexchar_to_int(char c) return -1; } - /* Some functions that are different in the embedded library and the normal server diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0584bcc5ba1..42d87d6dc2f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -318,7 +318,6 @@ static bool volatile ready_to_exit; static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0; static my_bool opt_bdb, opt_isam, opt_ndbcluster; static my_bool opt_short_log_format= 0; -static my_bool opt_log_queries_not_using_indexes= 0; static uint kill_cached_threads, wake_thread; static ulong killed_threads, thread_created; static ulong max_used_connections; @@ -344,6 +343,7 @@ static my_bool opt_sync_bdb_logs; /* Global variables */ bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; +my_bool opt_log_queries_not_using_indexes= 0; bool opt_error_log= IF_WIN(1,0); bool opt_disable_networking=0, opt_skip_show_db=0; my_bool opt_character_set_client_handshake= 1; @@ -693,6 +693,7 @@ my_bool opt_enable_shared_memory; HANDLE smem_event_connect_request= 0; #endif +#define SSL_VARS_NOT_STATIC #include "sslopt-vars.h" #ifdef HAVE_OPENSSL #include <openssl/crypto.h> @@ -710,7 +711,7 @@ static void openssl_lock(int, openssl_lock_t *, const char *, int); static unsigned long openssl_id_function(); #endif char *des_key_file; -struct st_VioSSLAcceptorFd *ssl_acceptor_fd; +struct st_VioSSLFd *ssl_acceptor_fd; #endif /* HAVE_OPENSSL */ @@ -1044,7 +1045,8 @@ static void __cdecl kill_server(int sig_ptr) RETURN_FROM_KILL_SERVER; kill_in_progress=TRUE; abort_loop=1; // This should be set - my_sigset(sig,SIG_IGN); + if (sig != 0) // 0 is not a valid signal number + my_sigset(sig,SIG_IGN); if (sig == MYSQL_KILL_SIGNAL || sig == 0) sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname); else @@ -1076,6 +1078,10 @@ static void __cdecl kill_server(int sig_ptr) pthread_join(select_thread, NULL); // wait for main thread #endif /* __NETWARE__ */ +#if defined(__NETWARE__) || (defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)) + my_thread_end(); +#endif + pthread_exit(0); /* purecov: deadcode */ #endif /* EMBEDDED_LIBRARY */ @@ -1220,6 +1226,7 @@ void clean_up(bool print_message) delete binlog_filter; delete rpl_filter; end_ssl(); + vio_end(); #ifdef USE_REGEX my_regex_end(); #endif diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e4eb6e8ab3f..ffaf3fad6c8 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -450,6 +450,8 @@ public: /* TRUE if last checked tree->key can be used for ROR-scan */ bool is_ror_scan; + /* Number of ranges in the last checked tree->key */ + uint n_ranges; }; class TABLE_READ_PLAN; @@ -4306,7 +4308,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, DBUG_EXECUTE("info", print_ror_scans_arr(param->table, "building covering ROR-I", ror_scan_mark, ror_scans_end);); - do { + do + { /* Update changed sorting info: #covered fields, @@ -4695,17 +4698,46 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func, if (inv) { - /* - We get here for conditions like "t.keypart NOT IN (....)". - - If the IN-list contains only constants (and func->array is an ordered - array of them), we construct the appropriate SEL_ARG tree manually, - because constructing it using the range analyzer (as - AND_i( t.keypart != c_i)) will cause lots of memory to be consumed - (see BUG#15872). - */ if (func->array && func->cmp_type != ROW_RESULT) { + /* + We get here for conditions in form "t.key NOT IN (c1, c2, ...)" + (where c{i} are constants). + Our goal is to produce a SEL_ARG graph that represents intervals: + + ($MIN<t.key<c1) OR (c1<t.key<c2) OR (c2<t.key<c3) OR ... (*) + + where $MIN is either "-inf" or NULL. + + The most straightforward way to handle NOT IN would be to convert + it to "(t.key != c1) AND (t.key != c2) AND ..." and let the range + optimizer to build SEL_ARG graph from that. However that will cause + the range optimizer to use O(N^2) memory (it's a bug, not filed), + and people do use big NOT IN lists (see BUG#15872). Also, for big + NOT IN lists constructing/using graph (*) does not make the query + faster. + + So, we will handle NOT IN manually in the following way: + * if the number of entries in the NOT IN list is less then + NOT_IN_IGNORE_THRESHOLD, we will construct SEL_ARG graph (*) + manually. + * Otherwise, we will construct a smaller graph: for + "t.key NOT IN (c1,...cN)" we construct a graph representing + ($MIN < t.key) OR (cN < t.key) // here sequence of c_i is + // ordered. + + A note about partially-covering indexes: for those (e.g. for + "a CHAR(10), KEY(a(5))") the handling is correct (albeit not very + efficient): + Instead of "t.key < c1" we get "t.key <= prefix-val(c1)". + Combining the intervals in (*) together, we get: + (-inf<=t.key<=c1) OR (c1<=t.key<=c2) OR (c2<=t.key<=c3) OR ... + i.e. actually we get intervals combined into one interval: + (-inf<=t.key<=+inf). This doesn't make much sense but it doesn't + cause any problems. + */ + MEM_ROOT *tmp_root= param->mem_root; + param->thd->mem_root= param->old_root; /* Create one Item_type constant object. We'll need it as get_mm_parts only accepts constant values wrapped in Item_Type @@ -4714,25 +4746,35 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func, per-statement mem_root (while thd->mem_root is currently pointing to mem_root local to range optimizer). */ - MEM_ROOT *tmp_root= param->mem_root; - param->thd->mem_root= param->old_root; Item *value_item= func->array->create_item(); param->thd->mem_root= tmp_root; if (!value_item) break; - /* Get a SEL_TREE for "-inf < X < c_0" interval */ - func->array->value_to_item(0, value_item); - tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, - value_item, cmp_type); - if (!tree) + /* Get a SEL_TREE for "(-inf|NULL) < X < c_0" interval. */ + uint i=0; + do + { + func->array->value_to_item(i, value_item); + tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, + value_item, cmp_type); + if (!tree) + break; + i++; + } while (i < func->array->count && tree->type == SEL_TREE::IMPOSSIBLE); + + if (!tree || tree->type == SEL_TREE::IMPOSSIBLE) + { + /* We get here in cases like "t.unsigned NOT IN (-1,-2,-3) */ + tree= NULL; break; + } #define NOT_IN_IGNORE_THRESHOLD 1000 SEL_TREE *tree2; if (func->array->count < NOT_IN_IGNORE_THRESHOLD) { - for (uint i=1; i < func->array->count; i++) + for (; i < func->array->count; i++) { if (func->array->compare_elems(i, i-1)) { @@ -4740,32 +4782,44 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func, func->array->value_to_item(i, value_item); tree2= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, value_item, cmp_type); - + if (!tree2) + { + tree= NULL; + break; + } + /* Change all intervals to be "c_{i-1} < X < c_i" */ for (uint idx= 0; idx < param->keys; idx++) { - SEL_ARG *new_interval; - if ((new_interval= tree2->keys[idx])) + SEL_ARG *new_interval, *last_val; + if (((new_interval= tree2->keys[idx])) && + ((last_val= tree->keys[idx]->last()))) { - SEL_ARG *last_val= tree->keys[idx]->last(); new_interval->min_value= last_val->max_value; new_interval->min_flag= NEAR_MIN; } } + /* + The following doesn't try to allocate memory so no need to + check for NULL. + */ tree= tree_or(param, tree, tree2); } } } else func->array->value_to_item(func->array->count - 1, value_item); - - /* - Get the SEL_TREE for the last "c_last < X < +inf" interval - (value_item cotains c_last already) - */ - tree2= get_mm_parts(param, cond_func, field, Item_func::GT_FUNC, - value_item, cmp_type); - tree= tree_or(param, tree, tree2); + + if (tree && tree->type != SEL_TREE::IMPOSSIBLE) + { + /* + Get the SEL_TREE for the last "c_last < X < +inf" interval + (value_item cotains c_last already) + */ + tree2= get_mm_parts(param, cond_func, field, Item_func::GT_FUNC, + value_item, cmp_type); + tree= tree_or(param, tree, tree2); + } } else { @@ -6581,6 +6635,7 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree) param->table->file->primary_key_is_clustered()); param->is_ror_scan= !cpk_scan; } + param->n_ranges= 0; records=check_quick_keys(param,idx,tree,param->min_key,0,param->max_key,0); if (records != HA_POS_ERROR) @@ -6588,7 +6643,7 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree) param->table->quick_keys.set_bit(key); param->table->quick_rows[key]=records; param->table->quick_key_parts[key]=param->max_key_part+1; - + param->table->quick_n_ranges[key]= param->n_ranges; if (cpk_scan) param->is_ror_scan= TRUE; } @@ -6724,7 +6779,10 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree, HA_NOSAME && min_key_length == max_key_length && !memcmp(param->min_key,param->max_key,min_key_length)) + { tmp=1; // Max one record + param->n_ranges++; + } else { if (param->is_ror_scan) @@ -6744,6 +6802,7 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree, is_key_scan_ror(param, keynr, key_tree->part + 1))) param->is_ror_scan= FALSE; } + param->n_ranges++; if (tmp_min_flag & GEOM_FLAG) { @@ -7387,64 +7446,69 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() uint last_rowid_count=0; DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::get_next"); - /* Get a rowid for first quick and save it as a 'candidate' */ - quick= quick_it++; - if (cpk_quick) + do { - do { + /* Get a rowid for first quick and save it as a 'candidate' */ + quick= quick_it++; + if (cpk_quick) + { + do + { + error= quick->get_next(); + }while (!error && !cpk_quick->row_in_ranges()); + } + else error= quick->get_next(); - }while (!error && !cpk_quick->row_in_ranges()); - } - else - error= quick->get_next(); - if (error) - DBUG_RETURN(error); + if (error) + DBUG_RETURN(error); - quick->file->position(quick->record); - memcpy(last_rowid, quick->file->ref, head->file->ref_length); - last_rowid_count= 1; + quick->file->position(quick->record); + memcpy(last_rowid, quick->file->ref, head->file->ref_length); + last_rowid_count= 1; - while (last_rowid_count < quick_selects.elements) - { - if (!(quick= quick_it++)) + while (last_rowid_count < quick_selects.elements) { - quick_it.rewind(); - quick= quick_it++; - } - - do { - if ((error= quick->get_next())) - DBUG_RETURN(error); - quick->file->position(quick->record); - cmp= head->file->cmp_ref(quick->file->ref, last_rowid); - } while (cmp < 0); + if (!(quick= quick_it++)) + { + quick_it.rewind(); + quick= quick_it++; + } - /* Ok, current select 'caught up' and returned ref >= cur_ref */ - if (cmp > 0) - { - /* Found a row with ref > cur_ref. Make it a new 'candidate' */ - if (cpk_quick) + do { - while (!cpk_quick->row_in_ranges()) + if ((error= quick->get_next())) + DBUG_RETURN(error); + quick->file->position(quick->record); + cmp= head->file->cmp_ref(quick->file->ref, last_rowid); + } while (cmp < 0); + + /* Ok, current select 'caught up' and returned ref >= cur_ref */ + if (cmp > 0) + { + /* Found a row with ref > cur_ref. Make it a new 'candidate' */ + if (cpk_quick) { - if ((error= quick->get_next())) - DBUG_RETURN(error); + while (!cpk_quick->row_in_ranges()) + { + if ((error= quick->get_next())) + DBUG_RETURN(error); + } } + memcpy(last_rowid, quick->file->ref, head->file->ref_length); + last_rowid_count= 1; + } + else + { + /* current 'candidate' row confirmed by this select */ + last_rowid_count++; } - memcpy(last_rowid, quick->file->ref, head->file->ref_length); - last_rowid_count= 1; - } - else - { - /* current 'candidate' row confirmed by this select */ - last_rowid_count++; } - } - /* We get here iff we got the same row ref in all scans. */ - if (need_to_fetch_row) - error= head->file->rnd_pos(head->record[0], last_rowid); + /* We get here iff we got the same row ref in all scans. */ + if (need_to_fetch_row) + error= head->file->rnd_pos(head->record[0], last_rowid); + } while (error == HA_ERR_RECORD_DELETED); DBUG_RETURN(error); } @@ -7473,41 +7537,44 @@ int QUICK_ROR_UNION_SELECT::get_next() do { - if (!queue.elements) - DBUG_RETURN(HA_ERR_END_OF_FILE); - /* Ok, we have a queue with >= 1 scans */ + do + { + if (!queue.elements) + DBUG_RETURN(HA_ERR_END_OF_FILE); + /* Ok, we have a queue with >= 1 scans */ - quick= (QUICK_SELECT_I*)queue_top(&queue); - memcpy(cur_rowid, quick->last_rowid, rowid_length); + quick= (QUICK_SELECT_I*)queue_top(&queue); + memcpy(cur_rowid, quick->last_rowid, rowid_length); - /* put into queue rowid from the same stream as top element */ - if ((error= quick->get_next())) - { - if (error != HA_ERR_END_OF_FILE) - DBUG_RETURN(error); - queue_remove(&queue, 0); - } - else - { - quick->save_last_pos(); - queue_replaced(&queue); - } + /* put into queue rowid from the same stream as top element */ + if ((error= quick->get_next())) + { + if (error != HA_ERR_END_OF_FILE) + DBUG_RETURN(error); + queue_remove(&queue, 0); + } + else + { + quick->save_last_pos(); + queue_replaced(&queue); + } - if (!have_prev_rowid) - { - /* No rows have been returned yet */ - dup_row= FALSE; - have_prev_rowid= TRUE; - } - else - dup_row= !head->file->cmp_ref(cur_rowid, prev_rowid); - }while (dup_row); + if (!have_prev_rowid) + { + /* No rows have been returned yet */ + dup_row= FALSE; + have_prev_rowid= TRUE; + } + else + dup_row= !head->file->cmp_ref(cur_rowid, prev_rowid); + } while (dup_row); - tmp= cur_rowid; - cur_rowid= prev_rowid; - prev_rowid= tmp; + tmp= cur_rowid; + cur_rowid= prev_rowid; + prev_rowid= tmp; - error= head->file->rnd_pos(quick->record, prev_rowid); + error= head->file->rnd_pos(quick->record, prev_rowid); + } while (error == HA_ERR_RECORD_DELETED); DBUG_RETURN(error); } diff --git a/sql/partition_info.h b/sql/partition_info.h index 3a1e6be4050..af43f7b7933 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -184,6 +184,7 @@ public: bool list_of_subpart_fields; bool linear_hash_ind; bool fixed; + bool is_auto_partitioned; bool from_openfrm; bool has_null_value; uint has_null_part_id; @@ -219,6 +220,7 @@ public: list_of_part_fields(FALSE), list_of_subpart_fields(FALSE), linear_hash_ind(FALSE), fixed(FALSE), + is_auto_partitioned(FALSE), from_openfrm(FALSE), has_null_value(FALSE), has_null_part_id(0) diff --git a/sql/set_var.cc b/sql/set_var.cc index 9b06e0f833f..c2925256d3b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -163,6 +163,7 @@ void fix_sql_mode_var(THD *thd, enum_var_type type); static byte *get_error_count(THD *thd); static byte *get_warning_count(THD *thd); static byte *get_prepared_stmt_count(THD *thd); +static byte *get_tmpdir(THD *thd); /* Variable definition list @@ -185,6 +186,7 @@ sys_var_thd_ulong sys_auto_increment_offset("auto_increment_offset", sys_var_bool_ptr sys_automatic_sp_privileges("automatic_sp_privileges", &sp_automatic_privileges); +sys_var_const_str sys_basedir("basedir", mysql_home); sys_var_long_ptr sys_binlog_cache_size("binlog_cache_size", &binlog_cache_size); sys_var_thd_binlog_format sys_binlog_format("binlog_format", @@ -210,6 +212,7 @@ sys_var_long_ptr sys_concurrent_insert("concurrent_insert", &myisam_concurrent_insert); sys_var_long_ptr sys_connect_timeout("connect_timeout", &connect_timeout); +sys_var_const_str sys_datadir("datadir", mysql_real_data_home); #ifndef DBUG_OFF sys_var_thd_dbug sys_dbug("debug"); #endif @@ -262,6 +265,9 @@ sys_trust_routine_creators("log_bin_trust_routine_creators", sys_var_bool_ptr sys_trust_function_creators("log_bin_trust_function_creators", &trust_function_creators); +sys_var_bool_ptr + sys_log_queries_not_using_indexes("log_queries_not_using_indexes", + &opt_log_queries_not_using_indexes); sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings); sys_var_thd_ulong sys_long_query_time("long_query_time", &SV::long_query_time); @@ -389,6 +395,7 @@ sys_var_thd_ulong sys_query_alloc_block_size("query_alloc_block_size", sys_var_thd_ulong sys_query_prealloc_size("query_prealloc_size", &SV::query_prealloc_size, 0, fix_thd_mem_root); +sys_var_readonly sys_tmpdir("tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir); sys_var_thd_ulong sys_trans_alloc_block_size("transaction_alloc_block_size", &SV::trans_alloc_block_size, 0, fix_trans_mem_root); @@ -425,6 +432,21 @@ sys_var_thd_ulong sys_sort_buffer("sort_buffer_size", &SV::sortbuff_size); sys_var_thd_sql_mode sys_sql_mode("sql_mode", &SV::sql_mode); +#ifdef HAVE_OPENSSL +extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher, + *opt_ssl_key; +sys_var_const_str_ptr sys_ssl_ca("ssl_ca", &opt_ssl_ca); +sys_var_const_str_ptr sys_ssl_capath("ssl_capath", &opt_ssl_capath); +sys_var_const_str_ptr sys_ssl_cert("ssl_cert", &opt_ssl_cert); +sys_var_const_str_ptr sys_ssl_cipher("ssl_cipher", &opt_ssl_cipher); +sys_var_const_str_ptr sys_ssl_key("ssl_key", &opt_ssl_key); +#else +sys_var_const_str sys_ssl_ca("ssl_ca", NULL); +sys_var_const_str sys_ssl_capath("ssl_capath", NULL); +sys_var_const_str sys_ssl_cert("ssl_cert", NULL); +sys_var_const_str sys_ssl_cipher("ssl_cipher", NULL); +sys_var_const_str sys_ssl_key("ssl_key", NULL); +#endif sys_var_thd_enum sys_updatable_views_with_limit("updatable_views_with_limit", &SV::updatable_views_with_limit, @@ -696,7 +718,6 @@ static int show_slave_skip_errors(THD *thd, SHOW_VAR *var, char *buff) } #endif /* HAVE_REPLICATION */ - /* Variables shown by SHOW variables in alphabetical order */ @@ -706,7 +727,7 @@ SHOW_VAR init_vars[]= { {"auto_increment_offset", (char*) &sys_auto_increment_offset, SHOW_SYS}, {sys_automatic_sp_privileges.name,(char*) &sys_automatic_sp_privileges, SHOW_SYS}, {"back_log", (char*) &back_log, SHOW_LONG}, - {"basedir", mysql_home, SHOW_CHAR}, + {sys_basedir.name, (char*) &sys_basedir, SHOW_SYS}, {"bdb_cache_parts", (char*) &berkeley_cache_parts, SHOW_LONG}, {"bdb_cache_size", (char*) &berkeley_cache_size, SHOW_LONGLONG}, {"bdb_home", (char*) &berkeley_home, SHOW_CHAR_PTR}, @@ -733,7 +754,7 @@ SHOW_VAR init_vars[]= { {sys_completion_type.name, (char*) &sys_completion_type, SHOW_SYS}, {sys_concurrent_insert.name,(char*) &sys_concurrent_insert, SHOW_SYS}, {sys_connect_timeout.name, (char*) &sys_connect_timeout, SHOW_SYS}, - {"datadir", mysql_real_data_home, SHOW_CHAR}, + {sys_datadir.name, (char*) &sys_datadir, SHOW_SYS}, {sys_date_format.name, (char*) &sys_date_format, SHOW_SYS}, {sys_datetime_format.name, (char*) &sys_datetime_format, SHOW_SYS}, #ifndef DBUG_OFF @@ -833,6 +854,8 @@ SHOW_VAR init_vars[]= { {"log_bin", (char*) &opt_bin_log, SHOW_BOOL}, {sys_trust_function_creators.name,(char*) &sys_trust_function_creators, SHOW_SYS}, {"log_error", (char*) log_error_file, SHOW_CHAR}, + {sys_log_queries_not_using_indexes.name, + (char*) &sys_log_queries_not_using_indexes, SHOW_SYS}, #ifdef HAVE_REPLICATION {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL}, #endif @@ -962,6 +985,11 @@ SHOW_VAR init_vars[]= { {sys_sql_mode.name, (char*) &sys_sql_mode, SHOW_SYS}, {"sql_notes", (char*) &sys_sql_notes, SHOW_SYS}, {"sql_warnings", (char*) &sys_sql_warnings, SHOW_SYS}, + {sys_ssl_ca.name, (char*) &sys_ssl_ca, SHOW_SYS}, + {sys_ssl_capath.name, (char*) &sys_ssl_capath, SHOW_SYS}, + {sys_ssl_cert.name, (char*) &sys_ssl_cert, SHOW_SYS}, + {sys_ssl_cipher.name, (char*) &sys_ssl_cipher, SHOW_SYS}, + {sys_ssl_key.name, (char*) &sys_ssl_key, SHOW_SYS}, {sys_storage_engine.name, (char*) &sys_storage_engine, SHOW_SYS}, #ifdef HAVE_REPLICATION {sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS}, @@ -983,7 +1011,7 @@ SHOW_VAR init_vars[]= { {"time_zone", (char*) &sys_time_zone, SHOW_SYS}, {sys_timed_mutexes.name, (char*) &sys_timed_mutexes, SHOW_SYS}, {sys_tmp_table_size.name, (char*) &sys_tmp_table_size, SHOW_SYS}, - {"tmpdir", (char*) &opt_mysql_tmpdir, SHOW_CHAR_PTR}, + {sys_tmpdir.name, (char*) &sys_tmpdir, SHOW_SYS}, {sys_trans_alloc_block_size.name, (char*) &sys_trans_alloc_block_size, SHOW_SYS}, {sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS}, @@ -2855,6 +2883,31 @@ static byte *get_prepared_stmt_count(THD *thd) return (byte*) &thd->sys_var_tmp.ulong_value; } + +/* + Get the tmpdir that was specified or chosen by default + + SYNOPSIS + get_tmpdir() + thd thread handle + + DESCRIPTION + This is necessary because if the user does not specify a temporary + directory via the command line, one is chosen based on the environment + or system defaults. But we can't just always use mysql_tmpdir, because + that is actually a call to my_tmpdir() which cycles among possible + temporary directories. + + RETURN VALUES + ptr pointer to NUL-terminated string + */ +static byte *get_tmpdir(THD *thd) +{ + if (opt_mysql_tmpdir) + return (byte *)opt_mysql_tmpdir; + return (byte*)mysql_tmpdir; +} + /**************************************************************************** Main handling of variables: - Initialisation @@ -3417,9 +3470,9 @@ ulong fix_sql_mode(ulong sql_mode) MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | MODE_NO_FIELD_OPTIONS | MODE_NO_AUTO_CREATE_USER); if (sql_mode & MODE_MYSQL40) - sql_mode|= MODE_NO_FIELD_OPTIONS | MODE_HIGH_NOT_PRECEDENCE; + sql_mode|= MODE_HIGH_NOT_PRECEDENCE; if (sql_mode & MODE_MYSQL323) - sql_mode|= MODE_NO_FIELD_OPTIONS | MODE_HIGH_NOT_PRECEDENCE; + sql_mode|= MODE_HIGH_NOT_PRECEDENCE; if (sql_mode & MODE_TRADITIONAL) sql_mode|= (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES | MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | diff --git a/sql/set_var.h b/sql/set_var.h index 0ae88144c0f..1049b154d47 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -231,6 +231,35 @@ public: }; +class sys_var_const_str_ptr :public sys_var +{ +public: + char **value; // Pointer to const value + sys_var_const_str_ptr(const char *name_arg, char **value_arg) + :sys_var(name_arg),value(value_arg) + {} + bool check(THD *thd, set_var *var) + { + return 1; + } + bool update(THD *thd, set_var *var) + { + return 1; + } + SHOW_TYPE type() { return SHOW_CHAR; } + byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + { + return (byte*) *value; + } + bool check_update_type(Item_result type) + { + return 1; + } + bool check_default(enum_var_type type) { return 1; } + bool is_readonly() const { return 1; } +}; + + class sys_var_enum :public sys_var { uint *value; diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index f34002ab0cf..aa9cbaef36d 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5472,7 +5472,7 @@ ER_SP_DUP_HANDLER 42000 eng "Duplicate handler declared in the same block" ger "Doppelter Handler im selben Block deklariert" ER_SP_NOT_VAR_ARG 42000 - eng "OUT or INOUT argument %d for routine %s is not a variable" + eng "OUT or INOUT argument %d for routine %s is not a variable or NEW pseudo-variable in BEFORE trigger" ger "OUT- oder INOUT-Argument %d für Routine %s ist keine Variable" ER_SP_NO_RETSET 0A000 eng "Not allowed to return a result set from a %s" diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 8a64799e5f9..de56e261bd3 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -315,14 +315,16 @@ sp_prepare_func_item(THD* thd, Item **it_addr) */ bool -sp_eval_expr(THD *thd, Field *result_field, Item *expr_item) +sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) { + Item *expr_item; + DBUG_ENTER("sp_eval_expr"); - if (!expr_item) + if (!*expr_item_ptr) DBUG_RETURN(TRUE); - if (!(expr_item= sp_prepare_func_item(thd, &expr_item))) + if (!(expr_item= sp_prepare_func_item(thd, expr_item_ptr))) DBUG_RETURN(TRUE); bool err_status= FALSE; @@ -951,6 +953,7 @@ sp_head::execute(THD *thd) bool err_status= FALSE; uint ip= 0; ulong save_sql_mode; + bool save_abort_on_warning; Query_arena *old_arena; /* per-instruction arena */ MEM_ROOT execute_mem_root; @@ -1011,6 +1014,10 @@ sp_head::execute(THD *thd) thd->derived_tables= 0; save_sql_mode= thd->variables.sql_mode; thd->variables.sql_mode= m_sql_mode; + save_abort_on_warning= thd->abort_on_warning; + thd->abort_on_warning= + (m_sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)); + /* It is also more efficient to save/restore current thd->lex once when do it in each instruction @@ -1143,6 +1150,7 @@ sp_head::execute(THD *thd) DBUG_ASSERT(!thd->derived_tables); thd->derived_tables= old_derived_tables; thd->variables.sql_mode= save_sql_mode; + thd->abort_on_warning= save_abort_on_warning; thd->stmt_arena= old_arena; state= EXECUTED; @@ -1219,18 +1227,22 @@ bool sp_head::execute_function(THD *thd, Item **argp, uint argcount, Field *return_value_fld) { - Item_cache **param_values; ulonglong binlog_save_options; bool need_binlog_call; - uint params; + uint arg_no; sp_rcontext *octx = thd->spcont; sp_rcontext *nctx = NULL; + char buf[STRING_BUFFER_USUAL_SIZE]; + String binlog_buf(buf, sizeof(buf), &my_charset_bin); bool err_status= FALSE; + MEM_ROOT call_mem_root; + Query_arena call_arena(&call_mem_root, Query_arena::INITIALIZED_FOR_SP); + Query_arena backup_arena; + DBUG_ENTER("sp_head::execute_function"); DBUG_PRINT("info", ("function %s", m_name.str)); LINT_INIT(binlog_save_options); - params= m_pcont->context_var_count(); /* Check that the function is called with all specified arguments. @@ -1238,74 +1250,97 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, If it is not, use my_error() to report an error, or it will not terminate the invoking query properly. */ - - if (argcount != params) + if (argcount != m_pcont->context_var_count()) { /* Need to use my_error here, or it will not terminate the invoking query properly. */ my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0), - "FUNCTION", m_qname.str, params, argcount); + "FUNCTION", m_qname.str, m_pcont->context_var_count(), argcount); DBUG_RETURN(TRUE); } - - /* Allocate param_values to be used for dumping the call into binlog. */ - - if (!(param_values= (Item_cache**)thd->alloc(sizeof(Item_cache*)*argcount))) - DBUG_RETURN(TRUE); - - // QQ Should have some error checking here? (types, etc...) + /* + Prepare arena and memroot for objects which lifetime is whole + duration of function call (sp_rcontext, it's tables and items, + sp_cursor and Item_cache holders for case expressions). + We can't use caller's arena/memroot for those objects because + in this case some fixed amount of memory will be consumed for + each function/trigger invocation and so statements which involve + lot of them will hog memory. + TODO: we should create sp_rcontext once per command and reuse + it on subsequent executions of a function/trigger. + */ + init_sql_alloc(&call_mem_root, MEM_ROOT_BLOCK_SIZE, 0); + thd->set_n_backup_active_arena(&call_arena, &backup_arena); if (!(nctx= new sp_rcontext(m_pcont, return_value_fld, octx)) || nctx->init(thd)) { - delete nctx; /* Delete nctx if it was init() that failed. */ - DBUG_RETURN(TRUE); + thd->restore_active_arena(&call_arena, &backup_arena); + err_status= TRUE; + goto err_with_cleanup; } + /* + We have to switch temporarily back to callers arena/memroot. + Function arguments belong to the caller and so the may reference + memory which they will allocate during calculation long after + this function call will be finished (e.g. in Item::cleanup()). + */ + thd->restore_active_arena(&call_arena, &backup_arena); + #ifndef DBUG_OFF nctx->sp= this; #endif /* Pass arguments. */ - + for (arg_no= 0; arg_no < argcount; arg_no++) { - uint i; - - for (i= 0 ; i < argcount ; i++) - { - if (!argp[i]->fixed && argp[i]->fix_fields(thd, &argp[i])) - { - err_status= TRUE; - break; - } - - param_values[i]= Item_cache::get_cache(argp[i]->result_type()); - param_values[i]->store(argp[i]); - - if (nctx->set_variable(thd, i, param_values[i])) - { - err_status= TRUE; - break; - } - } - } + /* Arguments must be fixed in Item_func_sp::fix_fields */ + DBUG_ASSERT(argp[arg_no]->fixed); - if (err_status) - { - delete nctx; - DBUG_RETURN(TRUE); + if ((err_status= nctx->set_variable(thd, arg_no, &(argp[arg_no])))) + goto err_with_cleanup; } - thd->spcont= nctx; - /* If row-based binlogging, we don't need to binlog the function's call, let each substatement be binlogged its way. */ need_binlog_call= mysql_bin_log.is_open() && (thd->options & OPTION_BIN_LOG) && !thd->current_stmt_binlog_row_based; + + /* + Remember the original arguments for unrolled replication of functions + before they are changed by execution. + */ + if (need_binlog_call) + { + binlog_buf.length(0); + binlog_buf.append(STRING_WITH_LEN("SELECT ")); + append_identifier(thd, &binlog_buf, m_name.str, m_name.length); + binlog_buf.append('('); + for (arg_no= 0; arg_no < argcount; arg_no++) + { + String str_value_holder; + String *str_value; + + if (arg_no) + binlog_buf.append(','); + + str_value= sp_get_item_value(nctx->get_item(arg_no), + &str_value_holder); + + if (str_value) + binlog_buf.append(*str_value); + else + binlog_buf.append(STRING_WITH_LEN("NULL")); + } + binlog_buf.append(')'); + } + thd->spcont= nctx; + if (need_binlog_call) { reset_dynamic(&thd->user_var_events); @@ -1314,38 +1349,27 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, thd->options&= ~OPTION_BIN_LOG; } + /* + Switch to call arena/mem_root so objects like sp_cursor or + Item_cache holders for case expressions can be allocated on it. + + TODO: In future we should associate call arena/mem_root with + sp_rcontext and allocate all these objects (and sp_rcontext + itself) on it directly rather than juggle with arenas. + */ + thd->set_n_backup_active_arena(&call_arena, &backup_arena); + err_status= execute(thd); + thd->restore_active_arena(&call_arena, &backup_arena); + if (need_binlog_call) { mysql_bin_log.stop_union_events(thd); thd->options= binlog_save_options; if (thd->binlog_evt_union.unioned_events) { - char buf[256]; - String bufstr(buf, sizeof(buf), &my_charset_bin); - bufstr.length(0); - bufstr.append(STRING_WITH_LEN("SELECT ")); - append_identifier(thd, &bufstr, m_name.str, m_name.length); - bufstr.append('('); - for (uint i=0; i < argcount; i++) - { - String str_value_holder; - String *str_value; - - if (i) - bufstr.append(','); - - str_value= sp_get_item_value(param_values[i], &str_value_holder); - - if (str_value) - bufstr.append(*str_value); - else - bufstr.append(STRING_WITH_LEN("NULL")); - } - bufstr.append(')'); - - Query_log_event qinfo(thd, bufstr.ptr(), bufstr.length(), + Query_log_event qinfo(thd, binlog_buf.ptr(), binlog_buf.length(), thd->binlog_evt_union.unioned_events_trans, FALSE); if (mysql_bin_log.write(&qinfo) && thd->binlog_evt_union.unioned_events_trans) @@ -1369,27 +1393,19 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, } } + nctx->pop_all_cursors(); // To avoid memory leaks after an error + +err_with_cleanup: delete nctx; + call_arena.free_items(); + free_root(&call_mem_root, MYF(0)); thd->spcont= octx; DBUG_RETURN(err_status); } -static Item_func_get_user_var *item_is_user_var(Item *it) -{ - if (it->type() == Item::FUNC_ITEM) - { - Item_func *fi= static_cast<Item_func*>(it); - - if (fi->functype() == Item_func::GUSERVAR_FUNC) - return static_cast<Item_func_get_user_var*>(fi); - } - return NULL; -} - - /* Execute a procedure. SYNOPSIS @@ -1467,22 +1483,28 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) for (uint i= 0 ; i < params ; i++) { Item *arg_item= it_args++; - sp_variable_t *spvar= m_pcont->find_variable(i); if (!arg_item) break; + sp_variable_t *spvar= m_pcont->find_variable(i); + if (!spvar) continue; if (spvar->mode != sp_param_in) { - if (!arg_item->is_splocal() && !item_is_user_var(arg_item)) + Settable_routine_parameter *srp= + arg_item->get_settable_routine_parameter(); + + if (!srp) { my_error(ER_SP_NOT_VAR_ARG, MYF(0), i+1, m_qname.str); err_status= TRUE; break; } + + srp->set_required_privilege(spvar->mode == sp_param_inout); } if (spvar->mode == sp_param_out) @@ -1490,7 +1512,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) Item_null *null_item= new Item_null(); if (!null_item || - nctx->set_variable(thd, i, null_item)) + nctx->set_variable(thd, i, (struct Item **)&null_item)) { err_status= TRUE; break; @@ -1498,7 +1520,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) } else { - if (nctx->set_variable(thd, i, *it_args.ref())) + if (nctx->set_variable(thd, i, it_args.ref())) { err_status= TRUE; break; @@ -1566,36 +1588,16 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (spvar->mode == sp_param_in) continue; - if (arg_item->is_splocal()) - { - if (octx->set_variable(thd, - ((Item_splocal*) arg_item)->get_var_idx(), - nctx->get_item(i))) - { - err_status= TRUE; - break; - } - } - else + Settable_routine_parameter *srp= + arg_item->get_settable_routine_parameter(); + + DBUG_ASSERT(srp); + + if (srp->set_value(thd, octx, nctx->get_item_addr(i))) { - Item_func_get_user_var *guv= item_is_user_var(arg_item); - - if (guv) - { - Item *item= nctx->get_item(i); - Item_func_set_user_var *suv; - - suv= new Item_func_set_user_var(guv->get_name(), item); - /* - Item_func_set_user_var is not fixed after construction, - call fix_fields(). - */ - if ((err_status= test(!suv || suv->fix_fields(thd, &item) || - suv->check() || suv->update()))) - break; - } + err_status= TRUE; + break; } - } } @@ -2372,7 +2374,7 @@ sp_instr_set::execute(THD *thd, uint *nextp) int sp_instr_set::exec_core(THD *thd, uint *nextp) { - int res= thd->spcont->set_variable(thd, m_offset, m_value); + int res= thd->spcont->set_variable(thd, m_offset, &m_value); if (res && thd->spcont->found_handler_here()) { @@ -2437,12 +2439,7 @@ sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) int sp_instr_set_trigger_field::exec_core(THD *thd, uint *nextp) { - int res= 0; - Item *it= sp_prepare_func_item(thd, &value); - if (!it || - !trigger_field->fixed && trigger_field->fix_fields(thd, 0) || - (it->save_in_field(trigger_field->field, 0) < 0)) - res= -1; + const int res= (trigger_field->set_value(thd, &value) ? -1 : 0); *nextp = m_ip+1; return res; } @@ -2647,7 +2644,7 @@ sp_instr_freturn::exec_core(THD *thd, uint *nextp) do it in scope of execution the current context/block. */ - return thd->spcont->set_return_value(thd, m_value); + return thd->spcont->set_return_value(thd, &m_value); } void @@ -3091,7 +3088,7 @@ sp_instr_set_case_expr::execute(THD *thd, uint *nextp) int sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) { - int res= thd->spcont->set_case_expr(thd, m_case_expr_id, m_case_expr); + int res= thd->spcont->set_case_expr(thd, m_case_expr_id, &m_case_expr); if (res && !thd->spcont->get_case_expr(m_case_expr_id) && @@ -3105,7 +3102,7 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) Item *null_item= new Item_null(); if (!null_item || - thd->spcont->set_case_expr(thd, m_case_expr_id, null_item)) + thd->spcont->set_case_expr(thd, m_case_expr_id, &null_item)) { /* If this also failed, we have to abort. */ diff --git a/sql/sp_head.h b/sql/sp_head.h index fbc277b4de8..791343f0061 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -1170,6 +1170,6 @@ Item * sp_prepare_func_item(THD* thd, Item **it_addr); bool -sp_eval_expr(THD *thd, Field *result_field, Item *expr_item); +sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr); #endif /* _SP_HEAD_H_ */ diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 38b6de0e75a..3bc27a029d0 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -150,7 +150,7 @@ sp_rcontext::init_var_items() bool -sp_rcontext::set_return_value(THD *thd, Item *return_value_item) +sp_rcontext::set_return_value(THD *thd, Item **return_value_item) { DBUG_ASSERT(m_return_value_fld); @@ -279,14 +279,14 @@ sp_rcontext::pop_cursors(uint count) int -sp_rcontext::set_variable(THD *thd, uint var_idx, Item *value) +sp_rcontext::set_variable(THD *thd, uint var_idx, Item **value) { return set_variable(thd, m_var_table->field[var_idx], value); } int -sp_rcontext::set_variable(THD *thd, Field *field, Item *value) +sp_rcontext::set_variable(THD *thd, Field *field, Item **value) { if (!value) { @@ -478,9 +478,10 @@ sp_rcontext::create_case_expr_holder(THD *thd, Item_result result_type) */ int -sp_rcontext::set_case_expr(THD *thd, int case_expr_id, Item *case_expr_item) +sp_rcontext::set_case_expr(THD *thd, int case_expr_id, Item **case_expr_item_ptr) { - if (!(case_expr_item= sp_prepare_func_item(thd, &case_expr_item))) + Item *case_expr_item= sp_prepare_func_item(thd, case_expr_item_ptr); + if (!case_expr_item) return TRUE; if (!m_case_expr_holders[case_expr_id] || @@ -542,7 +543,7 @@ bool Select_fetch_into_spvars::send_data(List<Item> &items) */ for (; spvar= spvar_iter++, item= item_iter++; ) { - if (thd->spcont->set_variable(thd, spvar->offset, item)) + if (thd->spcont->set_variable(thd, spvar->offset, &item)) return TRUE; } return FALSE; diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 20aaea3b7c1..30521f6da84 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -91,7 +91,7 @@ class sp_rcontext : public Sql_alloc ~sp_rcontext(); int - set_variable(THD *thd, uint var_idx, Item *value); + set_variable(THD *thd, uint var_idx, Item **value); Item * get_item(uint var_idx); @@ -100,7 +100,7 @@ class sp_rcontext : public Sql_alloc get_item_addr(uint var_idx); bool - set_return_value(THD *thd, Item *return_value_item); + set_return_value(THD *thd, Item **return_value_item); inline bool is_return_value_set() const @@ -200,7 +200,7 @@ class sp_rcontext : public Sql_alloc */ int - set_case_expr(THD *thd, int case_expr_id, Item *case_expr_item); + set_case_expr(THD *thd, int case_expr_id, Item **case_expr_item_ptr); Item * get_case_expr(int case_expr_id); @@ -254,7 +254,7 @@ private: Item_cache *create_case_expr_holder(THD *thd, Item_result result_type); - int set_variable(THD *thd, Field *field, Item *value); + int set_variable(THD *thd, Field *field, Item **value); }; // class sp_rcontext : public Sql_alloc diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 09b684c8706..d2501d08c4d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -987,8 +987,8 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (acl_user->x509_issuer) { DBUG_PRINT("info",("checkpoint 3")); - char *ptr = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); - DBUG_PRINT("info",("comparing issuers: '%s' and '%s'", + char *ptr = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); + DBUG_PRINT("info",("comparing issuers: '%s' and '%s'", acl_user->x509_issuer, ptr)); if (strcmp(acl_user->x509_issuer, ptr)) { @@ -1156,6 +1156,8 @@ static void acl_update_user(const char *user, const char *host, USER_RESOURCES *mqh, ulong privileges) { + safe_mutex_assert_owner(&acl_cache->lock); + for (uint i=0 ; i < acl_users.elements ; i++) { ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*); @@ -1206,6 +1208,9 @@ static void acl_insert_user(const char *user, const char *host, ulong privileges) { ACL_USER acl_user; + + safe_mutex_assert_owner(&acl_cache->lock); + acl_user.user=*user ? strdup_root(&mem,user) : 0; update_hostname(&acl_user.host, *host ? strdup_root(&mem, host): 0); acl_user.access=privileges; @@ -1235,6 +1240,8 @@ static void acl_insert_user(const char *user, const char *host, static void acl_update_db(const char *user, const char *host, const char *db, ulong privileges) { + safe_mutex_assert_owner(&acl_cache->lock); + for (uint i=0 ; i < acl_dbs.elements ; i++) { ACL_DB *acl_db=dynamic_element(&acl_dbs,i,ACL_DB*); @@ -1660,6 +1667,9 @@ find_acl_user(const char *host, const char *user, my_bool exact) { DBUG_ENTER("find_acl_user"); DBUG_PRINT("enter",("host: '%s' user: '%s'",host,user)); + + safe_mutex_assert_owner(&acl_cache->lock); + for (uint i=0 ; i < acl_users.elements ; i++) { ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*); @@ -1672,7 +1682,7 @@ find_acl_user(const char *host, const char *user, my_bool exact) if (!acl_user->user && !user[0] || acl_user->user && !strcmp(user,acl_user->user)) { - if (exact ? !my_strcasecmp(&my_charset_latin1, host, + if (exact ? !my_strcasecmp(system_charset_info, host, acl_user->host.hostname ? acl_user->host.hostname : "") : compare_hostname(&acl_user->host,host,host)) @@ -2977,7 +2987,6 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, some kind of updates to the mysql.% tables. */ if (thd->slave_thread && rpl_filter->is_on()) - if (thd->slave_thread && rpl_filter->is_on()) { /* The tables must be marked "updating" so that tables_ok() takes them into @@ -2999,6 +3008,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, create_new_users= test_if_create_new_users(thd); bool result= FALSE; rw_wrlock(&LOCK_grant); + pthread_mutex_lock(&acl_cache->lock); MEM_ROOT *old_root= thd->mem_root; thd->mem_root= &memex; grant_version++; @@ -3016,12 +3026,10 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, continue; } /* Create user if needed */ - pthread_mutex_lock(&acl_cache->lock); error=replace_user_table(thd, tables[0].table, *Str, 0, revoke_grant, create_new_users, test(thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER)); - pthread_mutex_unlock(&acl_cache->lock); if (error) { result= TRUE; // Remember error @@ -3113,6 +3121,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, } grant_option=TRUE; thd->mem_root= old_root; + pthread_mutex_unlock(&acl_cache->lock); rw_unlock(&LOCK_grant); if (!result) send_ok(thd); @@ -3205,6 +3214,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, if (!revoke_grant) create_new_users= test_if_create_new_users(thd); rw_wrlock(&LOCK_grant); + pthread_mutex_lock(&acl_cache->lock); MEM_ROOT *old_root= thd->mem_root; thd->mem_root= &memex; @@ -3224,12 +3234,10 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, continue; } /* Create user if needed */ - pthread_mutex_lock(&acl_cache->lock); error=replace_user_table(thd, tables[0].table, *Str, 0, revoke_grant, create_new_users, test(thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER)); - pthread_mutex_unlock(&acl_cache->lock); if (error) { result= TRUE; // Remember error @@ -3271,6 +3279,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, } grant_option=TRUE; thd->mem_root= old_root; + pthread_mutex_unlock(&acl_cache->lock); rw_unlock(&LOCK_grant); if (!result && !no_error) send_ok(thd); @@ -4247,20 +4256,15 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) DBUG_RETURN(TRUE); } - for (counter=0 ; counter < acl_users.elements ; counter++) - { - const char *user,*host; - acl_user=dynamic_element(&acl_users,counter,ACL_USER*); - if (!(user=acl_user->user)) - user= ""; - if (!(host=acl_user->host.hostname)) - host= ""; - if (!strcmp(lex_user->user.str,user) && - !my_strcasecmp(system_charset_info, lex_user->host.str, host)) - break; - } - if (counter == acl_users.elements) + rw_rdlock(&LOCK_grant); + VOID(pthread_mutex_lock(&acl_cache->lock)); + + acl_user= find_acl_user(lex_user->host.str, lex_user->user.str, TRUE); + if (!acl_user) { + VOID(pthread_mutex_unlock(&acl_cache->lock)); + rw_unlock(&LOCK_grant); + my_error(ER_NONEXISTING_GRANT, MYF(0), lex_user->user.str, lex_user->host.str); DBUG_RETURN(TRUE); @@ -4275,10 +4279,12 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) field_list.push_back(field); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(TRUE); + { + VOID(pthread_mutex_unlock(&acl_cache->lock)); + rw_unlock(&LOCK_grant); - rw_wrlock(&LOCK_grant); - VOID(pthread_mutex_lock(&acl_cache->lock)); + DBUG_RETURN(TRUE); + } /* Add first global access grants */ { @@ -4686,10 +4692,15 @@ void get_privilege_desc(char *to, uint max_length, ulong access) void get_mqh(const char *user, const char *host, USER_CONN *uc) { ACL_USER *acl_user; + + pthread_mutex_lock(&acl_cache->lock); + if (initialized && (acl_user= find_acl_user(host,user, FALSE))) uc->user_resources= acl_user->user_resource; else bzero((char*) &uc->user_resources, sizeof(uc->user_resources)); + + pthread_mutex_unlock(&acl_cache->lock); } /* @@ -4769,31 +4780,6 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables) DBUG_RETURN(0); } -ACL_USER *check_acl_user(LEX_USER *user_name, - uint *acl_acl_userdx) -{ - ACL_USER *acl_user= 0; - uint counter; - - for (counter= 0 ; counter < acl_users.elements ; counter++) - { - const char *user,*host; - acl_user= dynamic_element(&acl_users, counter, ACL_USER*); - if (!(user=acl_user->user)) - user= ""; - if (!(host=acl_user->host.hostname)) - host= ""; - if (!strcmp(user_name->user.str,user) && - !my_strcasecmp(system_charset_info, user_name->host.str, host)) - break; - } - if (counter == acl_users.elements) - return 0; - - *acl_acl_userdx= counter; - return acl_user; -} - /* Modify a privilege table. @@ -5040,6 +5026,8 @@ static int handle_grant_struct(uint struct_no, bool drop, LINT_INIT(user); LINT_INIT(host); + safe_mutex_assert_owner(&acl_cache->lock); + /* Get the number of elements in the in-memory structure. */ switch (struct_no) { case 0: @@ -5502,7 +5490,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) List_iterator <LEX_USER> user_list(list); while ((lex_user=user_list++)) { - if (!check_acl_user(lex_user, &counter)) + if (!find_acl_user(lex_user->host.str, lex_user->user.str, TRUE)) { sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' does not " "exists", lex_user->user.str, lex_user->host.str); @@ -5738,6 +5726,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, combo->user.str= sctx->user; + VOID(pthread_mutex_lock(&acl_cache->lock)); if (!find_acl_user(combo->host.str=(char*)sctx->host_or_ip, combo->user.str, FALSE) && !find_acl_user(combo->host.str=(char*)sctx->host, combo->user.str, @@ -5745,7 +5734,11 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, !find_acl_user(combo->host.str=(char*)sctx->ip, combo->user.str, FALSE) && !find_acl_user(combo->host.str=(char*)"%", combo->user.str, FALSE)) + { + VOID(pthread_mutex_unlock(&acl_cache->lock)); DBUG_RETURN(TRUE); + } + VOID(pthread_mutex_unlock(&acl_cache->lock)); bzero((char*)tables, sizeof(TABLE_LIST)); user_list.empty(); @@ -5863,6 +5856,8 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) char *curr_host= thd->security_ctx->priv_host_name(); DBUG_ENTER("fill_schema_user_privileges"); + pthread_mutex_lock(&acl_cache->lock); + for (counter=0 ; counter < acl_users.elements ; counter++) { const char *user,*host, *is_grantable="YES"; @@ -5898,6 +5893,9 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond) } } } + + pthread_mutex_unlock(&acl_cache->lock); + DBUG_RETURN(0); #else return(0); @@ -5917,6 +5915,8 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) char *curr_host= thd->security_ctx->priv_host_name(); DBUG_ENTER("fill_schema_schema_privileges"); + pthread_mutex_lock(&acl_cache->lock); + for (counter=0 ; counter < acl_dbs.elements ; counter++) { const char *user, *host, *is_grantable="YES"; @@ -5955,6 +5955,9 @@ int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond) } } } + + pthread_mutex_unlock(&acl_cache->lock); + DBUG_RETURN(0); #else return (0); @@ -5972,6 +5975,8 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) char *curr_host= thd->security_ctx->priv_host_name(); DBUG_ENTER("fill_schema_table_privileges"); + rw_rdlock(&LOCK_grant); + for (index=0 ; index < column_priv_hash.records ; index++) { const char *user, *is_grantable= "YES"; @@ -6017,6 +6022,9 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond) } } } + + rw_unlock(&LOCK_grant); + DBUG_RETURN(0); #else return (0); @@ -6034,6 +6042,8 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond) char *curr_host= thd->security_ctx->priv_host_name(); DBUG_ENTER("fill_schema_table_privileges"); + rw_rdlock(&LOCK_grant); + for (index=0 ; index < column_priv_hash.records ; index++) { const char *user, *is_grantable= "YES"; @@ -6085,6 +6095,9 @@ int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond) } } } + + rw_unlock(&LOCK_grant); + DBUG_RETURN(0); #else return (0); @@ -6141,20 +6154,21 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, } /* table privileges */ + rw_rdlock(&LOCK_grant); if (grant->version != grant_version) { - rw_rdlock(&LOCK_grant); grant->grant_table= table_hash_search(sctx->host, sctx->ip, db, sctx->priv_user, table, 0); /* purecov: inspected */ grant->version= grant_version; /* purecov: inspected */ - rw_unlock(&LOCK_grant); } if (grant->grant_table != 0) { grant->privilege|= grant->grant_table->privs; } + rw_unlock(&LOCK_grant); + DBUG_PRINT("info", ("privilege 0x%lx", grant->privilege)); DBUG_VOID_RETURN; } diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 8c64adbbece..e1153522ed5 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -236,7 +236,6 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list, bool mysql_routine_grant(THD *thd, TABLE_LIST *table, bool is_proc, List <LEX_USER> &user_list, ulong rights, bool revoke, bool no_error); -ACL_USER *check_acl_user(LEX_USER *user_name, uint *acl_acl_userdx); my_bool grant_init(); void grant_free(void); my_bool grant_reload(THD *thd); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 8ea53747b40..58c04224ac9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1289,7 +1289,7 @@ void close_temporary_tables(THD *thd) table= next) { end_cur= strxmov(end_cur, "`", table->s->db.str, "`.`", - table->s->table_name.str, "`,", NullS); + table->s->table_name.str, "`,", NullS); next= table->next; close_temporary(table, 1, 1); } @@ -1317,7 +1317,6 @@ void close_temporary_tables(THD *thd) thd->temporary_tables=0; } - /* Find table in list. @@ -1793,6 +1792,8 @@ bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list) MYSQL_LOCK_IGNORE_FLUSH - Open table even if someone has done a flush or namelock on it. No version number checking is done. + MYSQL_OPEN_IGNORE_LOCKED_TABLES - Open table + ignoring set of locked tables and prelocked mode. IMPLEMENTATION Uses a cache of open tables to find a table not in use. @@ -1852,7 +1853,8 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, } } - if (thd->locked_tables || thd->prelocked_mode) + if (!(flags & MYSQL_OPEN_IGNORE_LOCKED_TABLES) && + (thd->locked_tables || thd->prelocked_mode)) { // Using table locks TABLE *best_table= 0; int best_distance= INT_MIN; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a2ccaf092ee..9b2ad209e84 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1934,7 +1934,7 @@ bool select_dumpvar::send_data(List<Item> &items) if ((yy=var_li++)) { if (thd->spcont->set_variable(current_thd, yy->get_var_idx(), - *it.ref())) + it.ref())) DBUG_RETURN(1); } } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 946c0536897..675fb256b32 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2518,6 +2518,162 @@ bool select_insert::send_eof() CREATE TABLE (SELECT) ... ***************************************************************************/ +/* + Create table from lists of fields and items (or open existing table + with same name). + + SYNOPSIS + create_table_from_items() + thd in Thread object + create_info in Create information (like MAX_ROWS, ENGINE or + temporary table flag) + create_table in Pointer to TABLE_LIST object providing database + and name for table to be created or to be open + extra_fields in/out Initial list of fields for table to be created + keys in List of keys for table to be created + items in List of items which should be used to produce rest + of fields for the table (corresponding fields will + be added to the end of 'extra_fields' list) + lock out Pointer to the MYSQL_LOCK object for table created + (open) will be returned in this parameter. Since + this table is not included in THD::lock caller is + responsible for explicitly unlocking this table. + hooks + + NOTES + If 'create_info->options' bitmask has HA_LEX_CREATE_IF_NOT_EXISTS + flag and table with name provided already exists then this function will + simply open existing table. + Also note that create, open and lock sequence in this function is not + atomic and thus contains gap for deadlock and can cause other troubles. + Since this function contains some logic specific to CREATE TABLE ... SELECT + it should be changed before it can be used in other contexts. + + RETURN VALUES + non-zero Pointer to TABLE object for table created or opened + 0 Error +*/ + +static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, + TABLE_LIST *create_table, + List<create_field> *extra_fields, + List<Key> *keys, + List<Item> *items, + MYSQL_LOCK **lock, + TABLEOP_HOOKS *hooks) +{ + TABLE tmp_table; // Used during 'create_field()' + TABLE_SHARE share; + TABLE *table= 0; + uint select_field_count= items->elements; + /* Add selected items to field list */ + List_iterator_fast<Item> it(*items); + Item *item; + Field *tmp_field; + bool not_used; + DBUG_ENTER("create_table_from_items"); + + tmp_table.alias= 0; + tmp_table.timestamp_field= 0; + tmp_table.s= &share; + init_tmp_table_share(&share, "", 0, "", ""); + + tmp_table.s->db_create_options=0; + tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr; + tmp_table.s->db_low_byte_first= + test(create_info->db_type == &myisam_hton || + create_info->db_type == &heap_hton); + tmp_table.null_row=tmp_table.maybe_null=0; + + while ((item=it++)) + { + create_field *cr_field; + Field *field; + if (item->type() == Item::FUNC_ITEM) + field=item->tmp_table_field(&tmp_table); + else + field=create_tmp_field(thd, &tmp_table, item, item->type(), + (Item ***) 0, &tmp_field, 0, 0, 0, 0, 0); + if (!field || + !(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ? + ((Item_field *)item)->field : + (Field*) 0)))) + DBUG_RETURN(0); + if (item->maybe_null) + cr_field->flags &= ~NOT_NULL_FLAG; + extra_fields->push_back(cr_field); + } + /* + create and lock table + + We don't log the statement, it will be logged later. + + If this is a HEAP table, the automatic DELETE FROM which is written to the + binlog when a HEAP table is opened for the first time since startup, must + not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we + don't want to delete from it) 2) it would be written before the CREATE + TABLE, which is a wrong order. So we keep binary logging disabled when we + open_table(). + NOTE: By locking table which we just have created (or for which we just have + have found that it already exists) separately from other tables used by the + statement we create potential window for deadlock. + TODO: create and open should be done atomic ! + */ + { + tmp_disable_binlog(thd); + if (!mysql_create_table(thd, create_table->db, create_table->table_name, + create_info, *extra_fields, *keys, 0, + select_field_count)) + { + /* + If we are here in prelocked mode we either create temporary table + or prelocked mode is caused by the SELECT part of this statement. + */ + DBUG_ASSERT(!thd->prelocked_mode || + create_info->options & HA_LEX_CREATE_TMP_TABLE || + thd->lex->requires_prelocking()); + + /* + NOTE: We don't want to ignore set of locked tables here if we are + under explicit LOCK TABLES since it will open gap for deadlock + too wide (and also is not backward compatible). + */ + + if (! (table= open_table(thd, create_table, thd->mem_root, (bool*) 0, + (MYSQL_LOCK_IGNORE_FLUSH | + ((thd->prelocked_mode == PRELOCKED) ? + MYSQL_OPEN_IGNORE_LOCKED_TABLES:0))))) + quick_rm_table(create_info->db_type, create_table->db, + table_case_name(create_info, create_table->table_name)); + } + reenable_binlog(thd); + if (!table) // open failed + DBUG_RETURN(0); + } + + /* + FIXME: What happens if trigger manages to be created while we are + obtaining this lock ? May be it is sensible just to disable + trigger execution in this case ? Or will MYSQL_LOCK_IGNORE_FLUSH + save us from that ? + */ + table->reginfo.lock_type=TL_WRITE; + hooks->prelock(&table, 1); // Call prelock hooks + if (! ((*lock)= mysql_lock_tables(thd, &table, 1, + MYSQL_LOCK_IGNORE_FLUSH, ¬_used))) + { + VOID(pthread_mutex_lock(&LOCK_open)); + hash_delete(&open_cache,(byte*) table); + VOID(pthread_mutex_unlock(&LOCK_open)); + quick_rm_table(create_info->db_type, create_table->db, + table_case_name(create_info, create_table->table_name)); + DBUG_RETURN(0); + } + table->file->extra(HA_EXTRA_WRITE_CACHE); + DBUG_RETURN(table); +} + + int select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 826f09af425..af6ac7d862a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2857,6 +2857,17 @@ mysql_execute_command(THD *thd) res= 1; goto end_with_restore_list; } +#ifdef WITH_PARTITION_STORAGE_ENGINE + { + partition_info *part_info= thd->lex->part_info; + if (part_info && !(part_info= thd->lex->part_info->get_clone())) + { + res= -1; + goto end_with_restore_list; + } + thd->work_part_info= part_info; + } +#endif if (select_lex->item_list.elements) // With select { select_result *result; @@ -2926,15 +2937,6 @@ mysql_execute_command(THD *thd) lex->like_name); else { -#ifdef WITH_PARTITION_STORAGE_ENGINE - partition_info *part_info= thd->lex->part_info; - if (part_info && !(part_info= thd->lex->part_info->get_clone())) - { - res= -1; - goto end_with_restore_list; - } - thd->work_part_info= part_info; -#endif res= mysql_create_table(thd, create_table->db, create_table->table_name, &lex->create_info, lex->create_list, @@ -3994,7 +3996,6 @@ end_with_restore_list: if (thd->security_ctx->user) // If not replication { LEX_USER *user; - uint counter; List_iterator <LEX_USER> user_list(lex->users_list); while ((user= user_list++)) @@ -4012,7 +4013,8 @@ end_with_restore_list: user->host.str, thd->security_ctx->host_or_ip)) { // TODO: use check_change_password() - if (check_acl_user(user, &counter) && user->password.str && + if (is_acl_user(user->host.str, user->user.str) && + user->password.str && check_access(thd, UPDATE_ACL,"mysql",0,1,1,0)) { my_message(ER_PASSWORD_NOT_ALLOWED, @@ -5902,6 +5904,7 @@ void mysql_parse(THD *thd, char *inBuf, uint length) } else { + DBUG_ASSERT(thd->net.report_error); DBUG_PRINT("info",("Command aborted. Fatal_error: %d", thd->is_fatal_error)); query_cache_abort(&thd->net); @@ -7455,7 +7458,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, lex->create_info.merge_list.first)) goto err; if (grant_option && want_priv != CREATE_TMP_ACL && - check_grant(thd, want_priv, create_table, 0, UINT_MAX, 0)) + check_grant(thd, want_priv, create_table, 0, 1, 0)) goto err; if (select_lex->item_list.elements) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 71b8e9b1d95..e946e972968 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4076,6 +4076,7 @@ that are reorganised. tab_part_info->use_default_partitions= FALSE; } tab_part_info->use_default_no_partitions= FALSE; + tab_part_info->is_auto_partitioned= FALSE; } } else if (alter_info->flags == ALTER_DROP_PARTITION) @@ -4091,6 +4092,8 @@ that are reorganised. uint no_parts_dropped= alter_info->partition_names.elements; uint no_parts_found= 0; List_iterator<partition_element> part_it(tab_part_info->partitions); + + tab_part_info->is_auto_partitioned= FALSE; if (!(tab_part_info->part_type == RANGE_PARTITION || tab_part_info->part_type == LIST_PARTITION)) { @@ -4275,7 +4278,10 @@ state of p1. tab_part_info->no_parts= no_parts_remain; } if (!(alter_info->flags & ALTER_TABLE_REORG)) + { tab_part_info->use_default_no_partitions= FALSE; + tab_part_info->is_auto_partitioned= FALSE; + } } else if (alter_info->flags == ALTER_REORGANIZE_PARTITION) { @@ -4294,6 +4300,8 @@ state of p1. uint no_parts_new= thd->work_part_info->partitions.elements; partition_info *alt_part_info= thd->work_part_info; uint check_total_partitions; + + tab_part_info->is_auto_partitioned= FALSE; if (no_parts_reorged > tab_part_info->no_parts) { my_error(ER_REORG_PARTITION_NOT_EXIST, MYF(0)); @@ -4510,7 +4518,7 @@ the generated partition syntax in a correct manner. if (alter_info->flags & ALTER_REMOVE_PARTITIONING) { DBUG_PRINT("info", ("Remove partitioning")); - if (!(thd->lex->create_info.used_fields & HA_CREATE_USED_ENGINE)) + if (!(create_info->used_fields & HA_CREATE_USED_ENGINE)) { DBUG_PRINT("info", ("No explicit engine used")); create_info->db_type= table->part_info->default_engine_type; @@ -4527,14 +4535,29 @@ the generated partition syntax in a correct manner. beneath. */ thd->work_part_info= table->part_info; - if (thd->lex->create_info.used_fields & HA_CREATE_USED_ENGINE && + if (create_info->used_fields & HA_CREATE_USED_ENGINE && create_info->db_type != table->part_info->default_engine_type) { /* Make sure change of engine happens to all partitions. */ DBUG_PRINT("info", ("partition changed")); - set_engine_all_partitions(thd->work_part_info, create_info->db_type); + if (table->part_info->is_auto_partitioned) + { + /* + If the user originally didn't specify partitioning to be + used we can remove it now. + */ + thd->work_part_info= NULL; + } + else + { + /* + Ensure that all partitions have the proper engine set-up + */ + set_engine_all_partitions(thd->work_part_info, + create_info->db_type); + } *partition_changed= TRUE; } } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 6d0a0f4799c..14bcb437337 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2087,19 +2087,20 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) sl->exclude_from_table_unique_test= FALSE; /* - Copy WHERE, HAVING clause pointers to avoid damaging them by optimisation + Copy WHERE, HAVING clause pointers to avoid damaging them + by optimisation */ - if (sl->prep_where) - { - sl->where= sl->prep_where->copy_andor_structure(thd); - sl->where->cleanup(); - } - if (sl->prep_having) - { - sl->having= sl->prep_having->copy_andor_structure(thd); - sl->having->cleanup(); - } - DBUG_ASSERT(sl->join == 0); + if (sl->prep_where) + { + sl->where= sl->prep_where->copy_andor_structure(thd); + sl->where->cleanup(); + } + if (sl->prep_having) + { + sl->having= sl->prep_having->copy_andor_structure(thd); + sl->having->cleanup(); + } + DBUG_ASSERT(sl->join == 0); ORDER *order; /* Fix GROUP list */ for (order= (ORDER *)sl->group_list.first; order; order= order->next) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 5f8c4dd2e1a..810b7789f3d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2419,7 +2419,19 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, { if (old->field == new_fields->field) { - if (new_fields->val->used_tables()) + /* + NOTE: below const_item() call really works as "!used_tables()", i.e. + it can return FALSE where it is feasible to make it return TRUE. + + The cause is as follows: Some of the tables are already known to be + const tables (the detection code is in make_join_statistics(), + above the update_ref_and_keys() call), but we didn't propagate + information about this: TABLE::const_table is not set to TRUE, and + Item::update_used_tables() hasn't been called for each item. + The result of this is that we're missing some 'ref' accesses. + TODO: OptimizerTeam: Fix this + */ + if (!new_fields->val->const_item()) { /* If the value matches, we can use the key reference. @@ -2449,7 +2461,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, new_fields->null_rejecting); } else if (old->eq_func && new_fields->eq_func && - (old->val->is_null() || new_fields->val->is_null())) + ((old->val->const_item() && old->val->is_null()) || + new_fields->val->is_null())) { /* field = expression OR field IS NULL */ old->level= and_level; @@ -3364,7 +3377,10 @@ best_access_path(JOIN *join, uint key= keyuse->key; KEY *keyinfo= table->key_info+key; bool ft_key= (keyuse->keypart == FT_KEYPART); - uint found_ref_or_null= 0; + /* Bitmap of keyparts where the ref access is over 'keypart=const': */ + key_part_map const_part= 0; + /* The or-null keypart in ref-or-null access: */ + key_part_map ref_or_null_part= 0; /* Calculate how many key segments of the current key we can use */ start_key= keyuse; @@ -3376,12 +3392,14 @@ best_access_path(JOIN *join, do { if (!(remaining_tables & keyuse->used_tables) && - !(found_ref_or_null & keyuse->optimize)) + !(ref_or_null_part && (keyuse->optimize & + KEY_OPTIMIZE_REF_OR_NULL))) { found_part|= keyuse->keypart_map; - double tmp= prev_record_reads(join, - (found_ref | - keyuse->used_tables)); + if (!(keyuse->used_tables & ~join->const_table_map)) + const_part|= keyuse->keypart_map; + double tmp= prev_record_reads(join, (found_ref | + keyuse->used_tables)); if (tmp < best_prev_record_reads) { best_part_found_ref= keyuse->used_tables; @@ -3393,8 +3411,8 @@ best_access_path(JOIN *join, If there is one 'key_column IS NULL' expression, we can use this ref_or_null optimisation of this field */ - found_ref_or_null|= (keyuse->optimize & - KEY_OPTIMIZE_REF_OR_NULL); + if (keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL) + ref_or_null_part |= keyuse->keypart_map; } keyuse++; } while (keyuse->table == table && keyuse->key == key && @@ -3430,7 +3448,7 @@ best_access_path(JOIN *join, Check if we found full key */ if (found_part == PREV_BITS(uint,keyinfo->key_parts) && - !found_ref_or_null) + !ref_or_null_part) { /* use eq key */ max_key_part= (uint) ~0; if ((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME) @@ -3442,6 +3460,23 @@ best_access_path(JOIN *join, { if (!found_ref) { /* We found a const key */ + /* + ReuseRangeEstimateForRef-1: + We get here if we've found a ref(const) (c_i are constants): + "(keypart1=c1) AND ... AND (keypartN=cN)" [ref_const_cond] + + If range optimizer was able to construct a "range" + access on this index, then its condition "quick_cond" was + eqivalent to ref_const_cond (*), and we can re-use E(#rows) + from the range optimizer. + + Proof of (*): By properties of range and ref optimizers + quick_cond will be equal or tighther than ref_const_cond. + ref_const_cond already covers "smallest" possible interval - + a singlepoint interval over all keyparts. Therefore, + quick_cond is equivalent to ref_const_cond (if it was an + empty interval we wouldn't have got here). + */ if (table->quick_keys.is_set(key)) records= (double) table->quick_rows[key]; else @@ -3462,6 +3497,23 @@ best_access_path(JOIN *join, if (records < 2.0) records=2.0; /* Can't be as good as a unique */ } + /* + ReuseRangeEstimateForRef-2: We get here if we could not reuse + E(#rows) from range optimizer. Make another try: + + If range optimizer produced E(#rows) for a prefix of the ref + access we're considering, and that E(#rows) is lower then our + current estimate, make an adjustment. The criteria of when we + can make an adjustment is a special case of the criteria used + in ReuseRangeEstimateForRef-3. + */ + if (table->quick_keys.is_set(key) && + const_part & (1 << table->quick_key_parts[key]) && + table->quick_n_ranges[key] == 1 && + records > (double) table->quick_rows[key]) + { + records= (double) table->quick_rows[key]; + } } /* Limit the number of matched rows */ tmp= records; @@ -3490,12 +3542,50 @@ best_access_path(JOIN *join, { max_key_part= max_part_bit(found_part); /* - Check if quick_range could determinate how many rows we - will match + ReuseRangeEstimateForRef-3: + We're now considering a ref[or_null] access via + (t.keypart1=e1 AND ... AND t.keypartK=eK) [ OR + (same-as-above but with one cond replaced + with "t.keypart_i IS NULL")] (**) + + Try re-using E(#rows) from "range" optimizer: + We can do so if "range" optimizer used the same intervals as + in (**). The intervals used by range optimizer may be not + available at this point (as "range" access might have choosen to + create quick select over another index), so we can't compare + them to (**). We'll make indirect judgements instead. + The sufficient conditions for re-use are: + (C1) All e_i in (**) are constants, i.e. found_ref==FALSE. (if + this is not satisfied we have no way to know which ranges + will be actually scanned by 'ref' until we execute the + join) + (C2) max #key parts in 'range' access == K == max_key_part (this + is apparently a necessary requirement) + + We also have a property that "range optimizer produces equal or + tighter set of scan intervals than ref(const) optimizer". Each + of the intervals in (**) are "tightest possible" intervals when + one limits itself to using keyparts 1..K (which we do in #2). + From here it follows that range access used either one, or + both of the (I1) and (I2) intervals: + + (t.keypart1=c1 AND ... AND t.keypartK=eK) (I1) + (same-as-above but with one cond replaced + with "t.keypart_i IS NULL") (I2) + + The remaining part is to exclude the situation where range + optimizer used one interval while we're considering + ref-or-null and looking for estimate for two intervals. This + is done by last limitation: + + (C3) "range optimizer used (have ref_or_null?2:1) intervals" */ - if (table->quick_keys.is_set(key) && - table->quick_key_parts[key] == max_key_part) + if (table->quick_keys.is_set(key) && !found_ref && //(C1) + table->quick_key_parts[key] == max_key_part && //(C2) + table->quick_n_ranges[key] == 1+test(ref_or_null_part)) //(C3) + { tmp= records= (double) table->quick_rows[key]; + } else { /* Check if we have statistic about the distribution */ @@ -3539,21 +3629,37 @@ best_access_path(JOIN *join, } records = (ulong) tmp; } + + if (ref_or_null_part) + { + /* We need to do two key searches to find key */ + tmp *= 2.0; + records *= 2.0; + } + /* - If quick_select was used on a part of this key, we know - the maximum number of rows that the key can match. + ReuseRangeEstimateForRef-4: We get here if we could not reuse + E(#rows) from range optimizer. Make another try: + + If range optimizer produced E(#rows) for a prefix of the ref + access we're considering, and that E(#rows) is lower then our + current estimate, make the adjustment. + + The decision whether we can re-use the estimate from the range + optimizer is the same as in ReuseRangeEstimateForRef-3, + applied to first table->quick_key_parts[key] key parts. */ if (table->quick_keys.is_set(key) && table->quick_key_parts[key] <= max_key_part && + const_part & (1 << table->quick_key_parts[key]) && + table->quick_n_ranges[key] == 1 + test(ref_or_null_part & + const_part) && records > (double) table->quick_rows[key]) - tmp= records= (double) table->quick_rows[key]; - else if (found_ref_or_null) { - /* We need to do two key searches to find key */ - tmp *= 2.0; - records *= 2.0; + tmp= records= (double) table->quick_rows[key]; } } + /* Limit the number of matched rows */ set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key); if (table->used_keys.is_set(key)) @@ -4369,344 +4475,11 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, if ((rest_tables & real_table_bit) && !(rest_tables & s->dependent) && (!idx|| !check_interleaving_with_nj(join->positions[idx-1].table, s))) { - double best,best_time,records; - best=best_time=records=DBL_MAX; - KEYUSE *best_key=0; - uint best_max_key_part=0; - my_bool found_constraint= 0; - - if (s->keyuse) - { /* Use key if possible */ - TABLE *table=s->table; - KEYUSE *keyuse,*start_key=0; - double best_records=DBL_MAX; - uint max_key_part=0; - - /* Test how we can use keys */ - rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; // Assumed records/key - for (keyuse=s->keyuse ; keyuse->table == table ;) - { - key_part_map found_part=0; - table_map found_ref=0; - uint key=keyuse->key; - KEY *keyinfo=table->key_info+key; - bool ft_key=(keyuse->keypart == FT_KEYPART); - uint found_ref_or_null= 0; - - /* Calculate how many key segments of the current key we can use */ - start_key=keyuse; - do - { - uint keypart=keyuse->keypart; - table_map best_part_found_ref= 0; - double best_prev_record_reads= DBL_MAX; - do - { - if (!(rest_tables & keyuse->used_tables) && - !(found_ref_or_null & keyuse->optimize)) - { - found_part|=keyuse->keypart_map; - double tmp= prev_record_reads(join, - (found_ref | - keyuse->used_tables)); - if (tmp < best_prev_record_reads) - { - best_part_found_ref= keyuse->used_tables; - best_prev_record_reads= tmp; - } - if (rec > keyuse->ref_table_rows) - rec= keyuse->ref_table_rows; - /* - If there is one 'key_column IS NULL' expression, we can - use this ref_or_null optimisation of this field - */ - found_ref_or_null|= (keyuse->optimize & - KEY_OPTIMIZE_REF_OR_NULL); - } - keyuse++; - } while (keyuse->table == table && keyuse->key == key && - keyuse->keypart == keypart); - found_ref|= best_part_found_ref; - } while (keyuse->table == table && keyuse->key == key); - - /* - Assume that that each key matches a proportional part of table. - */ - if (!found_part && !ft_key) - continue; // Nothing usable found - if (rec < MATCHING_ROWS_IN_OTHER_TABLE) - rec= MATCHING_ROWS_IN_OTHER_TABLE; // Fix for small tables - - /* - ft-keys require special treatment - */ - if (ft_key) - { - /* - Really, there should be records=0.0 (yes!) - but 1.0 would be probably safer - */ - tmp=prev_record_reads(join,found_ref); - records=1.0; - } - else - { - found_constraint= 1; - /* - Check if we found full key - */ - if (found_part == PREV_BITS(uint,keyinfo->key_parts) && - !found_ref_or_null) - { /* use eq key */ - max_key_part= (uint) ~0; - if ((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY | - HA_END_SPACE_KEY)) == HA_NOSAME) - { - tmp=prev_record_reads(join,found_ref); - records=1.0; - } - else - { - if (!found_ref) - { // We found a const key - if (table->quick_keys.is_set(key)) - records= (double) table->quick_rows[key]; - else - { - /* quick_range couldn't use key! */ - records= (double) s->records/rec; - } - } - else - { - if (!(records=keyinfo->rec_per_key[keyinfo->key_parts-1])) - { // Prefere longer keys - records= - ((double) s->records / (double) rec * - (1.0 + - ((double) (table->s->max_key_length-keyinfo->key_length) / - (double) table->s->max_key_length))); - if (records < 2.0) - records=2.0; // Can't be as good as a unique - } - } - /* Limit the number of matched rows */ - tmp= records; - set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key); - if (table->used_keys.is_set(key)) - { - /* we can use only index tree */ - uint keys_per_block= table->file->block_size/2/ - (keyinfo->key_length+table->file->ref_length)+1; - tmp=record_count*(tmp+keys_per_block-1)/keys_per_block; - } - else - tmp=record_count*min(tmp,s->worst_seeks); - } - } - else - { - /* - Use as much key-parts as possible and a uniq key is better - than a not unique key - Set tmp to (previous record count) * (records / combination) - */ - if ((found_part & 1) && - (!(table->file->index_flags(key,0,0) & HA_ONLY_WHOLE_INDEX) || - found_part == PREV_BITS(uint,keyinfo->key_parts))) - { - max_key_part=max_part_bit(found_part); - /* - Check if quick_range could determinate how many rows we - will match - */ - if (table->quick_keys.is_set(key) && - table->quick_key_parts[key] == max_key_part) - tmp=records= (double) table->quick_rows[key]; - else - { - /* Check if we have statistic about the distribution */ - if ((records=keyinfo->rec_per_key[max_key_part-1])) - tmp=records; - else - { - /* - Assume that the first key part matches 1% of the file - and that the whole key matches 10 (duplicates) or 1 - (unique) records. - Assume also that more key matches proportionally more - records - This gives the formula: - records= (x * (b-a) + a*c-b)/(c-1) - - b = records matched by whole key - a = records matched by first key part (10% of all records?) - c = number of key parts in key - x = used key parts (1 <= x <= c) - */ - double rec_per_key; - rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ? - (double) keyinfo->rec_per_key[keyinfo->key_parts-1] : - (double) s->records/rec+1; - if (!s->records) - tmp=0; - else if (rec_per_key/(double) s->records >= 0.01) - tmp=rec_per_key; - else - { - double a=s->records*0.01; - tmp=(max_key_part * (rec_per_key - a) + - a*keyinfo->key_parts - rec_per_key)/ - (keyinfo->key_parts-1); - set_if_bigger(tmp,1.0); - } - records=(ulong) tmp; - } - /* - If quick_select was used on a part of this key, we know - the maximum number of rows that the key can match. - */ - if (table->quick_keys.is_set(key) && - table->quick_key_parts[key] <= max_key_part && - records > (double) table->quick_rows[key]) - tmp= records= (double) table->quick_rows[key]; - else if (found_ref_or_null) - { - /* We need to do two key searches to find key */ - tmp*= 2.0; - records*= 2.0; - } - } - /* Limit the number of matched rows */ - set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key); - if (table->used_keys.is_set(key)) - { - /* we can use only index tree */ - uint keys_per_block= table->file->block_size/2/ - (keyinfo->key_length+table->file->ref_length)+1; - tmp=record_count*(tmp+keys_per_block-1)/keys_per_block; - } - else - tmp=record_count*min(tmp,s->worst_seeks); - } - else - tmp=best_time; // Do nothing - } - } /* not ft_key */ - if (tmp < best_time - records/(double) TIME_FOR_COMPARE) - { - best_time=tmp + records/(double) TIME_FOR_COMPARE; - best=tmp; - best_records=records; - best_key=start_key; - best_max_key_part=max_key_part; - } - } - records=best_records; - } - - /* - Don't test table scan if it can't be better. - Prefer key lookup if we would use the same key for scanning. - - Don't do a table scan on InnoDB tables, if we can read the used - parts of the row from any of the used index. - This is because table scans uses index and we would not win - anything by using a table scan. - (see comment in best_access_path() for more details on the below - condition) - */ - if ((records >= s->found_records || best > s->read_time) && - !(s->quick && best_key && s->quick->index == best_key->key && - best_max_key_part >= s->table->quick_key_parts[best_key->key]) && - !((s->table->file->table_flags() & HA_TABLE_SCAN_ON_INDEX) && - ! s->table->used_keys.is_clear_all() && best_key) && - !(s->table->force_index && best_key && !s->quick)) - { // Check full join - ha_rows rnd_records= s->found_records; - /* - If there is a restriction on the table, assume that 25% of the - rows can be skipped on next part. - This is to force tables that this table depends on before this - table - */ - if (found_constraint) - rnd_records-= rnd_records/4; - - /* - Range optimizer never proposes a RANGE if it isn't better - than FULL: so if RANGE is present, it's always preferred to FULL. - Here we estimate its cost. - */ - if (s->quick) - { - /* - For each record we: - - read record range through 'quick' - - skip rows which does not satisfy WHERE constraints - */ - tmp= record_count * - (s->quick->read_time + - (s->found_records - rnd_records)/(double) TIME_FOR_COMPARE); - } - else - { - /* Estimate cost of reading table. */ - tmp= s->table->file->scan_time(); - if (s->table->map & join->outer_join) // Can't use join cache - { - /* - For each record we have to: - - read the whole table record - - skip rows which does not satisfy join condition - */ - tmp= record_count * - (tmp + - (s->records - rnd_records)/(double) TIME_FOR_COMPARE); - } - else - { - /* We read the table as many times as join buffer becomes full. */ - tmp*= (1.0 + floor((double) cache_record_length(join,idx) * - record_count / - (double) thd->variables.join_buff_size)); - /* - We don't make full cartesian product between rows in the scanned - table and existing records because we skip all rows from the - scanned table, which does not satisfy join condition when - we read the table (see flush_cached_records for details). Here we - take into account cost to read and skip these records. - */ - tmp+= (s->records - rnd_records)/(double) TIME_FOR_COMPARE; - } - } - - /* - We estimate the cost of evaluating WHERE clause for found records - as record_count * rnd_records / TIME_FOR_COMPARE. This cost plus - tmp give us total cost of using TABLE SCAN - */ - if (best == DBL_MAX || - (tmp + record_count/(double) TIME_FOR_COMPARE*rnd_records < - best + record_count/(double) TIME_FOR_COMPARE*records)) - { - /* - If the table has a range (s->quick is set) make_join_select() - will ensure that this will be used - */ - best=tmp; - records= rows2double(rnd_records); - best_key=0; - } - } - join->positions[idx].records_read= records; - join->positions[idx].key=best_key; - join->positions[idx].table= s; - if (!best_key && idx == join->const_tables && - s->table == join->sort_by_table && - join->unit->select_limit_cnt >= records) - join->sort_by_table= (TABLE*) 1; // Must use temporary table - + double records, best; + best_access_path(join, s, thd, rest_tables, idx, record_count, + read_time); + records= join->positions[idx].records_read; + best= join->positions[idx].read_time; /* Go to the next level only if there hasn't been a better key on this level! This will cut down the search for a lot simple cases! @@ -12803,6 +12576,17 @@ create_distinct_group(THD *thd, Item **ref_pointer_array, { if (!item->const_item() && !item->with_sum_func && !item->marker) { + /* + Don't put duplicate columns from the SELECT list into the + GROUP BY list. + */ + ORDER *ord_iter; + for (ord_iter= group; ord_iter; ord_iter= ord_iter->next) + if ((*ord_iter->item)->eq(item, 1)) + break; + if (ord_iter) + continue; + ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER)); if (!ord) return 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 7c8499f2a2c..f94ddc57c80 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -938,6 +938,9 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, MODE_DB2 | MODE_MAXDB | MODE_ANSI)) != 0; + bool limited_mysql_mode= (thd->variables.sql_mode & (MODE_NO_FIELD_OPTIONS | + MODE_MYSQL323 | + MODE_MYSQL40)) != 0; DBUG_ENTER("store_create_info"); DBUG_PRINT("enter",("table: %s", table->s->table_name.str)); @@ -1022,8 +1025,8 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, has_default= (field->type() != FIELD_TYPE_BLOB && !(field->flags & NO_DEFAULT_VALUE_FLAG) && field->unireg_check != Field::NEXT_NUMBER && - !((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) && - has_now_default)); + !((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) + && has_now_default)); if (has_default) { @@ -1052,8 +1055,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, packet->append(tmp); } - if (!(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS) && - table->timestamp_field == field && + if (!limited_mysql_mode && table->timestamp_field == field && field->unireg_check != Field::TIMESTAMP_DN_FIELD) packet->append(STRING_WITH_LEN(" ON UPDATE CURRENT_TIMESTAMP")); @@ -1100,12 +1102,6 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, if (!found_primary) append_identifier(thd, packet, key_info->name, strlen(key_info->name)); -#if MYSQL_VERSION_ID < 50300 - /* Key options moved to after key parts in 5.3.0 */ - if (!thd->variables.new_mode) - store_key_options(thd, packet, table, key_info); -#endif - packet->append(STRING_WITH_LEN(" (")); for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) @@ -1130,10 +1126,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, } } packet->append(')'); -#if MYSQL_VERSION_ID < 50300 - if (thd->variables.new_mode) -#endif - store_key_options(thd, packet, table, key_info); + store_key_options(thd, packet, table, key_info); if (key_info->parser) { packet->append(" WITH PARSER ", 13); @@ -1190,6 +1183,25 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, packet->append(file->table_type()); #endif } + + /* + Add AUTO_INCREMENT=... if there is an AUTO_INCREMENT column, + and NEXT_ID > 1 (the default). We must not print the clause + for engines that do not support this as it would break the + import of dumps, but as of this writing, the test for whether + AUTO_INCREMENT columns are allowed and wether AUTO_INCREMENT=... + is supported is identical, !(file->table_flags() & HA_NO_AUTO_INCREMENT)) + Because of that, we do not explicitly test for the feature, + but may extrapolate its existence from that of an AUTO_INCREMENT column. + */ + + if(create_info.auto_increment_value > 1) + { + packet->append(" AUTO_INCREMENT=", 16); + end= longlong10_to_str(create_info.auto_increment_value, buff,10); + packet->append(buff, (uint) (end - buff)); + } + if (share->table_charset && !(thd->variables.sql_mode & MODE_MYSQL323) && @@ -1274,6 +1286,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, uint part_syntax_len; char *part_syntax; if (table->part_info && + (!table->part_info->is_auto_partitioned) && ((part_syntax= generate_partition_syntax(table->part_info, &part_syntax_len, FALSE,FALSE)))) @@ -2919,7 +2932,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, field->real_type() == MYSQL_TYPE_STRING) // For binary type { uint32 octet_max_length= field->max_length(); - if (octet_max_length != (uint32) 4294967295U) + if (is_blob && octet_max_length != (uint32) 4294967295U) octet_max_length /= field->charset()->mbmaxlen; longlong char_max_len= is_blob ? (longlong) octet_max_length / field->charset()->mbminlen : @@ -3156,17 +3169,18 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, const char *wild, bool full_access, const char *sp_user) { String tmp_string; + String sp_db, sp_name, definer; TIME time; LEX *lex= thd->lex; CHARSET_INFO *cs= system_charset_info; - const char *sp_db, *sp_name, *definer; - sp_db= get_field(thd->mem_root, proc_table->field[0]); - sp_name= get_field(thd->mem_root, proc_table->field[1]); - definer= get_field(thd->mem_root, proc_table->field[11]); + get_field(thd->mem_root, proc_table->field[0], &sp_db); + get_field(thd->mem_root, proc_table->field[1], &sp_name); + get_field(thd->mem_root, proc_table->field[11], &definer); if (!full_access) - full_access= !strcmp(sp_user, definer); - if (!full_access && check_some_routine_access(thd, sp_db, sp_name, - proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE)) + full_access= !strcmp(sp_user, definer.ptr()); + if (!full_access && check_some_routine_access(thd, sp_db.ptr(), sp_name.ptr(), + proc_table->field[2]->val_int() == + TYPE_ENUM_PROCEDURE)) return 0; if (lex->orig_sql_command == SQLCOM_SHOW_STATUS_PROC && @@ -3176,13 +3190,13 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, lex->orig_sql_command == SQLCOM_END) { restore_record(table, s->default_values); - if (!wild || !wild[0] || !wild_compare(sp_name, wild, 0)) + if (!wild || !wild[0] || !wild_compare(sp_name.ptr(), wild, 0)) { int enum_idx= proc_table->field[5]->val_int(); - table->field[3]->store(sp_name, strlen(sp_name), cs); + table->field[3]->store(sp_name.ptr(), sp_name.length(), cs); get_field(thd->mem_root, proc_table->field[3], &tmp_string); table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs); - table->field[2]->store(sp_db, strlen(sp_db), cs); + table->field[2]->store(sp_db.ptr(), sp_db.length(), cs); get_field(thd->mem_root, proc_table->field[2], &tmp_string); table->field[4]->store(tmp_string.ptr(), tmp_string.length(), cs); if (proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION) @@ -3214,7 +3228,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, table->field[17]->store(tmp_string.ptr(), tmp_string.length(), cs); get_field(thd->mem_root, proc_table->field[15], &tmp_string); table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs); - table->field[19]->store(definer, strlen(definer), cs); + table->field[19]->store(definer.ptr(), definer.length(), cs); return schema_table_store_record(thd, table); } } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f890f504952..f530af33e48 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3078,6 +3078,7 @@ bool mysql_create_table_internal(THD *thd, } file->set_auto_partitions(part_info); part_info->default_engine_type= create_info->db_type; + part_info->is_auto_partitioned= TRUE; } if (part_info) { @@ -3138,8 +3139,8 @@ bool mysql_create_table_internal(THD *thd, } DBUG_PRINT("info", ("db_type = %d", ha_legacy_type(part_info->default_engine_type))); - if (part_info->check_partition_info( &engine_type, file, - create_info->max_rows)) + if (part_info->check_partition_info(&engine_type, file, + create_info->max_rows)) goto err; part_info->default_engine_type= engine_type; @@ -3198,6 +3199,12 @@ bool mysql_create_table_internal(THD *thd, } else if (create_info->db_type != engine_type) { + /* + We come here when we don't use a partitioned handler. + Since we use a partitioned table it must be "native partitioned". + We have switched engine from defaults, most likely only specified + engines in partition clauses. + */ delete file; if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, engine_type))) { @@ -3419,111 +3426,6 @@ make_unique_key_name(const char *field_name,KEY *start,KEY *end) /**************************************************************************** -** Create table from a list of fields and items -****************************************************************************/ - -TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, - TABLE_LIST *create_table, - List<create_field> *extra_fields, - List<Key> *keys, - List<Item> *items, - MYSQL_LOCK **lock, - TABLEOP_HOOKS *hooks) -{ - TABLE tmp_table; // Used during 'create_field()' - TABLE_SHARE share; - TABLE *table= 0; - uint select_field_count= items->elements; - /* Add selected items to field list */ - List_iterator_fast<Item> it(*items); - Item *item; - Field *tmp_field; - bool not_used; - DBUG_ENTER("create_table_from_items"); - - tmp_table.alias= 0; - tmp_table.timestamp_field= 0; - tmp_table.s= &share; - init_tmp_table_share(&share, "", 0, "", ""); - - tmp_table.s->db_create_options=0; - tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr; - tmp_table.s->db_low_byte_first= - test(create_info->db_type == &myisam_hton || - create_info->db_type == &heap_hton); - tmp_table.null_row=tmp_table.maybe_null=0; - - while ((item=it++)) - { - create_field *cr_field; - Field *field; - if (item->type() == Item::FUNC_ITEM) - field=item->tmp_table_field(&tmp_table); - else - field=create_tmp_field(thd, &tmp_table, item, item->type(), - (Item ***) 0, &tmp_field, 0, 0, 0, 0, 0); - if (!field || - !(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ? - ((Item_field *)item)->field : - (Field*) 0)))) - DBUG_RETURN(0); - if (item->maybe_null) - cr_field->flags &= ~NOT_NULL_FLAG; - extra_fields->push_back(cr_field); - } - /* - create and lock table - - We don't log the statement, it will be logged later. - - If this is a HEAP table, the automatic DELETE FROM which is written to the - binlog when a HEAP table is opened for the first time since startup, must - not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we - don't want to delete from it) 2) it would be written before the CREATE - TABLE, which is a wrong order. So we keep binary logging disabled when we - open_table(). - TODO: create and open should be done atomic ! - */ - { - tmp_disable_binlog(thd); - if (!mysql_create_table(thd, create_table->db, create_table->table_name, - create_info, *extra_fields, *keys, 0, - select_field_count)) - { - if (! (table= open_table(thd, create_table, thd->mem_root, (bool*) 0, - MYSQL_LOCK_IGNORE_FLUSH))) - quick_rm_table(create_info->db_type, create_table->db, - table_case_name(create_info, create_table->table_name)); - } - reenable_binlog(thd); - if (!table) // open failed - DBUG_RETURN(0); - } - - /* - FIXME: What happens if trigger manages to be created while we are - obtaining this lock ? May be it is sensible just to disable - trigger execution in this case ? Or will MYSQL_LOCK_IGNORE_FLUSH - save us from that ? - */ - table->reginfo.lock_type=TL_WRITE; - hooks->prelock(&table, 1); // Call prelock hooks - if (! ((*lock)= mysql_lock_tables(thd, &table, 1, - MYSQL_LOCK_IGNORE_FLUSH, ¬_used))) - { - VOID(pthread_mutex_lock(&LOCK_open)); - hash_delete(&open_cache,(byte*) table); - VOID(pthread_mutex_unlock(&LOCK_open)); - quick_rm_table(create_info->db_type, create_table->db, - table_case_name(create_info, create_table->table_name)); - DBUG_RETURN(0); - } - table->file->extra(HA_EXTRA_WRITE_CACHE); - DBUG_RETURN(table); -} - - -/**************************************************************************** ** Alter a table definition ****************************************************************************/ @@ -5098,7 +5000,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ha_resolve_storage_engine_name(old_db_type), ha_resolve_storage_engine_name(new_db_type))); if (ha_check_storage_engine_flag(old_db_type, HTON_ALTER_NOT_SUPPORTED) || - ha_check_storage_engine_flag(new_db_type, HTON_ALTER_NOT_SUPPORTED)) + ha_check_storage_engine_flag(new_db_type, HTON_ALTER_NOT_SUPPORTED) || + (old_db_type != new_db_type && + ha_check_storage_engine_flag(new_db_type, HTON_ALTER_CANNOT_CREATE))) { DBUG_PRINT("info", ("doesn't support alter")); my_error(ER_ILLEGAL_HA, MYF(0), table_name); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index aa42cd901d8..4398e0039e8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -475,6 +475,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token NUMERIC_SYM %token NVARCHAR_SYM %token OFFSET_SYM +%token OJ_SYM %token OLD_PASSWORD %token ON %token ONE_SHOT_SYM @@ -797,7 +798,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); key_type opt_unique_or_fulltext constraint_key_type %type <key_alg> - opt_btree_or_rtree + btree_or_rtree %type <string_list> key_usage_list using_list @@ -888,7 +889,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); view_suid view_tail view_list_opt view_list view_select view_check_option trigger_tail sp_tail install uninstall partition_entry binlog_base64_event - init_key_options key_options key_opts key_opt + init_key_options key_options key_opts key_opt key_using_alg END_OF_INPUT %type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt @@ -4529,7 +4530,7 @@ init_key_options: key_alg: /* empty */ init_key_options - | init_key_options key_opts + | init_key_options key_using_alg ; key_options: @@ -4541,10 +4542,14 @@ key_opts: key_opt | key_opts key_opt ; - + +key_using_alg: + USING btree_or_rtree { Lex->key_create_info.algorithm= $2; } + | TYPE_SYM btree_or_rtree { Lex->key_create_info.algorithm= $2; } + ; + key_opt: - USING opt_btree_or_rtree { Lex->key_create_info.algorithm= $2; } - | TYPE_SYM opt_btree_or_rtree { Lex->key_create_info.algorithm= $2; } + key_using_alg | KEY_BLOCK_SIZE opt_equal ulong_num { Lex->key_create_info.block_size= $3; } | WITH PARSER_SYM IDENT_sys @@ -4560,7 +4565,7 @@ key_opt: ; -opt_btree_or_rtree: +btree_or_rtree: BTREE_SYM { $$= HA_KEY_ALG_BTREE; } | RTREE_SYM { @@ -4574,7 +4579,7 @@ key_list: key_part: ident { $$=new key_part_spec($1.str); } - | ident '(' NUM ')' + | ident '(' NUM ')' { int key_part_len= atoi($3.str); if (!key_part_len) @@ -6940,11 +6945,14 @@ table_factor: } expr '}' { + LEX *lex= Lex; YYERROR_UNLESS($3 && $7); add_join_on($7,$10); Lex->pop_context(); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; + if (!($$= lex->current_select->nest_last_join(lex->thd))) + YYABORT; } | select_derived_init get_select_lex select_derived2 { @@ -7489,7 +7497,11 @@ select_var_ident: if (lex->result) ((select_dumpvar *)lex->result)->var_list.push_back( new my_var($2,0,0,(enum_field_types)0)); else - YYABORT; + /* + The parser won't create select_result instance only + if it's an EXPLAIN. + */ + DBUG_ASSERT(lex->describe); } | ident_or_text { @@ -7501,10 +7513,8 @@ select_var_ident: my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str); YYABORT; } - if (! lex->result) - YYABORT; - else - { + if (lex->result) + { my_var *var; ((select_dumpvar *)lex->result)-> var_list.push_back(var= new my_var($1,1,t->offset,t->type)); @@ -7512,6 +7522,14 @@ select_var_ident: if (var) var->sp= lex->sphead; #endif + } + else + { + /* + The parser won't create select_result instance only + if it's an EXPLAIN. + */ + DBUG_ASSERT(lex->describe); } } ; @@ -9016,12 +9034,18 @@ simple_ident_q: YYABORT; } + DBUG_ASSERT(!new_row || + (lex->trg_chistics.event == TRG_EVENT_INSERT || + lex->trg_chistics.event == TRG_EVENT_UPDATE)); + const bool read_only= + !(new_row && lex->trg_chistics.action_time == TRG_ACTION_BEFORE); if (!(trg_fld= new Item_trigger_field(Lex->current_context(), new_row ? Item_trigger_field::NEW_ROW: Item_trigger_field::OLD_ROW, $3.str, - Item_trigger_field::AT_READ))) + SELECT_ACL, + read_only))) YYABORT; /* @@ -9703,11 +9727,13 @@ sys_option_value: it= new Item_null(); } + DBUG_ASSERT(lex->trg_chistics.action_time == TRG_ACTION_BEFORE && + (lex->trg_chistics.event == TRG_EVENT_INSERT || + lex->trg_chistics.event == TRG_EVENT_UPDATE)); if (!(trg_fld= new Item_trigger_field(Lex->current_context(), Item_trigger_field::NEW_ROW, $2.base_name.str, - Item_trigger_field::AT_UPDATE) - ) || + UPDATE_ACL, FALSE)) || !(sp_fld= new sp_instr_set_trigger_field(lex->sphead-> instructions(), lex->spcont, diff --git a/sql/table.cc b/sql/table.cc index fb9733c9180..d0caba7fe9e 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -656,7 +656,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, my_free(buff, MYF(0)); goto err; } - next_chunk++; } #else if (partition_info_len) @@ -680,7 +679,15 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, */ next_chunk+= 4; } + else if (share->mysql_version >= 50110) #endif + { + /* New auto_partitioned indicator introduced in 5.1.11 */ +#ifdef WITH_PARTITION_STORAGE_ENGINE + share->auto_partitioned= *next_chunk; +#endif + next_chunk++; + } keyinfo= share->key_info; for (i= 0; i < keys; i++, keyinfo++) { @@ -1471,6 +1478,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, Fix the partition functions and ensure they are not constant functions */ + outparam->part_info->is_auto_partitioned= share->auto_partitioned; + DBUG_PRINT("info", ("autopartitioned = %u", share->auto_partitioned)); if (fix_partition_func(thd, share->normalized_path.str, outparam, is_create_table)) goto err; diff --git a/sql/table.h b/sql/table.h index 5fd9cd28585..ffecc60b19c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -214,6 +214,7 @@ typedef struct st_table_share */ bool log_table; #ifdef WITH_PARTITION_STORAGE_ENGINE + bool auto_partitioned; const uchar *partition_info; uint partition_info_len; const uchar *part_state; @@ -263,6 +264,7 @@ struct st_table { ha_rows quick_rows[MAX_KEY]; key_part_map const_key_parts[MAX_KEY]; uint quick_key_parts[MAX_KEY]; + uint quick_n_ranges[MAX_KEY]; /* If this table has TIMESTAMP field with auto-set property (pointed by diff --git a/sql/udf_example.cc b/sql/udf_example.cc index f4f936f34ef..6ad066eacc2 100644 --- a/sql/udf_example.cc +++ b/sql/udf_example.cc @@ -344,7 +344,7 @@ char *metaphon(UDF_INIT *initid, UDF_ARGS *args, char *result, KSflag = 0; /* state flag for KS translation */ for (metaph_end = result + MAXMETAPH, n_start = n; - n <= n_end && result < metaph_end; n++ ) + n < n_end && result < metaph_end; n++ ) { if ( KSflag ) diff --git a/sql/unireg.cc b/sql/unireg.cc index eb38e6c0592..11aa73bb502 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -130,8 +130,14 @@ bool mysql_create_frm(THD *thd, const char *file_name, /* str_db_type */ create_info->extra_size= (2 + str_db_type.length + 2 + create_info->connect_string.length); - /* Partition */ - create_info->extra_size+= 9; + /* + Partition: + Length of partition info = 4 byte + Potential NULL byte at end of partition info string = 1 byte + Indicator if auto-partitioned table = 1 byte + => Total 6 byte + */ + create_info->extra_size+= 6; #ifdef WITH_PARTITION_STORAGE_ENGINE if (part_info) { @@ -203,17 +209,19 @@ bool mysql_create_frm(THD *thd, const char *file_name, #ifdef WITH_PARTITION_STORAGE_ENGINE if (part_info) { + char auto_partitioned= part_info->is_auto_partitioned ? 1 : 0; int4store(buff, part_info->part_info_len); if (my_write(file, (const byte*)buff, 4, MYF_RW) || my_write(file, (const byte*)part_info->part_info_string, - part_info->part_info_len + 1, MYF_RW)) + part_info->part_info_len + 1, MYF_RW) || + my_write(file, (const byte*)&auto_partitioned, 1, MYF_RW)) goto err; } else #endif { - bzero(buff, 9); - if (my_write(file, (byte*) buff, 9, MYF_RW)) + bzero(buff, 6); + if (my_write(file, (byte*) buff, 6, MYF_RW)) goto err; } for (i= 0; i < keys; i++) diff --git a/storage/archive/cmakelists.txt b/storage/archive/CMakeLists.txt index a631f194b1a..a631f194b1a 100644 --- a/storage/archive/cmakelists.txt +++ b/storage/archive/CMakeLists.txt diff --git a/storage/archive/Makefile.am b/storage/archive/Makefile.am index 85577f406da..3d933408b0b 100644 --- a/storage/archive/Makefile.am +++ b/storage/archive/Makefile.am @@ -57,6 +57,6 @@ archive_test_LDADD = $(top_builddir)/mysys/libmysys.a \ archive_test_LDFLAGS = @NOINST_LDFLAGS@ -EXTRA_DIST = cmakelists.txt +EXTRA_DIST = CMakeLists.txt # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/archive/plug.in b/storage/archive/plug.in new file mode 100644 index 00000000000..52131b12e6b --- /dev/null +++ b/storage/archive/plug.in @@ -0,0 +1,4 @@ +MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine], + [Archive Storage Engine], [max,max-no-ndb]) +MYSQL_PLUGIN_STATIC(archive, [libarchive.a]) +MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la]) diff --git a/storage/bdb/cmakelists.txt b/storage/bdb/CMakeLists.txt index c27665d902c..c27665d902c 100644 --- a/storage/bdb/cmakelists.txt +++ b/storage/bdb/CMakeLists.txt diff --git a/storage/bdb/Makefile.in b/storage/bdb/Makefile.in index 4e2439025f3..6d7da66edf4 100644 --- a/storage/bdb/Makefile.in +++ b/storage/bdb/Makefile.in @@ -23,7 +23,7 @@ top_srcdir = @top_srcdir@ # distdir and top_distdir are set by the calling Makefile bdb_build = build_unix -files = LICENSE Makefile Makefile.in README cmakelists.txt +files = LICENSE Makefile Makefile.in README CMakeLists.txt subdirs = btree build_win32 clib common cxx db dbinc \ dbinc_auto db185 db_archive db_checkpoint db_deadlock db_dump \ db_dump185 db_hotbackup db_load db_printlog db_recover db_stat db_upgrade \ diff --git a/storage/blackhole/cmakelists.txt b/storage/blackhole/CMakeLists.txt index ea3a7eae38e..ea3a7eae38e 100644 --- a/storage/blackhole/cmakelists.txt +++ b/storage/blackhole/CMakeLists.txt diff --git a/storage/blackhole/Makefile.am b/storage/blackhole/Makefile.am index 902d57c1668..e3e28cd75b5 100644 --- a/storage/blackhole/Makefile.am +++ b/storage/blackhole/Makefile.am @@ -47,6 +47,6 @@ libblackhole_a_CFLAGS = $(AM_CFLAGS) libblackhole_a_SOURCES= ha_blackhole.cc -EXTRA_DIST = cmakelists.txt +EXTRA_DIST = CMakeLists.txt # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index e9fd1c2319d..098e44f39ee 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -67,7 +67,7 @@ handlerton blackhole_hton= { NULL, /* Alter table flags */ NULL, /* Alter Tablespace */ NULL, /* Fill FILES table */ - HTON_CAN_RECREATE, + HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE, NULL, /* binlog_func */ NULL, /* binlog_log_query */ NULL /* release_temporary_latches */ diff --git a/storage/csv/cmakelists.txt b/storage/csv/CMakeLists.txt index 28748527cc3..28748527cc3 100644 --- a/storage/csv/cmakelists.txt +++ b/storage/csv/CMakeLists.txt diff --git a/storage/csv/Makefile.am b/storage/csv/Makefile.am index a2afeba137f..adebebd7cd8 100644 --- a/storage/csv/Makefile.am +++ b/storage/csv/Makefile.am @@ -41,6 +41,6 @@ noinst_LIBRARIES = @plugin_csv_static_target@ libcsv_a_CXXFLAGS = $(AM_CFLAGS) libcsv_a_SOURCES = ha_tina.cc -EXTRA_DIST = cmakelists.txt +EXTRA_DIST = CMakeLists.txt # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/example/cmakelists.txt b/storage/example/CMakeLists.txt index f4579aa0c66..f4579aa0c66 100644 --- a/storage/example/cmakelists.txt +++ b/storage/example/CMakeLists.txt diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am index 9c4bedb2160..db3e35e4315 100644 --- a/storage/example/Makefile.am +++ b/storage/example/Makefile.am @@ -47,6 +47,6 @@ libexample_a_CFLAGS = $(AM_CFLAGS) libexample_a_SOURCES= ha_example.cc -EXTRA_DIST = cmakelists.txt +EXTRA_DIST = CMakeLists.txt # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/example/plug.in b/storage/example/plug.in new file mode 100644 index 00000000000..bf5bb49b429 --- /dev/null +++ b/storage/example/plug.in @@ -0,0 +1,4 @@ +MYSQL_STORAGE_ENGINE(example,, [Example Storage Engine], + [Skeleton for Storage Engines for developers], [max,max-no-ndb]) +MYSQL_PLUGIN_STATIC(example, [libexample.a]) +MYSQL_PLUGIN_DYNAMIC(example, [ha_example.la]) diff --git a/storage/heap/cmakelists.txt b/storage/heap/CMakeLists.txt index db5fb8b2981..db5fb8b2981 100644 --- a/storage/heap/cmakelists.txt +++ b/storage/heap/CMakeLists.txt diff --git a/storage/heap/Makefile.am b/storage/heap/Makefile.am index fceaeec664a..68dce9bca5f 100644 --- a/storage/heap/Makefile.am +++ b/storage/heap/Makefile.am @@ -30,7 +30,7 @@ libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \ hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \ hp_rkey.c hp_block.c \ hp_hash.c _check.c _rectest.c hp_static.c -EXTRA_DIST = cmakelists.txt +EXTRA_DIST = CMakeLists.txt # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/innobase/cmakelists.txt b/storage/innobase/CMakeLists.txt index def51873725..def51873725 100644 --- a/storage/innobase/cmakelists.txt +++ b/storage/innobase/CMakeLists.txt diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index 908f5d669a2..bf41d3dca88 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -77,7 +77,7 @@ EXTRA_DIST = include/btr0btr.h include/btr0btr.ic include/btr0cur.h include/btr include/ut0byte.h include/ut0byte.ic include/ut0dbg.h include/ut0lst.h \ include/ut0mem.h include/ut0mem.ic include/ut0rnd.h include/ut0rnd.ic \ include/ut0sort.h include/ut0ut.h include/ut0ut.ic include/ut0vec.h include/ut0vec.ic \ - cmakelists.txt + CMakeLists.txt noinst_LIBRARIES = libinnobase.a libinnobase_a_LIBADD = usr/libusr.a srv/libsrv.a dict/libdict.a \ diff --git a/storage/myisam/cmakelists.txt b/storage/myisam/CMakeLists.txt index 3ba7aba4555..3ba7aba4555 100644 --- a/storage/myisam/cmakelists.txt +++ b/storage/myisam/CMakeLists.txt diff --git a/storage/myisam/Makefile.am b/storage/myisam/Makefile.am index 3c6a5c22234..081d7facf3a 100644 --- a/storage/myisam/Makefile.am +++ b/storage/myisam/Makefile.am @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c cmakelists.txt +EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt pkgdata_DATA = mi_test_all mi_test_all.res INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include diff --git a/storage/myisammrg/cmakelists.txt b/storage/myisammrg/CMakeLists.txt index 83168f6c60c..83168f6c60c 100644 --- a/storage/myisammrg/cmakelists.txt +++ b/storage/myisammrg/CMakeLists.txt diff --git a/storage/myisammrg/Makefile.am b/storage/myisammrg/Makefile.am index 0719780b366..0402f2730b9 100644 --- a/storage/myisammrg/Makefile.am +++ b/storage/myisammrg/Makefile.am @@ -23,7 +23,7 @@ libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \ myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \ myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \ myrg_rnext_same.c -EXTRA_DIST = cmakelists.txt +EXTRA_DIST = CMakeLists.txt # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/ndb/include/ndbapi/Ndb.hpp b/storage/ndb/include/ndbapi/Ndb.hpp index 010b85b03a9..f6f313e9224 100644 --- a/storage/ndb/include/ndbapi/Ndb.hpp +++ b/storage/ndb/include/ndbapi/Ndb.hpp @@ -1262,6 +1262,7 @@ public: #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL + int flushIncompleteEvents(Uint64 gci); NdbEventOperation *getEventOperation(NdbEventOperation* eventOp= 0); Uint64 getLatestGCI(); void forceGCP(); diff --git a/storage/ndb/include/ndbapi/NdbDictionary.hpp b/storage/ndb/include/ndbapi/NdbDictionary.hpp index b31e2551e89..865fb506f05 100644 --- a/storage/ndb/include/ndbapi/NdbDictionary.hpp +++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp @@ -1132,7 +1132,8 @@ public: _TE_NODE_FAILURE=10, _TE_SUBSCRIBE=11, _TE_UNSUBSCRIBE=12, - _TE_NUL=13 // internal (e.g. INS o DEL within same GCI) + _TE_NUL=13, // internal (e.g. INS o DEL within same GCI) + _TE_ACTIVE=14 // internal (node becomes active) }; #endif /** diff --git a/storage/ndb/include/ndbapi/NdbOperation.hpp b/storage/ndb/include/ndbapi/NdbOperation.hpp index e747dedb84b..d64e86c3136 100644 --- a/storage/ndb/include/ndbapi/NdbOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbOperation.hpp @@ -636,6 +636,10 @@ public: bool nopad, Uint32 Label); int branch_col_ge(Uint32 ColId, const void * val, Uint32 len, bool nopad, Uint32 Label); + /** + * The argument is always plain char, even if the field is varchar + * (changed in 5.0.22). + */ int branch_col_like(Uint32 ColId, const void *, Uint32 len, bool nopad, Uint32 Label); int branch_col_notlike(Uint32 ColId, const void *, Uint32 len, diff --git a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp index 01c700d14b2..a803d010e61 100644 --- a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp +++ b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp @@ -110,6 +110,7 @@ public: unsigned no_db_nodes(); unsigned node_id(); + unsigned get_connect_count() const; void init_get_next_node(Ndb_cluster_connection_node_iter &iter); unsigned int get_next_node(Ndb_cluster_connection_node_iter &iter); diff --git a/storage/ndb/include/util/NdbSqlUtil.hpp b/storage/ndb/include/util/NdbSqlUtil.hpp index 36a75136c45..ff2d9766f81 100644 --- a/storage/ndb/include/util/NdbSqlUtil.hpp +++ b/storage/ndb/include/util/NdbSqlUtil.hpp @@ -45,14 +45,11 @@ public: typedef int Cmp(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full); /** - * Prototype for "like" comparison. Defined for string types. Second - * argument must have same type-specific format. Returns 0 on match, - * +1 on no match, and -1 on bad data. + * Prototype for "like" comparison. Defined for string types. First + * argument can be fixed or var* type, second argument is fixed. + * Returns 0 on match, +1 on no match, and -1 on bad data. * * Uses default special chars ( \ % _ ). - * - * TODO convert special chars to the cs so that ucs2 etc works - * TODO allow user-defined escape ( \ ) */ typedef int Like(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2); diff --git a/storage/ndb/include/util/SocketServer.hpp b/storage/ndb/include/util/SocketServer.hpp index e766a0b99c4..c4f7e8c0ade 100644 --- a/storage/ndb/include/util/SocketServer.hpp +++ b/storage/ndb/include/util/SocketServer.hpp @@ -106,7 +106,8 @@ public: void stopSessions(bool wait = false); void foreachSession(void (*f)(Session*, void*), void *data); - + void checkSessions(); + private: struct SessionInstance { Service * m_service; @@ -117,12 +118,13 @@ private: Service * m_service; NDB_SOCKET_TYPE m_socket; }; - MutexVector<SessionInstance> m_sessions; + NdbLockable m_session_mutex; + Vector<SessionInstance> m_sessions; MutexVector<ServiceInstance> m_services; unsigned m_maxSessions; void doAccept(); - void checkSessions(); + void checkSessionsImpl(); void startSession(SessionInstance &); /** diff --git a/storage/ndb/src/common/util/NdbSqlUtil.cpp b/storage/ndb/src/common/util/NdbSqlUtil.cpp index f2506eda6d4..f3d70a5734a 100644 --- a/storage/ndb/src/common/util/NdbSqlUtil.cpp +++ b/storage/ndb/src/common/util/NdbSqlUtil.cpp @@ -805,7 +805,9 @@ NdbSqlUtil::likeChar(const void* info, const void* p1, unsigned n1, const void* const char* v1 = (const char*)p1; const char* v2 = (const char*)p2; CHARSET_INFO* cs = (CHARSET_INFO*)(info); - int k = (cs->coll->wildcmp)(cs, v1, v1 + n1, v2, v2 + n2, ndb_wild_prefix, ndb_wild_one, ndb_wild_many); + // strip end spaces to match (incorrect) MySQL behaviour + n1 = (*cs->cset->lengthsp)(cs, v1, n1); + int k = (*cs->coll->wildcmp)(cs, v1, v1 + n1, v2, v2 + n2, ndb_wild_prefix, ndb_wild_one, ndb_wild_many); return k == 0 ? 0 : +1; } @@ -820,16 +822,16 @@ int NdbSqlUtil::likeVarchar(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2) { const unsigned lb = 1; - if (n1 >= lb && n2 >= lb) { + if (n1 >= lb) { const uchar* v1 = (const uchar*)p1; const uchar* v2 = (const uchar*)p2; unsigned m1 = *v1; - unsigned m2 = *v2; - if (lb + m1 <= n1 && lb + m2 <= n2) { + unsigned m2 = n2; + if (lb + m1 <= n1) { const char* w1 = (const char*)v1 + lb; - const char* w2 = (const char*)v2 + lb; + const char* w2 = (const char*)v2; CHARSET_INFO* cs = (CHARSET_INFO*)(info); - int k = (cs->coll->wildcmp)(cs, w1, w1 + m1, w2, w2 + m2, ndb_wild_prefix, ndb_wild_one, ndb_wild_many); + int k = (*cs->coll->wildcmp)(cs, w1, w1 + m1, w2, w2 + m2, ndb_wild_prefix, ndb_wild_one, ndb_wild_many); return k == 0 ? 0 : +1; } } @@ -847,16 +849,16 @@ int NdbSqlUtil::likeLongvarchar(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2) { const unsigned lb = 2; - if (n1 >= lb && n2 >= lb) { + if (n1 >= lb) { const uchar* v1 = (const uchar*)p1; const uchar* v2 = (const uchar*)p2; unsigned m1 = uint2korr(v1); - unsigned m2 = uint2korr(v2); - if (lb + m1 <= n1 && lb + m2 <= n2) { + unsigned m2 = n2; + if (lb + m1 <= n1) { const char* w1 = (const char*)v1 + lb; - const char* w2 = (const char*)v2 + lb; + const char* w2 = (const char*)v2; CHARSET_INFO* cs = (CHARSET_INFO*)(info); - int k = (cs->coll->wildcmp)(cs, w1, w1 + m1, w2, w2 + m2, ndb_wild_prefix, ndb_wild_one, ndb_wild_many); + int k = (*cs->coll->wildcmp)(cs, w1, w1 + m1, w2, w2 + m2, ndb_wild_prefix, ndb_wild_one, ndb_wild_many); return k == 0 ? 0 : +1; } } diff --git a/storage/ndb/src/common/util/SocketServer.cpp b/storage/ndb/src/common/util/SocketServer.cpp index f0af925cf6d..f9d2c7463be 100644 --- a/storage/ndb/src/common/util/SocketServer.cpp +++ b/storage/ndb/src/common/util/SocketServer.cpp @@ -184,9 +184,12 @@ SocketServer::doAccept(){ SessionInstance s; s.m_service = si.m_service; s.m_session = si.m_service->newSession(childSock); - if(s.m_session != 0){ + if(s.m_session != 0) + { + m_session_mutex.lock(); m_sessions.push_back(s); startSession(m_sessions.back()); + m_session_mutex.unlock(); } continue; @@ -240,10 +243,13 @@ void SocketServer::doRun(){ while(!m_stopThread){ - checkSessions(); + m_session_mutex.lock(); + checkSessionsImpl(); if(m_sessions.size() < m_maxSessions){ + m_session_mutex.unlock(); doAccept(); } else { + m_session_mutex.unlock(); NdbSleep_MilliSleep(200); } } @@ -276,17 +282,30 @@ transfer(NDB_SOCKET_TYPE sock){ void SocketServer::foreachSession(void (*func)(SocketServer::Session*, void *), void *data) { + m_session_mutex.lock(); for(int i = m_sessions.size() - 1; i >= 0; i--){ (*func)(m_sessions[i].m_session, data); } - checkSessions(); + m_session_mutex.unlock(); } void -SocketServer::checkSessions(){ - for(int i = m_sessions.size() - 1; i >= 0; i--){ - if(m_sessions[i].m_session->m_stopped){ - if(m_sessions[i].m_thread != 0){ +SocketServer::checkSessions() +{ + m_session_mutex.lock(); + checkSessionsImpl(); + m_session_mutex.unlock(); +} + +void +SocketServer::checkSessionsImpl() +{ + for(int i = m_sessions.size() - 1; i >= 0; i--) + { + if(m_sessions[i].m_session->m_stopped) + { + if(m_sessions[i].m_thread != 0) + { void* ret; NdbThread_WaitFor(m_sessions[i].m_thread, &ret); NdbThread_Destroy(&m_sessions[i].m_thread); @@ -301,19 +320,26 @@ SocketServer::checkSessions(){ void SocketServer::stopSessions(bool wait){ int i; + m_session_mutex.lock(); for(i = m_sessions.size() - 1; i>=0; i--) { m_sessions[i].m_session->stopSession(); m_sessions[i].m_session->m_stop = true; // to make sure } + m_session_mutex.unlock(); + for(i = m_services.size() - 1; i>=0; i--) m_services[i].m_service->stopSessions(); if(wait){ + m_session_mutex.lock(); while(m_sessions.size() > 0){ - checkSessions(); + checkSessionsImpl(); + m_session_mutex.unlock(); NdbSleep_MilliSleep(100); + m_session_mutex.lock(); } + m_session_mutex.unlock(); } } @@ -348,4 +374,4 @@ sessionThread_C(void* _sc){ } template class MutexVector<SocketServer::ServiceInstance>; -template class MutexVector<SocketServer::SessionInstance>; +template class Vector<SocketServer::SessionInstance>; diff --git a/storage/ndb/src/common/util/socket_io.cpp b/storage/ndb/src/common/util/socket_io.cpp index 83a546de773..58636e6663d 100644 --- a/storage/ndb/src/common/util/socket_io.cpp +++ b/storage/ndb/src/common/util/socket_io.cpp @@ -48,58 +48,66 @@ read_socket(NDB_SOCKET_TYPE socket, int timeout_millis, extern "C" int -readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, +readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, char * buf, int buflen){ if(buflen <= 1) return 0; + int sock_flags= fcntl(socket, F_GETFL); + if(fcntl(socket, F_SETFL, sock_flags | O_NONBLOCK) == -1) + return -1; + fd_set readset; FD_ZERO(&readset); FD_SET(socket, &readset); - + struct timeval timeout; timeout.tv_sec = (timeout_millis / 1000); timeout.tv_usec = (timeout_millis % 1000) * 1000; const int selectRes = select(socket + 1, &readset, 0, 0, &timeout); - if(selectRes == 0) + if(selectRes == 0){ return 0; - + } + if(selectRes == -1){ + fcntl(socket, F_SETFL, sock_flags); return -1; } - - int pos = 0; buf[pos] = 0; - while(true){ - const int t = recv(socket, &buf[pos], 1, 0); - if(t != 1){ - return -1; - } - if(buf[pos] == '\n'){ - buf[pos] = 0; - if(pos > 0 && buf[pos-1] == '\r'){ - pos--; - buf[pos] = 0; + buf[0] = 0; + const int t = recv(socket, buf, buflen, MSG_PEEK); + + if(t < 1) + { + fcntl(socket, F_SETFL, sock_flags); + return -1; + } + + for(int i=0; i< t;i++) + { + if(buf[i] == '\n'){ + recv(socket, buf, i+1, 0); + buf[i] = 0; + + if(i > 0 && buf[i-1] == '\r'){ + i--; + buf[i] = 0; } - return pos; - } - pos++; - if(pos == (buflen - 1)){ - buf[pos] = 0; - return buflen; - } - - FD_ZERO(&readset); - FD_SET(socket, &readset); - timeout.tv_sec = (timeout_millis / 1000); - timeout.tv_usec = (timeout_millis % 1000) * 1000; - const int selectRes = select(socket + 1, &readset, 0, 0, &timeout); - if(selectRes != 1){ - return -1; + fcntl(socket, F_SETFL, sock_flags); + return t; } } + + if(t == (buflen - 1)){ + recv(socket, buf, t, 0); + buf[t] = 0; + fcntl(socket, F_SETFL, sock_flags); + return buflen; + } + + return 0; } extern "C" diff --git a/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp b/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp index 5a9d6b9f053..8dee75398ed 100644 --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp @@ -179,7 +179,7 @@ Dbtc::Dbtc(Block_context& ctx): ndb_mgm_get_int_parameter(p, CFG_DB_TRANS_BUFFER_MEM, &transactionBufferMemory); - ndb_mgm_get_int_parameter(p, CFG_DB_NO_UNIQUE_HASH_INDEXES, + ndb_mgm_get_int_parameter(p, CFG_DICT_TABLE, &maxNoOfIndexes); ndb_mgm_get_int_parameter(p, CFG_DB_NO_INDEX_OPS, &maxNoOfConcurrentIndexOperations); diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp index 90abe2cb809..1b6fef9de37 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp @@ -1926,6 +1926,7 @@ int Dbtup::interpreterNextLab(Signal* signal, // word read. Thus we set the register to be a 32 bit register. /* ------------------------------------------------------------- */ TregMemBuffer[theRegister]= 0x50; + // arithmetic conversion if big-endian * (Int64*)(TregMemBuffer+theRegister+2)= TregMemBuffer[theRegister+1]; } else if (TnoDataRW == 3) { @@ -1985,6 +1986,11 @@ int Dbtup::interpreterNextLab(Signal* signal, Tlen= TattrNoOfWords + 1; if (Toptype == ZUPDATE) { if (TattrNoOfWords <= 2) { + if (TattrNoOfWords == 1) { + // arithmetic conversion if big-endian + TdataForUpdate[1] = *(Int64*)&TregMemBuffer[theRegister + 2]; + TdataForUpdate[2] = 0; + } if (TregType == 0) { /* --------------------------------------------------------- */ // Write a NULL value into the attribute diff --git a/storage/ndb/src/kernel/blocks/suma/Suma.cpp b/storage/ndb/src/kernel/blocks/suma/Suma.cpp index 867b13e1e40..91f0fab06f8 100644 --- a/storage/ndb/src/kernel/blocks/suma/Suma.cpp +++ b/storage/ndb/src/kernel/blocks/suma/Suma.cpp @@ -2649,6 +2649,22 @@ Suma::reportAllSubscribers(Signal *signal, SubscriptionPtr subPtr, SubscriberPtr subbPtr) { + SubTableData * data = (SubTableData*)signal->getDataPtrSend(); + + if (table_event == NdbDictionary::Event::_TE_SUBSCRIBE) + { + data->gci = m_last_complete_gci + 1; + data->tableId = subPtr.p->m_tableId; + data->operation = NdbDictionary::Event::_TE_ACTIVE; + data->ndbd_nodeid = refToNode(reference()); + data->changeMask = 0; + data->totalLen = 0; + data->req_nodeid = refToNode(subbPtr.p->m_senderRef); + data->senderData = subbPtr.p->m_senderData; + sendSignal(subbPtr.p->m_senderRef, GSN_SUB_TABLE_DATA, signal, + SubTableData::SignalLength, JBB); + } + if (!(subPtr.p->m_options & Subscription::REPORT_SUBSCRIBE)) { return; @@ -2663,7 +2679,6 @@ Suma::reportAllSubscribers(Signal *signal, ndbout_c("reportAllSubscribers subPtr.i: %d subPtr.p->n_subscribers: %d", subPtr.i, subPtr.p->n_subscribers); //#endif - SubTableData * data = (SubTableData*)signal->getDataPtrSend(); data->gci = m_last_complete_gci + 1; data->tableId = subPtr.p->m_tableId; data->operation = table_event; diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp index e0e414e5669..12badffe0e0 100644 --- a/storage/ndb/src/kernel/vm/Configuration.cpp +++ b/storage/ndb/src/kernel/vm/Configuration.cpp @@ -49,7 +49,9 @@ extern EventLogger g_eventLogger; enum ndbd_options { OPT_INITIAL = NDB_STD_OPTIONS_LAST, OPT_NODAEMON, - OPT_FOREGROUND + OPT_FOREGROUND, + OPT_NOWAIT_NODES, + OPT_INITIAL_START }; NDB_STD_OPTS_VARS; @@ -88,11 +90,11 @@ static struct my_option my_long_options[] = " (implies --nodaemon)", (gptr*) &_foreground, (gptr*) &_foreground, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, - { "nowait-nodes", NO_ARG, + { "nowait-nodes", OPT_NOWAIT_NODES, "Nodes that will not be waited for during start", (gptr*) &_nowait_nodes, (gptr*) &_nowait_nodes, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - { "initial-start", NO_ARG, + { "initial-start", OPT_INITIAL_START, "Perform initial start", (gptr*) &_initialstart, (gptr*) &_initialstart, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp index 08232471474..b3d2d403dcc 100644 --- a/storage/ndb/src/mgmapi/mgmapi.cpp +++ b/storage/ndb/src/mgmapi/mgmapi.cpp @@ -701,10 +701,12 @@ ndb_mgm_get_status(NdbMgmHandle handle) Vector<BaseString> split; tmp.split(split, ":"); if(split.size() != 2){ + SET_ERROR(handle, NDB_MGM_ILLEGAL_NODE_STATUS, buf); return NULL; } if(!(split[0].trim() == "nodes")){ + SET_ERROR(handle, NDB_MGM_ILLEGAL_NODE_STATUS, buf); return NULL; } @@ -752,6 +754,7 @@ ndb_mgm_get_status(NdbMgmHandle handle) if(i+1 != noOfNodes){ free(state); + SET_ERROR(handle, NDB_MGM_ILLEGAL_NODE_STATUS, "Node count mismatch"); return NULL; } diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp index aee6d4deeb5..1e655c29517 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2514,6 +2514,7 @@ int MgmtSrvr::abortBackup(Uint32 backupId) { SignalSender ss(theFacade); + ss.lock(); // lock will be released on exit bool next; NodeId nodeId = 0; diff --git a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp index be15484688b..d7f58d124aa 100644 --- a/storage/ndb/src/mgmsrv/Services.cpp +++ b/storage/ndb/src/mgmsrv/Services.cpp @@ -502,6 +502,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &, ps.tick= tick; m_mgmsrv.get_socket_server()-> foreachSession(stop_session_if_timed_out,&ps); + m_mgmsrv.get_socket_server()->checkSessions(); error_string = ""; continue; } @@ -1559,6 +1560,7 @@ MgmApiSession::purge_stale_sessions(Parser_t::Context &ctx, ps.free_nodes.bitXORC(NodeBitmask()); // invert connected_nodes to get free nodes m_mgmsrv.get_socket_server()->foreachSession(stop_session_if_not_connected,&ps); + m_mgmsrv.get_socket_server()->checkSessions(); m_output->println("purge stale sessions reply"); if (str.length() > 0) diff --git a/storage/ndb/src/ndbapi/ClusterMgr.cpp b/storage/ndb/src/ndbapi/ClusterMgr.cpp index 2ff403d53b3..b108ed3fd41 100644 --- a/storage/ndb/src/ndbapi/ClusterMgr.cpp +++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp @@ -70,6 +70,8 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade): noOfAliveNodes= 0; noOfConnectedNodes= 0; theClusterMgrThread= 0; + m_connect_count = 0; + m_cluster_state = CS_waiting_for_clean_cache; DBUG_VOID_RETURN; } @@ -174,6 +176,16 @@ ClusterMgr::threadMain( ){ int send_heartbeat_now= global_flag_send_heartbeat_now; global_flag_send_heartbeat_now= 0; + if (m_cluster_state == CS_waiting_for_clean_cache) + { + theFacade.m_globalDictCache.lock(); + unsigned sz= theFacade.m_globalDictCache.get_size(); + theFacade.m_globalDictCache.unlock(); + if (sz) + goto next; + m_cluster_state = CS_waiting_for_first_connect; + } + theFacade.lock_mutex(); for (int i = 1; i < MAX_NODES; i++){ /** @@ -222,6 +234,7 @@ ClusterMgr::threadMain( ){ */ theFacade.unlock_mutex(); +next: // Sleep for 100 ms between each Registration Heartbeat Uint64 before = now; NdbSleep_MilliSleep(100); @@ -445,6 +458,11 @@ ClusterMgr::reportNodeFailed(NodeId nodeId){ theNode.nfCompleteRep = false; if(noOfAliveNodes == 0) { + theFacade.m_globalDictCache.lock(); + theFacade.m_globalDictCache.invalidate_all(); + theFacade.m_globalDictCache.unlock(); + m_connect_count ++; + m_cluster_state = CS_waiting_for_clean_cache; NFCompleteRep rep; for(Uint32 i = 1; i<MAX_NODES; i++){ if(theNodes[i].defined && theNodes[i].nfCompleteRep == false){ diff --git a/storage/ndb/src/ndbapi/ClusterMgr.hpp b/storage/ndb/src/ndbapi/ClusterMgr.hpp index 31682885f90..ca879e7948e 100644 --- a/storage/ndb/src/ndbapi/ClusterMgr.hpp +++ b/storage/ndb/src/ndbapi/ClusterMgr.hpp @@ -57,6 +57,11 @@ private: class TransporterFacade & theFacade; public: + enum Cluster_state { + CS_waiting_for_clean_cache = 0, + CS_waiting_for_first_connect, + CS_connected + }; struct Node { Node(); bool defined; @@ -80,12 +85,13 @@ public: bool isClusterAlive() const; void hb_received(NodeId); + Uint32 m_connect_count; private: Uint32 noOfAliveNodes; Uint32 noOfConnectedNodes; Node theNodes[MAX_NODES]; NdbThread* theClusterMgrThread; - + enum Cluster_state m_cluster_state; /** * Used for controlling start/stop of the thread */ diff --git a/storage/ndb/src/ndbapi/DictCache.cpp b/storage/ndb/src/ndbapi/DictCache.cpp index 47e48974449..ea8a08c4065 100644 --- a/storage/ndb/src/ndbapi/DictCache.cpp +++ b/storage/ndb/src/ndbapi/DictCache.cpp @@ -178,6 +178,11 @@ GlobalDictCache::get(const char * name) { ver->m_status = DROPPED; retreive = true; // Break loop + if (ver->m_refCount == 0) + { + delete ver->m_impl; + versions->erase(versions->size() - 1); + } break; } ver->m_refCount++; @@ -280,6 +285,45 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) DBUG_RETURN(tab); } +unsigned +GlobalDictCache::get_size() +{ + NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0); + int sz = 0; + while(curr != 0){ + sz += curr->theData->size(); + curr = m_tableHash.getNext(curr); + } + if (sz) + { + printCache(); + } + return sz; +} + +void +GlobalDictCache::invalidate_all() +{ + DBUG_ENTER("GlobalDictCache::invalidate_all"); + NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0); + while(curr != 0){ + Vector<TableVersion> * vers = curr->theData; + if (vers->size()) + { + TableVersion * ver = & vers->back(); + ver->m_impl->m_status = NdbDictionary::Object::Invalid; + ver->m_status = DROPPED; + if (ver->m_refCount == 0) + { + delete ver->m_impl; + vers->erase(vers->size() - 1); + } + } + curr = m_tableHash.getNext(curr); + } + DBUG_VOID_RETURN; +} + void GlobalDictCache::release(NdbTableImpl * tab, int invalidate) { @@ -373,6 +417,11 @@ GlobalDictCache::alter_table_rep(const char * name, ver.m_status = DROPPED; ver.m_impl->m_status = altered ? NdbDictionary::Object::Altered : NdbDictionary::Object::Invalid; + if (ver.m_refCount == 0) + { + delete ver.m_impl; + vers->erase(i); + } DBUG_VOID_RETURN; } diff --git a/storage/ndb/src/ndbapi/DictCache.hpp b/storage/ndb/src/ndbapi/DictCache.hpp index f134e6b348e..77344586669 100644 --- a/storage/ndb/src/ndbapi/DictCache.hpp +++ b/storage/ndb/src/ndbapi/DictCache.hpp @@ -71,6 +71,9 @@ public: void alter_table_rep(const char * name, Uint32 tableId, Uint32 tableVersion, bool altered); + + unsigned get_size(); + void invalidate_all(); public: enum Status { OK = 0, diff --git a/storage/ndb/src/ndbapi/Ndb.cpp b/storage/ndb/src/ndbapi/Ndb.cpp index b963aeeff84..0b0749c835e 100644 --- a/storage/ndb/src/ndbapi/Ndb.cpp +++ b/storage/ndb/src/ndbapi/Ndb.cpp @@ -1287,6 +1287,7 @@ NdbEventOperation* Ndb::createEventOperation(const char* eventName) int Ndb::dropEventOperation(NdbEventOperation* tOp) { DBUG_ENTER("Ndb::dropEventOperation"); + DBUG_PRINT("info", ("name: %s", tOp->getEvent()->getTable()->getName())); // remove it from list NdbEventOperationImpl *op= NdbEventBuffer::getEventOperationImpl(tOp); @@ -1297,6 +1298,8 @@ int Ndb::dropEventOperation(NdbEventOperation* tOp) else theImpl->m_ev_op= op->m_next; + DBUG_PRINT("info", ("first: %s", + theImpl->m_ev_op ? theImpl->m_ev_op->getEvent()->getTable()->getName() : "<empty>")); assert(theImpl->m_ev_op == 0 || theImpl->m_ev_op->m_prev == 0); theEventBuffer->dropEventOperation(tOp); @@ -1321,6 +1324,12 @@ Ndb::pollEvents(int aMillisecondNumber, Uint64 *latestGCI) return theEventBuffer->pollEvents(aMillisecondNumber, latestGCI); } +int +Ndb::flushIncompleteEvents(Uint64 gci) +{ + return theEventBuffer->flushIncompleteEvents(gci); +} + NdbEventOperation *Ndb::nextEvent() { return theEventBuffer->nextEvent(); diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 5a842d1ecc5..d2d8c43a064 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -3002,63 +3002,6 @@ NdbDictionaryImpl::removeCachedObject(NdbTableImpl & impl) DBUG_RETURN(0); } -/***************************************************************** - * Get index info - */ -NdbIndexImpl* -NdbDictionaryImpl::getIndexImpl(const char * externalName, - const BaseString& internalName) -{ - ASSERT_NOT_MYSQLD; - Ndb_local_table_info * info = get_local_table_info(internalName); - if(info == 0){ - m_error.code = 4243; - return 0; - } - NdbTableImpl * tab = info->m_table_impl; - - if(tab->m_indexType == NdbDictionary::Object::TypeUndefined) - { - // Not an index - m_error.code = 4243; - return 0; - } - - NdbTableImpl* prim = getTable(tab->m_primaryTable.c_str()); - if(prim == 0){ - m_error.code = 4243; - return 0; - } - - return getIndexImpl(externalName, internalName, *tab, *prim); -} - -NdbIndexImpl* -NdbDictionaryImpl::getIndexImpl(const char * externalName, - const BaseString& internalName, - NdbTableImpl &tab, - NdbTableImpl &prim) -{ - DBUG_ENTER("NdbDictionaryImpl::getIndexImpl"); - DBUG_ASSERT(tab.m_indexType != NdbDictionary::Object::TypeUndefined); - /** - * Create index impl - */ - NdbIndexImpl* idx; - if(NdbDictInterface::create_index_obj_from_table(&idx, &tab, &prim) == 0){ - idx->m_table = &tab; - idx->m_externalName.assign(externalName); - idx->m_internalName.assign(internalName); - idx->m_table_id = prim.getObjectId(); - idx->m_table_version = prim.getObjectVersion(); - // TODO Assign idx to tab->m_index - // Don't do it right now since assign can't asign a table with index - // tab->m_index = idx; - DBUG_RETURN(idx); - } - DBUG_RETURN(0); -} - int NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst, NdbTableImpl* tab, @@ -3116,6 +3059,9 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst, tab->m_columns[i]->m_distributionKey = 0; } + idx->m_table_id = prim->getObjectId(); + idx->m_table_version = prim->getObjectVersion(); + * dst = idx; DBUG_PRINT("exit", ("m_id: %d m_version: %d", idx->m_id, idx->m_version)); DBUG_RETURN(0); diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 5a7a1ebb0ab..cf30abc6c3f 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -617,6 +617,7 @@ public: get_local_table_info(const BaseString& internalTableName); NdbIndexImpl * getIndex(const char * indexName, const char * tableName); + NdbIndexImpl * getIndex(const char * indexName, const NdbTableImpl& prim); NdbEventImpl * getEvent(const char * eventName, NdbTableImpl* = NULL); NdbEventImpl * getBlobEvent(const NdbEventImpl& ev, uint col_no); NdbEventImpl * getEventImpl(const char * internalName); @@ -958,51 +959,36 @@ NdbDictionaryImpl::get_local_table_info(const BaseString& internalTableName) DBUG_RETURN(info); // autoincrement already initialized } -class InitIndexGlobal : public GlobalCacheInitObject +class InitIndex : public GlobalCacheInitObject { public: const char *m_index_name; - NdbTableImpl &m_prim; + const NdbTableImpl &m_prim; - InitIndexGlobal(NdbDictionaryImpl *dict, - const BaseString &internal_indexname, - const char *index_name, - NdbTableImpl &prim) : - GlobalCacheInitObject(dict, internal_indexname), + InitIndex(const BaseString &internal_indexname, + const char *index_name, + const NdbTableImpl &prim) : + GlobalCacheInitObject(0, internal_indexname), m_index_name(index_name), m_prim(prim) - {} - int init(NdbTableImpl &tab) const - { - tab.m_index= m_dict->getIndexImpl(m_index_name, m_name, tab, m_prim); - if (tab.m_index == 0) - return 1; - tab.m_index->m_table= &tab; - return 0; - } -}; - -class InitIndex : public GlobalCacheInitObject -{ -public: - const char *m_index_name; - - InitIndex(NdbDictionaryImpl *dict, - const BaseString &internal_indexname, - const char *index_name) : - GlobalCacheInitObject(dict, internal_indexname), - m_index_name(index_name) - {} - int init(NdbTableImpl &tab) const - { - DBUG_ASSERT(tab.m_index == 0); - tab.m_index= m_dict->getIndexImpl(m_index_name, m_name); - if (tab.m_index) + {} + + int init(NdbTableImpl &tab) const { + DBUG_ENTER("InitIndex::init"); + DBUG_ASSERT(tab.m_indexType != NdbDictionary::Object::TypeUndefined); + /** + * Create index impl + */ + NdbIndexImpl* idx; + if(NdbDictInterface::create_index_obj_from_table(&idx, &tab, &m_prim) == 0) { - tab.m_index->m_table= &tab; - return 0; + idx->m_table = &tab; + idx->m_externalName.assign(m_index_name); + idx->m_internalName.assign(m_name); + tab.m_index = idx; + DBUG_RETURN(0); } - return 1; + DBUG_RETURN(1); } }; @@ -1019,14 +1005,14 @@ NdbDictionaryImpl::getIndexGlobal(const char * index_name, while (retry) { NdbTableImpl *tab= - fetchGlobalTableImplRef(InitIndexGlobal(this, internal_indexname, - index_name, ndbtab)); + fetchGlobalTableImplRef(InitIndex(internal_indexname, + index_name, ndbtab)); if (tab) { // tab->m_index sould be set. otherwise tab == 0 NdbIndexImpl *idx= tab->m_index; - if (idx->m_table_id != ndbtab.getObjectId() || - idx->m_table_version != ndbtab.getObjectVersion()) + if (idx->m_table_id != (unsigned)ndbtab.getObjectId() || + idx->m_table_version != (unsigned)ndbtab.getObjectVersion()) { releaseIndexGlobal(*idx, 1); retry--; @@ -1067,41 +1053,54 @@ NdbIndexImpl * NdbDictionaryImpl::getIndex(const char * index_name, const char * table_name) { - while (table_name || m_ndb.usingFullyQualifiedNames()) + if (table_name == 0) { - const BaseString internal_indexname( - (table_name) - ? - m_ndb.internalize_index_name(getTable(table_name), index_name) - : - m_ndb.internalize_table_name(index_name)); // Index is also a table - - if (internal_indexname.length()) - { - Ndb_local_table_info *info= m_localHash.get(internal_indexname.c_str()); - NdbTableImpl *tab; - if (info == 0) - { - tab= fetchGlobalTableImplRef(InitIndex(this, internal_indexname, - index_name)); - if (tab) - { - info= Ndb_local_table_info::create(tab, 0); - if (info) - m_localHash.put(internal_indexname.c_str(), info); - else - break; - } - else - break; - } - else - tab= info->m_table_impl; - return tab->m_index; - } - break; + assert(0); + m_error.code= 4243; + return 0; + } + + + NdbTableImpl* prim = getTable(table_name); + if (prim == 0) + { + m_error.code= 4243; + return 0; } + return getIndex(index_name, *prim); +} + +inline +NdbIndexImpl * +NdbDictionaryImpl::getIndex(const char* index_name, + const NdbTableImpl& prim) +{ + + const BaseString + internal_indexname(m_ndb.internalize_index_name(&prim, index_name)); + + Ndb_local_table_info *info= m_localHash.get(internal_indexname.c_str()); + NdbTableImpl *tab; + if (info == 0) + { + tab= fetchGlobalTableImplRef(InitIndex(internal_indexname, + index_name, + prim)); + if (!tab) + goto err; + + info= Ndb_local_table_info::create(tab, 0); + if (!info) + goto err; + m_localHash.put(internal_indexname.c_str(), info); + } + else + tab= info->m_table_impl; + + return tab->m_index; + +err: m_error.code= 4243; return 0; } diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp index 628ad5d925f..a5fbd84e5b0 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp @@ -153,11 +153,14 @@ NdbEventOperationImpl::init(NdbEventImpl& evnt) m_state= EO_CREATED; + m_node_bit_mask.clear(); #ifdef ndb_event_stores_merge_events_flag m_mergeEvents = m_eventImpl->m_mergeEvents; #else - m_mergeEvents = false; + m_mergeEvents = false; #endif + m_ref_count = 0; + DBUG_PRINT("info", ("m_ref_count = 0 for op: %p", this)); m_has_error= 0; @@ -530,7 +533,11 @@ NdbEventOperationImpl::execute_nolock() } } if (r == 0) + { + m_ref_count++; + DBUG_PRINT("info", ("m_ref_count: %u for op: %p", m_ref_count, this)); DBUG_RETURN(0); + } } //Error m_state= EO_ERROR; @@ -657,80 +664,79 @@ NdbEventOperationImpl::execSUB_TABLE_DATA(NdbApiSignal * signal, int NdbEventOperationImpl::receive_event() { - DBUG_ENTER_EVENT("NdbEventOperationImpl::receive_event"); - Uint32 operation= (Uint32)m_data_item->sdata->operation; - DBUG_PRINT_EVENT("info",("sdata->operation %u",operation)); - - if (operation == NdbDictionary::Event::_TE_ALTER) - { - // Parse the new table definition and - // create a table object - NdbDictionary::Dictionary *myDict = m_ndb->getDictionary(); - NdbDictionaryImpl *dict = & NdbDictionaryImpl::getImpl(*myDict); - NdbError error; - NdbDictInterface dif(error); - NdbTableImpl *at; - m_change_mask = m_data_item->sdata->changeMask; - error.code = dif.parseTableInfo(&at, - (Uint32*)m_buffer.get_data(), - m_buffer.length() / 4, - true); - m_buffer.clear(); - if (at) - at->buildColumnHash(); - else - { - DBUG_PRINT_EVENT("info", ("Failed to parse DictTabInfo error %u", - error.code)); - DBUG_RETURN_EVENT(1); - } - - NdbTableImpl *tmp_table_impl= m_eventImpl->m_tableImpl; - m_eventImpl->m_tableImpl = at; - - DBUG_PRINT("info", ("switching table impl 0x%x -> 0x%x", - tmp_table_impl, at)); - - // change the rec attrs to refer to the new table object - int i; - for (i = 0; i < 2; i++) + if (unlikely(operation >= NdbDictionary::Event::_TE_FIRST_NON_DATA_EVENT)) + { + DBUG_ENTER("NdbEventOperationImpl::receive_event"); + DBUG_PRINT("info",("sdata->operation %u this: %p", operation, this)); + if (operation == NdbDictionary::Event::_TE_ALTER) { - NdbRecAttr *p = theFirstPkAttrs[i]; - while (p) + // Parse the new table definition and + // create a table object + NdbDictionary::Dictionary *myDict = m_ndb->getDictionary(); + NdbDictionaryImpl *dict = & NdbDictionaryImpl::getImpl(*myDict); + NdbError error; + NdbDictInterface dif(error); + NdbTableImpl *at; + m_change_mask = m_data_item->sdata->changeMask; + error.code = dif.parseTableInfo(&at, + (Uint32*)m_buffer.get_data(), + m_buffer.length() / 4, + true); + m_buffer.clear(); + if (unlikely(!at)) { - int no = p->getColumn()->getColumnNo(); - NdbColumnImpl *tAttrInfo = at->getColumn(no); - DBUG_PRINT("info", ("rec_attr: 0x%x " - "switching column impl 0x%x -> 0x%x", - p, p->m_column, tAttrInfo)); - p->m_column = tAttrInfo; - p = p->next(); + DBUG_PRINT("info", ("Failed to parse DictTabInfo error %u", + error.code)); + ndbout_c("Failed to parse DictTabInfo error %u", error.code); + DBUG_RETURN(1); } - } - for (i = 0; i < 2; i++) - { - NdbRecAttr *p = theFirstDataAttrs[i]; - while (p) + at->buildColumnHash(); + + NdbTableImpl *tmp_table_impl= m_eventImpl->m_tableImpl; + m_eventImpl->m_tableImpl = at; + + DBUG_PRINT("info", ("switching table impl 0x%x -> 0x%x", + tmp_table_impl, at)); + + // change the rec attrs to refer to the new table object + int i; + for (i = 0; i < 2; i++) + { + NdbRecAttr *p = theFirstPkAttrs[i]; + while (p) + { + int no = p->getColumn()->getColumnNo(); + NdbColumnImpl *tAttrInfo = at->getColumn(no); + DBUG_PRINT("info", ("rec_attr: 0x%x " + "switching column impl 0x%x -> 0x%x", + p, p->m_column, tAttrInfo)); + p->m_column = tAttrInfo; + p = p->next(); + } + } + for (i = 0; i < 2; i++) { - int no = p->getColumn()->getColumnNo(); - NdbColumnImpl *tAttrInfo = at->getColumn(no); - DBUG_PRINT("info", ("rec_attr: 0x%x " - "switching column impl 0x%x -> 0x%x", - p, p->m_column, tAttrInfo)); - p->m_column = tAttrInfo; - p = p->next(); + NdbRecAttr *p = theFirstDataAttrs[i]; + while (p) + { + int no = p->getColumn()->getColumnNo(); + NdbColumnImpl *tAttrInfo = at->getColumn(no); + DBUG_PRINT("info", ("rec_attr: 0x%x " + "switching column impl 0x%x -> 0x%x", + p, p->m_column, tAttrInfo)); + p->m_column = tAttrInfo; + p = p->next(); + } } + if (tmp_table_impl) + delete tmp_table_impl; } - if (tmp_table_impl) - delete tmp_table_impl; - } - - if (unlikely(operation >= NdbDictionary::Event::_TE_FIRST_NON_DATA_EVENT)) - { - DBUG_RETURN_EVENT(1); + DBUG_RETURN(1); } + DBUG_ENTER_EVENT("NdbEventOperationImpl::receive_event"); + DBUG_PRINT_EVENT("info",("sdata->operation %u this: %p", operation, this)); // now move the data into the RecAttrs int is_update= operation == NdbDictionary::Event::_TE_UPDATE; @@ -1089,6 +1095,33 @@ NdbEventBuffer::pollEvents(int aMillisecondNumber, Uint64 *latestGCI) return ret; } +int +NdbEventBuffer::flushIncompleteEvents(Uint64 gci) +{ + /** + * Find min complete gci + */ + Uint32 i; + Uint32 sz= m_active_gci.size(); + Gci_container* array = (Gci_container*)m_active_gci.getBase(); + for(i = 0; i < sz; i++) + { + Gci_container* tmp = array + i; + if (tmp->m_gci && tmp->m_gci < gci) + { + // we have found an old not-completed gci, remove it + ndbout_c("ndb: flushing incomplete epoch %lld (<%lld)", tmp->m_gci, gci); + if(!tmp->m_data.is_empty()) + { + free_list(tmp->m_data); + } + tmp->~Gci_container(); + bzero(tmp, sizeof(Gci_container)); + } + } + return 0; +} + NdbEventOperation * NdbEventBuffer::nextEvent() { @@ -1157,7 +1190,10 @@ NdbEventBuffer::nextEvent() } EventBufData_list::Gci_ops *gci_ops = m_available_data.first_gci_ops(); while (gci_ops && op->getGCI() > gci_ops->m_gci) + { + deleteUsedEventOperations(); gci_ops = m_available_data.next_gci_ops(); + } assert(gci_ops && (op->getGCI() == gci_ops->m_gci)); DBUG_RETURN_EVENT(op->m_facade); } @@ -1177,7 +1213,10 @@ NdbEventBuffer::nextEvent() // free all "per gci unique" collected operations EventBufData_list::Gci_ops *gci_ops = m_available_data.first_gci_ops(); while (gci_ops) + { + deleteUsedEventOperations(); gci_ops = m_available_data.next_gci_ops(); + } DBUG_RETURN_EVENT(0); } @@ -1191,31 +1230,37 @@ NdbEventBuffer::getGCIEventOperations(Uint32* iter, Uint32* event_types) EventBufData_list::Gci_op g = gci_ops->m_gci_op_list[(*iter)++]; if (event_types != NULL) *event_types = g.event_types; - DBUG_PRINT("info", ("gci: %d", (unsigned)gci_ops->m_gci)); + DBUG_PRINT("info", ("gci: %d g.op: %x g.event_types: %x", + (unsigned)gci_ops->m_gci, g.op, g.event_types)); DBUG_RETURN(g.op); } DBUG_RETURN(NULL); } void -NdbEventBuffer::lock() -{ - NdbMutex_Lock(m_mutex); -} -void -NdbEventBuffer::unlock() -{ - NdbMutex_Unlock(m_mutex); -} -void -NdbEventBuffer::add_drop_lock() +NdbEventBuffer::deleteUsedEventOperations() { - NdbMutex_Lock(p_add_drop_mutex); -} -void -NdbEventBuffer::add_drop_unlock() -{ - NdbMutex_Unlock(p_add_drop_mutex); + Uint32 iter= 0; + const NdbEventOperation *op_f; + while ((op_f= getGCIEventOperations(&iter, NULL)) != NULL) + { + NdbEventOperationImpl *op = &op_f->m_impl; + DBUG_ASSERT(op->m_ref_count > 0); + op->m_ref_count--; + DBUG_PRINT("info", ("m_ref_count: %u for op: %p", op->m_ref_count, op)); + if (op->m_ref_count == 0) + { + DBUG_PRINT("info", ("deleting op: %p", op)); + DBUG_ASSERT(op->m_node_bit_mask.isclear()); + if (op->m_next) + op->m_next->m_prev = op->m_prev; + if (op->m_prev) + op->m_prev->m_next = op->m_next; + else + m_dropped_ev_op = op->m_next; + delete op->m_facade; + } + } } static @@ -1469,6 +1514,10 @@ NdbEventBuffer::complete_outof_order_gcis() void NdbEventBuffer::report_node_failure(Uint32 node_id) { + NdbEventOperation* op= m_ndb->getEventOperation(0); + if (op == 0) + return; + DBUG_ENTER("NdbEventBuffer::report_node_failure"); SubTableData data; LinearSectionPtr ptr[3]; @@ -1484,12 +1533,20 @@ NdbEventBuffer::report_node_failure(Uint32 node_id) /** * Insert this event for each operation */ - NdbEventOperation* op= 0; - while((op = m_ndb->getEventOperation(op))) { - NdbEventOperationImpl* impl= &op->m_impl; - data.senderData = impl->m_oid; - insertDataL(impl, &data, ptr); + // no need to lock()/unlock(), receive thread calls this + NdbEventOperationImpl* impl = &op->m_impl; + do if (!impl->m_node_bit_mask.isclear()) + { + data.senderData = impl->m_oid; + insertDataL(impl, &data, ptr); + } while((impl = impl->m_next)); + for (impl = m_dropped_ev_op; impl; impl = impl->m_next) + if (!impl->m_node_bit_mask.isclear()) + { + data.senderData = impl->m_oid; + insertDataL(impl, &data, ptr); + } } DBUG_VOID_RETURN; } @@ -1515,12 +1572,21 @@ NdbEventBuffer::completeClusterFailed() /** * Insert this event for each operation */ - do { - NdbEventOperationImpl* impl= &op->m_impl; - data.senderData = impl->m_oid; - insertDataL(impl, &data, ptr); - } while((op = m_ndb->getEventOperation(op))); + // no need to lock()/unlock(), receive thread calls this + NdbEventOperationImpl* impl = &op->m_impl; + do if (!impl->m_node_bit_mask.isclear()) + { + data.senderData = impl->m_oid; + insertDataL(impl, &data, ptr); + } while((impl = impl->m_next)); + for (impl = m_dropped_ev_op; impl; impl = impl->m_next) + if (!impl->m_node_bit_mask.isclear()) + { + data.senderData = impl->m_oid; + insertDataL(impl, &data, ptr); + } + } /** * Release all GCI's with m_gci > gci @@ -1565,7 +1631,11 @@ NdbEventBuffer::completeClusterFailed() } } - assert(bucket != 0); + if (bucket == 0) + { + // no bucket to complete + DBUG_VOID_RETURN; + } const Uint32 cnt= bucket->m_gcp_complete_rep_count = 1; bucket->m_gci = gci; @@ -1595,6 +1665,40 @@ NdbEventBuffer::insertDataL(NdbEventOperationImpl *op, { DBUG_ENTER_EVENT("NdbEventBuffer::insertDataL"); Uint64 gci= sdata->gci; + const bool is_data_event = + sdata->operation < NdbDictionary::Event::_TE_FIRST_NON_DATA_EVENT; + + if (!is_data_event) + { + switch (sdata->operation) + { + case NdbDictionary::Event::_TE_NODE_FAILURE: + op->m_node_bit_mask.clear(sdata->ndbd_nodeid); + break; + case NdbDictionary::Event::_TE_ACTIVE: + op->m_node_bit_mask.set(sdata->ndbd_nodeid); + // internal event, do not relay to user + DBUG_RETURN_EVENT(0); + break; + case NdbDictionary::Event::_TE_CLUSTER_FAILURE: + op->m_node_bit_mask.clear(); + DBUG_ASSERT(op->m_ref_count > 0); + op->m_ref_count--; + DBUG_PRINT("info", ("m_ref_count: %u for op: %p", op->m_ref_count, op)); + break; + case NdbDictionary::Event::_TE_STOP: + op->m_node_bit_mask.clear(sdata->ndbd_nodeid); + if (op->m_node_bit_mask.isclear()) + { + DBUG_ASSERT(op->m_ref_count > 0); + op->m_ref_count--; + DBUG_PRINT("info", ("m_ref_count: %u for op: %p", op->m_ref_count, op)); + } + break; + default: + break; + } + } if ( likely((Uint32)op->mi_type & (1 << (Uint32)sdata->operation)) ) { @@ -1615,8 +1719,6 @@ NdbEventBuffer::insertDataL(NdbEventOperationImpl *op, } const bool is_blob_event = (op->theMainOp != NULL); - const bool is_data_event = - sdata->operation < NdbDictionary::Event::_TE_FIRST_NON_DATA_EVENT; const bool use_hash = op->m_mergeEvents && is_data_event; if (! is_data_event && is_blob_event) @@ -2244,6 +2346,8 @@ void EventBufData_list::append_list(EventBufData_list *list, Uint64 gci) void EventBufData_list::add_gci_op(Gci_op g, bool del) { + DBUG_ENTER_EVENT("EventBufData_list::add_gci_op"); + DBUG_PRINT_EVENT("info", ("p.op: %p g.event_types: %x", g.op, g.event_types)); assert(g.op != NULL); Uint32 i; for (i = 0; i < m_gci_op_count; i++) { @@ -2273,8 +2377,15 @@ EventBufData_list::add_gci_op(Gci_op g, bool del) } assert(m_gci_op_count < m_gci_op_alloc); assert(! del); +#ifndef DBUG_OFF + i = m_gci_op_count; +#endif + g.op->m_ref_count++; + DBUG_PRINT("info", ("m_ref_count: %u for op: %p", g.op->m_ref_count, g.op)); m_gci_op_list[m_gci_op_count++] = g; } + DBUG_PRINT_EVENT("exit", ("m_gci_op_list[%u].event_types: %x", i, m_gci_op_list[i].event_types)); + DBUG_VOID_RETURN_EVENT; } void @@ -2337,6 +2448,9 @@ NdbEventBuffer::createEventOperation(const char* eventName, delete tOp; DBUG_RETURN(NULL); } + getEventOperationImpl(tOp)->m_ref_count = 1; + DBUG_PRINT("info", ("m_ref_count: %u for op: %p", + getEventOperationImpl(tOp)->m_ref_count, getEventOperationImpl(tOp))); DBUG_RETURN(tOp); } @@ -2362,16 +2476,10 @@ NdbEventBuffer::createEventOperation(NdbEventImpl& evnt, void NdbEventBuffer::dropEventOperation(NdbEventOperation* tOp) { + DBUG_ENTER("NdbEventBuffer::dropEventOperation"); NdbEventOperationImpl* op= getEventOperationImpl(tOp); op->stop(); - - op->m_next= m_dropped_ev_op; - op->m_prev= 0; - if (m_dropped_ev_op) - m_dropped_ev_op->m_prev= op; - m_dropped_ev_op= op; - // stop blob event ops if (op->theMainOp == NULL) { @@ -2391,11 +2499,24 @@ NdbEventBuffer::dropEventOperation(NdbEventOperation* tOp) } } - // ToDo, take care of these to be deleted at the - // appropriate time, after we are sure that there - // are _no_ more events coming - - // delete tOp; + DBUG_ASSERT(op->m_ref_count > 0); + op->m_ref_count--; + DBUG_PRINT("info", ("m_ref_count: %u for op: %p", op->m_ref_count, op)); + if (op->m_ref_count == 0) + { + DBUG_PRINT("info", ("deleting op: %p", op)); + DBUG_ASSERT(op->m_node_bit_mask.isclear()); + delete op->m_facade; + } + else + { + op->m_next= m_dropped_ev_op; + op->m_prev= 0; + if (m_dropped_ev_op) + m_dropped_ev_op->m_prev= op; + m_dropped_ev_op= op; + } + DBUG_VOID_RETURN; } void diff --git a/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp b/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp index 70b3ce6b8de..bcae650bf44 100644 --- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp @@ -367,6 +367,8 @@ public: Uint32 m_eventId; Uint32 m_oid; + Bitmask<(unsigned int)_NDB_NODE_BITMASK_SIZE> m_node_bit_mask; + int m_ref_count; bool m_mergeEvents; EventBufData *m_data_item; @@ -406,10 +408,10 @@ public: void dropEventOperation(NdbEventOperation *); static NdbEventOperationImpl* getEventOperationImpl(NdbEventOperation* tOp); - void add_drop_lock(); - void add_drop_unlock(); - void lock(); - void unlock(); + void add_drop_lock() { NdbMutex_Lock(p_add_drop_mutex); } + void add_drop_unlock() { NdbMutex_Unlock(p_add_drop_mutex); } + void lock() { NdbMutex_Lock(m_mutex); } + void unlock() { NdbMutex_Unlock(m_mutex); } void add_op(); void remove_op(); @@ -430,9 +432,11 @@ public: Uint32 getEventId(int bufferId); int pollEvents(int aMillisecondNumber, Uint64 *latestGCI= 0); + int flushIncompleteEvents(Uint64 gci); NdbEventOperation *nextEvent(); NdbEventOperationImpl* getGCIEventOperations(Uint32* iter, Uint32* event_types); + void deleteUsedEventOperations(); NdbEventOperationImpl *move_data(); diff --git a/storage/ndb/src/ndbapi/SignalSender.cpp b/storage/ndb/src/ndbapi/SignalSender.cpp index a29fe68937b..0ecc98f5f29 100644 --- a/storage/ndb/src/ndbapi/SignalSender.cpp +++ b/storage/ndb/src/ndbapi/SignalSender.cpp @@ -75,7 +75,9 @@ SignalSender::SignalSender(TransporterFacade *facade) { m_cond = NdbCondition_Create(); theFacade = facade; + lock(); m_blockNo = theFacade->open(this, execSignal, execNodeStatus); + unlock(); assert(m_blockNo > 0); } diff --git a/storage/ndb/src/ndbapi/TransporterFacade.hpp b/storage/ndb/src/ndbapi/TransporterFacade.hpp index eb2f162da88..2d47a2febf8 100644 --- a/storage/ndb/src/ndbapi/TransporterFacade.hpp +++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp @@ -319,6 +319,12 @@ TransporterFacade::unlock_mutex() #include "ClusterMgr.hpp" inline +unsigned Ndb_cluster_connection_impl::get_connect_count() const +{ + return m_transporter_facade->theClusterMgr->m_connect_count; +} + +inline bool TransporterFacade::check_send_size(Uint32 node_id, Uint32 send_size) { diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp index 544f7424a82..a7e645f5100 100644 --- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -253,6 +253,12 @@ Ndb_cluster_connection::wait_until_ready(int timeout, } while (1); } +unsigned Ndb_cluster_connection::get_connect_count() const +{ + return m_impl.get_connect_count(); +} + + /* diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp index db6e1f9e6ed..6f0df0403d9 100644 --- a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp @@ -40,6 +40,7 @@ class Ndb_cluster_connection_impl : public Ndb_cluster_connection void init_get_next_node(Ndb_cluster_connection_node_iter &iter); Uint32 get_next_node(Ndb_cluster_connection_node_iter &iter); + inline unsigned get_connect_count() const; private: friend class Ndb; friend class NdbImpl; diff --git a/storage/ndb/test/ndbapi/Makefile.am b/storage/ndb/test/ndbapi/Makefile.am index 9a1e1c5e9ea..b55acd2420d 100644 --- a/storage/ndb/test/ndbapi/Makefile.am +++ b/storage/ndb/test/ndbapi/Makefile.am @@ -24,6 +24,7 @@ testOIBasic \ testOperations \ testRestartGci \ testScan \ +testInterpreter \ testScanInterpreter \ testScanPerf \ testSystemRestart \ @@ -64,6 +65,7 @@ testOIBasic_SOURCES = testOIBasic.cpp testOperations_SOURCES = testOperations.cpp testRestartGci_SOURCES = testRestartGci.cpp testScan_SOURCES = testScan.cpp ScanFunctions.hpp +testInterpreter_SOURCES = testInterpreter.cpp testScanInterpreter_SOURCES = testScanInterpreter.cpp ScanFilter.hpp ScanInterpretTest.hpp testScanPerf_SOURCES = testScanPerf.cpp testSystemRestart_SOURCES = testSystemRestart.cpp diff --git a/storage/ndb/test/ndbapi/testInterpreter.cpp b/storage/ndb/test/ndbapi/testInterpreter.cpp index 0baba33d2b2..5d930d3d555 100644 --- a/storage/ndb/test/ndbapi/testInterpreter.cpp +++ b/storage/ndb/test/ndbapi/testInterpreter.cpp @@ -79,46 +79,46 @@ int runTestIncValue32(NDBT_Context* ctx, NDBT_Step* step){ Ndb* pNdb = GETNDB(step); - NdbConnection* pTrans = pNdb->startTransaction(); - if (pTrans == NULL){ - ERR(pNdb->getNdbError()); - return NDBT_FAILED; - } - - NdbOperation* pOp = pTrans->getNdbOperation(pTab->getName()); - if (pOp == NULL) { - ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); - return NDBT_FAILED; - } - - int check = pOp->interpretedUpdateTuple(); - if( check == -1 ) { - ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); - return NDBT_FAILED; - } - - - // Primary keys - Uint32 pkVal = 1; - check = pOp->equal("KOL1", pkVal ); - if( check == -1 ) { - ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); - return NDBT_FAILED; - } - - // Attributes - - // Update column - Uint32 valToIncWith = 1; - check = pOp->incValue("KOL2", valToIncWith); - if( check == -1 ) { - ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); - return NDBT_FAILED; - } + NdbConnection* pTrans = pNdb->startTransaction(); + if (pTrans == NULL){ + ERR(pNdb->getNdbError()); + return NDBT_FAILED; + } + + NdbOperation* pOp = pTrans->getNdbOperation(pTab->getName()); + if (pOp == NULL) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + int check = pOp->interpretedUpdateTuple(); + if( check == -1 ) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + + // Primary keys + Uint32 pkVal = 1; + check = pOp->equal("KOL1", pkVal ); + if( check == -1 ) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + // Attributes + + // Update column + Uint32 valToIncWith = 1; + check = pOp->incValue("KOL2", valToIncWith); + if( check == -1 ) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } NdbRecAttr* valueRec = pOp->getValue("KOL2"); if( valueRec == NULL ) { @@ -142,6 +142,122 @@ int runTestIncValue32(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +int runTestBug19537(NDBT_Context* ctx, NDBT_Step* step){ + int result = NDBT_OK; + const NdbDictionary::Table * pTab = ctx->getTab(); + Ndb* pNdb = GETNDB(step); + + if (strcmp(pTab->getName(), "T1") != 0) { + g_err << "runTestBug19537: skip, table != T1" << endl; + return NDBT_OK; + } + + + NdbConnection* pTrans = pNdb->startTransaction(); + if (pTrans == NULL){ + ERR(pNdb->getNdbError()); + return NDBT_FAILED; + } + + NdbOperation* pOp = pTrans->getNdbOperation(pTab->getName()); + if (pOp == NULL) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + if (pOp->interpretedUpdateTuple() == -1) { + ERR(pOp->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + + // Primary keys + const Uint32 pkVal = 1; + if (pOp->equal("KOL1", pkVal) == -1) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + // Load 64-bit constant into register 1 and + // write from register 1 to 32-bit column KOL2 + const Uint64 reg_val = 0x0102030405060708ULL; + + const Uint32* reg_ptr32 = (const Uint32*)®_val; + if (reg_ptr32[0] == 0x05060708 && reg_ptr32[1] == 0x01020304) { + g_err << "runTestBug19537: platform is LITTLE endian" << endl; + } else if (reg_ptr32[0] == 0x01020304 && reg_ptr32[1] == 0x05060708) { + g_err << "runTestBug19537: platform is BIG endian" << endl; + } else { + g_err << "runTestBug19537: impossible platform" + << hex << " [0]=" << reg_ptr32[0] << " [1]=" <<reg_ptr32[1] << endl; + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + if (pOp->load_const_u64(1, reg_val) == -1 || + pOp->write_attr("KOL2", 1) == -1) { + ERR(pOp->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + if (pTrans->execute(Commit) == -1) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + // Read value via a new transaction + + pTrans = pNdb->startTransaction(); + if (pTrans == NULL){ + ERR(pNdb->getNdbError()); + return NDBT_FAILED; + } + + pOp = pTrans->getNdbOperation(pTab->getName()); + if (pOp == NULL) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + Uint32 kol2 = 0x09090909; + if (pOp->readTuple() == -1 || + pOp->equal("KOL1", pkVal) == -1 || + pOp->getValue("KOL2", (char*)&kol2) == 0) { + ERR(pOp->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + if (pTrans->execute(Commit) == -1) { + ERR(pTrans->getNdbError()); + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + // Expected conversion as in C - truncate to lower (logical) word + + if (kol2 == 0x01020304) { + g_err << "runTestBug19537: the bug manifests itself !" << endl; + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + if (kol2 != 0x05060708) { + g_err << "runTestBug19537: impossible KOL2 " << hex << kol2 << endl; + pNdb->closeTransaction(pTrans); + return NDBT_FAILED; + } + + pNdb->closeTransaction(pTrans); + return NDBT_OK; +} + NDBT_TESTSUITE(testInterpreter); TESTCASE("IncValue32", @@ -156,6 +272,12 @@ TESTCASE("IncValue64", INITIALIZER(runTestIncValue64); FINALIZER(runClearTable); } +TESTCASE("Bug19537", + "Test big-endian write_attr of 32 bit integer\n"){ + INITIALIZER(runLoadTable); + INITIALIZER(runTestBug19537); + FINALIZER(runClearTable); +} #if 0 TESTCASE("MaxTransactions", "Start transactions until no more can be created\n"){ diff --git a/storage/ndb/tools/desc.cpp b/storage/ndb/tools/desc.cpp index 37157ef9eec..7c5ce68c950 100644 --- a/storage/ndb/tools/desc.cpp +++ b/storage/ndb/tools/desc.cpp @@ -18,6 +18,7 @@ #include <ndb_opts.h> #include <NDBT.hpp> #include <NdbApi.hpp> +#include <NdbSleep.h> void desc_AutoGrowSpecification(struct NdbDictionary::AutoGrowSpecification ags); int desc_logfilegroup(Ndb *myndb, char* name); @@ -31,6 +32,7 @@ NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; static int _unqualified = 0; static int _partinfo = 0; +static int _retries = 0; static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), @@ -43,6 +45,9 @@ static struct my_option my_long_options[] = { "extra-partition-info", 'p', "Print more info per partition", (gptr*) &_partinfo, (gptr*) &_partinfo, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "retries", 'r', "Retry every second for # retries", + (gptr*) &_retries, (gptr*) &_retries, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void usage() @@ -231,7 +236,8 @@ int desc_datafile(Ndb_cluster_connection &con, Ndb *myndb, char* name) int desc_table(Ndb *myndb, char* name) { NdbDictionary::Dictionary * dict= myndb->getDictionary(); - NDBT_Table* pTab = (NDBT_Table*)dict->getTable(name); + NDBT_Table* pTab; + while ((pTab = (NDBT_Table*)dict->getTable(name)) == NULL && --_retries >= 0) NdbSleep_SecSleep(1); if (!pTab) return 0; diff --git a/storage/ndb/tools/waiter.cpp b/storage/ndb/tools/waiter.cpp index db90bd8bd90..cb02d5e7c36 100644 --- a/storage/ndb/tools/waiter.cpp +++ b/storage/ndb/tools/waiter.cpp @@ -124,6 +124,12 @@ getStatus(){ ndbout << "status==NULL, retries="<<retries<<endl; MGMERR(handle); retries++; + ndb_mgm_disconnect(handle); + if (ndb_mgm_connect(handle,0,0,1)) { + MGMERR(handle); + g_err << "Reconnect failed" << endl; + break; + } continue; } int count = status->no_of_nodes; diff --git a/strings/cmakelists.txt b/strings/CMakeLists.txt index ab4031f071a..ab4031f071a 100644 --- a/strings/cmakelists.txt +++ b/strings/CMakeLists.txt diff --git a/strings/Makefile.am b/strings/Makefile.am index 1183fcae01a..1cba4bab3f0 100644 --- a/strings/Makefile.am +++ b/strings/Makefile.am @@ -54,7 +54,7 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc bmove_upp-sparc.s strappend-sparc.s strend-sparc.s \ strinstr-sparc.s strmake-sparc.s strmov-sparc.s \ strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \ - t_ctype.h my_strchr.c cmakelists.txt + t_ctype.h my_strchr.c CMakeLists.txt libmystrings_a_LIBADD= conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 88d9ed034b4..6c0565c51cf 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -217,8 +217,9 @@ sh -c "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \ --with-fast-mutexes \ --with-mysqld-user=%{mysqld_user} \ --with-unix-socket-path=/var/lib/mysql/mysql.sock \ + --with-pic \ --prefix=/ \ - --with-extra-charsets=complex \ + --with-extra-charsets=all \ %if %{YASSL_BUILD} --with-yassl \ %endif @@ -311,6 +312,7 @@ fi CFLAGS="${MYSQL_BUILD_CFLAGS:-$RPM_OPT_FLAGS} -g" \ CXXFLAGS="${MYSQL_BUILD_CXXFLAGS:-$RPM_OPT_FLAGS -felide-constructors -fno-exceptions -fno-rtti} -g" \ BuildMySQL "--enable-shared \ + --with-berkeley-db \ --with-innodb \ --with-ndbcluster \ --with-archive-storage-engine \ @@ -318,7 +320,7 @@ BuildMySQL "--enable-shared \ --with-example-storage-engine \ --with-blackhole-storage-engine \ --with-federated-storage-engine \ - --with-big-tables \ + --with-big-tables \ --with-comment=\"MySQL Community Server - Max (GPL)\"") # We might want to save the config log file @@ -682,9 +684,15 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog -* Tue May 16 2006 Kent Boortz <kent@mysql.com> +* Sat May 20 2006 Kent Boortz <kent@mysql.com> + +- Always compile for PIC, position independent code. + +* Wed May 10 2006 Kent Boortz <kent@mysql.com> -- Removed Berkeley DB +- Use character set "all" when compiling with Cluster, to make Cluster + nodes independent on the character set directory, and the problem + that two RPM sub packages both wants to install this directory. * Mon May 01 2006 Kent Boortz <kent@mysql.com> diff --git a/tests/cmakelists.txt b/tests/CMakeLists.txt index 46c42d461f3..46c42d461f3 100644 --- a/tests/cmakelists.txt +++ b/tests/CMakeLists.txt diff --git a/tests/Makefile.am b/tests/Makefile.am index 292e37faa35..8ee64f8179c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -37,7 +37,7 @@ EXTRA_DIST = auto_increment.res auto_increment.tst \ grant.pl grant.res test_delayed_insert.pl \ pmail.pl mail_to_db.pl table_types.pl \ udf_test udf_test.res myisam-big-rows.tst \ - cmakelists.txt + CMakeLists.txt bin_PROGRAMS = mysql_client_test noinst_PROGRAMS = insert_test select_test thread_test diff --git a/vio/cmakelists.txt b/vio/CMakeLists.txt index a3cbb304289..a3cbb304289 100644 --- a/vio/cmakelists.txt +++ b/vio/CMakeLists.txt diff --git a/vio/Makefile.am b/vio/Makefile.am index b7e002a3033..e1830fdc636 100644 --- a/vio/Makefile.am +++ b/vio/Makefile.am @@ -38,7 +38,7 @@ test_sslclient_LDADD= @CLIENT_EXTRA_LDFLAGS@ ../dbug/libdbug.a libvio.a \ ../mysys/libmysys.a ../strings/libmystrings.a \ $(openssl_libs) $(yassl_libs) libvio_a_SOURCES= vio.c viosocket.c viossl.c viosslfactories.c -EXTRA_DIST= cmakelists.txt +EXTRA_DIST= CMakeLists.txt # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/vio/test-ssl.c b/vio/test-ssl.c index a94eb1a21ff..f8172426e38 100644 --- a/vio/test-ssl.c +++ b/vio/test-ssl.c @@ -57,8 +57,8 @@ main(int argc, char** argv) char* cipher=0; int child_pid,sv[2]; my_bool unused; - struct st_VioSSLAcceptorFd* ssl_acceptor=0; - struct st_VioSSLConnectorFd* ssl_connector=0; + struct st_VioSSLFd* ssl_acceptor= 0; + struct st_VioSSLFd* ssl_connector= 0; Vio* client_vio=0, *server_vio=0; MY_INIT(argv[0]); DBUG_PROCESS(argv[0]); diff --git a/vio/test-sslclient.c b/vio/test-sslclient.c index 3811ba0fb6a..49d6768c884 100644 --- a/vio/test-sslclient.c +++ b/vio/test-sslclient.c @@ -46,7 +46,7 @@ main( int argc __attribute__((unused)), { char client_key[] = "../SSL/client-key.pem", client_cert[] = "../SSL/client-cert.pem"; char ca_file[] = "../SSL/cacert.pem", *ca_path = 0, *cipher=0; - struct st_VioSSLConnectorFd* ssl_connector=0; + struct st_VioSSLFd* ssl_connector= 0; struct sockaddr_in sa; Vio* client_vio=0; int err; diff --git a/vio/test-sslserver.c b/vio/test-sslserver.c index e4d32a75264..daec3a6e6f9 100644 --- a/vio/test-sslserver.c +++ b/vio/test-sslserver.c @@ -44,7 +44,7 @@ fatal_error( const char* r) typedef struct { int sd; - struct st_VioSSLAcceptorFd* ssl_acceptor; + struct st_VioSSLFd* ssl_acceptor; } TH_ARGS; static void @@ -82,7 +82,7 @@ main(int argc __attribute__((unused)), char** argv) char ca_file[] = "../SSL/cacert.pem", *ca_path = 0, *cipher = 0; - struct st_VioSSLAcceptorFd* ssl_acceptor; + struct st_VioSSLFd* ssl_acceptor; pthread_t th; TH_ARGS th_args; diff --git a/vio/vio.c b/vio/vio.c index 9ace22e3780..f20acb249ef 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -88,19 +88,19 @@ static void vio_init(Vio* vio, enum enum_vio_type type, if (type == VIO_TYPE_SSL) { vio->viodelete =vio_delete; - vio->vioerrno =vio_ssl_errno; + vio->vioerrno =vio_errno; vio->read =vio_ssl_read; vio->write =vio_ssl_write; - vio->fastsend =vio_ssl_fastsend; - vio->viokeepalive =vio_ssl_keepalive; - vio->should_retry =vio_ssl_should_retry; - vio->was_interrupted=vio_ssl_was_interrupted; + vio->fastsend =vio_fastsend; + vio->viokeepalive =vio_keepalive; + vio->should_retry =vio_should_retry; + vio->was_interrupted=vio_was_interrupted; vio->vioclose =vio_ssl_close; - vio->peer_addr =vio_ssl_peer_addr; - vio->in_addr =vio_ssl_in_addr; + vio->peer_addr =vio_peer_addr; + vio->in_addr =vio_in_addr; vio->vioblocking =vio_ssl_blocking; vio->is_blocking =vio_is_blocking; - vio->timeout =vio_ssl_timeout; + vio->timeout =vio_timeout; } else /* default is VIO_TYPE_TCPIP */ #endif /* HAVE_OPENSSL */ @@ -233,3 +233,16 @@ void vio_delete(Vio* vio) my_free((gptr) vio,MYF(0)); } } + + +/* + Cleanup memory allocated by vio or the + components below it when application finish + +*/ +void vio_end(void) +{ +#ifdef HAVE_YASSL + yaSSL_CleanUp(); +#endif +} diff --git a/vio/vio_priv.h b/vio/vio_priv.h index eb495025ddd..db331abdea8 100644 --- a/vio/vio_priv.h +++ b/vio/vio_priv.h @@ -30,28 +30,10 @@ void vio_ignore_timeout(Vio *vio, uint which, uint timeout); int vio_ssl_read(Vio *vio,gptr buf, int size); int vio_ssl_write(Vio *vio,const gptr buf,int size); -void vio_ssl_timeout(Vio *vio, uint which, uint timeout); - -/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ -int vio_ssl_fastsend(Vio *vio); -/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ -int vio_ssl_keepalive(Vio *vio, my_bool onoff); -/* Whenever we should retry the last read/write operation. */ -my_bool vio_ssl_should_retry(Vio *vio); -/* Check that operation was timed out */ -my_bool vio_ssl_was_interrupted(Vio *vio); + /* When the workday is over... */ int vio_ssl_close(Vio *vio); -/* Return last error number */ -int vio_ssl_errno(Vio *vio); -my_bool vio_ssl_peer_addr(Vio *vio, char *buf, uint16 *port); -void vio_ssl_in_addr(Vio *vio, struct in_addr *in); + int vio_ssl_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode); -/* Single copy for server */ -enum vio_ssl_acceptorfd_state -{ - state_connect = 1, - state_accept = 2 -}; #endif /* HAVE_OPENSSL */ diff --git a/vio/viossl.c b/vio/viossl.c index a0262a79209..e869493c604 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -51,384 +51,240 @@ static int SSL_set_fd_bsd(SSL *s, int fd) static void -report_errors() +report_errors(SSL* ssl) { unsigned long l; - const char* file; - const char* data; - int line,flags; + const char *file; + const char *data; + int line, flags; +#ifndef DBUG_OFF + char buf[512]; +#endif + DBUG_ENTER("report_errors"); - while ((l=ERR_get_error_line_data(&file,&line,&data,&flags))) + while ((l= ERR_get_error_line_data(&file,&line,&data,&flags))) { - char buf[512]; DBUG_PRINT("error", ("OpenSSL: %s:%s:%d:%s\n", ERR_error_string(l,buf), file,line,(flags&ERR_TXT_STRING)?data:"")) ; } - DBUG_PRINT("info", ("errno: %d", socket_errno)); - DBUG_VOID_RETURN; -} + if (ssl) + DBUG_PRINT("error", ("error: %s", + ERR_error_string(SSL_get_error(ssl, l), buf))); -int vio_ssl_errno(Vio *vio __attribute__((unused))) -{ - return socket_errno; /* On Win32 this mapped to WSAGetLastError() */ + DBUG_PRINT("info", ("socket_errno: %d", socket_errno)); + DBUG_VOID_RETURN; } -int vio_ssl_read(Vio * vio, gptr buf, int size) +int vio_ssl_read(Vio *vio, gptr buf, int size) { int r; DBUG_ENTER("vio_ssl_read"); DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d, ssl_: 0x%p", vio->sd, buf, size, vio->ssl_arg)); - if ((r= SSL_read((SSL*) vio->ssl_arg, buf, size)) < 0) - { - int err= SSL_get_error((SSL*) vio->ssl_arg, r); - DBUG_PRINT("error",("SSL_read(): %d SSL_get_error(): %d", r, err)); - report_errors(); - } + r= SSL_read((SSL*) vio->ssl_arg, buf, size); +#ifndef DBUG_OFF + if (r < 0) + report_errors((SSL*) vio->ssl_arg); +#endif DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); } -int vio_ssl_write(Vio * vio, const gptr buf, int size) +int vio_ssl_write(Vio *vio, const gptr buf, int size) { int r; DBUG_ENTER("vio_ssl_write"); DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size)); - if ((r= SSL_write((SSL*) vio->ssl_arg, buf, size)) < 0) - report_errors(); - DBUG_PRINT("exit", ("%d", r)); - DBUG_RETURN(r); -} - - -int vio_ssl_fastsend(Vio * vio __attribute__((unused))) -{ - int r=0; - DBUG_ENTER("vio_ssl_fastsend"); - -#if defined(IPTOS_THROUGHPUT) - { - int tos= IPTOS_THROUGHPUT; - r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)); - } -#endif /* IPTOS_THROUGHPUT */ - if (!r) - { -#ifdef __WIN__ - BOOL nodelay= 1; - r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay, - sizeof(nodelay)); -#else - int nodelay= 1; - r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay, - sizeof(nodelay)); -#endif /* __WIN__ */ - } - if (r) - { - DBUG_PRINT("warning", ("Couldn't set socket option for fast send")); - r= -1; - } + r= SSL_write((SSL*) vio->ssl_arg, buf, size); +#ifndef DBUG_OFF + if (r < 0) + report_errors((SSL*) vio->ssl_arg); +#endif DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); } -int vio_ssl_keepalive(Vio* vio, my_bool set_keep_alive) +int vio_ssl_close(Vio *vio) { - int r=0; - DBUG_ENTER("vio_ssl_keepalive"); - DBUG_PRINT("enter", ("sd: %d, set_keep_alive: %d", vio->sd, (int) - set_keep_alive)); - if (vio->type != VIO_TYPE_NAMEDPIPE) - { - uint opt = (set_keep_alive) ? 1 : 0; - r= setsockopt(vio->sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt, - sizeof(opt)); - } - DBUG_RETURN(r); -} - - -my_bool -vio_ssl_should_retry(Vio * vio __attribute__((unused))) -{ - int en = socket_errno; - return (en == SOCKET_EAGAIN || en == SOCKET_EINTR || - en == SOCKET_EWOULDBLOCK); -} - - -my_bool -vio_ssl_was_interrupted(Vio *vio __attribute__((unused))) -{ - int en= socket_errno; - return (en == SOCKET_EAGAIN || en == SOCKET_EINTR || - en == SOCKET_EWOULDBLOCK || en == SOCKET_ETIMEDOUT); -} - - -int vio_ssl_close(Vio * vio) -{ - int r; + int r= 0; + SSL *ssl= (SSL*)vio->ssl_arg; DBUG_ENTER("vio_ssl_close"); - r=0; - if ((SSL*) vio->ssl_arg) - { - r = SSL_shutdown((SSL*) vio->ssl_arg); - SSL_free((SSL*) vio->ssl_arg); - vio->ssl_arg= 0; - } - if (vio->sd >= 0) - { - if (shutdown(vio->sd, 2)) - r= -1; - if (closesocket(vio->sd)) - r= -1; - } - if (r) - { - DBUG_PRINT("error", ("close() failed, error: %d",socket_errno)); - report_errors(); - /* FIXME: error handling (not critical for MySQL) */ - } - vio->type= VIO_CLOSED; - vio->sd= -1; - DBUG_RETURN(r); -} - -const char *vio_ssl_description(Vio * vio) -{ - return vio->desc; -} - -enum enum_vio_type vio_ssl_type(Vio* vio) -{ - return vio->type; -} - -my_socket vio_ssl_fd(Vio* vio) -{ - return vio->sd; -} - - -my_bool vio_ssl_peer_addr(Vio * vio, char *buf, uint16 *port) -{ - DBUG_ENTER("vio_ssl_peer_addr"); - DBUG_PRINT("enter", ("sd: %d", vio->sd)); - if (vio->localhost) - { - strmov(buf,"127.0.0.1"); - *port=0; - } - else + if (ssl) { - size_socket addrLen = sizeof(struct sockaddr); - if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)), - &addrLen) != 0) + switch ((r= SSL_shutdown(ssl))) { - DBUG_PRINT("exit", ("getpeername, error: %d", socket_errno)); - DBUG_RETURN(1); + case 1: /* Shutdown successful */ + break; + case 0: /* Shutdown not yet finished, call it again */ + if ((r= SSL_shutdown(ssl) >= 0)) + break; + /* Fallthrough */ + default: /* Shutdown failed */ + DBUG_PRINT("vio_error", ("SSL_shutdown() failed, error: %s", + SSL_get_error(ssl, r))); + break; } -#ifdef TO_BE_FIXED - my_inet_ntoa(vio->remote.sin_addr,buf); - *port= 0; -#else - strmov(buf, "unknown"); - *port= 0; -#endif + SSL_free(ssl); + vio->ssl_arg= 0; } - DBUG_PRINT("exit", ("addr: %s", buf)); - DBUG_RETURN(0); + DBUG_RETURN(vio_close(vio)); } -void vio_ssl_in_addr(Vio *vio, struct in_addr *in) +int sslaccept(struct st_VioSSLFd *ptr, Vio *vio, long timeout) { - DBUG_ENTER("vio_ssl_in_addr"); - if (vio->localhost) - bzero((char*) in, sizeof(*in)); - else - *in=vio->remote.sin_addr; - DBUG_VOID_RETURN; -} - - -/* - TODO: Add documentation -*/ - -int sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) -{ - char *str; - char buf[1024]; - X509* client_cert; + SSL *ssl; my_bool unused; my_bool net_blocking; enum enum_vio_type old_type; DBUG_ENTER("sslaccept"); - DBUG_PRINT("enter", ("sd: %d ptr: Ox%p, timeout: %d", + DBUG_PRINT("enter", ("sd: %d ptr: %p, timeout: %d", vio->sd, ptr, timeout)); old_type= vio->type; - net_blocking = vio_is_blocking(vio); + net_blocking= vio_is_blocking(vio); vio_blocking(vio, 1, &unused); /* Must be called before reset */ - vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); - vio->ssl_arg= 0; - if (!(vio->ssl_arg= (void*) SSL_new(ptr->ssl_context))) + vio_reset(vio, VIO_TYPE_SSL, vio->sd, 0, FALSE); + + if (!(ssl= SSL_new(ptr->ssl_context))) { DBUG_PRINT("error", ("SSL_new failure")); - report_errors(); + report_errors(ssl); vio_reset(vio, old_type,vio->sd,0,FALSE); vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } - DBUG_PRINT("info", ("ssl_: Ox%p timeout: %ld", - (SSL*) vio->ssl_arg, timeout)); - SSL_clear((SSL*) vio->ssl_arg); - SSL_SESSION_set_timeout(SSL_get_session((SSL*) vio->ssl_arg), timeout); - SSL_set_fd((SSL*) vio->ssl_arg,vio->sd); - SSL_set_accept_state((SSL*) vio->ssl_arg); - if (SSL_do_handshake((SSL*) vio->ssl_arg) < 1) + vio->ssl_arg= (void*)ssl; + DBUG_PRINT("info", ("ssl_: %p timeout: %ld", ssl, timeout)); + SSL_clear(ssl); + SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout); + SSL_set_fd(ssl, vio->sd); + SSL_set_accept_state(ssl); + if (SSL_do_handshake(ssl) < 1) { DBUG_PRINT("error", ("SSL_do_handshake failure")); - report_errors(); - SSL_free((SSL*) vio->ssl_arg); + report_errors(ssl); + SSL_free(ssl); vio->ssl_arg= 0; vio_reset(vio, old_type,vio->sd,0,FALSE); vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } + #ifndef DBUG_OFF - DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" - ,SSL_get_cipher_name((SSL*) vio->ssl_arg))); - client_cert = SSL_get_peer_certificate ((SSL*) vio->ssl_arg); - if (client_cert != NULL) { - DBUG_PRINT("info",("Client certificate:")); - str = X509_NAME_oneline (X509_get_subject_name (client_cert), 0, 0); - DBUG_PRINT("info",("\t subject: %s", str)); - free (str); + char buf[1024]; + X509 *client_cert; + DBUG_PRINT("info",("cipher_name= '%s'", SSL_get_cipher_name(ssl))); - str = X509_NAME_oneline (X509_get_issuer_name (client_cert), 0, 0); - DBUG_PRINT("info",("\t issuer: %s", str)); - free (str); + if ((client_cert= SSL_get_peer_certificate (ssl))) + { + DBUG_PRINT("info",("Client certificate:")); + X509_NAME_oneline (X509_get_subject_name (client_cert), + buf, sizeof(buf)); + DBUG_PRINT("info",("\t subject: %s", buf)); - X509_free (client_cert); - } - else - DBUG_PRINT("info",("Client does not have certificate.")); + X509_NAME_oneline (X509_get_issuer_name (client_cert), + buf, sizeof(buf)); + DBUG_PRINT("info",("\t issuer: %s", buf)); - str=SSL_get_shared_ciphers((SSL*) vio->ssl_arg, buf, sizeof(buf)); - if (str) - { - DBUG_PRINT("info",("SSL_get_shared_ciphers() returned '%s'",str)); - } - else - { - DBUG_PRINT("info",("no shared ciphers!")); - } + X509_free (client_cert); + } + else + DBUG_PRINT("info",("Client does not have certificate.")); + if (SSL_get_shared_ciphers(ssl, buf, sizeof(buf))) + { + DBUG_PRINT("info",("shared_ciphers: '%s'", buf)); + } + else + DBUG_PRINT("info",("no shared ciphers!")); + } #endif + DBUG_RETURN(0); } -int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) +int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout) { - char *str; - X509* server_cert; + SSL *ssl; my_bool unused; my_bool net_blocking; - enum enum_vio_type old_type; + enum enum_vio_type old_type; + DBUG_ENTER("sslconnect"); - DBUG_PRINT("enter", ("sd: %d ptr: 0x%p ctx: 0x%p", - vio->sd,ptr,ptr->ssl_context)); + DBUG_PRINT("enter", ("sd: %d, ptr: %p, ctx: %p", + vio->sd, ptr, ptr->ssl_context)); old_type= vio->type; - net_blocking = vio_is_blocking(vio); + net_blocking= vio_is_blocking(vio); vio_blocking(vio, 1, &unused); /* Must be called before reset */ - vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); - vio->ssl_arg= 0; - if (!(vio->ssl_arg = SSL_new(ptr->ssl_context))) + vio_reset(vio, VIO_TYPE_SSL, vio->sd, 0, FALSE); + if (!(ssl= SSL_new(ptr->ssl_context))) { DBUG_PRINT("error", ("SSL_new failure")); - report_errors(); - vio_reset(vio, old_type,vio->sd,0,FALSE); - vio_blocking(vio, net_blocking, &unused); + report_errors(ssl); + vio_reset(vio, old_type, vio->sd, 0, FALSE); + vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } - DBUG_PRINT("info", ("ssl_: 0x%p timeout: %ld", - (SSL*) vio->ssl_arg, timeout)); - SSL_clear((SSL*) vio->ssl_arg); - SSL_SESSION_set_timeout(SSL_get_session((SSL*) vio->ssl_arg), timeout); - SSL_set_fd ((SSL*) vio->ssl_arg, vio_ssl_fd(vio)); - SSL_set_connect_state((SSL*) vio->ssl_arg); - if (SSL_do_handshake((SSL*) vio->ssl_arg) < 1) + vio->ssl_arg= (void*)ssl; + DBUG_PRINT("info", ("ssl: %p, timeout: %ld", ssl, timeout)); + SSL_clear(ssl); + SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout); + SSL_set_fd(ssl, vio->sd); + SSL_set_connect_state(ssl); + if (SSL_do_handshake(ssl) < 1) { DBUG_PRINT("error", ("SSL_do_handshake failure")); - report_errors(); - SSL_free((SSL*) vio->ssl_arg); + report_errors(ssl); + SSL_free(ssl); vio->ssl_arg= 0; - vio_reset(vio, old_type,vio->sd,0,FALSE); + vio_reset(vio, old_type, vio->sd, 0, FALSE); vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); - } + } #ifndef DBUG_OFF - DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" - ,SSL_get_cipher_name((SSL*) vio->ssl_arg))); - server_cert = SSL_get_peer_certificate ((SSL*) vio->ssl_arg); - if (server_cert != NULL) { - DBUG_PRINT("info",("Server certificate:")); - str = X509_NAME_oneline (X509_get_subject_name (server_cert), 0, 0); - DBUG_PRINT("info",("\t subject: %s", str)); - free(str); - - str = X509_NAME_oneline (X509_get_issuer_name (server_cert), 0, 0); - DBUG_PRINT("info",("\t issuer: %s", str)); - free(str); - - /* - We could do all sorts of certificate verification stuff here before - deallocating the certificate. - */ - X509_free (server_cert); + X509 *server_cert; + DBUG_PRINT("info",("cipher_name: '%s'" , SSL_get_cipher_name(ssl))); + + if ((server_cert= SSL_get_peer_certificate (ssl))) + { + char buf[256]; + DBUG_PRINT("info",("Server certificate:")); + X509_NAME_oneline(X509_get_subject_name(server_cert), buf, sizeof(buf)); + DBUG_PRINT("info",("\t subject: %s", buf)); + X509_NAME_oneline (X509_get_issuer_name(server_cert), buf, sizeof(buf)); + DBUG_PRINT("info",("\t issuer: %s", buf)); + X509_free (server_cert); + } + else + DBUG_PRINT("info",("Server does not have certificate.")); } - else - DBUG_PRINT("info",("Server does not have certificate.")); #endif + DBUG_RETURN(0); } -int vio_ssl_blocking(Vio * vio __attribute__((unused)), +int vio_ssl_blocking(Vio *vio __attribute__((unused)), my_bool set_blocking_mode, my_bool *old_mode) { + /* Mode is always blocking */ + *old_mode= 1; /* Return error if we try to change to non_blocking mode */ - *old_mode=1; /* Mode is always blocking */ - return set_blocking_mode ? 0 : 1; + return (set_blocking_mode ? 0 : 1); } - -void vio_ssl_timeout(Vio *vio __attribute__((unused)), - uint which __attribute__((unused)), - uint timeout __attribute__((unused))) -{ -#ifdef __WIN__ - ulong wait_timeout= (ulong) timeout * 1000; - (void) setsockopt(vio->sd, SOL_SOCKET, - which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout, - sizeof(wait_timeout)); -#endif /* __WIN__ */ -} #endif /* HAVE_OPENSSL */ diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 002874caf58..ca7a96d5801 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -21,7 +21,6 @@ static bool ssl_algorithms_added = FALSE; static bool ssl_error_strings_loaded= FALSE; static int verify_depth = 0; -static int verify_error = X509_V_OK; static unsigned char dh512_p[]= { @@ -82,30 +81,31 @@ vio_set_cert_stuff(SSL_CTX *ctx, const char *cert_file, const char *key_file) DBUG_ENTER("vio_set_cert_stuff"); DBUG_PRINT("enter", ("ctx: %p, cert_file: %s, key_file: %s", ctx, cert_file, key_file)); - if (cert_file != NULL) + if (cert_file) { - if (SSL_CTX_use_certificate_file(ctx,cert_file,SSL_FILETYPE_PEM) <= 0) + if (SSL_CTX_use_certificate_file(ctx, cert_file, SSL_FILETYPE_PEM) <= 0) { - DBUG_PRINT("error",("unable to get certificate from '%s'\n",cert_file)); + DBUG_PRINT("error",("unable to get certificate from '%s'\n", cert_file)); /* FIX stderr */ fprintf(stderr,"Error when connection to server using SSL:"); ERR_print_errors_fp(stderr); fprintf(stderr,"Unable to get certificate from '%s'\n", cert_file); fflush(stderr); - DBUG_RETURN(0); + DBUG_RETURN(1); } - if (key_file == NULL) - key_file = cert_file; - if (SSL_CTX_use_PrivateKey_file(ctx,key_file, - SSL_FILETYPE_PEM) <= 0) + + if (!key_file) + key_file= cert_file; + + if (SSL_CTX_use_PrivateKey_file(ctx, key_file, SSL_FILETYPE_PEM) <= 0) { - DBUG_PRINT("error", ("unable to get private key from '%s'\n",key_file)); + DBUG_PRINT("error", ("unable to get private key from '%s'\n", key_file)); /* FIX stderr */ fprintf(stderr,"Error when connection to server using SSL:"); ERR_print_errors_fp(stderr); - fprintf(stderr,"Unable to get private key from '%s'\n", cert_file); - fflush(stderr); - DBUG_RETURN(0); + fprintf(stderr,"Unable to get private key from '%s'\n", key_file); + fflush(stderr); + DBUG_RETURN(1); } /* @@ -116,45 +116,45 @@ vio_set_cert_stuff(SSL_CTX *ctx, const char *cert_file, const char *key_file) { DBUG_PRINT("error", ("Private key does not match the certificate public key\n")); - DBUG_RETURN(0); + DBUG_RETURN(1); } } - DBUG_RETURN(1); + DBUG_RETURN(0); } static int vio_verify_callback(int ok, X509_STORE_CTX *ctx) { - char buf[256]; - X509* err_cert; - int err,depth; + char buf[256]; + X509 *err_cert; DBUG_ENTER("vio_verify_callback"); - DBUG_PRINT("enter", ("ok: %d, ctx: 0x%p", ok, ctx)); - err_cert=X509_STORE_CTX_get_current_cert(ctx); - err= X509_STORE_CTX_get_error(ctx); - depth= X509_STORE_CTX_get_error_depth(ctx); + DBUG_PRINT("enter", ("ok: %d, ctx: %p", ok, ctx)); - X509_NAME_oneline(X509_get_subject_name(err_cert),buf,sizeof(buf)); + err_cert= X509_STORE_CTX_get_current_cert(ctx); + X509_NAME_oneline(X509_get_subject_name(err_cert), buf, sizeof(buf)); + DBUG_PRINT("info", ("cert: %s", buf)); if (!ok) { - DBUG_PRINT("error",("verify error: num: %d : '%s'\n",err, + int err, depth; + err= X509_STORE_CTX_get_error(ctx); + depth= X509_STORE_CTX_get_error_depth(ctx); + + DBUG_PRINT("error",("verify error: %d, '%s'",err, X509_verify_cert_error_string(err))); + /* + Approve cert if depth is greater then "verify_depth", currently + verify_depth is always 0 and there is no way to increase it. + */ if (verify_depth >= depth) - { - ok=1; - verify_error=X509_V_OK; - } - else - { - verify_error=X509_V_ERR_CERT_CHAIN_TOO_LONG; - } + ok= 1; } - switch (ctx->error) { + switch (ctx->error) + { case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: - X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert),buf,256); - DBUG_PRINT("info",("issuer= %s\n",buf)); + X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), buf, 256); + DBUG_PRINT("info",("issuer= %s\n", buf)); break; case X509_V_ERR_CERT_NOT_YET_VALID: case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: @@ -198,201 +198,156 @@ static void netware_ssl_init() #endif /* __NETWARE__ */ -/************************ VioSSLConnectorFd **********************************/ -/* - TODO: - Add option --verify to mysql to be able to change verification mode -*/ - -struct st_VioSSLConnectorFd * -new_VioSSLConnectorFd(const char* key_file, - const char* cert_file, - const char* ca_file, - const char* ca_path, - const char* cipher) +static void check_ssl_init() { - int verify = SSL_VERIFY_NONE; - struct st_VioSSLConnectorFd* ptr; - int result; - DH *dh; - DBUG_ENTER("new_VioSSLConnectorFd"); - - if (!(ptr=((struct st_VioSSLConnectorFd*) - my_malloc(sizeof(struct st_VioSSLConnectorFd),MYF(0))))) - DBUG_RETURN(0); - - ptr->ssl_context= 0; - ptr->ssl_method= 0; - /* FIXME: constants! */ - if (!ssl_algorithms_added) { - DBUG_PRINT("info", ("todo: OpenSSL_add_all_algorithms()")); - ssl_algorithms_added = TRUE; + ssl_algorithms_added= TRUE; SSL_library_init(); OpenSSL_add_all_algorithms(); + } + #ifdef __NETWARE__ netware_ssl_init(); #endif if (!ssl_error_strings_loaded) { - DBUG_PRINT("info", ("todo:SSL_load_error_strings()")); - ssl_error_strings_loaded = TRUE; + ssl_error_strings_loaded= TRUE; SSL_load_error_strings(); } - ptr->ssl_method = TLSv1_client_method(); - ptr->ssl_context = SSL_CTX_new(ptr->ssl_method); - DBUG_PRINT("info", ("ssl_context: %p",ptr->ssl_context)); - if (ptr->ssl_context == 0) +} + +/************************ VioSSLFd **********************************/ +static struct st_VioSSLFd * +new_VioSSLFd(const char *key_file, const char *cert_file, + const char *ca_file, const char *ca_path, + const char *cipher, SSL_METHOD *method) +{ + DH *dh; + struct st_VioSSLFd *ssl_fd; + DBUG_ENTER("new_VioSSLFd"); + + check_ssl_init(); + + if (!(ssl_fd= ((struct st_VioSSLFd*) + my_malloc(sizeof(struct st_VioSSLFd),MYF(0))))) + DBUG_RETURN(0); + + if (!(ssl_fd->ssl_context= SSL_CTX_new(method))) { DBUG_PRINT("error", ("SSL_CTX_new failed")); report_errors(); - goto ctor_failure; - } - /* - SSL_CTX_set_options - SSL_CTX_set_info_callback - */ - if (cipher) - { - result=SSL_CTX_set_cipher_list(ptr->ssl_context, cipher); - DBUG_PRINT("info",("SSL_set_cipher_list() returned %d",result)); + my_free((void*)ssl_fd,MYF(0)); + DBUG_RETURN(0); } - SSL_CTX_set_verify(ptr->ssl_context, verify, vio_verify_callback); - if (vio_set_cert_stuff(ptr->ssl_context, cert_file, key_file) == -1) + + /* Set the ciphers that can be used */ + if (cipher && SSL_CTX_set_cipher_list(ssl_fd->ssl_context, cipher)) { - DBUG_PRINT("error", ("vio_set_cert_stuff failed")); + DBUG_PRINT("error", ("failed to set ciphers to use")); report_errors(); - goto ctor_failure; + my_free((void*)ssl_fd,MYF(0)); + DBUG_RETURN(0); } - if (SSL_CTX_load_verify_locations( ptr->ssl_context, ca_file,ca_path) == 0) + + /* Load certs from the trusted ca */ + if (SSL_CTX_load_verify_locations(ssl_fd->ssl_context, ca_file, ca_path) == 0) { DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed")); - if (SSL_CTX_set_default_verify_paths(ptr->ssl_context) == 0) + if (SSL_CTX_set_default_verify_paths(ssl_fd->ssl_context) == 0) { DBUG_PRINT("error", ("SSL_CTX_set_default_verify_paths failed")); report_errors(); - goto ctor_failure; + my_free((void*)ssl_fd,MYF(0)); + DBUG_RETURN(0); } - } + } + + if (vio_set_cert_stuff(ssl_fd->ssl_context, cert_file, key_file)) + { + DBUG_PRINT("error", ("vio_set_cert_stuff failed")); + report_errors(); + my_free((void*)ssl_fd,MYF(0)); + DBUG_RETURN(0); + } /* DH stuff */ dh=get_dh512(); - SSL_CTX_set_tmp_dh(ptr->ssl_context,dh); + SSL_CTX_set_tmp_dh(ssl_fd->ssl_context, dh); DH_free(dh); - DBUG_RETURN(ptr); -ctor_failure: - DBUG_PRINT("exit", ("there was an error")); - my_free((gptr)ptr,MYF(0)); - DBUG_RETURN(0); + DBUG_PRINT("exit", ("OK 1")); + + DBUG_RETURN(ssl_fd); } -/************************ VioSSLAcceptorFd **********************************/ -/* - TODO: - Add option --verify to mysqld to be able to change verification mode -*/ -struct st_VioSSLAcceptorFd * -new_VioSSLAcceptorFd(const char *key_file, - const char *cert_file, - const char *ca_file, - const char *ca_path, - const char *cipher) +/************************ VioSSLConnectorFd **********************************/ +struct st_VioSSLFd * +new_VioSSLConnectorFd(const char *key_file, const char *cert_file, + const char *ca_file, const char *ca_path, + const char *cipher) { - int verify = (SSL_VERIFY_PEER | - SSL_VERIFY_CLIENT_ONCE); - struct st_VioSSLAcceptorFd* ptr; - int result; - DH *dh; - DBUG_ENTER("new_VioSSLAcceptorFd"); + struct st_VioSSLFd *ssl_fd; + int verify= SSL_VERIFY_PEER; + if (!(ssl_fd= new_VioSSLFd(key_file, cert_file, ca_file, + ca_path, cipher, TLSv1_client_method()))) + { + return 0; + } - ptr= ((struct st_VioSSLAcceptorFd*) - my_malloc(sizeof(struct st_VioSSLAcceptorFd),MYF(0))); - ptr->ssl_context=0; - ptr->ssl_method=0; - /* FIXME: constants! */ - ptr->session_id_context= ptr; + /* Init the VioSSLFd as a "connector" ie. the client side */ - if (!ssl_algorithms_added) - { - DBUG_PRINT("info", ("todo: OpenSSL_add_all_algorithms()")); - ssl_algorithms_added = TRUE; - SSL_library_init(); - OpenSSL_add_all_algorithms(); + /* + The verify_callback function is used to control the behaviour + when the SSL_VERIFY_PEER flag is set. + */ + SSL_CTX_set_verify(ssl_fd->ssl_context, verify, vio_verify_callback); - } -#ifdef __NETWARE__ - netware_ssl_init(); -#endif + return ssl_fd; +} - if (!ssl_error_strings_loaded) - { - DBUG_PRINT("info", ("todo: SSL_load_error_strings()")); - ssl_error_strings_loaded = TRUE; - SSL_load_error_strings(); - } - ptr->ssl_method= TLSv1_server_method(); - ptr->ssl_context= SSL_CTX_new(ptr->ssl_method); - if (ptr->ssl_context == 0) - { - DBUG_PRINT("error", ("SSL_CTX_new failed")); - report_errors(); - goto ctor_failure; - } - if (cipher) + +/************************ VioSSLAcceptorFd **********************************/ +struct st_VioSSLFd * +new_VioSSLAcceptorFd(const char *key_file, const char *cert_file, + const char *ca_file, const char *ca_path, + const char *cipher) +{ + struct st_VioSSLFd *ssl_fd; + int verify= SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; + if (!(ssl_fd= new_VioSSLFd(key_file, cert_file, ca_file, + ca_path, cipher, TLSv1_server_method()))) { - result=SSL_CTX_set_cipher_list(ptr->ssl_context, cipher); - DBUG_PRINT("info",("SSL_set_cipher_list() returned %d",result)); + return 0; } - /* SSL_CTX_set_quiet_shutdown(ctx,1); */ - SSL_CTX_sess_set_cache_size(ptr->ssl_context,128); + /* Init the the VioSSLFd as a "acceptor" ie. the server side */ - /* DH? */ - SSL_CTX_set_verify(ptr->ssl_context, verify, vio_verify_callback); - SSL_CTX_set_session_id_context(ptr->ssl_context, - (const uchar*) &(ptr->session_id_context), - sizeof(ptr->session_id_context)); + /* Set max number of cached sessions, returns the previous size */ + SSL_CTX_sess_set_cache_size(ssl_fd->ssl_context, 128); /* - SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile)); + The verify_callback function is used to control the behaviour + when the SSL_VERIFY_PEER flag is set. */ - if (vio_set_cert_stuff(ptr->ssl_context, cert_file, key_file) == -1) - { - DBUG_PRINT("error", ("vio_set_cert_stuff failed")); - report_errors(); - goto ctor_failure; - } - if (SSL_CTX_load_verify_locations( ptr->ssl_context, ca_file, ca_path) == 0) - { - DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed")); - if (SSL_CTX_set_default_verify_paths(ptr->ssl_context)==0) - { - DBUG_PRINT("error", ("SSL_CTX_set_default_verify_paths failed")); - report_errors(); - goto ctor_failure; - } - } - /* DH stuff */ - dh=get_dh512(); - SSL_CTX_set_tmp_dh(ptr->ssl_context,dh); - DH_free(dh); - DBUG_RETURN(ptr); + SSL_CTX_set_verify(ssl_fd->ssl_context, verify, vio_verify_callback); -ctor_failure: - DBUG_PRINT("exit", ("there was an error")); - my_free((gptr) ptr,MYF(0)); - DBUG_RETURN(0); -} + /* + Set session_id - an identifier for this server session + Use the ssl_fd pointer + */ + SSL_CTX_set_session_id_context(ssl_fd->ssl_context, + (const unsigned char *)ssl_fd, + sizeof(ssl_fd)); + return ssl_fd; +} -void free_vio_ssl_acceptor_fd(struct st_VioSSLAcceptorFd *fd) +void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd) { SSL_CTX_free(fd->ssl_context); my_free((gptr) fd, MYF(0)); } - #endif /* HAVE_OPENSSL */ diff --git a/zlib/cmakelists.txt b/zlib/CMakeLists.txt index 53560adf6d1..53560adf6d1 100644 --- a/zlib/cmakelists.txt +++ b/zlib/CMakeLists.txt diff --git a/zlib/Makefile.am b/zlib/Makefile.am index cc3777b1e88..40258ec589a 100644 --- a/zlib/Makefile.am +++ b/zlib/Makefile.am @@ -29,4 +29,4 @@ libz_la_SOURCES= adler32.c compress.c crc32.c deflate.c gzio.c \ infback.c inffast.c inflate.c inftrees.c trees.c \ uncompr.c zutil.c -EXTRA_DIST= README FAQ INDEX ChangeLog algorithm.txt zlib.3 cmakelists.txt +EXTRA_DIST= README FAQ INDEX ChangeLog algorithm.txt zlib.3 CMakeLists.txt |